poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1652877 - in /poi/trunk/src/ooxml/java/org/apache/poi: extractor/ExtractorFactory.java xssf/extractor/XSSFExcelExtractor.java
Date Sun, 18 Jan 2015 23:46:29 GMT
Author: nick
Date: Sun Jan 18 23:46:29 2015
New Revision: 1652877

URL: http://svn.apache.org/r1652877
Log:
Have ExtractorFactory open OPCPackages from files in read-only mode by default, since writing
should never be needed when extracting text

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java?rev=1652877&r1=1652876&r2=1652877&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/extractor/ExtractorFactory.java Sun Jan 18 23:46:29
2015
@@ -44,6 +44,7 @@ import org.apache.poi.hwpf.extractor.Wor
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
 import org.apache.poi.openxml4j.opc.OPCPackage;
+import org.apache.poi.openxml4j.opc.PackageAccess;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationshipCollection;
 import org.apache.poi.poifs.filesystem.DirectoryEntry;
@@ -131,7 +132,7 @@ public class ExtractorFactory {
                 return createExtractor(new POIFSFileSystem(inp));
             }
             if(POIXMLDocument.hasOOXMLHeader(inp)) {
-                return createExtractor(OPCPackage.open(f.toString()));
+                return createExtractor(OPCPackage.open(f.toString(), PackageAccess.READ));
             }
             throw new IllegalArgumentException("Your File was neither an OLE2 file, nor an
OOXML file");
         } finally {

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java?rev=1652877&r1=1652876&r2=1652877&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java Sun Jan
18 23:46:29 2015
@@ -195,13 +195,15 @@ public class XSSFExcelExtractor extends
             
             // add textboxes
             if (includeTextBoxes){
-                XSSFDrawing drawing = sheet.createDrawingPatriarch();
-                for (XSSFShape shape : drawing.getShapes()){
-                    if (shape instanceof XSSFSimpleShape){
-                        String boxText = ((XSSFSimpleShape)shape).getText();
-                        if (boxText.length() > 0){
-                            text.append(boxText);
-                            text.append('\n');
+                XSSFDrawing drawing = sheet.getDrawingPatriarch();
+                if (drawing != null) {
+                    for (XSSFShape shape : drawing.getShapes()){
+                        if (shape instanceof XSSFSimpleShape){
+                            String boxText = ((XSSFSimpleShape)shape).getText();
+                            if (boxText.length() > 0){
+                                text.append(boxText);
+                                text.append('\n');
+                            }
                         }
                     }
                 }



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


Mime
View raw message