From 12b239f3f21c9bc59af07db51f7773d5b472947c Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Thu, 2 Aug 2018 20:04:49 +0000 Subject: [PATCH] [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 --- .../usermodel/FootnoteEndnoteIdManager.java | 4 +-- ....java => XWPFAbstractFootnoteEndnote.java} | 10 +++---- ...ava => XWPFAbstractFootnotesEndnotes.java} | 18 ++++++------ ...tractXWPFSDT.java => XWPFAbstractSDT.java} | 4 +-- .../poi/xwpf/usermodel/XWPFEndnote.java | 8 +++--- .../poi/xwpf/usermodel/XWPFEndnotes.java | 4 +-- .../poi/xwpf/usermodel/XWPFFootnote.java | 6 ++-- .../poi/xwpf/usermodel/XWPFFootnotes.java | 4 +-- .../poi/xwpf/usermodel/XWPFParagraph.java | 4 +-- .../apache/poi/xwpf/usermodel/XWPFSDT.java | 2 +- .../poi/xwpf/usermodel/XWPFSDTCell.java | 2 +- .../poi/xwpf/usermodel/TestXWPFFootnotes.java | 4 +-- .../poi/xwpf/usermodel/TestXWPFSDT.java | 28 +++++++++---------- 13 files changed, 49 insertions(+), 49 deletions(-) rename src/ooxml/java/org/apache/poi/xwpf/usermodel/{AbstractXWPFFootnoteEndnote.java => XWPFAbstractFootnoteEndnote.java} (98%) rename src/ooxml/java/org/apache/poi/xwpf/usermodel/{AbstractXWPFFootnotesEndnotes.java => XWPFAbstractFootnotesEndnotes.java} (80%) rename src/ooxml/java/org/apache/poi/xwpf/usermodel/{AbstractXWPFSDT.java => XWPFAbstractSDT.java} (96%) diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/FootnoteEndnoteIdManager.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/FootnoteEndnoteIdManager.java index 7fcefe2f79..2dc78b1d94 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/FootnoteEndnoteIdManager.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/FootnoteEndnoteIdManager.java @@ -41,10 +41,10 @@ public class FootnoteEndnoteIdManager { public BigInteger nextId() { List ids = new ArrayList(); - for (AbstractXWPFFootnoteEndnote note : document.getFootnotes()) { + for (XWPFAbstractFootnoteEndnote note : document.getFootnotes()) { ids.add(note.getId()); } - for (AbstractXWPFFootnoteEndnote note : document.getEndnotes()) { + for (XWPFAbstractFootnoteEndnote note : document.getEndnotes()) { ids.add(note.getId()); } int cand = ids.size(); diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/AbstractXWPFFootnoteEndnote.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFAbstractFootnoteEndnote.java similarity index 98% rename from src/ooxml/java/org/apache/poi/xwpf/usermodel/AbstractXWPFFootnoteEndnote.java rename to src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFAbstractFootnoteEndnote.java index 606bf50a3b..88998af955 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/AbstractXWPFFootnoteEndnote.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFAbstractFootnoteEndnote.java @@ -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}.

* @since 4.0.0 */ -public abstract class AbstractXWPFFootnoteEndnote implements Iterable, IBody { +public abstract class XWPFAbstractFootnoteEndnote implements Iterable, IBody { private List paragraphs = new ArrayList<>(); private List tables = new ArrayList<>(); private List pictures = new ArrayList<>(); private List bodyElements = new ArrayList<>(); protected CTFtnEdn ctFtnEdn; - protected AbstractXWPFFootnotesEndnotes footnotes; + protected XWPFAbstractFootnotesEndnotes footnotes; protected XWPFDocument document; - public AbstractXWPFFootnoteEndnote() { + public XWPFAbstractFootnoteEndnote() { super(); } @Internal - protected AbstractXWPFFootnoteEndnote(XWPFDocument document, CTFtnEdn body) { + protected XWPFAbstractFootnoteEndnote(XWPFDocument document, CTFtnEdn body) { ctFtnEdn = body; this.document = document; init(); } @Internal - protected AbstractXWPFFootnoteEndnote(CTFtnEdn note, AbstractXWPFFootnotesEndnotes footnotes) { + protected XWPFAbstractFootnoteEndnote(CTFtnEdn note, XWPFAbstractFootnotesEndnotes footnotes) { this.footnotes = footnotes; ctFtnEdn = note; document = footnotes.getXWPFDocument(); diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/AbstractXWPFFootnotesEndnotes.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFAbstractFootnotesEndnotes.java similarity index 80% rename from src/ooxml/java/org/apache/poi/xwpf/usermodel/AbstractXWPFFootnotesEndnotes.java rename to src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFAbstractFootnotesEndnotes.java index e0ed976f43..d626350298 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/AbstractXWPFFootnotesEndnotes.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFAbstractFootnotesEndnotes.java @@ -27,36 +27,36 @@ import org.apache.poi.openxml4j.opc.PackagePart; * Base class for the Footnotes and Endnotes part implementations. * @since 4.0.0 */ -public abstract class AbstractXWPFFootnotesEndnotes extends POIXMLDocumentPart { +public abstract class XWPFAbstractFootnotesEndnotes extends POIXMLDocumentPart { protected XWPFDocument document; - protected List listFootnote = new ArrayList<>(); + protected List listFootnote = new ArrayList<>(); private FootnoteEndnoteIdManager idManager; - public AbstractXWPFFootnotesEndnotes(OPCPackage pkg) { + public XWPFAbstractFootnotesEndnotes(OPCPackage pkg) { super(pkg); } - public AbstractXWPFFootnotesEndnotes(OPCPackage pkg, + public XWPFAbstractFootnotesEndnotes(OPCPackage pkg, String coreDocumentRel) { super(pkg, coreDocumentRel); } - public AbstractXWPFFootnotesEndnotes() { + public XWPFAbstractFootnotesEndnotes() { super(); } - public AbstractXWPFFootnotesEndnotes(PackagePart part) { + public XWPFAbstractFootnotesEndnotes(PackagePart part) { super(part); } - public AbstractXWPFFootnotesEndnotes(POIXMLDocumentPart parent, PackagePart part) { + public XWPFAbstractFootnotesEndnotes(POIXMLDocumentPart parent, PackagePart part) { super(parent, part); } - public AbstractXWPFFootnoteEndnote getFootnoteById(int id) { - for (AbstractXWPFFootnoteEndnote note : listFootnote) { + public XWPFAbstractFootnoteEndnote getFootnoteById(int id) { + for (XWPFAbstractFootnoteEndnote note : listFootnote) { if (note.getCTFtnEdn().getId().intValue() == id) return note; } diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/AbstractXWPFSDT.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFAbstractSDT.java similarity index 96% rename from src/ooxml/java/org/apache/poi/xwpf/usermodel/AbstractXWPFSDT.java rename to src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFAbstractSDT.java index bacabcbe84..93b2cdba8a 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/AbstractXWPFSDT.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFAbstractSDT.java @@ -27,12 +27,12 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTString; *

* 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 tag; private final IBody part; - public AbstractXWPFSDT(CTSdtPr pr, IBody part) { + public XWPFAbstractSDT(CTSdtPr pr, IBody part) { if (pr == null) { title = ""; tag = ""; diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFEndnote.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFEndnote.java index 8f728788de..f18c1c118a 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFEndnote.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFEndnote.java @@ -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.

*

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. - * The {@link XWPFParagraph#addFootnoteReference(AbstractXWPFFootnoteEndnote)} + * The {@link XWPFParagraph#addFootnoteReference(XWPFAbstractFootnoteEndnote)} * method does this for you.

* @since 4.0.0 */ -public class XWPFEndnote extends AbstractXWPFFootnoteEndnote { +public class XWPFEndnote extends XWPFAbstractFootnoteEndnote { public XWPFEndnote() {} @@ -48,7 +48,7 @@ public class XWPFEndnote extends AbstractXWPFFootnoteEndnote { } @Internal - public XWPFEndnote(CTFtnEdn note, AbstractXWPFFootnotesEndnotes footnotes) { + public XWPFEndnote(CTFtnEdn note, XWPFAbstractFootnotesEndnotes 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. *

This method is for the first paragraph in the footnote, not * paragraphs that will refer to the footnote. For references to - * the footnote, use {@link XWPFParagraph#addFootnoteReference(AbstractXWPFFootnoteEndnote))}. + * the footnote, use {@link XWPFParagraph#addFootnoteReference(XWPFAbstractFootnoteEndnote))}. *

*

The first run of the first paragraph in a footnote should * contain a {@link CTFtnEdnRef} object.

diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFEndnotes.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFEndnotes.java index ebca459c05..deb76de2cb 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFEndnotes.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFEndnotes.java @@ -44,7 +44,7 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.STFtnEdn; * Managed end notes ({@link XWPFEndnote}). * @since 4.0.0 */ -public class XWPFEndnotes extends AbstractXWPFFootnotesEndnotes { +public class XWPFEndnotes extends XWPFAbstractFootnotesEndnotes { protected CTEndnotes ctEndnotes; @@ -183,7 +183,7 @@ public class XWPFEndnotes extends AbstractXWPFFootnotesEndnotes { */ public List getEndnotesList() { List resultList = new ArrayList(); - for (AbstractXWPFFootnoteEndnote note : listFootnote) { + for (XWPFAbstractFootnoteEndnote note : listFootnote) { resultList.add((XWPFEndnote)note); } return resultList; diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnote.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnote.java index d4afd64512..77459ecc87 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnote.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnote.java @@ -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.

*

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. - * The {@link XWPFParagraph#addFootnoteReference(AbstractXWPFFootnoteEndnote)} + * The {@link XWPFParagraph#addFootnoteReference(XWPFAbstractFootnoteEndnote)} * method does this for you.

*/ -public class XWPFFootnote extends AbstractXWPFFootnoteEndnote { +public class XWPFFootnote extends XWPFAbstractFootnoteEndnote { @Internal - public XWPFFootnote(CTFtnEdn note, AbstractXWPFFootnotesEndnotes xFootnotes) { + public XWPFFootnote(CTFtnEdn note, XWPFAbstractFootnotesEndnotes xFootnotes) { super(note, xFootnotes); } diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnotes.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnotes.java index 4f3fa83b0d..144c692dcc 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnotes.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFFootnotes.java @@ -43,7 +43,7 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.STFtnEdn; * Looks after the collection of Footnotes for a document. * Manages bottom-of-the-page footnotes ({@link XWPFFootnote}). */ -public class XWPFFootnotes extends AbstractXWPFFootnotesEndnotes { +public class XWPFFootnotes extends XWPFAbstractFootnotesEndnotes { protected CTFootnotes ctFootnotes; /** @@ -173,7 +173,7 @@ public class XWPFFootnotes extends AbstractXWPFFootnotesEndnotes { */ public List getFootnotesList() { List resultList = new ArrayList(); - for (AbstractXWPFFootnoteEndnote note : listFootnote) { + for (XWPFAbstractFootnoteEndnote note : listFootnote) { resultList.add((XWPFFootnote)note); } return resultList; diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java index 5080cec9f3..41ad4222fb 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java @@ -76,7 +76,7 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para if (o instanceof CTFtnEdnRef) { CTFtnEdnRef ftn = (CTFtnEdnRef) o; footnoteText.append(" [").append(ftn.getId()).append(": "); - AbstractXWPFFootnoteEndnote footnote = + XWPFAbstractFootnoteEndnote footnote = ftn.getDomNode().getLocalName().equals("footnoteReference") ? document.getFootnoteByID(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. * @since 4.0.0 */ - public void addFootnoteReference(AbstractXWPFFootnoteEndnote footnote) { + public void addFootnoteReference(XWPFAbstractFootnoteEndnote footnote) { XWPFRun run = createRun(); CTR ctRun = run.getCTR(); ctRun.addNewRPr().addNewRStyle().setVal("FootnoteReference"); diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDT.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDT.java index 0f876357ce..82aa024623 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDT.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDT.java @@ -25,7 +25,7 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtRun; *

* WARNING - APIs expected to change rapidly */ -public class XWPFSDT extends AbstractXWPFSDT +public class XWPFSDT extends XWPFAbstractSDT implements IBodyElement, IRunBody, ISDTContents, IRunElement { private final ISDTContent content; diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTCell.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTCell.java index 438303c40b..5589287263 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTCell.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTCell.java @@ -27,7 +27,7 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtCell; *

* WARNING - APIs expected to change rapidly */ -public class XWPFSDTCell extends AbstractXWPFSDT implements ICell { +public class XWPFSDTCell extends XWPFAbstractSDT implements ICell { private final XWPFSDTContentCell cellContent; public XWPFSDTCell(CTSdtCell sdtCell, XWPFTableRow xwpfTableRow, IBody part) { diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFFootnotes.java b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFFootnotes.java index 39fb397442..1071f40c79 100644 --- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFFootnotes.java +++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFFootnotes.java @@ -31,11 +31,11 @@ public class TestXWPFFootnotes extends TestCase { public void testCreateFootnotes() throws IOException{ XWPFDocument docOut = new XWPFDocument(); - AbstractXWPFFootnotesEndnotes footnotes = docOut.createFootnotes(); + XWPFAbstractFootnotesEndnotes footnotes = docOut.createFootnotes(); assertNotNull(footnotes); - AbstractXWPFFootnotesEndnotes secondFootnotes = docOut.createFootnotes(); + XWPFAbstractFootnotesEndnotes secondFootnotes = docOut.createFootnotes(); assertSame(footnotes, secondFootnotes); diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFSDT.java b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFSDT.java index 39a3ac6751..deac5c09ae 100644 --- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFSDT.java +++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFSDT.java @@ -40,8 +40,8 @@ public final class TestXWPFSDT { XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("Bug54849.docx"); String tag = null; String title = null; - List sdts = extractAllSDTs(doc); - for (AbstractXWPFSDT sdt : sdts) { + List sdts = extractAllSDTs(doc); + for (XWPFAbstractSDT sdt : sdts) { if (sdt.getContent().toString().equals("Rich_text")) { tag = "MyTag"; title = "MyTitle"; @@ -74,12 +74,12 @@ public final class TestXWPFSDT { }; XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("Bug54849.docx"); - List sdts = extractAllSDTs(doc); + List sdts = extractAllSDTs(doc); assertEquals("number of sdts", contents.length, sdts.size()); 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()); } } @@ -92,7 +92,7 @@ public final class TestXWPFSDT { //Bug54771a.docx and Bug54771b.docx test slightly //different recursion patterns. Keep both! XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("Bug54771a.docx"); - List sdts = extractAllSDTs(doc); + List sdts = extractAllSDTs(doc); String text = sdts.get(0).getContent().getText(); assertEquals(2, sdts.size()); assertContains(text, "Test"); @@ -118,7 +118,7 @@ public final class TestXWPFSDT { @Test public void testNewLinesBetweenRuns() throws Exception { XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("Bug55142.docx"); - List sdts = extractAllSDTs(doc); + List sdts = extractAllSDTs(doc); List targs = new ArrayList<>(); //these test newlines and tabs in paragraphs/body elements targs.add("Rich-text1 abcdefghi"); @@ -133,7 +133,7 @@ public final class TestXWPFSDT { targs.add("sdt_incell2 abcdefg"); 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()); } } @@ -142,15 +142,15 @@ public final class TestXWPFSDT { public void test60341() throws IOException { //handle sdtbody without an sdtpr XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("Bug60341.docx"); - List sdts = extractAllSDTs(doc); + List sdts = extractAllSDTs(doc); assertEquals(1, sdts.size()); assertEquals("", sdts.get(0).getTag()); assertEquals("", sdts.get(0).getTitle()); } - private List extractAllSDTs(XWPFDocument doc) { + private List extractAllSDTs(XWPFDocument doc) { - List sdts = new ArrayList<>(); + List sdts = new ArrayList<>(); List headers = doc.getHeaderList(); for (XWPFHeader header : headers) { @@ -172,8 +172,8 @@ public final class TestXWPFSDT { return sdts; } - private List extractSDTsFromBodyElements(List elements) { - List sdts = new ArrayList<>(); + private List extractSDTsFromBodyElements(List elements) { + List sdts = new ArrayList<>(); for (IBodyElement e : elements) { if (e instanceof XWPFSDT) { XWPFSDT sdt = (XWPFSDT) e; @@ -195,9 +195,9 @@ public final class TestXWPFSDT { return sdts; } - private List extractSDTsFromTable(XWPFTable table) { + private List extractSDTsFromTable(XWPFTable table) { - List sdts = new ArrayList<>(); + List sdts = new ArrayList<>(); for (XWPFTableRow r : table.getRows()) { for (ICell c : r.getTableICells()) { if (c instanceof XWPFSDTCell) { -- 2.39.5