You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2014/03/08 20:52:10 UTC
svn commit: r1575597 -
/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
Author: nick
Date: Sat Mar 8 19:52:09 2014
New Revision: 1575597
URL: http://svn.apache.org/r1575597
Log:
When adding a new XPWFRun to a paragraph, update both the Runs and IRuns lists with it
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.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=1575597&r1=1575596&r2=1575597&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 Sat Mar 8 19:52:09 2014
@@ -338,17 +338,6 @@ public class XWPFParagraph implements IB
}
/**
- * Appends a new run to this paragraph
- *
- * @return a new text run
- */
- public XWPFRun createRun() {
- XWPFRun xwpfRun = new XWPFRun(paragraph.addNewR(), this);
- runs.add(xwpfRun);
- return xwpfRun;
- }
-
- /**
* Returns the paragraph alignment which shall be applied to text in this
* paragraph.
* <p/>
@@ -1187,6 +1176,48 @@ public class XWPFParagraph implements IB
}
/**
+ * Appends a new run to this paragraph
+ *
+ * @return a new text run
+ */
+ public XWPFRun createRun() {
+ XWPFRun xwpfRun = new XWPFRun(paragraph.addNewR(), this);
+ runs.add(xwpfRun);
+ iruns.add(xwpfRun);
+ return xwpfRun;
+ }
+
+ /**
+ * insert a new Run in RunArray
+ * @param pos
+ * @return the inserted run
+ */
+ public XWPFRun insertNewRun(int pos){
+ if (pos >= 0 && pos <= paragraph.sizeOfRArray()) {
+ CTR ctRun = paragraph.insertNewR(pos);
+ XWPFRun newRun = new XWPFRun(ctRun, this);
+
+ // To update the iruns, find where we're going
+ // in the normal runs, and go in there
+ int iPos = iruns.size();
+ if (pos < runs.size()) {
+ XWPFRun oldAtPos = runs.get(pos);
+ int oldAt = iruns.indexOf(oldAtPos);
+ if (oldAt != -1) {
+ iPos = oldAt;
+ }
+ }
+ iruns.add(iPos, newRun);
+
+ // Runs itself is easy to update
+ runs.add(pos, newRun);
+
+ return newRun;
+ }
+ return null;
+ }
+
+ /**
* this methods parse the paragraph and search for the string searched.
* If it finds the string, it will return true and the position of the String
* will be saved in the parameter startPos.
@@ -1257,21 +1288,6 @@ public class XWPFParagraph implements IB
}
/**
- * insert a new Run in RunArray
- * @param pos
- * @return the inserted run
- */
- public XWPFRun insertNewRun(int pos){
- if (pos >= 0 && pos <= paragraph.sizeOfRArray()) {
- CTR ctRun = paragraph.insertNewR(pos);
- XWPFRun newRun = new XWPFRun(ctRun, this);
- runs.add(pos, newRun);
- return newRun;
- }
- return null;
- }
-
- /**
* get a Text
* @param segment
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org