When adding a new XPWFRun to a paragraph, update both the Runs and IRuns lists with it
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1575597 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
70e1b5edeb
commit
d5c8510750
@ -337,17 +337,6 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents {
|
|||||||
return footnoteText.toString();
|
return footnoteText.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
* Returns the paragraph alignment which shall be applied to text in this
|
||||||
* paragraph.
|
* paragraph.
|
||||||
@ -1186,6 +1175,48 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents {
|
|||||||
paragraph.setRArray(pos, run);
|
paragraph.setRArray(pos, run);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
* 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
|
* If it finds the string, it will return true and the position of the String
|
||||||
@ -1256,21 +1287,6 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
* get a Text
|
||||||
* @param segment
|
* @param segment
|
||||||
|
Loading…
Reference in New Issue
Block a user