poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1649107 - in /poi/trunk/src: java/org/apache/poi/hssf/model/ java/org/apache/poi/hssf/record/aggregates/ java/org/apache/poi/hssf/usermodel/ java/org/apache/poi/ss/usermodel/ ooxml/java/org/apache/poi/xssf/streaming/ ooxml/java/org/apache/...
Date Fri, 02 Jan 2015 20:03:28 GMT
Author: centic
Date: Fri Jan  2 20:03:28 2015
New Revision: 1649107

URL: http://svn.apache.org/r1649107
Log:
Bug 46192: Add methods to query outline level for HSSF and XSSF

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/model/InternalSheet.java
    poi/trunk/src/java/org/apache/poi/hssf/record/aggregates/ColumnInfoRecordsAggregate.java
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
    poi/trunk/src/java/org/apache/poi/ss/usermodel/Row.java
    poi/trunk/src/java/org/apache/poi/ss/usermodel/Sheet.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestOutlining.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/model/InternalSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/model/InternalSheet.java?rev=1649107&r1=1649106&r2=1649107&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/model/InternalSheet.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/model/InternalSheet.java Fri Jan  2 20:03:28 2015
@@ -1667,4 +1667,8 @@ public final class InternalSheet {
         temp.toArray(result);
         return result;
     }
+    
+    public int getColumnOutlineLevel(int columnIndex) {
+        return _columnInfos.getOutlineLevel(columnIndex);
+    }
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/aggregates/ColumnInfoRecordsAggregate.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/aggregates/ColumnInfoRecordsAggregate.java?rev=1649107&r1=1649106&r2=1649107&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/aggregates/ColumnInfoRecordsAggregate.java
(original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/aggregates/ColumnInfoRecordsAggregate.java
Fri Jan  2 20:03:28 2015
@@ -520,4 +520,12 @@ public final class ColumnInfoRecordsAggr
 		}
 		return result;
 	}
+	public int getOutlineLevel(int columnIndex) {
+	    ColumnInfoRecord ci = findColumnInfo(columnIndex);
+	    if (ci != null) {
+            return ci.getOutlineLevel();
+	    } else {
+	        return 0;
+	    }
+	}
 }

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java?rev=1649107&r1=1649106&r2=1649107&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java Fri Jan  2 20:03:28 2015
@@ -268,9 +268,8 @@ public final class HSSFRow implements Ro
      * Returns the rows outline level. Increased as you
      *  put it into more groups (outlines), reduced as
      *  you take it out of them.
-     * TODO - Should this really be public?
      */
-    protected int getOutlineLevel() {
+    public int getOutlineLevel() {
         return row.getOutlineLevel();
     }
 

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java?rev=1649107&r1=1649106&r2=1649107&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java Fri Jan  2 20:03:28 2015
@@ -2340,6 +2340,13 @@ public final class HSSFSheet implements
         }
         return _workbook.getNameRecord(recIndex);
     }
-
-
+    
+    /**
+     * Returns the column outline level. Increased as you
+     *  put it into more groups (outlines), reduced as
+     *  you take it out of them.
+     */
+    public int getColumnOutlineLevel(int columnIndex) {
+        return _sheet.getColumnOutlineLevel(columnIndex);
+    }
 }

Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/Row.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/Row.java?rev=1649107&r1=1649106&r2=1649107&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/Row.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/Row.java Fri Jan  2 20:03:28 2015
@@ -234,4 +234,11 @@ public interface Row extends Iterable<Ce
     public static final MissingCellPolicy RETURN_BLANK_AS_NULL = new MissingCellPolicy();
     /** A new, blank cell is created for missing cells. Blank cells are returned as normal
*/
     public static final MissingCellPolicy CREATE_NULL_AS_BLANK = new MissingCellPolicy();
+    
+    /**
+     * Returns the rows outline level. Increased as you
+     *  put it into more groups (outlines), reduced as
+     *  you take it out of them.
+     */
+    public int getOutlineLevel();
 }

Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/Sheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/Sheet.java?rev=1649107&r1=1649106&r2=1649107&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/Sheet.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/Sheet.java Fri Jan  2 20:03:28 2015
@@ -1053,5 +1053,11 @@ public interface Sheet extends Iterable<
      *        columns for the Sheet, or null.
      */
     void setRepeatingColumns(CellRangeAddress columnRangeRef);
-
+    
+    /**
+     * Returns the column outline level. Increased as you
+     *  put it into more groups (outlines), reduced as
+     *  you take it out of them.
+     */
+    int getColumnOutlineLevel(int columnIndex);
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java?rev=1649107&r1=1649106&r2=1649107&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java Fri Jan  2 20:03:28
2015
@@ -58,7 +58,7 @@ public class SXSSFRow implements Row
         return _height!=-1;
     }
 
-    int getOutlineLevel(){
+    public int getOutlineLevel(){
         return _outlineLevel;
     }
     void setOutlineLevel(int level){

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java?rev=1649107&r1=1649106&r2=1649107&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java Fri Jan  2 20:03:28
2015
@@ -1477,4 +1477,8 @@ public class SXSSFSheet implements Sheet
     boolean dispose() {
         return _writer.dispose();
     }
+
+    public int getColumnOutlineLevel(int columnIndex) {
+        return _sh.getColumnOutlineLevel(columnIndex);
+    }
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java?rev=1649107&r1=1649106&r2=1649107&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java Fri Jan  2 20:03:28
2015
@@ -513,4 +513,8 @@ public class XSSFRow implements Row, Com
         }
         setRowNum(rownum);
     }
