diff options
author | PJ Fanning <pjfanning@users.noreply.github.com> | 2025-07-24 21:12:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-24 21:12:33 +0100 |
commit | 5642c122f33b313b4a835da4f7379befc7c4dcac (patch) | |
tree | 7e6bea7a640a5a55f901208d697af99f4abbdf01 /poi-ooxml/src | |
parent | a96c0d9d78215d99063145382233a4bdf098e993 (diff) | |
download | poi-trunk.tar.gz poi-trunk.zip |
we've seen evidence in deeply nested docs that it can cause recursion issues when this is lazily evaluated
Diffstat (limited to 'poi-ooxml/src')
-rw-r--r-- | poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFAbstractSDT.java | 5 | ||||
-rw-r--r-- | poi-ooxml/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(); |