XSSFSheet freeze/splitPane support + tests

git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@645662 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Paolo Mottadelli 2008-04-07 19:54:43 +00:00
parent 5da68800de
commit b80094b1a2
2 changed files with 38 additions and 7 deletions

View 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();
}
}

View 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);