From: Tim Allison Date: Fri, 23 Nov 2018 13:32:22 +0000 (+0000) Subject: bug 60316 -- skip the glossary document, not the template document. X-Git-Tag: REL_4_0_1^2~11 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8e427c180668f056c8d161025db43c08a8ee0457;p=poi.git bug 60316 -- skip the glossary document, not the template document. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1847263 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/ooxml/java/org/apache/poi/ooxml/POIXMLDocumentPart.java b/src/ooxml/java/org/apache/poi/ooxml/POIXMLDocumentPart.java index 54fa790eca..c8e1a277a4 100644 --- a/src/ooxml/java/org/apache/poi/ooxml/POIXMLDocumentPart.java +++ b/src/ooxml/java/org/apache/poi/ooxml/POIXMLDocumentPart.java @@ -615,7 +615,7 @@ public class POIXMLDocumentPart { protected void read(POIXMLFactory factory, Map context) throws OpenXML4JException { PackagePart pp = getPackagePart(); - if (pp.getContentType().equals(XWPFRelation.TEMPLATE.getContentType())) { + if (pp.getContentType().equals(XWPFRelation.GLOSSARY_DOCUMENT.getContentType())) { logger.log(POILogger.WARN, "POI does not currently support template.main+xml (glossary) parts. " + "Skipping this part for now."); 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 0fcccd1838..30d943051f 100644 --- a/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java +++ b/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java @@ -452,4 +452,12 @@ public class TestXWPFWordExtractor extends TestCase { //once we add processing for this, we can change this to contains assertNotContained(txt, "table rows"); } + + public void testPartsInTemplate() throws IOException { + XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("60316b.dotx"); + XWPFWordExtractor extractor = new XWPFWordExtractor(doc); + String txt = extractor.getText(); + assertContains(txt, "header 2"); + assertContains(txt, "footer 1"); + } } diff --git a/test-data/document/60316.docx b/test-data/document/60316.docx new file mode 100644 index 0000000000..78b2b1d846 Binary files /dev/null and b/test-data/document/60316.docx differ diff --git a/test-data/document/60316b.dotx b/test-data/document/60316b.dotx new file mode 100644 index 0000000000..e0e0d588fe Binary files /dev/null and b/test-data/document/60316b.dotx differ