This is an automated email from the ASF dual-hosted git repository.
fanningpj pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi.git
The following commit(s) were added to refs/heads/trunk by this push:
new 5642c122f3 eager XWPF doc eval (#860)
5642c122f3 is described below
commit 5642c122f33b313b4a835da4f7379befc7c4dcac
Author: PJ Fanning <[email protected]>
AuthorDate: Thu Jul 24 21:12:33 2025 +0100
eager XWPF doc eval (#860)
we've seen evidence in deeply nested docs that it can cause recursion
issues when this is lazily evaluated
---
.../main/java/org/apache/poi/xwpf/usermodel/XWPFAbstractSDT.java | 5 +++--
.../src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java | 6 +++++-
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git
a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFAbstractSDT.java
b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFAbstractSDT.java
index 434d857f2c..78ed571886 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFAbstractSDT.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFAbstractSDT.java
@@ -30,12 +30,13 @@ public abstract class XWPFAbstractSDT implements
ISDTContents {
private final String title;
private final String tag;
private final IBody part;
+ private final XWPFDocument xwpfDocument;
public XWPFAbstractSDT(CTSdtPr pr, IBody part) {
title = (pr != null && pr.isSetAlias()) ? pr.getAlias().getVal() : "";
tag = (pr != null && pr.isSetTag()) ? pr.getTag().getVal() : "";
this.part = part;
-
+ this.xwpfDocument = part.getXWPFDocument();
}
/**
@@ -86,6 +87,6 @@ public abstract class XWPFAbstractSDT implements ISDTContents
{
}
public XWPFDocument getDocument() {
- return part.getXWPFDocument();
+ return xwpfDocument;
}
}
diff --git
a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java
b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java
index d8d3304e99..27f7dbfaf9 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java
@@ -67,6 +67,7 @@ public class XWPFTableCell implements IBody, ICell {
}
private final CTTc ctTc;
+ private final XWPFDocument xwpfDocument;
protected List<XWPFParagraph> paragraphs;
protected List<XWPFTable> tables;
protected List<IBodyElement> bodyElements;
@@ -81,6 +82,7 @@ public class XWPFTableCell implements IBody, ICell {
this.ctTc = cell;
this.part = part;
this.tableRow = tableRow;
+ this.xwpfDocument = part.getXWPFDocument();
bodyElements = new ArrayList<>();
paragraphs = new ArrayList<>();
@@ -524,7 +526,9 @@ public class XWPFTableCell implements IBody, ICell {
@Override
public XWPFDocument getXWPFDocument() {
- if (part instanceof XWPFTableCell) {
+ if (xwpfDocument != null) {
+ return xwpfDocument;
+ } else if (part instanceof XWPFTableCell) {
return getCellDocument((XWPFTableCell) part, 0);
} else {
return part.getXWPFDocument();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]