You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by "komarovd95 (via GitHub)" <gi...@apache.org> on 2024/02/29 16:21:51 UTC

[PR] XDGF: replace an elliptical arc with a line when a control point is co-linear with begin and end [poi]

komarovd95 opened a new pull request, #601:
URL: https://github.com/apache/poi/pull/601

   We've faced an issue with elliptical arcs in VSDX files - when a control point of the elliptic arc is co-linear (i.e. lies on the same line) with begin and end points of the arc, it leads to very huge numbers when calculating coordinates of the center of the arc. 
   
   It happens because slopes of two tangents (class `EllipticalArcTo` lines 198 and 201) are equal to each other which leads to division by zero (or by value that is very near to zero).
   
   As the solution it's proposed to check co-linearity before calculating an arc. I added this condition check into `EllipticalArcTo#createEllipticalArc` method to also cover corner-cases with `ArcTo` (which uses the method under the hood) and with `RelEllipticalArcTo`. 
   
   Below you can find an example that high-lights the problem. 
   <img width="270" alt="Screenshot 2024-02-29 at 16 11 00" src="https://github.com/apache/poi/assets/11631627/9b4cd6f8-f453-407c-b91e-db23b41df9d8">
   
   And after the fix: 
   <img width="270" alt="Screenshot 2024-02-29 at 16 12 11" src="https://github.com/apache/poi/assets/11631627/147ababc-cdd8-4311-8c35-decc7749cd7b">
   
   The file itself (just change extension to `.vsdx` since GitHub does not allow to upload VSDX files)
   [Single Icon.zip](https://github.com/apache/poi/files/14450770/Single.Icon.zip)
   
   
     


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: [PR] XDGF: replace an elliptical arc with a line when a control point is co-linear with begin and end [poi]

Posted by "asfgit (via GitHub)" <gi...@apache.org>.
asfgit closed pull request #601: XDGF: replace an elliptical arc with a line when a control point is co-linear with begin and end
URL: https://github.com/apache/poi/pull/601


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: [PR] XDGF: replace an elliptical arc with a line when a control point is co-linear with begin and end [poi]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on PR #601:
URL: https://github.com/apache/poi/pull/601#issuecomment-1980633224

   thanks - merged


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: [PR] XDGF: replace an elliptical arc with a line when a control point is co-linear with begin and end [poi]

Posted by "komarovd95 (via GitHub)" <gi...@apache.org>.
komarovd95 commented on PR #601:
URL: https://github.com/apache/poi/pull/601#issuecomment-1978439172

   Hi @pjfanning! Can you please take a look one more time? 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: [PR] XDGF: replace an elliptical arc with a line when a control point is co-linear with begin and end [poi]

Posted by "komarovd95 (via GitHub)" <gi...@apache.org>.
komarovd95 commented on code in PR #601:
URL: https://github.com/apache/poi/pull/601#discussion_r1508754067


##########
poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/shape/ShapeDebuggerRenderer.java:
##########
@@ -40,9 +39,9 @@ public void setDebugAcceptor(ShapeVisitorAcceptor acceptor) {
     }
 
     @Override
-    protected Path2D drawPath(XDGFShape shape) {

Review Comment:
   Hey @pjfanning! Good catch. I completely forgot that `ShapeRenderer` class might be used outside of `poi` codebase itself. 
   
   Can you please check out the last revision? I reverted changing the method signature and preserved its behaviour. Now, it draws all the sections but returns only first drawn path. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: [PR] XDGF: replace an elliptical arc with a line when a control point is co-linear with begin and end [poi]

Posted by "komarovd95 (via GitHub)" <gi...@apache.org>.
komarovd95 commented on code in PR #601:
URL: https://github.com/apache/poi/pull/601#discussion_r1512636641


##########
poi-ooxml/src/test/java/org/apache/poi/xdgf/usermodel/section/geometry/TestEllipticalArcTo.java:
##########
@@ -0,0 +1,76 @@
+package org.apache.poi.xdgf.usermodel.section.geometry;

Review Comment:
   Just pushed the changes. Headers are added to this file and `TestGeometryUtils.java`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: [PR] XDGF: replace an elliptical arc with a line when a control point is co-linear with begin and end [poi]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #601:
URL: https://github.com/apache/poi/pull/601#discussion_r1507996868


##########
poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/shape/ShapeDebuggerRenderer.java:
##########
@@ -40,9 +39,9 @@ public void setDebugAcceptor(ShapeVisitorAcceptor acceptor) {
     }
 
     @Override
-    protected Path2D drawPath(XDGFShape shape) {

Review Comment:
   does this compile? Regardless, I don't think we should change protected method signatures in a patch release. Could you consider adding new private methods and leave the protected methods alone.



##########
poi-ooxml/src/main/java/org/apache/poi/xdgf/usermodel/shape/ShapeDebuggerRenderer.java:
##########
@@ -40,9 +39,9 @@ public void setDebugAcceptor(ShapeVisitorAcceptor acceptor) {
     }
 
     @Override
-    protected Path2D drawPath(XDGFShape shape) {

Review Comment:
   does this compile? Regardless, I don't think we should change protected method signatures in a patch release. Could you consider adding new private methods and leave the protected methods alone?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: [PR] XDGF: replace an elliptical arc with a line when a control point is co-linear with begin and end [poi]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #601:
URL: https://github.com/apache/poi/pull/601#discussion_r1512616377


##########
poi-ooxml/src/test/java/org/apache/poi/xdgf/usermodel/section/geometry/TestEllipticalArcTo.java:
##########
@@ -0,0 +1,76 @@
+package org.apache.poi.xdgf.usermodel.section.geometry;

Review Comment:
   could you add license headers to the new files?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org