]> source.dussan.org Git - poi.git/commitdiff
XSLF: remove creation of empty paragraph in XSLFTextShape.addNewTextParagraph()
authorAndreas Beeker <kiwiwings@apache.org>
Sun, 22 May 2016 23:57:14 +0000 (23:57 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Sun, 22 May 2016 23:57:14 +0000 (23:57 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1745100 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java
src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java

index 5aa11f1deb64594f2ee921170d18bad62c703c2e..f38ea9701e9f9aa90d05e26ce1a097f2dc25d556 100644 (file)
@@ -175,8 +175,15 @@ public abstract class XSLFTextShape extends XSLFSimpleShape
      * @return created paragraph run
      */
     public XSLFTextParagraph addNewTextParagraph() {
-        CTTextBody txBody = getTextBody(true);
-        CTTextParagraph p = txBody.addNewP();
+        CTTextBody txBody = getTextBody(false);
+        CTTextParagraph p;
+        if (txBody == null) {
+            txBody = getTextBody(true);
+            p = txBody.getPArray(0);
+            p.removeR(0);
+        } else {
+            p = txBody.addNewP();
+        }
         XSLFTextParagraph paragraph = new XSLFTextParagraph(p, this);
         _paragraphs.add(paragraph);
         return paragraph;
index 525f55ef7b3fcb756cef43a3b266b6f289937d16..798dc472aa93345d363f1d9039228ebe3a3784aa 100644 (file)
@@ -194,7 +194,8 @@ public class TestXSLFAutoShape {
         assertEquals(1000, p.getXmlObject().getPPr().getLnSpc().getSpcPts().getVal());\r
         assertFalse(p.getXmlObject().getPPr().getLnSpc().isSetSpcPct());\r
 \r
-        assertFalse(p.getXmlObject().getPPr().isSetAlgn());\r
+        // align is set in autoshape prototype\r
+        assertTrue(p.getXmlObject().getPPr().isSetAlgn());\r
         assertEquals(TextAlign.LEFT, p.getTextAlign());\r
         p.setTextAlign(TextAlign.LEFT);\r
         assertTrue(p.getXmlObject().getPPr().isSetAlgn());\r