poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1179440 - in /poi/trunk/src: documentation/content/xdocs/ ooxml/java/org/apache/poi/xssf/eventusermodel/ ooxml/java/org/apache/poi/xssf/model/ ooxml/testcases/org/apache/poi/xssf/eventusermodel/
Date Wed, 05 Oct 2011 21:05:00 GMT
Author: nick
Date: Wed Oct  5 21:05:00 2011
New Revision: 1179440

URL: http://svn.apache.org/viewvc?rev=1179440&view=rev
Log:
Fix bug #51955 - XSSFReader supplied StylesTables need to have the theme data available

Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=1179440&r1=1179439&r2=1179440&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Wed Oct  5 21:05:00 2011
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.8-beta5" date="2011-??-??">
+           <action dev="poi-developers" type="fix">51955 - XSSFReader supplied StylesTables
need to have the theme data available</action>
            <action dev="poi-developers" type="fix">51716 - Removed incorrect assert
in SXSSFSheet#getSXSSFSheet</action>
            <action dev="poi-developers" type="fix">51834 - Opening and Writing .doc
file results in corrupt document</action>
            <action dev="poi-developers" type="fix">51902 - Picture.fillRawImageContent
- ArrayIndexOutOfBoundsException (duplicate)</action>

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java?rev=1179440&r1=1179439&r2=1179440&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java Wed Oct  5
21:05:00 2011
@@ -36,6 +36,7 @@ import org.apache.poi.openxml4j.opc.Pack
 import org.apache.poi.xssf.model.CommentsTable;
 import org.apache.poi.xssf.model.SharedStringsTable;
 import org.apache.poi.xssf.model.StylesTable;
+import org.apache.poi.xssf.model.ThemesTable;
 import org.apache.poi.xssf.usermodel.XSSFRelation;
 import org.apache.xmlbeans.XmlException;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheet;
@@ -83,7 +84,15 @@ public class XSSFReader {
      */
     public StylesTable getStylesTable() throws IOException, InvalidFormatException {
         ArrayList<PackagePart> parts = pkg.getPartsByContentType( XSSFRelation.STYLES.getContentType());
-        return parts.size() == 0 ? null : new StylesTable(parts.get(0), null);
+        if(parts.size() == 0) return null;
+        
+        // Create the Styles Table, and associate the Themes if present
+        StylesTable styles = new StylesTable(parts.get(0), null);
+        parts = pkg.getPartsByContentType( XSSFRelation.THEME.getContentType());
+        if(parts.size() != 0) {
+           styles.setTheme(new ThemesTable(parts.get(0), null));
+        }
+        return styles;
     }
 
 
@@ -106,6 +115,14 @@ public class XSSFReader {
 
     /**
      * Returns an InputStream to read the contents of the
+     *  themes table.
+     */
+    public InputStream getThemesData() throws IOException, InvalidFormatException {
+        return XSSFRelation.THEME.getContents(workbookPart);
+    }
+
+    /**
+     * Returns an InputStream to read the contents of the
      *  main Workbook, which contains key overall data for
      *  the file, including sheet definitions.
      */

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java?rev=1179440&r1=1179439&r2=1179440&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/ThemesTable.java Wed Oct  5 21:05:00
2011
@@ -16,10 +16,13 @@
 ==================================================================== */
 package org.apache.poi.xssf.model;
 
+import java.io.IOException;
+
 import org.apache.poi.POIXMLDocumentPart;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.poi.xssf.usermodel.XSSFColor;
+import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTColorScheme;
 import org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument;
@@ -34,9 +37,14 @@ import org.openxmlformats.schemas.drawin
 public class ThemesTable extends POIXMLDocumentPart {
     private ThemeDocument theme;
 
-    public ThemesTable(PackagePart part, PackageRelationship rel) throws Exception {
+    public ThemesTable(PackagePart part, PackageRelationship rel) throws IOException {
         super(part, rel);
-        theme = ThemeDocument.Factory.parse(part.getInputStream());
+        
+        try {
+           theme = ThemeDocument.Factory.parse(part.getInputStream());
+        } catch(XmlException e) {
+           throw new IOException(e.getLocalizedMessage());
+        }
     }
 
     public ThemesTable(ThemeDocument theme) {

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java?rev=1179440&r1=1179439&r2=1179440&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java Wed
Oct  5 21:05:00 2011
@@ -55,6 +55,13 @@ public final class TestXSSFReader extend
 
 		assertEquals(3, r.getStylesTable().getFonts().size());
 		assertEquals(0, r.getStylesTable()._getNumberFormatSize());
+		
+		// The Styles Table should have the themes associated with it too
+		assertNotNull(r.getStylesTable().getTheme());
+		
+		// Check we get valid data for the two
+		assertNotNull(r.getStylesData());
+      assertNotNull(r.getThemesData());
 	}
 
 	public void testStrings() throws Exception {



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


Mime
View raw message