You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by sa...@apache.org on 2020/08/27 04:16:57 UTC
svn commit: r1881232 - in /poi/trunk/src/ooxml:
java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java
Author: sayi
Date: Thu Aug 27 04:16:56 2020
New Revision: 1881232
URL: http://svn.apache.org/viewvc?rev=1881232&view=rev
Log:
Add get/set indentationLeftChars/indentationRightChars in paragraph
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java?rev=1881232&r1=1881231&r2=1881232&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java Thu Aug 27 04:16:56 2020
@@ -1167,6 +1167,32 @@ public class XWPFParagraph implements IB
}
/**
+ * Get the indentation which is placed at the left/start of this paragraph
+ *
+ * @return indentation in hundredths of a character unit or -1 if indentation is not set
+ */
+ public int getIndentationLeftChars() {
+ CTInd indentation = getCTInd(false);
+ return (indentation != null && indentation.isSetLeftChars()) ? indentation.getLeftChars().intValue()
+ : -1;
+ }
+
+ /**
+ * Specifies the indentation which shall be placed at the left/start of this paragraph
+ * <p>
+ * If this attribute is omitted, its value shall be assumed to be zero.
+ * if the left/start attribute is specified, then its value is ignored, and is superseded by this value.
+ * </p>
+ *
+ * @param indentation this value is specified in hundredths of a character unit
+ */
+ public void setIndentationLeftChars(int indentation) {
+ CTInd indent = getCTInd(true);
+ BigInteger bi = new BigInteger(Integer.toString(indentation));
+ indent.setLeftChars(bi);
+ }
+
+ /**
* Specifies the indentation which shall be placed between the right text
* margin for this paragraph and the right edge of that paragraph's content
* in a left to right paragraph, and the right text margin and the right
@@ -1206,6 +1232,32 @@ public class XWPFParagraph implements IB
}
/**
+ * Get the indentation which is placed at the right/end of this paragraph
+ *
+ * @return indentation in hundredths of a character unit or -1 if indentation is not set
+ */
+ public int getIndentationRightChars() {
+ CTInd indentation = getCTInd(false);
+ return (indentation != null && indentation.isSetRightChars()) ? indentation.getRightChars().intValue()
+ : -1;
+ }
+
+ /**
+ * Specifies the indentation which shall be placed at the right/end of this paragraph
+ * <p>
+ * If this attribute is omitted, its value shall be assumed to be zero.
+ * if the right/end attribute is specified, then its value is ignored, and is superseded by this value.
+ * </p>
+ *
+ * @param indentation this value is specified in hundredths of a character unit
+ */
+ public void setIndentationRightChars(int indentation) {
+ CTInd indent = getCTInd(true);
+ BigInteger bi = new BigInteger(Integer.toString(indentation));
+ indent.setRightChars(bi);
+ }
+
+ /**
* Specifies the indentation which shall be removed from the first line of
* the parent paragraph, by moving the indentation on the first line back
* towards the beginning of the direction of text flow.
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java?rev=1881232&r1=1881231&r2=1881232&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java Thu Aug 27 04:16:56 2020
@@ -202,6 +202,22 @@ public final class TestXWPFParagraph {
}
@Test
+ public void testSetGetIndentationChars() throws IOException {
+ try (XWPFDocument doc = new XWPFDocument()) {
+ XWPFParagraph p = doc.createParagraph();
+
+ assertEquals(-1, p.getIndentationLeftChars());
+ assertEquals(-1, p.getIndentationRightChars());
+ // set 1.5 characters
+ p.setIndentationLeftChars(150);
+ assertEquals(150, p.getIndentationLeftChars());
+
+ p.setIndentationRightChars(250);
+ assertEquals(250, p.getIndentationRightChars());
+ }
+ }
+
+ @Test
public void testSetGetIndentation() throws IOException {
try (XWPFDocument doc = new XWPFDocument()) {
XWPFParagraph p = doc.createParagraph();
@@ -221,7 +237,6 @@ public final class TestXWPFParagraph {
assertEquals(100, ind.getLeft().intValue());
}
}
-
@Test
public void testSetGetVerticalAlignment() throws IOException {
//new clean instance of paragraph
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org