You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2020/11/14 16:39:44 UTC
svn commit: r1883424 - in
/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel: IBody.java
XWPFAbstractFootnoteEndnote.java XWPFDocument.java XWPFHeaderFooter.java
XWPFTableCell.java
Author: fanningpj
Date: Sat Nov 14 16:39:44 2020
New Revision: 1883424
URL: http://svn.apache.org/viewvc?rev=1883424&view=rev
Log:
[github-195] Rework getParagraph functions for XWPF. Thanks to Marius Volhart. This closes #195
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/IBody.java
poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFAbstractFootnoteEndnote.java
poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java
poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/IBody.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/IBody.java?rev=1883424&r1=1883423&r2=1883424&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/IBody.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/IBody.java Sat Nov 14 16:39:44 2020
@@ -71,13 +71,11 @@ public interface IBody {
public List<XWPFTable> getTables();
/**
- * if there is a corresponding {@link XWPFParagraph} of the parameter ctTable in the paragraphList of this header or footer
- * the method will return this paragraph
- * if there is no corresponding {@link XWPFParagraph} the method will return null
+ * Returns the paragraph corresponding to the provided {@link CTP}.
*
* @param p is instance of CTP and is searching for an XWPFParagraph
- * @return null if there is no XWPFParagraph with an corresponding CTPparagraph in the paragraphList of this header or footer
- * XWPFParagraph with the correspondig CTP p
+ * @return The paragraph corresponding to the {@link CTP}, or {@code null} if there is no corresponding paragraph in
+ * this body.
*/
public XWPFParagraph getParagraph(CTP p);
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFAbstractFootnoteEndnote.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFAbstractFootnoteEndnote.java?rev=1883424&r1=1883423&r2=1883424&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFAbstractFootnoteEndnote.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFAbstractFootnoteEndnote.java Sat Nov 14 16:39:44 2020
@@ -90,7 +90,7 @@ public abstract class XWPFAbstractFootno
XWPFSDT c = new XWPFSDT((CTSdtBlock) o, this);
bodyElements.add(c);
}
-
+
}
cursor.dispose();
}
@@ -182,7 +182,7 @@ public abstract class XWPFAbstractFootno
i++;
}
tables.add(i, table);
-
+
}
/**
@@ -204,15 +204,7 @@ public abstract class XWPFAbstractFootno
return null;
}
- /**
- * if there is a corresponding {@link XWPFParagraph} of the parameter p in the paragraphList of this header or footer
- * the method will return that paragraph, otherwise the method will return null.
- *
- * @param p The CTP paragraph to find the corresponding {@link XWPFParagraph} for.
- * @return The {@link XWPFParagraph} that corresponds to the CTP paragraph in the paragraph
- * list of this footnote or null if no paragraph is found.
- * @see org.apache.poi.xwpf.usermodel.IBody#getParagraph(CTP p)
- */
+ @Override
public XWPFParagraph getParagraph(CTP p) {
for (XWPFParagraph paragraph : paragraphs) {
if (paragraph.getCTP().equals(p))
@@ -456,10 +448,10 @@ public abstract class XWPFAbstractFootno
XWPFParagraph p = new XWPFParagraph(this.ctFtnEdn.addNewP(), this);
paragraphs.add(p);
bodyElements.add(p);
-
+
// If the paragraph is the first paragraph in the footnote,
// ensure that it has a footnote reference run.
-
+
if (p.equals(getParagraphs().get(0))) {
ensureFootnoteRef(p);
}
@@ -512,4 +504,4 @@ public abstract class XWPFAbstractFootno
return table;
}
-}
\ No newline at end of file
+}
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java?rev=1883424&r1=1883423&r2=1883424&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java Sat Nov 14 16:39:44 2020
@@ -1546,17 +1546,11 @@ public class XWPFDocument extends POIXML
return styles;
}
- /**
- * get the paragraph with the CTP class p
- *
- * @param p
- * @return the paragraph with the CTP class p
- */
@Override
public XWPFParagraph getParagraph(CTP p) {
- for (int i = 0; i < getParagraphs().size(); i++) {
- if (getParagraphs().get(i).getCTP() == p) {
- return getParagraphs().get(i);
+ for (XWPFParagraph paragraph : paragraphs) {
+ if (paragraph.getCTP() == p) {
+ return paragraph;
}
}
return null;
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java?rev=1883424&r1=1883423&r2=1883424&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFHeaderFooter.java Sat Nov 14 16:39:44 2020
@@ -180,22 +180,13 @@ public abstract class XWPFHeaderFooter e
return null;
}
- /**
- * if there is a corresponding {@link XWPFParagraph} of the parameter ctTable in the paragraphList of this header or footer
- * the method will return this paragraph
- * if there is no corresponding {@link XWPFParagraph} the method will return null
- *
- * @param p is instance of CTP and is searching for an XWPFParagraph
- * @return null if there is no XWPFParagraph with an corresponding CTPparagraph in the paragraphList of this header or footer
- * XWPFParagraph with the correspondig CTP p
- */
+ @Override
public XWPFParagraph getParagraph(CTP p) {
for (XWPFParagraph paragraph : paragraphs) {
if (paragraph.getCTP().equals(p))
return paragraph;
}
return null;
-
}
/**
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java?rev=1883424&r1=1883423&r2=1883424&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java Sat Nov 14 16:39:44 2020
@@ -175,15 +175,7 @@ public class XWPFTableCell implements IB
bodyElements.remove(removedParagraph);
}
- /**
- * if there is a corresponding {@link XWPFParagraph} of the parameter ctTable in the paragraphList of this table
- * the method will return this paragraph
- * if there is no corresponding {@link XWPFParagraph} the method will return null
- *
- * @param p is instance of CTP and is searching for an XWPFParagraph
- * @return null if there is no XWPFParagraph with an corresponding CTPparagraph in the paragraphList of this table
- * XWPFParagraph with the correspondig CTP p
- */
+ @Override
public XWPFParagraph getParagraph(CTP p) {
for (XWPFParagraph paragraph : paragraphs) {
if (p.equals(paragraph.getCTP())) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org