You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2012/05/02 12:52:40 UTC

[Bug 53176] New: Auto shapes render problem in pptx files

https://issues.apache.org/bugzilla/show_bug.cgi?id=53176

          Priority: P2
            Bug ID: 53176
          Assignee: dev@poi.apache.org
           Summary: Auto shapes render problem in pptx files
          Severity: critical
    Classification: Unclassified
                OS: Windows XP
          Reporter: mdbhaskar@gmail.com
          Hardware: PC
            Status: NEW
           Version: 3.8
         Component: XSLF
           Product: POI

Created attachment 28707
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=28707&action=edit
The attachment have the auto shape that is not coming properly after rending
using the pptx2png tool

I am converting the few PPTX slides to images. few of the slides having the
multiple auto shapes (some are custom drawing shapes). all the shapes are not
rendering properly.
I have attached one image for understanding the problem.
http://apache-poi.1045710.n5.nabble.com/file/n5679512/problem.png

Is there any limitation on auto shapes rendering. 
Based on the feed back I am raising the bug, please review and let me know what
could be the issue?

I am using the poi-3.8-beta5 version jar files.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 53176] [PATCH] Auto shapes render problem in pptx files

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53176

Yegor Kozlov <ye...@dinom.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #9 from Yegor Kozlov <ye...@dinom.ru> ---
A very good patch, Andreas! Applied in r1540290. 

I suspect there may be similar rendering issues in the future when we will need
to tweak the transformation matrix. When I was writing the pptx rendering
engine I tried to cover *most* of the base cases such as rotation and flipping
but you never know it for sure with graphics :) 

Regards,
Yegor

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 53176] Auto shapes render problem in pptx files

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53176

mdbhaskar <md...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|Windows XP                  |All

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 53176] Auto shapes render problem in pptx files

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53176

Nick Burch <ni...@alfresco.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO
                 OS|All                         |Windows XP

--- Comment #4 from Nick Burch <ni...@alfresco.com> ---
(In reply to comment #3)
> It is one of the severe blocker in my current development project. Could you please provide us the solution, it is very much helpful to development?

Apache POI is, like all Apache projects, a volunteer project. We do try to fix
all the bugs we can do, but the priorities are set by the people willing to put
the time in to do the work!

If this bug is important to you, there are two main options. 

The first is to work on it yourself! If you want to go down this round, please
join the dev list, and people will do their best to guide you and give advice
on the general area. The second option is pay someone (either via a support
contract, or some consultancy) to work on the problem urgently. Otherwise, it
will be fixed when volunteer time permits, which depending on the complexity of
the issue and how it affects those who are willing to work on it, may be some
time...

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 53176] [PATCH] Auto shapes render problem in pptx files

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53176

Yegor Kozlov <ye...@dinom.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 53176] Auto shapes render problem in pptx files

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53176

mdbhaskar <md...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 53176] Auto shapes render problem in pptx files

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53176

mdbhaskar <md...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P1

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 53176] Auto shapes render problem in pptx files

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53176

mdbhaskar <md...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mdbhaskar@gmail.com

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 53176] Auto shapes render problem in pptx files

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53176

--- Comment #5 from Andreas Beeker <an...@gmx.de> ---
Created attachment 30902
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=30902&action=edit
[patch] Bug 53176 - scale to bounding box after/in XSLFShape.applyTransform

When shapes are rotated their bounding box wasn't resized to the specified
anchor.
I have to admit, that it seems to be a bit clumsy to use the graphics-transform
to calculate the scaling, but at least it eventually worked ...
I haven't added a test-case, as I don't know how to check for that certain
geometrical feature.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 53176] Auto shapes render problem in pptx files

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53176

Andreas Beeker <an...@gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #30902|0                           |1
        is obsolete|                            |

--- Comment #8 from Andreas Beeker <an...@gmx.de> ---
Created attachment 30919
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=30919&action=edit
[patch] Bug 53176 - scale to bounding box after/in XSLFShape.applyTransform II

fixed version ... sorry for the double posting (see above), but for a moment it
looked like I could edit the existing attachment ..

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 53176] Auto shapes render problem in pptx files

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53176

--- Comment #7 from Andreas Beeker <an...@gmx.de> ---
Comment on attachment 30902
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=30902
[patch] Bug 53176 - scale to bounding box after/in XSLFShape.applyTransform

