poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From talli...@apache.org
Subject svn commit: r1845517 - in /poi/trunk: src/ooxml/java/org/apache/poi/ooxml/POIXMLDocumentPart.java src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java test-data/document/60316.dotx
Date Thu, 01 Nov 2018 21:14:03 GMT
Author: tallison
Date: Thu Nov  1 21:14:03 2018
New Revision: 1845517

URL: http://svn.apache.org/viewvc?rev=1845517&view=rev
Log:
bug 60316 -- until we can implement it properly, gracefully skip the glossary document in
XWPF.

Added:
    poi/trunk/test-data/document/60316.dotx   (with props)
Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/ooxml/POIXMLDocumentPart.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/ooxml/POIXMLDocumentPart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/ooxml/POIXMLDocumentPart.java?rev=1845517&r1=1845516&r2=1845517&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/ooxml/POIXMLDocumentPart.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/ooxml/POIXMLDocumentPart.java Thu Nov  1 21:14:03
2018
@@ -42,6 +42,7 @@ import org.apache.poi.util.POILogger;
 import org.apache.poi.xddf.usermodel.chart.XDDFChart;
 import org.apache.poi.xssf.usermodel.XSSFRelation;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.apache.poi.xwpf.usermodel.XWPFRelation;
 
 /**
  * Represents an entry of a OOXML package.
@@ -613,6 +614,14 @@ public class POIXMLDocumentPart {
      */
     protected void read(POIXMLFactory factory, Map<PackagePart, POIXMLDocumentPart>
context) throws OpenXML4JException {
         PackagePart pp = getPackagePart();
+
+        if (pp.getContentType().equals(XWPFRelation.TEMPLATE.getContentType())) {
+            logger.log(POILogger.WARN,
+                    "POI does not currently support template.main+xml (glossary) parts. 
" +
+                    "Skipping this part for now.");
+            return;
+        }
+
         // add mapping a second time, in case of initial caller hasn't done so
         POIXMLDocumentPart otherChild = context.put(pp, this);
         if (otherChild != null && otherChild != this) {

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java?rev=1845517&r1=1845516&r2=1845517&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java
(original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/extractor/TestXWPFWordExtractor.java
Thu Nov  1 21:14:03 2018
@@ -29,6 +29,7 @@ import org.apache.poi.xwpf.XWPFTestDataS
 import org.apache.poi.xwpf.usermodel.XWPFDocument;
 import static org.apache.poi.POITestCase.assertContains;
 import static org.apache.poi.POITestCase.assertEndsWith;
+import static org.apache.poi.POITestCase.assertNotContained;
 import static org.apache.poi.POITestCase.assertStartsWith;
 
 /**
@@ -441,4 +442,14 @@ public class TestXWPFWordExtractor exten
         assertContains(txt, "Sequencing data");
         extractor.close();
     }
+
+    public void testGlossary() throws IOException {
+        XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("60316.dotx");
+        XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
+        String txt = extractor.getText();
+        assertContains(txt, "Getting the perfect");
+        //this content appears only in the glossary document
+        //once we add processing for this, we can change this to contains
+        assertNotContained(txt, "table rows");
+    }
 }

Added: poi/trunk/test-data/document/60316.dotx
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/document/60316.dotx?rev=1845517&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/document/60316.dotx
------------------------------------------------------------------------------
--- svn:mime-type (added)
+++ svn:mime-type Thu Nov  1 21:14:03 2018
@@ -0,0 +1 @@
+application/vnd.openxmlformats-officedocument.wordprocessingml.template



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message