+
+    public int getOutlineLevel() {
+        return _row.getOutlineLevel();
+    }
 }

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=1649107&r1=1649106&r2=1649107&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 Fri Jan  2 20:03:28
2015
@@ -3821,4 +3821,12 @@ public class XSSFSheet extends POIXMLDoc
         }
         return tables;
     }
+    
+    public int getColumnOutlineLevel(int columnIndex) {
+        CTCol col = columnHelper.getColumn(columnIndex, false);
+        if (col == null) {
+            return 0;
+        }
+        return col.getOutlineLevel();
+    }
 }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestOutlining.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestOutlining.java?rev=1649107&r1=1649106&r2=1649107&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestOutlining.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestOutlining.java Fri Jan
 2 20:03:28 2015
@@ -19,11 +19,18 @@
 
 package org.apache.poi.xssf.streaming;
 
+import java.io.IOException;
+
 import junit.framework.TestCase;
 
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
 public final class TestOutlining extends TestCase {
 	public void testSetRowGroupCollapsed() throws Exception {
-
 		SXSSFWorkbook wb2 = new SXSSFWorkbook(100);
 		wb2.setCompressTempFiles(true);
 		SXSSFSheet sheet2 = (SXSSFSheet) wb2.createSheet("new sheet");
@@ -45,10 +52,11 @@ public final class TestOutlining extends
 		r = (SXSSFRow) sheet2.getRow(12);
 		assertNull(r.getHidden());
 		wb2.dispose();
+		
+		wb2.close();
 	}
 
 	public void testSetRowGroupCollapsedError() throws Exception {
-
 		SXSSFWorkbook wb2 = new SXSSFWorkbook(100);
 		wb2.setCompressTempFiles(true);
 		SXSSFSheet sheet2 = (SXSSFSheet) wb2.createSheet("new sheet");
@@ -98,5 +106,61 @@ public final class TestOutlining extends
 		r = (SXSSFRow) sheet2.getRow(12);
 		assertNull(r.getHidden());
 		wb2.dispose();
+		
+		wb2.close();
 	}
+	
+    public void testOutlineGetters() throws IOException {
+        HSSFWorkbook hssfWorkbook = new HSSFWorkbook();
+        HSSFSheet hssfSheet = hssfWorkbook.createSheet();
+        hssfSheet.createRow(0);
+        hssfSheet.createRow(1);
+        hssfSheet.createRow(2);
+        hssfSheet.createRow(3);
+        hssfSheet.createRow(4);
+        hssfSheet.groupRow(1, 3);
+        hssfSheet.groupRow(2, 3);
+
+        assertEquals(0, hssfSheet.getRow(0).getOutlineLevel());
+        assertEquals(1, hssfSheet.getRow(1).getOutlineLevel());
+        assertEquals(2, hssfSheet.getRow(2).getOutlineLevel());
+        assertEquals(2, hssfSheet.getRow(3).getOutlineLevel());
+        assertEquals(0, hssfSheet.getRow(4).getOutlineLevel());
+        hssfWorkbook.close();
+
+        XSSFWorkbook xssfWorkbook = new XSSFWorkbook();
+        XSSFSheet xssfSheet = xssfWorkbook.createSheet();
+        xssfSheet.createRow(0);
+        xssfSheet.createRow(1);
+        xssfSheet.createRow(2);
+        xssfSheet.createRow(3);
+        xssfSheet.createRow(4);
+        xssfSheet.groupRow(1, 3);
+        xssfSheet.groupRow(2, 3);
+
+        assertEquals(0, xssfSheet.getRow(0).getOutlineLevel());
+        assertEquals(1, xssfSheet.getRow(1).getOutlineLevel());
+        assertEquals(2, xssfSheet.getRow(2).getOutlineLevel());
+        assertEquals(2, xssfSheet.getRow(3).getOutlineLevel());
+        assertEquals(0, xssfSheet.getRow(4).getOutlineLevel());
+        xssfWorkbook.close();
+
+        SXSSFWorkbook sxssfWorkbook = new SXSSFWorkbook();
+        Sheet sxssfSheet = sxssfWorkbook.createSheet();
+        sxssfSheet.createRow(0);
+        sxssfSheet.createRow(1);
+        sxssfSheet.createRow(2);
+        sxssfSheet.createRow(3);
+        sxssfSheet.createRow(4);
+        sxssfSheet.groupRow(1, 3);
+        sxssfSheet.groupRow(2, 3);
+
+        assertEquals(0, sxssfSheet.getRow(0).getOutlineLevel());
+        assertEquals(1, sxssfSheet.getRow(1).getOutlineLevel());
+        assertEquals(2, sxssfSheet.getRow(2).getOutlineLevel());
+        assertEquals(2, sxssfSheet.getRow(3).getOutlineLevel());
+        assertEquals(0, sxssfSheet.getRow(4).getOutlineLevel());
+        sxssfWorkbook.dispose();
+        sxssfWorkbook.close();
+    }
 }



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


Mime
View raw message