]> source.dussan.org Git - poi.git/commitdiff
XSSFSheet freeze/splitPane support + tests
authorPaolo Mottadelli <paolo@apache.org>
Mon, 7 Apr 2008 19:54:43 +0000 (19:54 +0000)
committerPaolo Mottadelli <paolo@apache.org>
Mon, 7 Apr 2008 19:54:43 +0000 (19:54 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@645662 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java

index 9ffa8947bad24a6a9b760e912ef3337c72873031..96ffe3c03a428a3db67aaa1a25b9c73bd49f9274 100644 (file)
@@ -53,6 +53,7 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTMergeCells;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageBreak;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageMargins;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageSetUpPr;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPane;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPrintOptions;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSelection;
@@ -63,6 +64,8 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetProtection;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetView;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetViews;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPane;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPaneState;
 
 
 public class XSSFSheet implements Sheet {
@@ -205,13 +208,15 @@ public class XSSFSheet implements Sheet {
     }
 
     public void createFreezePane(int colSplit, int rowSplit, int leftmostColumn, int topRow) {
-        // TODO Auto-generated method stub
-
+       this.createFreezePane(colSplit, rowSplit);
+       this.showInPane((short)topRow, (short)leftmostColumn);
     }
 
     public void createFreezePane(int colSplit, int rowSplit) {
-        // TODO Auto-generated method stub
-
+       getPane().setXSplit(colSplit);
+       getPane().setYSplit(rowSplit);
+       // make bottomRight default active pane
+       getPane().setActivePane(STPane.BOTTOM_RIGHT);
     }
     
     /**
@@ -250,9 +255,9 @@ public class XSSFSheet implements Sheet {
         return xrow;
     }
 
-    public void createSplitPane(int splitPos, int splitPos2, int leftmostColumn, int topRow, int activePane) {
-        // TODO Auto-generated method stub
-
+    public void createSplitPane(int xSplitPos, int ySplitPos, int leftmostColumn, int topRow, int activePane) {
+       createFreezePane(xSplitPos, ySplitPos, leftmostColumn, topRow);
+       getPane().setActivePane(STPane.Enum.forInt(activePane));
     }
 
     public void dumpDrawingRecords(boolean fat) {
@@ -1017,4 +1022,11 @@ public class XSSFSheet implements Sheet {
        }
        return false;
     }
+
+       private CTPane getPane() {
+               if (getDefaultSheetView().getPane() == null) {
+                       getDefaultSheetView().addNewPane();
+               }
+               return getDefaultSheetView().getPane();
+       }
 }
index 4b9abe2514ff62a7f8785437f127440d38aea666..e92d5d06574e27117d6d65886422cbfed6a54e8c 100644 (file)
@@ -30,6 +30,8 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComment;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComments;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheet;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPane;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPaneState;
 
 
 public class TestXSSFSheet extends TestCase {
@@ -529,6 +531,23 @@ public class TestXSSFSheet extends TestCase {
        
     }
     
+    public void testCreateFreezePane() {
+       Workbook workbook = new XSSFWorkbook();
+       CTSheet ctSheet = CTSheet.Factory.newInstance();
+       CTWorksheet ctWorksheet = CTWorksheet.Factory.newInstance();
+       XSSFSheet sheet = new XSSFSheet(ctSheet, ctWorksheet, (XSSFWorkbook) workbook);
+       sheet.createFreezePane(2, 4);
+       assertEquals((double)2, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getXSplit());
+       assertEquals(STPane.BOTTOM_RIGHT, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getActivePane());
+       sheet.createFreezePane(3, 6, 10, 10);
+       assertEquals((double)3, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getXSplit());
+       assertEquals(10, sheet.getTopRow());
+       assertEquals(10, sheet.getLeftCol());
+       sheet.createSplitPane(4, 8, 12, 12, 1);
+       assertEquals((double)8, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getYSplit());
+       assertEquals(STPane.BOTTOM_RIGHT, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getActivePane());
+    }
+    
 
        private XSSFSheet createSheet(XSSFWorkbook workbook, String name) {
         XSSFSheet sheet = (XSSFSheet) workbook.createSheet(name);