ASF Bugzilla – Attachment 24004 Details for
Bug 45556
[PATCH] poi-3.5-beta1-20080718.jar - content from the foot notes of a 2007 docx document is not extracted.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Additional patch for endnotes
endnotes.patch (text/plain), 6.80 KB, created by
Maxim Valyanskiy
on 2009-07-17 05:40:48 UTC
(
hide
)
Description:
Additional patch for endnotes
Filename:
MIME Type:
Creator:
Maxim Valyanskiy
Created:
2009-07-17 05:40:48 UTC
Size:
6.80 KB
patch
obsolete
>commit 84becd4347671682aff5fca8d1ce59c224f83788 >Author: maxcom <maxcom@jet.msk.su> >Date: Fri Jul 17 16:39:56 2009 +0400 > > endnotes in docx > >diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java >index 83f9ffb..4bc92b6 100644 >--- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java >+++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java >@@ -54,6 +54,7 @@ public class XWPFDocument extends POIXMLDocument { > protected List<XWPFParagraph> paragraphs; > protected List<XWPFTable> tables; > protected Map<BigInteger, XWPFFootnote> footnotes; >+ protected Map<BigInteger, XWPFFootnote> endnotes; > > /** Handles the joy of different headers/footers for different pages */ > private XWPFHeaderFooterPolicy headerFooterPolicy; >@@ -82,6 +83,7 @@ public class XWPFDocument extends POIXMLDocument { > paragraphs = new ArrayList<XWPFParagraph>(); > tables= new ArrayList<XWPFTable>(); > footnotes = new HashMap<BigInteger, XWPFFootnote>(); >+ endnotes = new HashMap<BigInteger, XWPFFootnote>(); > > try { > DocumentDocument doc = DocumentDocument.Factory.parse(getPackagePart().getInputStream()); >@@ -144,6 +146,12 @@ public class XWPFDocument extends POIXMLDocument { > for(CTFtnEdn ctFtnEdn : footnotesDocument.getFootnotes().getFootnoteArray()) { > footnotes.put(ctFtnEdn.getId(), new XWPFFootnote(this, ctFtnEdn)); > } >+ } else if (relation.equals(XWPFRelation.ENDNOTE.getRelation())){ >+ EndnotesDocument endnotesDocument = EndnotesDocument.Factory.parse(p.getPackagePart().getInputStream()); >+ >+ for(CTFtnEdn ctFtnEdn : endnotesDocument.getEndnotes().getEndnoteArray()) { >+ endnotes.put(ctFtnEdn.getId(), new XWPFFootnote(this, ctFtnEdn)); >+ } > } > } > } >@@ -219,6 +227,10 @@ public class XWPFDocument extends POIXMLDocument { > return footnotes.get(id); > } > >+ public XWPFFootnote getEndnoteByID(BigInteger id) { >+ return endnotes.get(id); >+ } >+ > public XWPFHyperlink[] getHyperlinks() { > return hyperlinks.toArray( > new XWPFHyperlink[hyperlinks.size()] >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 3dd73ff..445c5e8 100644 >--- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java >+++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java >@@ -91,7 +91,8 @@ public class XWPFParagraph { > if (o instanceof CTFtnEdnRef) { > CTFtnEdnRef ftn = (CTFtnEdnRef) o; > text.append("[").append(ftn.getId()).append(": "); >- XWPFFootnote footnote = document.getFootnoteByID(ftn.getId()); >+ XWPFFootnote footnote = >+ ftn.getDomNode().getLocalName().equals("footnoteReference")?document.getFootnoteByID(ftn.getId()):document.getEndnoteByID(ftn.getId()); > > boolean first = true; > >diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java >index c1b91bb..8000174 100755 >--- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java >+++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRelation.java >@@ -112,7 +112,12 @@ public final class XWPFRelation extends POIXMLRelation { > null, > null > ); >- >+ public static final XWPFRelation ENDNOTE = new XWPFRelation( >+ null, >+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes", >+ null, >+ null >+ ); > > private XWPFRelation(String type, String rel, String defaultName, Class<? extends POIXMLDocumentPart> cls) { > super(type, rel, defaultName, cls); >diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java b/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java >index 3391ae3..1a99cd3 100644 >--- a/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java >+++ b/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java >@@ -66,6 +66,12 @@ public class TestXWPFWordExtractor extends TestCase { > private XWPFDocument xmlFootnotes2; > private File fileFootnotes2; > >+ /** >+ * File with endnotes >+ */ >+ private XWPFDocument xmlEndnotes; >+ private File fileEndnotes; >+ > protected void setUp() throws Exception { > super.setUp(); > >@@ -97,6 +103,10 @@ public class TestXWPFWordExtractor extends TestCase { > System.getProperty("HWPF.testdata.path") + > File.separator + "Table.docx" > ); >+ fileEndnotes = new File( >+ System.getProperty("HWPF.testdata.path") + >+ File.separator + "A Nepalese name for Tilaka.docx" >+ ); > > assertTrue(fileA.exists()); > assertTrue(fileB.exists()); >@@ -105,6 +115,7 @@ public class TestXWPFWordExtractor extends TestCase { > assertTrue(fileE.exists()); > assertTrue(fileFootnotes.exists()); > assertTrue(fileFootnotes2.exists()); >+ assertTrue(fileEndnotes.exists()); > > xmlA = new XWPFDocument(POIXMLDocument.openPackage(fileA.toString())); > xmlB = new XWPFDocument(POIXMLDocument.openPackage(fileB.toString())); >@@ -113,6 +124,7 @@ public class TestXWPFWordExtractor extends TestCase { > xmlE = new XWPFDocument(POIXMLDocument.openPackage(fileE.toString())); > xmlFootnotes = new XWPFDocument(POIXMLDocument.openPackage(fileFootnotes.toString())); > xmlFootnotes2 = new XWPFDocument(POIXMLDocument.openPackage(fileFootnotes2.toString())); >+ xmlEndnotes = new XWPFDocument(POIXMLDocument.openPackage(fileEndnotes.toString())); > } > > /** >@@ -267,4 +279,12 @@ public class TestXWPFWordExtractor extends TestCase { > assertTrue(extractor.getText().contains("snoska")); > } > >+ public void testEndnotes() throws Exception { >+ XWPFWordExtractor extractor = >+ new XWPFWordExtractor(xmlEndnotes); >+ extractor.getText(); >+ >+ assertTrue(extractor.getText().contains("XXX")); >+ } >+ > } >diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/data/A Nepalese name for Tilaka.docx b/src/scratchpad/testcases/org/apache/poi/hwpf/data/A Nepalese name for Tilaka.docx >new file mode 100644 >index 0000000..a5db349 >Binary files /dev/null and b/src/scratchpad/testcases/org/apache/poi/hwpf/data/A Nepalese name for Tilaka.docx differ
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 45556
:
22379
|
23975
|
23976
|
24000
|
24001
|
24003
| 24004 |
24005