diff options
-rw-r--r-- | src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextRun.java | 3 | ||||
-rw-r--r-- | src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java | 3 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xddf/usermodel/text/TestXDDFTextRun.java | 31 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java | 27 | ||||
-rw-r--r-- | test-data/slideshow/bug63290.pptx | bin | 0 -> 31877 bytes |
5 files changed, 63 insertions, 1 deletions
diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextRun.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextRun.java index a9583c200d..89f5dced01 100644 --- a/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextRun.java +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextRun.java @@ -612,7 +612,8 @@ public class XDDFTextRun { } else if (isRegularRun() && _rtr.isSetRPr()) { return _rtr.getRPr(); } - return null; + XDDFRunProperties defaultProperties = _parent.getDefaultRunProperties(); + return (defaultProperties == null) ? null : defaultProperties.getXmlObject(); } private XDDFRunProperties getOrCreateProperties() { diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java index d89c881711..16df8cecd7 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java @@ -492,6 +492,9 @@ public class XSLFTextRun implements TextRun { return tr.addNewRPr(); } } + if (_p.getXmlObject().isSetPPr() && _p.getXmlObject().getPPr().isSetDefRPr()) { + return _p.getXmlObject().getPPr().getDefRPr(); + } return null; } diff --git a/src/ooxml/testcases/org/apache/poi/xddf/usermodel/text/TestXDDFTextRun.java b/src/ooxml/testcases/org/apache/poi/xddf/usermodel/text/TestXDDFTextRun.java index e162ba18fb..1b45b8251f 100644 --- a/src/ooxml/testcases/org/apache/poi/xddf/usermodel/text/TestXDDFTextRun.java +++ b/src/ooxml/testcases/org/apache/poi/xddf/usermodel/text/TestXDDFTextRun.java @@ -18,16 +18,22 @@ package org.apache.poi.xddf.usermodel.text; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import java.io.IOException; +import java.io.InputStream; import java.util.List; +import org.apache.poi.POIDataSamples; import org.apache.poi.util.LocaleUtil; import org.apache.poi.xslf.usermodel.XMLSlideShow; +import org.apache.poi.xslf.usermodel.XSLFShape; import org.apache.poi.xslf.usermodel.XSLFSlide; +import org.apache.poi.xslf.usermodel.XSLFTextParagraph; +import org.apache.poi.xslf.usermodel.XSLFTextRun; import org.apache.poi.xslf.usermodel.XSLFTextShape; import org.apache.poi.xssf.usermodel.XSSFClientAnchor; import org.apache.poi.xssf.usermodel.XSSFDrawing; @@ -133,4 +139,29 @@ public class TestXDDFTextRun { assertNotNull(run.getText()); } } + + @Test + public void testDefaultRunProperties() throws IOException { + // bug #63290 + POIDataSamples pds = POIDataSamples.getSlideShowInstance(); + try (InputStream is = pds.openResourceAsStream("bug63290.pptx"); + XMLSlideShow ppt = new XMLSlideShow(is)) { + XSLFSlide slide = ppt.getSlides().get(0); + for (XSLFShape shape : slide.getShapes()) { + if (shape instanceof XSLFTextShape) { + XSLFTextShape text = (XSLFTextShape) shape; + XDDFTextParagraph paragraph = text.getTextBody().getParagraph(0); + XDDFTextRun defaultRun = paragraph.getTextRuns().get(0); + assertEquals("DefaultRunProperties", defaultRun.getText().trim()); + XDDFTextRun explicitRun = paragraph.getTextRuns().get(1); + assertEquals("ExplicitRunProperties", explicitRun.getText().trim()); + assertEquals(defaultRun.getDirty(), explicitRun.getDirty()); + assertEquals(defaultRun.getFontSize(), explicitRun.getFontSize()); + assertEquals(defaultRun.getLanguage(), explicitRun.getLanguage()); + assertEquals(defaultRun.getSpellError(), explicitRun.getSpellError()); + assertNotEquals(defaultRun.getFontColor(), explicitRun.getFontColor()); + } + } + } + } } diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java index a3158b234d..8d26fc62e5 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java @@ -21,11 +21,15 @@ package org.apache.poi.xslf.usermodel; import static org.apache.poi.sl.TestCommonSL.getColor; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; import java.awt.Color; import java.io.IOException; +import java.io.InputStream; +import org.apache.poi.POIDataSamples; +import org.apache.poi.ooxml.POIXMLDocumentPart; import org.apache.poi.sl.draw.DrawTextParagraph; import org.junit.Test; import org.openxmlformats.schemas.drawingml.x2006.main.CTTextLineBreak; @@ -118,4 +122,27 @@ public class TestXSLFTextRun { r.copy(s); } + + @Test + public void testDefaultRunProperties() throws IOException { + // bug #63290 + POIDataSamples pds = POIDataSamples.getSlideShowInstance(); + try (InputStream is = pds.openResourceAsStream("bug63290.pptx"); + XMLSlideShow ppt = new XMLSlideShow(is)) { + XSLFSlide slide = ppt.getSlides().get(0); + for (XSLFShape shape : slide.getShapes()) { + if (shape instanceof XSLFTextShape) { + XSLFTextShape text = (XSLFTextShape) shape; + XSLFTextParagraph paragraph = text.getTextParagraphs().get(0); + XSLFTextRun defaultRun = paragraph.getTextRuns().get(0); + assertEquals("DefaultRunProperties", defaultRun.getRawText().trim()); + XSLFTextRun explicitRun = paragraph.getTextRuns().get(1); + assertEquals("ExplicitRunProperties", explicitRun.getRawText().trim()); + assertEquals(defaultRun.getFontSize(), explicitRun.getFontSize()); + assertNotEquals(defaultRun.getFontColor(), explicitRun.getFontColor()); + } + } + } + } + } diff --git a/test-data/slideshow/bug63290.pptx b/test-data/slideshow/bug63290.pptx Binary files differnew file mode 100644 index 0000000000..84c3994b5c --- /dev/null +++ b/test-data/slideshow/bug63290.pptx |