mirror of https://github.com/apache/poi.git
[github-120] rename some new xpwf abstract classes. This closes #120
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1837335 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
56facac036
commit
12b239f3f2
|
@ -41,10 +41,10 @@ public class FootnoteEndnoteIdManager {
|
||||||
public BigInteger nextId() {
|
public BigInteger nextId() {
|
||||||
|
|
||||||
List<BigInteger> ids = new ArrayList<BigInteger>();
|
List<BigInteger> ids = new ArrayList<BigInteger>();
|
||||||
for (AbstractXWPFFootnoteEndnote note : document.getFootnotes()) {
|
for (XWPFAbstractFootnoteEndnote note : document.getFootnotes()) {
|
||||||
ids.add(note.getId());
|
ids.add(note.getId());
|
||||||
}
|
}
|
||||||
for (AbstractXWPFFootnoteEndnote note : document.getEndnotes()) {
|
for (XWPFAbstractFootnoteEndnote note : document.getEndnotes()) {
|
||||||
ids.add(note.getId());
|
ids.add(note.getId());
|
||||||
}
|
}
|
||||||
int cand = ids.size();
|
int cand = ids.size();
|
||||||
|
|
|
@ -42,29 +42,29 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc;
|
||||||
* {@link XWPFFootnotes} and end notes are managed by the Endnotes part {@link XWPFEndnotes}.</p>
|
* {@link XWPFFootnotes} and end notes are managed by the Endnotes part {@link XWPFEndnotes}.</p>
|
||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractXWPFFootnoteEndnote implements Iterable<XWPFParagraph>, IBody {
|
public abstract class XWPFAbstractFootnoteEndnote implements Iterable<XWPFParagraph>, IBody {
|
||||||
|
|
||||||
private List<XWPFParagraph> paragraphs = new ArrayList<>();
|
private List<XWPFParagraph> paragraphs = new ArrayList<>();
|
||||||
private List<XWPFTable> tables = new ArrayList<>();
|
private List<XWPFTable> tables = new ArrayList<>();
|
||||||
private List<XWPFPictureData> pictures = new ArrayList<>();
|
private List<XWPFPictureData> pictures = new ArrayList<>();
|
||||||
private List<IBodyElement> bodyElements = new ArrayList<>();
|
private List<IBodyElement> bodyElements = new ArrayList<>();
|
||||||
protected CTFtnEdn ctFtnEdn;
|
protected CTFtnEdn ctFtnEdn;
|
||||||
protected AbstractXWPFFootnotesEndnotes footnotes;
|
protected XWPFAbstractFootnotesEndnotes footnotes;
|
||||||
protected XWPFDocument document;
|
protected XWPFDocument document;
|
||||||
|
|
||||||
public AbstractXWPFFootnoteEndnote() {
|
public XWPFAbstractFootnoteEndnote() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Internal
|
@Internal
|
||||||
protected AbstractXWPFFootnoteEndnote(XWPFDocument document, CTFtnEdn body) {
|
protected XWPFAbstractFootnoteEndnote(XWPFDocument document, CTFtnEdn body) {
|
||||||
ctFtnEdn = body;
|
ctFtnEdn = body;
|
||||||
this.document = document;
|
this.document = document;
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Internal
|
@Internal
|
||||||
protected AbstractXWPFFootnoteEndnote(CTFtnEdn note, AbstractXWPFFootnotesEndnotes footnotes) {
|
protected XWPFAbstractFootnoteEndnote(CTFtnEdn note, XWPFAbstractFootnotesEndnotes footnotes) {
|
||||||
this.footnotes = footnotes;
|
this.footnotes = footnotes;
|
||||||
ctFtnEdn = note;
|
ctFtnEdn = note;
|
||||||
document = footnotes.getXWPFDocument();
|
document = footnotes.getXWPFDocument();
|
|
@ -27,36 +27,36 @@ import org.apache.poi.openxml4j.opc.PackagePart;
|
||||||
* Base class for the Footnotes and Endnotes part implementations.
|
* Base class for the Footnotes and Endnotes part implementations.
|
||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractXWPFFootnotesEndnotes extends POIXMLDocumentPart {
|
public abstract class XWPFAbstractFootnotesEndnotes extends POIXMLDocumentPart {
|
||||||
|
|
||||||
protected XWPFDocument document;
|
protected XWPFDocument document;
|
||||||
protected List<AbstractXWPFFootnoteEndnote> listFootnote = new ArrayList<>();
|
protected List<XWPFAbstractFootnoteEndnote> listFootnote = new ArrayList<>();
|
||||||
private FootnoteEndnoteIdManager idManager;
|
private FootnoteEndnoteIdManager idManager;
|
||||||
|
|
||||||
public AbstractXWPFFootnotesEndnotes(OPCPackage pkg) {
|
public XWPFAbstractFootnotesEndnotes(OPCPackage pkg) {
|
||||||
super(pkg);
|
super(pkg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractXWPFFootnotesEndnotes(OPCPackage pkg,
|
public XWPFAbstractFootnotesEndnotes(OPCPackage pkg,
|
||||||
String coreDocumentRel) {
|
String coreDocumentRel) {
|
||||||
super(pkg, coreDocumentRel);
|
super(pkg, coreDocumentRel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractXWPFFootnotesEndnotes() {
|
public XWPFAbstractFootnotesEndnotes() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractXWPFFootnotesEndnotes(PackagePart part) {
|
public XWPFAbstractFootnotesEndnotes(PackagePart part) {
|
||||||
super(part);
|
super(part);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractXWPFFootnotesEndnotes(POIXMLDocumentPart parent, PackagePart part) {
|
public XWPFAbstractFootnotesEndnotes(POIXMLDocumentPart parent, PackagePart part) {
|
||||||
super(parent, part);
|
super(parent, part);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public AbstractXWPFFootnoteEndnote getFootnoteById(int id) {
|
public XWPFAbstractFootnoteEndnote getFootnoteById(int id) {
|
||||||
for (AbstractXWPFFootnoteEndnote note : listFootnote) {
|
for (XWPFAbstractFootnoteEndnote note : listFootnote) {
|
||||||
if (note.getCTFtnEdn().getId().intValue() == id)
|
if (note.getCTFtnEdn().getId().intValue() == id)
|
||||||
return note;
|
return note;
|
||||||
}
|
}
|
|
@ -27,12 +27,12 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTString;
|
||||||
* <p>
|
* <p>
|
||||||
* These classes have so far been built only for read-only processing.
|
* These classes have so far been built only for read-only processing.
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractXWPFSDT implements ISDTContents {
|
public abstract class XWPFAbstractSDT implements ISDTContents {
|
||||||
private final String title;
|
private final String title;
|
||||||
private final String tag;
|
private final String tag;
|
||||||
private final IBody part;
|
private final IBody part;
|
||||||
|
|
||||||
public AbstractXWPFSDT(CTSdtPr pr, IBody part) {
|
public XWPFAbstractSDT(CTSdtPr pr, IBody part) {
|
||||||
if (pr == null) {
|
if (pr == null) {
|
||||||
title = "";
|
title = "";
|
||||||
tag = "";
|
tag = "";
|
|
@ -34,11 +34,11 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
|
||||||
* the footnote ID to create a reference to a footnote from within a paragraph.</p>
|
* the footnote ID to create a reference to a footnote from within a paragraph.</p>
|
||||||
* <p>To create a reference to a footnote within a paragraph you create a run
|
* <p>To create a reference to a footnote within a paragraph you create a run
|
||||||
* with a CTFtnEdnRef that specifies the ID of the target paragraph.
|
* with a CTFtnEdnRef that specifies the ID of the target paragraph.
|
||||||
* The {@link XWPFParagraph#addFootnoteReference(AbstractXWPFFootnoteEndnote)}
|
* The {@link XWPFParagraph#addFootnoteReference(XWPFAbstractFootnoteEndnote)}
|
||||||
* method does this for you.</p>
|
* method does this for you.</p>
|
||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
*/
|
*/
|
||||||
public class XWPFEndnote extends AbstractXWPFFootnoteEndnote {
|
public class XWPFEndnote extends XWPFAbstractFootnoteEndnote {
|
||||||
|
|
||||||
public XWPFEndnote() {}
|
public XWPFEndnote() {}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ public class XWPFEndnote extends AbstractXWPFFootnoteEndnote {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Internal
|
@Internal
|
||||||
public XWPFEndnote(CTFtnEdn note, AbstractXWPFFootnotesEndnotes footnotes) {
|
public XWPFEndnote(CTFtnEdn note, XWPFAbstractFootnotesEndnotes footnotes) {
|
||||||
super(note, footnotes);
|
super(note, footnotes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public class XWPFEndnote extends AbstractXWPFFootnoteEndnote {
|
||||||
* end note by adding a footnote reference if one is not found.
|
* end note by adding a footnote reference if one is not found.
|
||||||
* <p>This method is for the first paragraph in the footnote, not
|
* <p>This method is for the first paragraph in the footnote, not
|
||||||
* paragraphs that will refer to the footnote. For references to
|
* paragraphs that will refer to the footnote. For references to
|
||||||
* the footnote, use {@link XWPFParagraph#addFootnoteReference(AbstractXWPFFootnoteEndnote))}.
|
* the footnote, use {@link XWPFParagraph#addFootnoteReference(XWPFAbstractFootnoteEndnote))}.
|
||||||
* </p>
|
* </p>
|
||||||
* <p>The first run of the first paragraph in a footnote should
|
* <p>The first run of the first paragraph in a footnote should
|
||||||
* contain a {@link CTFtnEdnRef} object.</p>
|
* contain a {@link CTFtnEdnRef} object.</p>
|
||||||
|
|
|
@ -44,7 +44,7 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.STFtnEdn;
|
||||||
* Managed end notes ({@link XWPFEndnote}).
|
* Managed end notes ({@link XWPFEndnote}).
|
||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
*/
|
*/
|
||||||
public class XWPFEndnotes extends AbstractXWPFFootnotesEndnotes {
|
public class XWPFEndnotes extends XWPFAbstractFootnotesEndnotes {
|
||||||
|
|
||||||
protected CTEndnotes ctEndnotes;
|
protected CTEndnotes ctEndnotes;
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ public class XWPFEndnotes extends AbstractXWPFFootnotesEndnotes {
|
||||||
*/
|
*/
|
||||||
public List<XWPFEndnote> getEndnotesList() {
|
public List<XWPFEndnote> getEndnotesList() {
|
||||||
List<XWPFEndnote> resultList = new ArrayList<XWPFEndnote>();
|
List<XWPFEndnote> resultList = new ArrayList<XWPFEndnote>();
|
||||||
for (AbstractXWPFFootnoteEndnote note : listFootnote) {
|
for (XWPFAbstractFootnoteEndnote note : listFootnote) {
|
||||||
resultList.add((XWPFEndnote)note);
|
resultList.add((XWPFEndnote)note);
|
||||||
}
|
}
|
||||||
return resultList;
|
return resultList;
|
||||||
|
|
|
@ -32,13 +32,13 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
|
||||||
* the footnote ID to create a reference to a footnote from within a paragraph.</p>
|
* the footnote ID to create a reference to a footnote from within a paragraph.</p>
|
||||||
* <p>To create a reference to a footnote within a paragraph you create a run
|
* <p>To create a reference to a footnote within a paragraph you create a run
|
||||||
* with a CTFtnEdnRef that specifies the ID of the target paragraph.
|
* with a CTFtnEdnRef that specifies the ID of the target paragraph.
|
||||||
* The {@link XWPFParagraph#addFootnoteReference(AbstractXWPFFootnoteEndnote)}
|
* The {@link XWPFParagraph#addFootnoteReference(XWPFAbstractFootnoteEndnote)}
|
||||||
* method does this for you.</p>
|
* method does this for you.</p>
|
||||||
*/
|
*/
|
||||||
public class XWPFFootnote extends AbstractXWPFFootnoteEndnote {
|
public class XWPFFootnote extends XWPFAbstractFootnoteEndnote {
|
||||||
|
|
||||||
@Internal
|
@Internal
|
||||||
public XWPFFootnote(CTFtnEdn note, AbstractXWPFFootnotesEndnotes xFootnotes) {
|
public XWPFFootnote(CTFtnEdn note, XWPFAbstractFootnotesEndnotes xFootnotes) {
|
||||||
super(note, xFootnotes);
|
super(note, xFootnotes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.STFtnEdn;
|
||||||
* Looks after the collection of Footnotes for a document.
|
* Looks after the collection of Footnotes for a document.
|
||||||
* Manages bottom-of-the-page footnotes ({@link XWPFFootnote}).
|
* Manages bottom-of-the-page footnotes ({@link XWPFFootnote}).
|
||||||
*/
|
*/
|
||||||
public class XWPFFootnotes extends AbstractXWPFFootnotesEndnotes {
|
public class XWPFFootnotes extends XWPFAbstractFootnotesEndnotes {
|
||||||
protected CTFootnotes ctFootnotes;
|
protected CTFootnotes ctFootnotes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -173,7 +173,7 @@ public class XWPFFootnotes extends AbstractXWPFFootnotesEndnotes {
|
||||||
*/
|
*/
|
||||||
public List<XWPFFootnote> getFootnotesList() {
|
public List<XWPFFootnote> getFootnotesList() {
|
||||||
List<XWPFFootnote> resultList = new ArrayList<XWPFFootnote>();
|
List<XWPFFootnote> resultList = new ArrayList<XWPFFootnote>();
|
||||||
for (AbstractXWPFFootnoteEndnote note : listFootnote) {
|
for (XWPFAbstractFootnoteEndnote note : listFootnote) {
|
||||||
resultList.add((XWPFFootnote)note);
|
resultList.add((XWPFFootnote)note);
|
||||||
}
|
}
|
||||||
return resultList;
|
return resultList;
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
|
||||||
if (o instanceof CTFtnEdnRef) {
|
if (o instanceof CTFtnEdnRef) {
|
||||||
CTFtnEdnRef ftn = (CTFtnEdnRef) o;
|
CTFtnEdnRef ftn = (CTFtnEdnRef) o;
|
||||||
footnoteText.append(" [").append(ftn.getId()).append(": ");
|
footnoteText.append(" [").append(ftn.getId()).append(": ");
|
||||||
AbstractXWPFFootnoteEndnote footnote =
|
XWPFAbstractFootnoteEndnote footnote =
|
||||||
ftn.getDomNode().getLocalName().equals("footnoteReference") ?
|
ftn.getDomNode().getLocalName().equals("footnoteReference") ?
|
||||||
document.getFootnoteByID(ftn.getId().intValue()) :
|
document.getFootnoteByID(ftn.getId().intValue()) :
|
||||||
document.getEndnoteByID(ftn.getId().intValue());
|
document.getEndnoteByID(ftn.getId().intValue());
|
||||||
|
@ -1678,7 +1678,7 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
|
||||||
* @param footnote Footnote to which to add a reference.
|
* @param footnote Footnote to which to add a reference.
|
||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
*/
|
*/
|
||||||
public void addFootnoteReference(AbstractXWPFFootnoteEndnote footnote) {
|
public void addFootnoteReference(XWPFAbstractFootnoteEndnote footnote) {
|
||||||
XWPFRun run = createRun();
|
XWPFRun run = createRun();
|
||||||
CTR ctRun = run.getCTR();
|
CTR ctRun = run.getCTR();
|
||||||
ctRun.addNewRPr().addNewRStyle().setVal("FootnoteReference");
|
ctRun.addNewRPr().addNewRStyle().setVal("FootnoteReference");
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtRun;
|
||||||
* <p>
|
* <p>
|
||||||
* WARNING - APIs expected to change rapidly
|
* WARNING - APIs expected to change rapidly
|
||||||
*/
|
*/
|
||||||
public class XWPFSDT extends AbstractXWPFSDT
|
public class XWPFSDT extends XWPFAbstractSDT
|
||||||
implements IBodyElement, IRunBody, ISDTContents, IRunElement {
|
implements IBodyElement, IRunBody, ISDTContents, IRunElement {
|
||||||
private final ISDTContent content;
|
private final ISDTContent content;
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtCell;
|
||||||
* <p>
|
* <p>
|
||||||
* WARNING - APIs expected to change rapidly
|
* WARNING - APIs expected to change rapidly
|
||||||
*/
|
*/
|
||||||
public class XWPFSDTCell extends AbstractXWPFSDT implements ICell {
|
public class XWPFSDTCell extends XWPFAbstractSDT implements ICell {
|
||||||
private final XWPFSDTContentCell cellContent;
|
private final XWPFSDTContentCell cellContent;
|
||||||
|
|
||||||
public XWPFSDTCell(CTSdtCell sdtCell, XWPFTableRow xwpfTableRow, IBody part) {
|
public XWPFSDTCell(CTSdtCell sdtCell, XWPFTableRow xwpfTableRow, IBody part) {
|
||||||
|
|
|
@ -31,11 +31,11 @@ public class TestXWPFFootnotes extends TestCase {
|
||||||
public void testCreateFootnotes() throws IOException{
|
public void testCreateFootnotes() throws IOException{
|
||||||
XWPFDocument docOut = new XWPFDocument();
|
XWPFDocument docOut = new XWPFDocument();
|
||||||
|
|
||||||
AbstractXWPFFootnotesEndnotes footnotes = docOut.createFootnotes();
|
XWPFAbstractFootnotesEndnotes footnotes = docOut.createFootnotes();
|
||||||
|
|
||||||
assertNotNull(footnotes);
|
assertNotNull(footnotes);
|
||||||
|
|
||||||
AbstractXWPFFootnotesEndnotes secondFootnotes = docOut.createFootnotes();
|
XWPFAbstractFootnotesEndnotes secondFootnotes = docOut.createFootnotes();
|
||||||
|
|
||||||
assertSame(footnotes, secondFootnotes);
|
assertSame(footnotes, secondFootnotes);
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,8 @@ public final class TestXWPFSDT {
|
||||||
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("Bug54849.docx");
|
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("Bug54849.docx");
|
||||||
String tag = null;
|
String tag = null;
|
||||||
String title = null;
|
String title = null;
|
||||||
List<AbstractXWPFSDT> sdts = extractAllSDTs(doc);
|
List<XWPFAbstractSDT> sdts = extractAllSDTs(doc);
|
||||||
for (AbstractXWPFSDT sdt : sdts) {
|
for (XWPFAbstractSDT sdt : sdts) {
|
||||||
if (sdt.getContent().toString().equals("Rich_text")) {
|
if (sdt.getContent().toString().equals("Rich_text")) {
|
||||||
tag = "MyTag";
|
tag = "MyTag";
|
||||||
title = "MyTitle";
|
title = "MyTitle";
|
||||||
|
@ -74,12 +74,12 @@ public final class TestXWPFSDT {
|
||||||
|
|
||||||
};
|
};
|
||||||
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("Bug54849.docx");
|
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("Bug54849.docx");
|
||||||
List<AbstractXWPFSDT> sdts = extractAllSDTs(doc);
|
List<XWPFAbstractSDT> sdts = extractAllSDTs(doc);
|
||||||
|
|
||||||
assertEquals("number of sdts", contents.length, sdts.size());
|
assertEquals("number of sdts", contents.length, sdts.size());
|
||||||
|
|
||||||
for (int i = 0; i < contents.length; i++) {
|
for (int i = 0; i < contents.length; i++) {
|
||||||
AbstractXWPFSDT sdt = sdts.get(i);
|
XWPFAbstractSDT sdt = sdts.get(i);
|
||||||
assertEquals(i + ": " + contents[i], contents[i], sdt.getContent().toString());
|
assertEquals(i + ": " + contents[i], contents[i], sdt.getContent().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ public final class TestXWPFSDT {
|
||||||
//Bug54771a.docx and Bug54771b.docx test slightly
|
//Bug54771a.docx and Bug54771b.docx test slightly
|
||||||
//different recursion patterns. Keep both!
|
//different recursion patterns. Keep both!
|
||||||
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("Bug54771a.docx");
|
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("Bug54771a.docx");
|
||||||
List<AbstractXWPFSDT> sdts = extractAllSDTs(doc);
|
List<XWPFAbstractSDT> sdts = extractAllSDTs(doc);
|
||||||
String text = sdts.get(0).getContent().getText();
|
String text = sdts.get(0).getContent().getText();
|
||||||
assertEquals(2, sdts.size());
|
assertEquals(2, sdts.size());
|
||||||
assertContains(text, "Test");
|
assertContains(text, "Test");
|
||||||
|
@ -118,7 +118,7 @@ public final class TestXWPFSDT {
|
||||||
@Test
|
@Test
|
||||||
public void testNewLinesBetweenRuns() throws Exception {
|
public void testNewLinesBetweenRuns() throws Exception {
|
||||||
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("Bug55142.docx");
|
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("Bug55142.docx");
|
||||||
List<AbstractXWPFSDT> sdts = extractAllSDTs(doc);
|
List<XWPFAbstractSDT> sdts = extractAllSDTs(doc);
|
||||||
List<String> targs = new ArrayList<>();
|
List<String> targs = new ArrayList<>();
|
||||||
//these test newlines and tabs in paragraphs/body elements
|
//these test newlines and tabs in paragraphs/body elements
|
||||||
targs.add("Rich-text1 abcdefghi");
|
targs.add("Rich-text1 abcdefghi");
|
||||||
|
@ -133,7 +133,7 @@ public final class TestXWPFSDT {
|
||||||
targs.add("sdt_incell2 abcdefg");
|
targs.add("sdt_incell2 abcdefg");
|
||||||
|
|
||||||
for (int i = 0; i < sdts.size(); i++) {
|
for (int i = 0; i < sdts.size(); i++) {
|
||||||
AbstractXWPFSDT sdt = sdts.get(i);
|
XWPFAbstractSDT sdt = sdts.get(i);
|
||||||
assertEquals(targs.get(i), targs.get(i), sdt.getContent().getText());
|
assertEquals(targs.get(i), targs.get(i), sdt.getContent().getText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,15 +142,15 @@ public final class TestXWPFSDT {
|
||||||
public void test60341() throws IOException {
|
public void test60341() throws IOException {
|
||||||
//handle sdtbody without an sdtpr
|
//handle sdtbody without an sdtpr
|
||||||
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("Bug60341.docx");
|
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("Bug60341.docx");
|
||||||
List<AbstractXWPFSDT> sdts = extractAllSDTs(doc);
|
List<XWPFAbstractSDT> sdts = extractAllSDTs(doc);
|
||||||
assertEquals(1, sdts.size());
|
assertEquals(1, sdts.size());
|
||||||
assertEquals("", sdts.get(0).getTag());
|
assertEquals("", sdts.get(0).getTag());
|
||||||
assertEquals("", sdts.get(0).getTitle());
|
assertEquals("", sdts.get(0).getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<AbstractXWPFSDT> extractAllSDTs(XWPFDocument doc) {
|
private List<XWPFAbstractSDT> extractAllSDTs(XWPFDocument doc) {
|
||||||
|
|
||||||
List<AbstractXWPFSDT> sdts = new ArrayList<>();
|
List<XWPFAbstractSDT> sdts = new ArrayList<>();
|
||||||
|
|
||||||
List<XWPFHeader> headers = doc.getHeaderList();
|
List<XWPFHeader> headers = doc.getHeaderList();
|
||||||
for (XWPFHeader header : headers) {
|
for (XWPFHeader header : headers) {
|
||||||
|
@ -172,8 +172,8 @@ public final class TestXWPFSDT {
|
||||||
return sdts;
|
return sdts;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<AbstractXWPFSDT> extractSDTsFromBodyElements(List<IBodyElement> elements) {
|
private List<XWPFAbstractSDT> extractSDTsFromBodyElements(List<IBodyElement> elements) {
|
||||||
List<AbstractXWPFSDT> sdts = new ArrayList<>();
|
List<XWPFAbstractSDT> sdts = new ArrayList<>();
|
||||||
for (IBodyElement e : elements) {
|
for (IBodyElement e : elements) {
|
||||||
if (e instanceof XWPFSDT) {
|
if (e instanceof XWPFSDT) {
|
||||||
XWPFSDT sdt = (XWPFSDT) e;
|
XWPFSDT sdt = (XWPFSDT) e;
|
||||||
|
@ -195,9 +195,9 @@ public final class TestXWPFSDT {
|
||||||
return sdts;
|
return sdts;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<AbstractXWPFSDT> extractSDTsFromTable(XWPFTable table) {
|
private List<XWPFAbstractSDT> extractSDTsFromTable(XWPFTable table) {
|
||||||
|
|
||||||
List<AbstractXWPFSDT> sdts = new ArrayList<>();
|
List<XWPFAbstractSDT> sdts = new ArrayList<>();
|
||||||
for (XWPFTableRow r : table.getRows()) {
|
for (XWPFTableRow r : table.getRows()) {
|
||||||
for (ICell c : r.getTableICells()) {
|
for (ICell c : r.getTableICells()) {
|
||||||
if (c instanceof XWPFSDTCell) {
|
if (c instanceof XWPFSDTCell) {
|
||||||
|
|
Loading…
Reference in New Issue