[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:
PJ Fanning 2018-08-02 20:04:49 +00:00
parent 361117c17a
commit 9a6fde7673
13 changed files with 49 additions and 49 deletions

View File

@ -41,10 +41,10 @@ public class FootnoteEndnoteIdManager {
public BigInteger nextId() {
List<BigInteger> ids = new ArrayList<BigInteger>();
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();

View File

@ -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>
* @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<XWPFTable> tables = new ArrayList<>();
private List<XWPFPictureData> pictures = new ArrayList<>();
private List<IBodyElement> 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();

View File

@ -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<AbstractXWPFFootnoteEndnote> listFootnote = new ArrayList<>();
protected List<XWPFAbstractFootnoteEndnote> 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;
}

View File

@ -27,12 +27,12 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTString;
* <p>
* 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 = "";

View File

@ -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>
* <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.
* The {@link XWPFParagraph#addFootnoteReference(AbstractXWPFFootnoteEndnote)}
* The {@link XWPFParagraph#addFootnoteReference(XWPFAbstractFootnoteEndnote)}
* method does this for you.</p>
* @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.
* <p>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))}.
* </p>
* <p>The first run of the first paragraph in a footnote should
* contain a {@link CTFtnEdnRef} object.</p>

View File

@ -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<XWPFEndnote> getEndnotesList() {
List<XWPFEndnote> resultList = new ArrayList<XWPFEndnote>();
for (AbstractXWPFFootnoteEndnote note : listFootnote) {
for (XWPFAbstractFootnoteEndnote note : listFootnote) {
resultList.add((XWPFEndnote)note);
}
return resultList;

View File

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

View File

@ -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<XWPFFootnote> getFootnotesList() {
List<XWPFFootnote> resultList = new ArrayList<XWPFFootnote>();
for (AbstractXWPFFootnoteEndnote note : listFootnote) {
for (XWPFAbstractFootnoteEndnote note : listFootnote) {
resultList.add((XWPFFootnote)note);
}
return resultList;

View File

@ -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");

View File

@ -25,7 +25,7 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtRun;
* <p>
* 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;

View File

@ -27,7 +27,7 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtCell;
* <p>
* 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) {

View File

@ -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);

View File

@ -40,8 +40,8 @@ public final class TestXWPFSDT {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("Bug54849.docx");
String tag = null;
String title = null;
List<AbstractXWPFSDT> sdts = extractAllSDTs(doc);
for (AbstractXWPFSDT sdt : sdts) {
List<XWPFAbstractSDT> 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<AbstractXWPFSDT> sdts = extractAllSDTs(doc);
List<XWPFAbstractSDT> 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<AbstractXWPFSDT> sdts = extractAllSDTs(doc);
List<XWPFAbstractSDT> 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<AbstractXWPFSDT> sdts = extractAllSDTs(doc);
List<XWPFAbstractSDT> sdts = extractAllSDTs(doc);
List<String> 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<AbstractXWPFSDT> sdts = extractAllSDTs(doc);
List<XWPFAbstractSDT> sdts = extractAllSDTs(doc);
assertEquals(1, sdts.size());
assertEquals("", sdts.get(0).getTag());
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();
for (XWPFHeader header : headers) {
@ -172,8 +172,8 @@ public final class TestXWPFSDT {
return sdts;
}
private List<AbstractXWPFSDT> extractSDTsFromBodyElements(List<IBodyElement> elements) {
List<AbstractXWPFSDT> sdts = new ArrayList<>();
private List<XWPFAbstractSDT> extractSDTsFromBodyElements(List<IBodyElement> elements) {
List<XWPFAbstractSDT> 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<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 (ICell c : r.getTableICells()) {
if (c instanceof XWPFSDTCell) {