add more xsbs to the ooxml-lite jar by recursing through XWPF and XSSF documents

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1887978 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/integrationtest/org/apache/poi/stress/POIXMLDocumentHandler.java b/src/integrationtest/org/apache/poi/stress/POIXMLDocumentHandler.java
index a06b315..930c904 100644
--- a/src/integrationtest/org/apache/poi/stress/POIXMLDocumentHandler.java
+++ b/src/integrationtest/org/apache/poi/stress/POIXMLDocumentHandler.java
@@ -25,6 +25,8 @@
 import org.apache.poi.poifs.crypt.Decryptor;
 import org.apache.poi.poifs.filesystem.FileMagic;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
 
 public final class POIXMLDocumentHandler {
 	protected void handlePOIXMLDocument(POIXMLDocument doc) throws Exception {
@@ -46,4 +48,25 @@
         }
         return false;
     }
+
+    /**
+     * Recurse through the document and convert all elements so they are available in the ooxml-lite jar.
+     * This method only makes sense for hierarchical documents like .docx.
+     * If the document is split up in different parts like in .pptx, each part needs to be provided.
+     *
+     * @param base the entry point
+     */
+    protected static void cursorRecursive(XmlObject base) {
+        XmlCursor cur = base.newCursor();
+        try {
+            if (!cur.toFirstChild()) {
+                return;
+            }
+            do {
+                cursorRecursive(cur.getObject());
+            } while (cur.toNextSibling());
+        } finally {
+            cur.dispose();
+        }
+    }
 }
diff --git a/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java b/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java
index 68f07b5..def8750 100644
--- a/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java
+++ b/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java
@@ -48,11 +48,13 @@
 import org.apache.poi.poifs.crypt.Decryptor;
 import org.apache.poi.poifs.crypt.EncryptionInfo;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.NullPrintStream;
 import org.apache.poi.xssf.eventusermodel.XSSFReader;
 import org.apache.poi.xssf.extractor.XSSFExportToXml;
 import org.apache.poi.xssf.usermodel.XSSFMap;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.junit.jupiter.api.Test;
 import org.xml.sax.SAXException;
@@ -106,6 +108,11 @@
         // also verify general POIFS-stuff
         new POIXMLDocumentHandler().handlePOIXMLDocument(wb);
 
+        POIXMLDocumentHandler.cursorRecursive(wb.getCTWorkbook());
+        for (Sheet sh : wb) {
+            POIXMLDocumentHandler.cursorRecursive(((XSSFSheet)sh).getCTWorksheet());
+        }
+
         // and finally ensure that exporting to XML works
         exportToXML(wb);
 
diff --git a/src/integrationtest/org/apache/poi/stress/XWPFFileHandler.java b/src/integrationtest/org/apache/poi/stress/XWPFFileHandler.java
index b5a497a..0970d4f 100644
--- a/src/integrationtest/org/apache/poi/stress/XWPFFileHandler.java
+++ b/src/integrationtest/org/apache/poi/stress/XWPFFileHandler.java
@@ -34,6 +34,7 @@
         try (XWPFDocument doc = new XWPFDocument(stream)) {
 
             new POIXMLDocumentHandler().handlePOIXMLDocument(doc);
+            POIXMLDocumentHandler.cursorRecursive(doc.getDocument());
         } catch (POIXMLException e) {
             Exception cause = (Exception)e.getCause();
             throw cause == null ? e : cause;
diff --git a/src/multimodule/ooxml-lite/java9/module-info.class b/src/multimodule/ooxml-lite/java9/module-info.class
index 2a720c7..6c12f9f 100644
--- a/src/multimodule/ooxml-lite/java9/module-info.class
+++ b/src/multimodule/ooxml-lite/java9/module-info.class
Binary files differ
diff --git a/src/multimodule/ooxml-lite/java9/module-info.java b/src/multimodule/ooxml-lite/java9/module-info.java
index 2559d36..f8e193e 100644
--- a/src/multimodule/ooxml-lite/java9/module-info.java
+++ b/src/multimodule/ooxml-lite/java9/module-info.java
@@ -29,6 +29,7 @@
     exports com.microsoft.schemas.office.excel;
     exports com.microsoft.schemas.office.office;
     exports com.microsoft.schemas.office.visio.x2012.main;
+    exports com.microsoft.schemas.office.word;
     exports com.microsoft.schemas.office.x2006.digsig;
     exports com.microsoft.schemas.vml;
     exports org.apache.poi.schemas.ooxml.system.ooxml;