Author: kiwiwings
Date: Tue Mar 23 23:58:47 2021
New Revision: 1887978
URL: http://svn.apache.org/viewvc?rev=1887978&view=rev
Log:
add more xsbs to the ooxml-lite jar by recursing through XWPF and XSSF documents
Modified:
poi/trunk/src/integrationtest/org/apache/poi/stress/POIXMLDocumentHandler.java
poi/trunk/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java
poi/trunk/src/integrationtest/org/apache/poi/stress/XWPFFileHandler.java
poi/trunk/src/multimodule/ooxml-lite/java9/module-info.class
poi/trunk/src/multimodule/ooxml-lite/java9/module-info.java
Modified:
poi/trunk/src/integrationtest/org/apache/poi/stress/POIXMLDocumentHandler.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/integrationtest/org/apache/poi/stress/POIXMLDocumentHandler.java?rev=1887978&r1=1887977&r2=1887978&view=diff
==============================================================================
---
poi/trunk/src/integrationtest/org/apache/poi/stress/POIXMLDocumentHandler.java
(original)
+++
poi/trunk/src/integrationtest/org/apache/poi/stress/POIXMLDocumentHandler.java
Tue Mar 23 23:58:47 2021
@@ -25,6 +25,8 @@ import org.apache.poi.ooxml.POIXMLDocume
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 @@ public final class POIXMLDocumentHandler
}
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();
+ }
+ }
}
Modified:
poi/trunk/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java?rev=1887978&r1=1887977&r2=1887978&view=diff
==============================================================================
--- poi/trunk/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java
(original)
+++ poi/trunk/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java
Tue Mar 23 23:58:47 2021
@@ -48,11 +48,13 @@ import org.apache.poi.openxml4j.opc.OPCP
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 @@ class XSSFFileHandler extends Spreadshee
// 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);
Modified:
poi/trunk/src/integrationtest/org/apache/poi/stress/XWPFFileHandler.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/integrationtest/org/apache/poi/stress/XWPFFileHandler.java?rev=1887978&r1=1887977&r2=1887978&view=diff
==============================================================================
--- poi/trunk/src/integrationtest/org/apache/poi/stress/XWPFFileHandler.java
(original)
+++ poi/trunk/src/integrationtest/org/apache/poi/stress/XWPFFileHandler.java
Tue Mar 23 23:58:47 2021
@@ -34,6 +34,7 @@ class XWPFFileHandler extends AbstractFi
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;
Modified: poi/trunk/src/multimodule/ooxml-lite/java9/module-info.class
URL:
http://svn.apache.org/viewvc/poi/trunk/src/multimodule/ooxml-lite/java9/module-info.class?rev=1887978&r1=1887977&r2=1887978&view=diff
==============================================================================
Binary files - no diff available.
Modified: poi/trunk/src/multimodule/ooxml-lite/java9/module-info.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/multimodule/ooxml-lite/java9/module-info.java?rev=1887978&r1=1887977&r2=1887978&view=diff
==============================================================================
--- poi/trunk/src/multimodule/ooxml-lite/java9/module-info.java (original)
+++ poi/trunk/src/multimodule/ooxml-lite/java9/module-info.java Tue Mar 23
23:58:47 2021
@@ -29,6 +29,7 @@ open module org.apache.poi.ooxml.schemas
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;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]