diff options
author | PJ Fanning <fanningpj@apache.org> | 2022-09-14 19:32:25 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2022-09-14 19:32:25 +0000 |
commit | cf22264d7054884bc8a4ae322bafd7fb631c950e (patch) | |
tree | f96fb81235f2db6ae90f85c3d3e323bd2470a814 /poi-ooxml/src/main | |
parent | af6bc9660ff4383bb132cefbe08ce23dab2301bf (diff) | |
download | poi-cf22264d7054884bc8a4ae322bafd7fb631c950e.tar.gz poi-cf22264d7054884bc8a4ae322bafd7fb631c950e.zip |
[bug-66263] add test case to try to get extra classes into poi-ooxml-lite
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1904081 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml/src/main')
-rw-r--r-- | poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFSDT.java | 6 | ||||
-rw-r--r-- | poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java | 20 |
2 files changed, 26 insertions, 0 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFSDT.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFSDT.java index 82aa024623..645653a8cb 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFSDT.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFSDT.java @@ -17,6 +17,7 @@ package org.apache.poi.xwpf.usermodel; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtBlock; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtRow; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtRun; /** @@ -39,6 +40,11 @@ public class XWPFSDT extends XWPFAbstractSDT this.content = new XWPFSDTContent(block.getSdtContent(), part, this); } + public XWPFSDT(CTSdtRow row, IBody part) { + super(row.getSdtPr(), part); + this.content = new XWPFSDTContent(row.getSdtContent(), part, this); + } + public ISDTContent getContent() { return content; } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java index da4fc7de35..8223435efe 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java @@ -87,6 +87,26 @@ public class XWPFSDTContent implements ISDTContent { } } + public XWPFSDTContent(CTSdtContentRow sdtContentRow, IBody part, IRunBody parent) { + if (sdtContentRow == null) { + return; + } + try (final XmlCursor cursor = sdtContentRow.newCursor()) { + cursor.selectPath("./*"); + while (cursor.toNextSelection()) { + XmlObject o = cursor.getObject(); + if (o instanceof CTSdtRow) { + XWPFSDT c = new XWPFSDT(((CTSdtRow) o), part); + bodyElements.add(c); + // contentControls.add(c); + } else if (o instanceof CTRow) { + //can only create XWPFTableRow if you have an XWPFTable instance + //XWPFTableRow tableRow = new XWPFTableRow((CTRow) o, parent); + } + } + } + } + @Override public String getText() { StringBuilder text = new StringBuilder(); |