Author: centic
Date: Thu Nov 28 15:15:59 2013
New Revision: 1546385

URL: http://svn.apache.org/r1546385
Log:
Bug 55745: fix handling of tables in XSSF if there are comments as well, there 
is not much sense in leaving the loop on the first instance of comment table 
and skipping all the other tables.

Added:
    poi/trunk/test-data/spreadsheet/55745.xlsx   (with props)
Modified:
    
poi/tags/REL_3_9/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java

Modified: 
poi/tags/REL_3_9/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
URL: 
http://svn.apache.org/viewvc/poi/tags/REL_3_9/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java?rev=1546385&r1=1546384&r2=1546385&view=diff
==============================================================================
--- 
poi/tags/REL_3_9/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
 (original)
+++ 
poi/tags/REL_3_9/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
 Thu Nov 28 15:15:59 2013
@@ -33,18 +33,7 @@ import org.apache.poi.xssf.model.Calcula
 import org.apache.poi.xssf.model.CommentsTable;
 import org.apache.poi.xssf.model.StylesTable;
 import org.apache.poi.xssf.usermodel.helpers.ColumnHelper;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCalcPr;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComments;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetData;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetProtection;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCalcMode;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPane;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
 
 
 @SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are 
deprecated in xmlbeans with JDK 1.5 support
@@ -1107,4 +1096,22 @@ public final class TestXSSFSheet extends
         sheet = workbook.getSheet("Sheet 1");
         assertEquals(false, sheet.getForceFormulaRecalculation());
        }
+
+    public static void test55745() throws Exception {
+        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("55745.xlsx");
+        XSSFSheet sheet = wb.getSheetAt(0);
+        List<XSSFTable> tables = sheet.getTables();
+        /*System.out.println(tables.size());
+        
+        for(XSSFTable table : tables) {
+            System.out.println("XPath: " + table.getCommonXpath());
+            System.out.println("Name: " + table.getName());
+            System.out.println("Mapped Cols: " + 
table.getNumerOfMappedColumns());
+            System.out.println("Rowcount: " + table.getRowCount());
+            System.out.println("End Cell: " + table.getEndCellReference());
+            System.out.println("Start Cell: " + table.getStartCellReference());
+        }*/
+        assertEquals("Sheet should contain 8 tables", 8, tables.size());
+        assertNotNull("Sheet should contain a comments table", 
sheet.getCommentsTable(false));
+    }
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java?rev=1546385&r1=1546384&r2=1546385&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java 
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Thu 
Nov 28 15:15:59 2013
@@ -147,7 +147,6 @@ public class XSSFSheet extends POIXMLDoc
         for(POIXMLDocumentPart p : getRelations()){
             if(p instanceof CommentsTable) {
                sheetComments = (CommentsTable)p;
-               break;
             }
             if(p instanceof XSSFTable) {
                tables.put( p.getPackageRelationship().getId(), (XSSFTable)p );

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

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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to