]> source.dussan.org Git - poi.git/commitdiff
#65551 - Incorrect fetching paragraph and text runs props from master shape
authorAndreas Beeker <kiwiwings@apache.org>
Mon, 11 Oct 2021 19:44:47 +0000 (19:44 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Mon, 11 Oct 2021 19:44:47 +0000 (19:44 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894140 13f79535-47bb-0310-9956-ffa450edef68

poi-ooxml/src/main/java/org/apache/poi/xslf/model/CharacterPropertyFetcher.java
poi-ooxml/src/main/java/org/apache/poi/xslf/model/ParagraphPropertyFetcher.java
poi-ooxml/src/test/java/org/apache/poi/xslf/TestXSLFBugs.java
test-data/slideshow/bug65551.pptx [new file with mode: 0644]

index 0ad4ef8743978bf6539bbf0fea72d9c4b60b27f8..9443580496a42bdfb1a16c62b5bff9a75200b0b6 100644 (file)
@@ -62,9 +62,9 @@ public final class CharacterPropertyFetcher<T> extends PropertyFetcher<T> {
     public T fetchProperty(XSLFShape shape) {
         final XSLFSheet sheet = shape.getSheet();
 
+        fetchRunProp();
 
         if (!(sheet instanceof XSLFSlideMaster)) {
-            fetchRunProp();
             fetchParagraphDefaultRunProp();
             fetchShapeProp(shape);
             fetchThemeProp(shape);
index 7cce4c64a776acdb0f1b0ed13b97f18f9b8cac15..eabe75df112c8105142f97f296768d1d7633cb92 100644 (file)
@@ -72,8 +72,9 @@ public final class ParagraphPropertyFetcher<T> extends PropertyFetcher<T> {
     public T fetchProperty(XSLFShape shape) {
         final XSLFSheet sheet = shape.getSheet();
 
+        fetchParagraphProp();
+
         if (!(sheet instanceof XSLFSlideMaster)) {
-            fetchParagraphProp();
             fetchShapeProp(shape);
             fetchThemeProp(shape);
         }
index c21d24f513ebb823b74879933d2fe54060001ace..80ebf055569894e3fee66e385787edc8cd3a7369 100644 (file)
@@ -71,6 +71,7 @@ import org.apache.poi.sl.usermodel.ShapeType;
 import org.apache.poi.sl.usermodel.Slide;
 import org.apache.poi.sl.usermodel.SlideShow;
 import org.apache.poi.sl.usermodel.SlideShowFactory;
+import org.apache.poi.sl.usermodel.TextParagraph;
 import org.apache.poi.sl.usermodel.TextRun;
 import org.apache.poi.sl.usermodel.TextShape;
 import org.apache.poi.sl.usermodel.VerticalAlignment;
@@ -1063,4 +1064,18 @@ class TestXSLFBugs {
             targetPresentation.write(new UnsynchronizedByteArrayOutputStream());
         }
     }
+
+    @Test
+    public void bug65551() throws IOException {
+        try (XMLSlideShow ppt = openSampleDocument("bug65551.pptx")) {
+            XSLFTextShape shape = (XSLFTextShape)ppt.getSlideMasters().get(0).getShapes().get(1);
+            XSLFTextParagraph tp = shape.getTextParagraphs().get(0);
+            assertEquals(TextParagraph.TextAlign.RIGHT, tp.getTextAlign());
+            XSLFTextRun tr = tp.getTextRuns().get(0);
+            PaintStyle fc = tr.getFontColor();
+            assertTrue(fc instanceof SolidPaint);
+            SolidPaint sp = (SolidPaint)fc;
+            assertEquals(Color.RED, sp.getSolidColor().getColor());
+        }
+    }
 }
diff --git a/test-data/slideshow/bug65551.pptx b/test-data/slideshow/bug65551.pptx
new file mode 100644 (file)
index 0000000..f0baa5b
Binary files /dev/null and b/test-data/slideshow/bug65551.pptx differ