Index: src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java
===================================================================
--- src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java    (revision
1529677)
+++ src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java    (working
copy)
@@ -141,11 +141,42 @@
         double rotation = getRotation();
         if (rotation != 0.) {
             // PowerPoint rotates shapes relative to the geometric center
-            double centerX = anchor.getX() + anchor.getWidth() / 2;
-            double centerY = anchor.getY() + anchor.getHeight() / 2;
+            double centerX = anchor.getCenterX();
+            double centerY = anchor.getCenterY();

+            // normalize rotation
+            rotation = (360.+(rotation%360.))%360.;
+            int quadrant = (((int)rotation+45)/90)%4;
+            double scaleX = 1.0, scaleY = 1.0;
+
+            // scale to bounding box (bug #53176)
+            if (quadrant == 1 || quadrant == 3) {
+                // In quadrant 1 and 3, which is basically a shape in a more
or less portrait orientation (45°-135° and 225°-315°),
+                // we need to first rotate the shape by a multiple of 90° and
then resize the bounding box  
+                // to its original bbox. After that we can rotate the shape to
the exact rotation amount.
+                // It's strange that you'll need to rotate the shape back and
forth again, but you can
+                // think of it, as if you paint the shape on a canvas. First
you rotate the canvas, which might
+                // be already (differently) scaled, so you can paint the shape
in its default orientation
+                // and later on, turn it around again to compare it with its
original size ...
+                AffineTransform txg = new AffineTransform(); // graphics
coordinate space
+                AffineTransform txs = new AffineTransform(tx); // shape
coordinate space
+                txg.translate(centerX, centerY);
+                txg.rotate(Math.toRadians(quadrant*90));
+                txg.translate(-centerX, -centerY);
+                txs.translate(centerX, centerY);
+                txs.rotate(Math.toRadians(-quadrant*90));
+                txs.translate(-centerX, -centerY);
+                txg.concatenate(txs);
+                Rectangle2D anchor2 =
txg.createTransformedShape(getAnchor()).getBounds2D();
+                scaleX = anchor.getWidth() == 0. ? 1.0 : anchor.getWidth() /
anchor2.getWidth();
+                scaleY = anchor.getHeight() == 0. ? 1.0 : anchor.getHeight() /
anchor2.getHeight();
+            }
+
+            // transformation is applied reversed ...
             graphics.translate(centerX, centerY);
-            graphics.rotate(Math.toRadians(rotation));
+            graphics.rotate(Math.toRadians(rotation-(double)(quadrant*90)));
+            graphics.scale(scaleX, scaleY);
+            graphics.rotate(Math.toRadians(quadrant*90));
             graphics.translate(-centerX, -centerY);
         }

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 53176] Auto shapes render problem in pptx files

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53176

mdbhaskar <md...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 53176] Auto shapes render problem in pptx files

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53176

mdbhaskar <md...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 53176] Auto shapes render problem in pptx files

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53176

--- Comment #2 from mdbhaskar <md...@gmail.com> ---
Created attachment 28716
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=28716&action=edit
Sample pptx file

Please find attached problematic pptx file. Please let me know what could be
the issue?

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 53176] Auto shapes render problem in pptx files

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53176

--- Comment #6 from Andreas Beeker <an...@gmx.de> ---
Comment on attachment 30902
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=30902
[patch] Bug 53176 - scale to bounding box after/in XSLFShape.applyTransform

This patch doesn't work as intended. The transformation is applied twice and it
only works for the bug example, because its rotated 90°. When you use other
values for the rotation, the rendering differs between libre office and office
viewer. In LO its somehow skewed whereas in office viewer, the scaling depends
on the quadrant of the circle, i.e. for degrees 0-45° it won't be scaled, for
deg. 46-135° the height of the bounding box will be scaled to the width and
vice versa ...
I hopefully supply a different patch soon ...

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 53176] Auto shapes render problem in pptx files

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53176

Yegor Kozlov <ye...@dinom.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #1 from Yegor Kozlov <ye...@dinom.ru> ---
Please attach the .pptx file.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 53176] Auto shapes render problem in pptx files

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53176

--- Comment #3 from mdbhaskar <md...@gmail.com> ---
I have attached requested sample problematic file. It is one of the severe
blocker in my current development project. Could you please provide us the
solution, it is very much helpful to development?

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 53176] [PATCH] Auto shapes render problem in pptx files

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53176

Nick Burch <ap...@gagravarr.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Auto shapes render problem  |[PATCH] Auto shapes render
                   |in pptx files               |problem in pptx files

-- 
You are receiving this mail because:
You are the assignee for the bug.

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