aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2016-05-22 23:57:14 +0000
committerAndreas Beeker <kiwiwings@apache.org>2016-05-22 23:57:14 +0000
commit74f28fbaecea2141ae08fb7434f1c0f22d49bcdd (patch)
tree8d97b93656fb9177a956085876d8aebf0b97bff4 /src
parent00b6716c191f078b9b4608365d412d1be007c6cb (diff)
downloadpoi-74f28fbaecea2141ae08fb7434f1c0f22d49bcdd.tar.gz
poi-74f28fbaecea2141ae08fb7434f1c0f22d49bcdd.zip
XSLF: remove creation of empty paragraph in XSLFTextShape.addNewTextParagraph()
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1745100 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java11
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java3
2 files changed, 11 insertions, 3 deletions
diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java
index 5aa11f1deb..f38ea9701e 100644
--- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java
+++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java
@@ -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;
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java
index 525f55ef7b..798dc472aa 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java
@@ -194,7 +194,8 @@ public class TestXSLFAutoShape {
assertEquals(1000, p.getXmlObject().getPPr().getLnSpc().getSpcPts().getVal());
assertFalse(p.getXmlObject().getPPr().getLnSpc().isSetSpcPct());
- assertFalse(p.getXmlObject().getPPr().isSetAlgn());
+ // align is set in autoshape prototype
+ assertTrue(p.getXmlObject().getPPr().isSetAlgn());
assertEquals(TextAlign.LEFT, p.getTextAlign());
p.setTextAlign(TextAlign.LEFT);
assertTrue(p.getXmlObject().getPPr().isSetAlgn());