poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r1148724 - in /poi/trunk: src/documentation/content/xdocs/ src/ooxml/java/org/apache/poi/ src/ooxml/java/org/apache/poi/xssf/usermodel/ src/ooxml/testcases/org/apache/poi/xssf/usermodel/ test-data/spreadsheet/
Date Wed, 20 Jul 2011 12:29:29 GMT
Author: yegor
Date: Wed Jul 20 12:29:27 2011
New Revision: 1148724

URL: http://svn.apache.org/viewvc?rev=1148724&view=rev
Log:
fixed bug 51470 - avoid exception when cloning XSSF sheets with background images

Added:
    poi/trunk/test-data/spreadsheet/51470.xlsx   (with props)
Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocumentPart.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.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=1148724&r1=1148723&r2=1148724&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Wed Jul 20 12:29:27 2011
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.8-beta4" date="2011-??-??">
+           <action dev="poi-developers" type="fix">51470 - avoid exception when cloning
XSSF sheets with background images</action>
            <action dev="poi-developers" type="fix">51481 - Fixed autofilters in HSSF
to avoid warnings in Excel 2007</action>
            <action dev="poi-developers" type="fix">51533 - Avoid exception when changing
name of a sheet containing shared formulas</action>
            <action dev="poi-developers" type="add">Support for appending images to
existing drawings in HSSF</action>

Modified: poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocumentPart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocumentPart.java?rev=1148724&r1=1148723&r2=1148724&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocumentPart.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/POIXMLDocumentPart.java Wed Jul 20 12:29:27 2011
@@ -233,7 +233,7 @@ public class POIXMLDocumentPart {
      *
      * @param part the child to add
      */
-    protected final void addRelation(String id,POIXMLDocumentPart part){
+    public final void addRelation(String id,POIXMLDocumentPart part){
         relations.put(id,part);
         part.incrementRelationCounter();
     }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java?rev=1148724&r1=1148723&r2=1148724&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java Wed Jul 20 12:29:27
2011
@@ -385,6 +385,15 @@ public class XSSFWorkbook extends POIXML
         }
 
         clonedSheet.setSelected(false);
+
+        // copy sheet's relations
+        List<POIXMLDocumentPart> rels = srcSheet.getRelations();
+        for(POIXMLDocumentPart r : rels) {
+            PackageRelationship rel = r.getPackageRelationship();
+            clonedSheet.getPackagePart().addRelationship(rel.getTargetURI(), rel.getTargetMode(),rel.getRelationshipType());
+            clonedSheet.addRelation(rel.getId(), r);
+        }
+
         return clonedSheet;
     }
 

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java?rev=1148724&r1=1148723&r2=1148724&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java Wed Jul
20 12:29:27 2011
@@ -1157,4 +1157,16 @@ public final class TestXSSFBugs extends 
 //       assertEquals("FFEEECE1", cA4_EEECE1.getCellStyle().getFillForegroundXSSFColor().getARGBHex());
 //       assertEquals("FF1F497D", cA5_1F497D.getCellStyle().getFillForegroundXSSFColor().getARGBHex());
     }
+
+    public void test51470() throws Exception {
+        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("51470.xlsx");
+        XSSFSheet sh0 = wb.getSheetAt(0);
+        XSSFSheet sh1 = wb.cloneSheet(0);
+        List<POIXMLDocumentPart> rels0 = sh0.getRelations();
+        List<POIXMLDocumentPart> rels1 = sh1.getRelations();
+        assertEquals(1, rels0.size());
+        assertEquals(1, rels1.size());
+
+        assertEquals(rels0.get(0).getPackageRelationship(), rels1.get(0).getPackageRelationship());
+    }
 }

Added: poi/trunk/test-data/spreadsheet/51470.xlsx
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/51470.xlsx?rev=1148724&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/spreadsheet/51470.xlsx
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



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


Mime
View raw message