wip: bookmark replace

This commit is contained in:
zzs 2025-03-03 18:30:33 +08:00
parent 4643237449
commit efd01c8d2e

View File

@ -82,6 +82,7 @@ public class BookmarkExec {
List<XWPFRun> runs = paragraph.getRuns();
XWPFRun run = null;
int idx = 0;
boolean doR = false;
for (int i = 0; i < runs.size(); i++) {
Node previousSibling = runs.get(i).getCTR().getDomNode().getPreviousSibling();
if (previousSibling != null) {
@ -92,16 +93,17 @@ public class BookmarkExec {
Node nameAttribute = bookmarkStartNode.getAttributes().getNamedItem("w:name");
if (nameAttribute != null && name.equals(nameAttribute.getNodeValue())) {
idx = i - 1;
doR = true;
break;
}
}
}
}
}
if (idx >= 0 && idx < runs.size()) {
if (idx >= 0 && idx < runs.size() && doR) {
run = runs.get(idx);
} else {
run = paragraph.createRun();
run = runs.get(runs.size() - 1);
}
BookmarkReplaceDataModel model = map.get(name);
BookmarkType type = model.getType();