Return-Path: Delivered-To: apmail-jakarta-poi-dev-archive@www.apache.org Received: (qmail 2189 invoked from network); 9 Feb 2004 23:17:03 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 9 Feb 2004 23:17:03 -0000 Received: (qmail 31823 invoked by uid 500); 9 Feb 2004 23:16:47 -0000 Delivered-To: apmail-jakarta-poi-dev-archive@jakarta.apache.org Received: (qmail 31797 invoked by uid 500); 9 Feb 2004 23:16:46 -0000 Mailing-List: contact poi-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "POI Developers List" Reply-To: "POI Developers List" Delivered-To: mailing list poi-dev@jakarta.apache.org Received: (qmail 31745 invoked from network); 9 Feb 2004 23:16:45 -0000 Received: from unknown (HELO set.superlinksoftware.com) (66.35.175.110) by daedalus.apache.org with SMTP; 9 Feb 2004 23:16:45 -0000 Received: from localhost.localdomain ([127.0.0.1]) by set.superlinksoftware.com (JAMES SMTP Server 2.1) with SMTP ID 201 for ; Mon, 9 Feb 2004 17:37:34 -0500 (EST) User-Agent: Microsoft-Entourage/10.1.4.030702.0 Date: Mon, 09 Feb 2004 18:16:53 -0500 Subject: Commits branches and features oh my From: "Andrew C. Oliver" To: POI Developers List Message-ID: In-Reply-To: <20040209224127.81658.qmail@minotaur.apache.org> Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Don't forget to add this to 3.0! We need to start moving on 3.0 again. I need everyone's help to make the HSSF stuff work. There was too much stuff I didn't work on for me to be able to do it myself. Lets also get the discussion on TNEF and POIFS2 rolling again. SuperLink also has a significant new feature to add in the coming days: Escher images. I'd like to propose that we do a 2.5. . . . Oh I know I know we said never again, but this feature is far too mature for 3.0 and far to sweeping for a 2.01 release in my opinion. I'd like to hear what others think. Based on this you can now draw company logos on the reports and more. Alternatively, we could make the HEAD 4.0 and do the drawing stuff as 3.0.... Thoughts? -- Andrew C. Oliver http://www.superlinksoftware.com/poi.jsp Custom enhancements and Commercial Implementation for Jakarta POI http://jakarta.apache.org/poi For Java and Excel, Got POI? > From: dmui@apache.org > Reply-To: "POI Developers List" > Date: 9 Feb 2004 22:41:27 -0000 > To: jakarta-poi-cvs@apache.org > Subject: cvs commit: jakarta-poi/src/testcases/org/apache/poi/hssf/model > SheetTest.java > > dmui 2004/02/09 14:41:27 > > Modified: src/testcases/org/apache/poi/hssf/usermodel Tag: > REL_2_BRANCH TestCloneSheet.java > TestSheetShiftRows.java TestHSSFSheet.java > src/java/org/apache/poi/hssf/record Tag: REL_2_BRANCH > RecordFactory.java > src/java/org/apache/poi/hssf/model Tag: REL_2_BRANCH > Sheet.java > src/java/org/apache/poi/hssf/dev Tag: REL_2_BRANCH > BiffViewer.java > src/java/org/apache/poi/hssf/usermodel Tag: REL_2_BRANCH > HSSFSheet.java > src/testcases/org/apache/poi/hssf/model Tag: REL_2_BRANCH > SheetTest.java > Added: src/java/org/apache/poi/hssf/record Tag: REL_2_BRANCH > VerticalPageBreakRecord.java > HorizontalPageBreakRecord.java PageBreakRecord.java > src/testcases/org/apache/poi/hssf/data Tag: REL_2_BRANCH > SimpleWithPageBreaks.xls > Log: > Patch to support Horizontal and Vertical Page breaks, included testcases > and files. > PR: > Obtained from: > Submitted by: > Reviewed by: > CVS: ---------------------------------------------------------------------- > CVS: PR: > CVS: If this change addresses a PR in the problem report tracking > CVS: database, then enter the PR number(s) here. > CVS: Obtained from: > CVS: If this change has been taken from another system, such as NCSA, > CVS: then name the system in this line, otherwise delete it. > CVS: Submitted by: > CVS: If this code has been contributed to Apache by someone else; i.e., > CVS: they sent us a patch or a new module, then include their name/email > CVS: address here. If this is your work then delete this line. > CVS: Reviewed by: > CVS: If we are doing pre-commit code reviews and someone else has > CVS: reviewed your changes, include their name(s) here. > CVS: If you have not had it reviewed then delete this line. > > Revision Changes Path > No revision > No revision > 1.2.2.2 +19 -0 > jakarta-poi/src/testcases/org/apache/poi/hssf/usermodel/TestCloneSheet.java > > Index: TestCloneSheet.java > =================================================================== > RCS file: > /home/cvs/jakarta-poi/src/testcases/org/apache/poi/hssf/usermodel/TestCloneShe > et.java,v > retrieving revision 1.2.2.1 > retrieving revision 1.2.2.2 > diff -u -r1.2.2.1 -r1.2.2.2 > --- TestCloneSheet.java 13 Oct 2003 16:45:01 -0000 1.2.2.1 > +++ TestCloneSheet.java 9 Feb 2004 22:41:26 -0000 1.2.2.2 > @@ -82,4 +82,23 @@ > catch(Exception e){e.printStackTrace();fail(e.getMessage());} > } > > + /** > + * Ensures that pagebreak cloning works properly > + * > + */ > + public void testPageBreakClones() { > + HSSFWorkbook b = new HSSFWorkbook(); > + HSSFSheet s = b.createSheet("Test"); > + s.setRowBreak(3); > + s.setColumnBreak((short)6); > + > + HSSFSheet clone = b.cloneSheet(0); > + assertTrue("Row 3 not broken", clone.isRowBroken(3)); > + assertTrue("Column 6 not broken", clone.isColumnBroken((short)6)); > + > + s.removeRowBreak(3); > + > + assertTrue("Row 3 still should be broken", clone.isRowBroken(3)); > + } > + > } > > > > 1.2.2.2 +26 -10 > jakarta-poi/src/testcases/org/apache/poi/hssf/usermodel/TestSheetShiftRows.jav> a > > Index: TestSheetShiftRows.java > =================================================================== > RCS file: > /home/cvs/jakarta-poi/src/testcases/org/apache/poi/hssf/usermodel/TestSheetShi > ftRows.java,v > retrieving revision 1.2.2.1 > retrieving revision 1.2.2.2 > diff -u -r1.2.2.1 -r1.2.2.2 > --- TestSheetShiftRows.java 23 Oct 2003 17:16:03 -0000 1.2.2.1 > +++ TestSheetShiftRows.java 9 Feb 2004 22:41:26 -0000 1.2.2.2 > @@ -169,11 +169,11 @@ > * @author Toshiaki Kamoshida (kamoshida.toshiaki at future dot co dot > jp) > */ > public void testShiftRow(){ > - HSSFWorkbook b = new HSSFWorkbook(); > - HSSFSheet s = b.createSheet(); > - s.createRow(0).createCell((short)0).setCellValue("TEST1"); > - s.createRow(3).createCell((short)0).setCellValue("TEST2"); > - s.shiftRows(0,4,1); > + HSSFWorkbook b = new HSSFWorkbook(); > + HSSFSheet s = b.createSheet(); > + s.createRow(0).createCell((short)0).setCellValue("TEST1"); > + s.createRow(3).createCell((short)0).setCellValue("TEST2"); > + s.shiftRows(0,4,1); > } > > /** > @@ -182,11 +182,27 @@ > * @author Toshiaki Kamoshida (kamoshida.toshiaki at future dot co dot > jp) > */ > public void testShiftRow0(){ > - HSSFWorkbook b = new HSSFWorkbook(); > - HSSFSheet s = b.createSheet(); > - s.createRow(0).createCell((short)0).setCellValue("TEST1"); > - s.createRow(3).createCell((short)0).setCellValue("TEST2"); > - s.shiftRows(0,4,1); > + HSSFWorkbook b = new HSSFWorkbook(); > + HSSFSheet s = b.createSheet(); > + s.createRow(0).createCell((short)0).setCellValue("TEST1"); > + s.createRow(3).createCell((short)0).setCellValue("TEST2"); > + s.shiftRows(0,4,1); > + } > + > + /** > + * When shifting rows, the page breaks should go with it > + * > + */ > + public void testShiftRowBreaks(){ > + HSSFWorkbook b = new HSSFWorkbook(); > + HSSFSheet s = b.createSheet(); > + HSSFRow row = s.createRow(4); > + row.createCell((short)0).setCellValue("test"); > + s.setRowBreak(4); > + > + s.shiftRows(4, 4, 2); > + assertTrue("Row number 6 should have a pagebreak", s.isRowBroken(6)); > + > } > } > > > > > 1.12.2.6 +66 -17 > jakarta-poi/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java > > Index: TestHSSFSheet.java > =================================================================== > RCS file: > /home/cvs/jakarta-poi/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFShee > t.java,v > retrieving revision 1.12.2.5 > retrieving revision 1.12.2.6 > diff -u -r1.12.2.5 -r1.12.2.6 > --- TestHSSFSheet.java 23 Aug 2003 18:54:28 -0000 1.12.2.5 > +++ TestHSSFSheet.java 9 Feb 2004 22:41:26 -0000 1.12.2.6 > @@ -1,7 +1,7 @@ > /* ==================================================================== > * The Apache Software License, Version 1.1 > * > - * Copyright (c) 2003 The Apache Software Foundation. All rights > + * Copyright (c) 2004 The Apache Software Foundation. All rights > * reserved. > * > * Redistribution and use in source and binary forms, with or without > @@ -345,8 +345,8 @@ > * @author Shawn Laubach (slaubach at apache dot org) > */ > public void testDisplayOptions() throws Exception { > - HSSFWorkbook wb = new HSSFWorkbook(); > - HSSFSheet sheet = wb.createSheet(); > + HSSFWorkbook wb = new HSSFWorkbook(); > + HSSFSheet sheet = wb.createSheet(); > > File tempFile = File.createTempFile("display", "test.xls"); > FileOutputStream stream = new FileOutputStream(tempFile); > @@ -356,15 +356,15 @@ > FileInputStream readStream = new FileInputStream(tempFile); > wb = new HSSFWorkbook(readStream); > sheet = wb.getSheetAt(0); > - readStream.close(); > - > - assertEquals(sheet.isDisplayGridlines(), true); > - assertEquals(sheet.isDisplayRowColHeadings(), true); > - assertEquals(sheet.isDisplayFormulas(), false); > - > - sheet.setDisplayGridlines(false); > - sheet.setDisplayRowColHeadings(false); > - sheet.setDisplayFormulas(true); > + readStream.close(); > + > + assertEquals(sheet.isDisplayGridlines(), true); > + assertEquals(sheet.isDisplayRowColHeadings(), true); > + assertEquals(sheet.isDisplayFormulas(), false); > + > + sheet.setDisplayGridlines(false); > + sheet.setDisplayRowColHeadings(false); > + sheet.setDisplayFormulas(true); > > tempFile = File.createTempFile("display", "test.xls"); > stream = new FileOutputStream(tempFile); > @@ -374,14 +374,63 @@ > readStream = new FileInputStream(tempFile); > wb = new HSSFWorkbook(readStream); > sheet = wb.getSheetAt(0); > - readStream.close(); > + readStream.close(); > + > + > + assertEquals(sheet.isDisplayGridlines(), false); > + assertEquals(sheet.isDisplayRowColHeadings(), false); > + assertEquals(sheet.isDisplayFormulas(), true); > + } > + > + > + /** > + * Make sure the excel file loads work > + * > + */ > + public void testPageBreakFiles() throws Exception{ > + FileInputStream fis = null; > + HSSFWorkbook wb = null; > + > + String filename = System.getProperty("HSSF.testdata.path"); > > + filename = filename + "/SimpleWithPageBreaks.xls"; > + fis = new FileInputStream(filename); > + wb = new HSSFWorkbook(fis); > + fis.close(); > + > + HSSFSheet sheet = wb.getSheetAt(0); > + assertNotNull(sheet); > + > + assertEquals("1 row page break", 1, sheet.getRowBreaks().length); > + assertEquals("1 column page break", 1, > sheet.getColumnBreaks().length); > > - assertEquals(sheet.isDisplayGridlines(), false); > - assertEquals(sheet.isDisplayRowColHeadings(), false); > - assertEquals(sheet.isDisplayFormulas(), true); > - } > + assertTrue("No row page break", sheet.isRowBroken(22)); > + assertTrue("No column page break", sheet.isColumnBroken((short)4)); > + > + sheet.setRowBreak(10); > + sheet.setColumnBreak((short)13); > + > + assertEquals("row breaks number", 2, sheet.getRowBreaks().length); > + assertEquals("column breaks number", 2, > sheet.getColumnBreaks().length); > + > + File tempFile = File.createTempFile("display", "testPagebreaks.xls"); > + FileOutputStream stream = new FileOutputStream(tempFile); > + wb.write(stream); > + stream.close(); > + > + wb = new HSSFWorkbook(new FileInputStream(tempFile)); > + sheet = wb.getSheetAt(0); > + > + assertTrue("No row page break", sheet.isRowBroken(22)); > + assertTrue("No column page break", sheet.isColumnBroken((short)4)); > > + > + assertEquals("row breaks number", 2, sheet.getRowBreaks().length); > + assertEquals("column breaks number", 2, > sheet.getColumnBreaks().length); > + > + > + } > + > public static void main(java.lang.String[] args) { > junit.textui.TestRunner.run(TestHSSFSheet.class); > } > > > > No revision > No revision > 1.16.2.1 +5 -3 > jakarta-poi/src/java/org/apache/poi/hssf/record/RecordFactory.java > > Index: RecordFactory.java > =================================================================== > RCS file: > /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/RecordFactory.java,v > retrieving revision 1.16 > retrieving revision 1.16.2.1 > diff -u -r1.16 -r1.16.2.1 > --- RecordFactory.java 8 May 2003 00:02:03 -0000 1.16 > +++ RecordFactory.java 9 Feb 2004 22:41:26 -0000 1.16.2.1 > @@ -2,7 +2,7 @@ > /* ==================================================================== > * The Apache Software License, Version 1.1 > * > - * Copyright (c) 2003 The Apache Software Foundation. All rights > + * Copyright (c) 2004 The Apache Software Foundation. All rights > * reserved. > * > * Redistribution and use in source and binary forms, with or without > @@ -112,7 +112,8 @@ > FormulaRecord.class, BoolErrRecord.class, > ExternSheetRecord.class, > NameRecord.class, LeftMarginRecord.class, > RightMarginRecord.class, > TopMarginRecord.class, BottomMarginRecord.class, > - PaletteRecord.class, StringRecord.class, > RecalcIdRecord.class, SharedFormulaRecord.class > + PaletteRecord.class, StringRecord.class, > RecalcIdRecord.class, SharedFormulaRecord.class, > + HorizontalPageBreakRecord.class, > VerticalPageBreakRecord.class > }; > } else { > records = new Class[] > @@ -143,7 +144,8 @@ > BoolErrRecord.class, ExternSheetRecord.class, > NameRecord.class, > LeftMarginRecord.class, RightMarginRecord.class, > TopMarginRecord.class, BottomMarginRecord.class, > - PaletteRecord.class, StringRecord.class, > RecalcIdRecord.class, SharedFormulaRecord.class > + PaletteRecord.class, StringRecord.class, > RecalcIdRecord.class, SharedFormulaRecord.class, > + HorizontalPageBreakRecord.class, > VerticalPageBreakRecord.class > }; > > } > > > > No revision > > Index: RecordFactory.java > =================================================================== > RCS file: > /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/RecordFactory.java,v > retrieving revision 1.16 > retrieving revision 1.16.2.1 > diff -u -r1.16 -r1.16.2.1 > --- RecordFactory.java 8 May 2003 00:02:03 -0000 1.16 > +++ RecordFactory.java 9 Feb 2004 22:41:26 -0000 1.16.2.1 > @@ -2,7 +2,7 @@ > /* ==================================================================== > * The Apache Software License, Version 1.1 > * > - * Copyright (c) 2003 The Apache Software Foundation. All rights > + * Copyright (c) 2004 The Apache Software Foundation. All rights > * reserved. > * > * Redistribution and use in source and binary forms, with or without > @@ -112,7 +112,8 @@ > FormulaRecord.class, BoolErrRecord.class, > ExternSheetRecord.class, > NameRecord.class, LeftMarginRecord.class, > RightMarginRecord.class, > TopMarginRecord.class, BottomMarginRecord.class, > - PaletteRecord.class, StringRecord.class, > RecalcIdRecord.class, SharedFormulaRecord.class > + PaletteRecord.class, StringRecord.class, > RecalcIdRecord.class, SharedFormulaRecord.class, > + HorizontalPageBreakRecord.class, > VerticalPageBreakRecord.class > }; > } else { > records = new Class[] > @@ -143,7 +144,8 @@ > BoolErrRecord.class, ExternSheetRecord.class, > NameRecord.class, > LeftMarginRecord.class, RightMarginRecord.class, > TopMarginRecord.class, BottomMarginRecord.class, > - PaletteRecord.class, StringRecord.class, > RecalcIdRecord.class, SharedFormulaRecord.class > + PaletteRecord.class, StringRecord.class, > RecalcIdRecord.class, SharedFormulaRecord.class, > + HorizontalPageBreakRecord.class, > VerticalPageBreakRecord.class > }; > > } > > > > No revision > > Index: RecordFactory.java > =================================================================== > RCS file: > /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/record/RecordFactory.java,v > retrieving revision 1.16 > retrieving revision 1.16.2.1 > diff -u -r1.16 -r1.16.2.1 > --- RecordFactory.java 8 May 2003 00:02:03 -0000 1.16 > +++ RecordFactory.java 9 Feb 2004 22:41:26 -0000 1.16.2.1 > @@ -2,7 +2,7 @@ > /* ==================================================================== > * The Apache Software License, Version 1.1 > * > - * Copyright (c) 2003 The Apache Software Foundation. All rights > + * Copyright (c) 2004 The Apache Software Foundation. All rights > * reserved. > * > * Redistribution and use in source and binary forms, with or without > @@ -112,7 +112,8 @@ > FormulaRecord.class, BoolErrRecord.class, > ExternSheetRecord.class, > NameRecord.class, LeftMarginRecord.class, > RightMarginRecord.class, > TopMarginRecord.class, BottomMarginRecord.class, > - PaletteRecord.class, StringRecord.class, > RecalcIdRecord.class, SharedFormulaRecord.class > + PaletteRecord.class, StringRecord.class, > RecalcIdRecord.class, SharedFormulaRecord.class, > + HorizontalPageBreakRecord.class, > VerticalPageBreakRecord.class > }; > } else { > records = new Class[] > @@ -143,7 +144,8 @@ > BoolErrRecord.class, ExternSheetRecord.class, > NameRecord.class, > LeftMarginRecord.class, RightMarginRecord.class, > TopMarginRecord.class, BottomMarginRecord.class, > - PaletteRecord.class, StringRecord.class, > RecalcIdRecord.class, SharedFormulaRecord.class > + PaletteRecord.class, StringRecord.class, > RecalcIdRecord.class, SharedFormulaRecord.class, > + HorizontalPageBreakRecord.class, > VerticalPageBreakRecord.class > }; > > } > > > > 1.1.2.1 +107 -0 > jakarta-poi/src/java/org/apache/poi/hssf/record/Attic/VerticalPageBreakRecord. > java > > > > > 1.1.2.1 +107 -0 > jakarta-poi/src/java/org/apache/poi/hssf/record/Attic/HorizontalPageBreakRecor > d.java > > > > > 1.1.2.1 +304 -0 > jakarta-poi/src/java/org/apache/poi/hssf/record/Attic/PageBreakRecord.java > > > > > No revision > No revision > 1.31.2.9 +200 -49 jakarta-poi/src/java/org/apache/poi/hssf/model/Sheet.java > > Index: Sheet.java > =================================================================== > RCS file: > /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/model/Sheet.java,v > retrieving revision 1.31.2.8 > retrieving revision 1.31.2.9 > diff -u -r1.31.2.8 -r1.31.2.9 > --- Sheet.java 21 Sep 2003 09:58:24 -0000 1.31.2.8 > +++ Sheet.java 9 Feb 2004 22:41:26 -0000 1.31.2.9 > @@ -2,7 +2,7 @@ > /* ==================================================================== > * The Apache Software License, Version 1.1 > * > - * Copyright (c) 2003 The Apache Software Foundation. All rights > + * Copyright (c) 2004 The Apache Software Foundation. All rights > * reserved. > * > * Redistribution and use in source and binary forms, with or without > @@ -111,7 +111,7 @@ > protected WindowTwoRecord windowTwo = null; > protected MergeCellsRecord merged = null; > protected Margin margins[] = null; > - protected List mergedRecords = new ArrayList(); > + protected List mergedRecords = new ArrayList(); > protected int numMergedRegions = 0; > protected SelectionRecord selection = null; > private static POILogger log = > POILogFactory.getLogger(Sheet.class); > @@ -121,8 +121,11 @@ > private Iterator valueRecIterator = null; > private Iterator rowRecIterator = null; > protected int eofLoc = 0; > - protected ProtectRecord protect = null; > - > + protected ProtectRecord protect = null; > + protected PageBreakRecord rowBreaks = null; > + protected PageBreakRecord colBreaks = null; > + > + > public static final byte PANE_LOWER_RIGHT = (byte)0; > public static final byte PANE_UPPER_RIGHT = (byte)1; > public static final byte PANE_LOWER_LEFT = (byte)2; > @@ -155,7 +158,7 @@ > */ > public static Sheet createSheet(List recs, int sheetnum, int offset) > { > - log.logFormatted(log.DEBUG, > + log.logFormatted(POILogger.DEBUG, > "Sheet createSheet (existing file) with %", > new Integer(recs.size())); > Sheet retval = new Sheet(); > @@ -170,18 +173,18 @@ > > if (rec.getSid() == LabelRecord.sid) > { > - log.log(log.DEBUG, "Hit label record."); > + log.log(POILogger.DEBUG, "Hit label record."); > retval.containsLabels = true; > } > else if (rec.getSid() == BOFRecord.sid) > { > bofEofNestingLevel++; > - log.log(log.DEBUG, "Hit BOF record. Nesting increased to " + > bofEofNestingLevel); > + log.log(POILogger.DEBUG, "Hit BOF record. Nesting increased > to " + bofEofNestingLevel); > } > else if (rec.getSid() == EOFRecord.sid) > { > --bofEofNestingLevel; > - log.log(log.DEBUG, "Hit EOF record. Nesting decreased to " + > bofEofNestingLevel); > + log.log(POILogger.DEBUG, "Hit EOF record. Nesting decreased > to " + bofEofNestingLevel); > if (bofEofNestingLevel == 0) { > records.add(rec); > retval.eofLoc = k; > @@ -289,8 +292,16 @@ > else if ( rec.getSid() == ProtectRecord.sid ) > { > retval.protect = (ProtectRecord) rec; > + } > + else if (rec.getSid() == PageBreakRecord.HORIZONTAL_SID) > + { > + retval.rowBreaks = (PageBreakRecord)rec; > } > - > + else if (rec.getSid() == PageBreakRecord.VERTICAL_SID) > + { > + retval.colBreaks = (PageBreakRecord)rec; > + } > + > if (rec != null) > { > records.add(rec); > @@ -307,7 +318,7 @@ > // { > // retval.cells = new ValueRecordsAggregate(); > // } > - log.log(log.DEBUG, "sheet createSheet (existing file) exited"); > + log.log(POILogger.DEBUG, "sheet createSheet (existing file) exited"); > return retval; > } > > @@ -366,7 +377,7 @@ > > public static Sheet createSheet(List records, int sheetnum) > { > - log.log(log.DEBUG, > + log.log(POILogger.DEBUG, > "Sheet createSheet (exisiting file) assumed offset 0"); > return createSheet(records, sheetnum, 0); > } > @@ -381,7 +392,7 @@ > > public static Sheet createSheet() > { > - log.log(log.DEBUG, "Sheet createsheet from scratch called"); > + log.log(POILogger.DEBUG, "Sheet createsheet from scratch called"); > Sheet retval = new Sheet(); > ArrayList records = new ArrayList(30); > > @@ -404,8 +415,14 @@ > (DefaultRowHeightRecord) retval.createDefaultRowHeight(); > records.add( retval.defaultrowheight ); > records.add( retval.createWSBool() ); > + > + retval.rowBreaks = new > PageBreakRecord(PageBreakRecord.HORIZONTAL_SID); > + records.add(retval.rowBreaks); > + retval.colBreaks = new PageBreakRecord(PageBreakRecord.VERTICAL_SID); > + records.add(retval.colBreaks); > + > retval.header = (HeaderRecord) retval.createHeader(); > - records.add( retval.header ); > + records.add( retval.header ); > retval.footer = (FooterRecord) retval.createFooter(); > records.add( retval.footer ); > records.add( retval.createHCenter() ); > @@ -415,9 +432,9 @@ > retval.defaultcolwidth = > (DefaultColWidthRecord) retval.createDefaultColWidth(); > records.add( retval.defaultcolwidth); > - retval.dims = ( DimensionsRecord ) retval.createDimensions(); > - retval.dimsloc = 19; > + retval.dims = ( DimensionsRecord ) retval.createDimensions(); > records.add(retval.dims); > + retval.dimsloc = records.size()-1; > records.add(retval.windowTwo = retval.createWindowTwo()); > retval.setLoc(records.size() - 1); > retval.selection = > @@ -426,8 +443,9 @@ > retval.protect = (ProtectRecord) retval.createProtect(); > records.add(retval.protect); > records.add(retval.createEOF()); > + > retval.records = records; > - log.log(log.DEBUG, "Sheet createsheet from scratch exit"); > + log.log(POILogger.DEBUG, "Sheet createsheet from scratch exit"); > return retval; > } > > @@ -566,7 +584,7 @@ > > public void convertLabelRecords(Workbook wb) > { > - log.log(log.DEBUG, "convertLabelRecords called"); > + log.log(POILogger.DEBUG, "convertLabelRecords called"); > if (containsLabels) > { > for (int k = 0; k < records.size(); k++) > @@ -590,7 +608,7 @@ > } > } > } > - log.log(log.DEBUG, "convertLabelRecords exit"); > + log.log(POILogger.DEBUG, "convertLabelRecords exit"); > } > > /** > @@ -604,8 +622,8 @@ > { > checkCells(); > checkRows(); > - log.log(log.DEBUG, "Sheet.getNumRecords"); > - log.logFormatted(log.DEBUG, "returning % + % + % - 2 = %", new int[] > + log.log(POILogger.DEBUG, "Sheet.getNumRecords"); > + log.logFormatted(POILogger.DEBUG, "returning % + % + % - 2 = %", new > int[] > { > records.size(), cells.getPhysicalNumberOfCells(), > rows.getPhysicalNumberOfRows(), > @@ -628,8 +646,8 @@ > public void setDimensions(int firstrow, short firstcol, int lastrow, > short lastcol) > { > - log.log(log.DEBUG, "Sheet.setDimensions"); > - log.log(log.DEBUG, > + log.log(POILogger.DEBUG, "Sheet.setDimensions"); > + log.log(POILogger.DEBUG, > (new StringBuffer("firstrow")).append(firstrow) > .append("firstcol").append(firstcol).append("lastrow") > .append(lastrow).append("lastcol").append(lastcol) > @@ -638,7 +656,7 @@ > dims.setFirstRow(firstrow); > dims.setLastCol(lastcol); > dims.setLastRow(lastrow); > - log.log(log.DEBUG, "Sheet.setDimensions exiting"); > + log.log(POILogger.DEBUG, "Sheet.setDimensions exiting"); > } > > /** > @@ -660,7 +678,7 @@ > public void setLoc(int loc) > { > valueRecIterator = null; > - log.log(log.DEBUG, "sheet.setLoc(): " + loc); > + log.log(POILogger.DEBUG, "sheet.setLoc(): " + loc); > this.loc = loc; > } > > @@ -671,7 +689,7 @@ > > public int getLoc() > { > - log.log(log.DEBUG, "sheet.getLoc():" + loc); > + log.log(POILogger.DEBUG, "sheet.getLoc():" + loc); > return loc; > } > > @@ -709,7 +727,7 @@ > > public byte [] serialize() > { > - log.log(log.DEBUG, "Sheet.serialize"); > + log.log(POILogger.DEBUG, "Sheet.serialize"); > > // addDBCellRecords(); > byte[] retval = null; > @@ -726,7 +744,7 @@ > // for (int k = 0; k < bytes.size(); k++) > // { > // arraysize += (( byte [] ) bytes.get(k)).length; > - // log.debug((new StringBuffer("arraysize=")).append(arraysize) > + // POILogger.DEBUG((new StringBuffer("arraysize=")).append(arraysize) > // .toString()); > // } > retval = new byte[ arraysize ]; > @@ -738,7 +756,7 @@ > pos += (( Record ) records.get(k)).serialize(pos, > retval); // rec.length; > } > - log.log(log.DEBUG, "Sheet.serialize returning " + retval); > + log.log(POILogger.DEBUG, "Sheet.serialize returning " + retval); > return retval; > } > > @@ -753,7 +771,7 @@ > > public int serialize(int offset, byte [] data) > { > - log.log(log.DEBUG, "Sheet.serialize using offsets"); > + log.log(POILogger.DEBUG, "Sheet.serialize using offsets"); > > // addDBCellRecords(); > // ArrayList bytes = new ArrayList(4096); > @@ -768,7 +786,7 @@ > // for (int k = 0; k < bytes.size(); k++) > // { > // arraysize += (( byte [] ) bytes.get(k)).length; > - // log.debug((new StringBuffer("arraysize=")).append(arraysize) > + // POILogger.DEBUG((new StringBuffer("arraysize=")).append(arraysize) > // .toString()); > // } > for (int k = 0; k < records.size(); k++) > @@ -787,7 +805,7 @@ > pos += record.serialize(pos + offset, data ); // rec.length; > > } > - log.log(log.DEBUG, "Sheet.serialize returning "); > + log.log(POILogger.DEBUG, "Sheet.serialize returning "); > return pos; > } > > @@ -801,7 +819,7 @@ > > public RowRecord createRow(int row) > { > - log.log(log.DEBUG, "create row number " + row); > + log.log(POILogger.DEBUG, "create row number " + row); > RowRecord rowrec = new RowRecord(); > > //rowrec.setRowNumber(( short ) row); > @@ -826,7 +844,7 @@ > //public LabelSSTRecord createLabelSST(short row, short col, int index) > public LabelSSTRecord createLabelSST(int row, short col, int index) > { > - log.logFormatted(log.DEBUG, "create labelsst row,col,index %,%,%", > + log.logFormatted(POILogger.DEBUG, "create labelsst row,col,index > %,%,%", > new int[] > { > row, col, index > @@ -853,7 +871,7 @@ > //public NumberRecord createNumber(short row, short col, double value) > public NumberRecord createNumber(int row, short col, double value) > { > - log.logFormatted(log.DEBUG, "create number row,col,value %,%,%", > + log.logFormatted(POILogger.DEBUG, "create number row,col,value > %,%,%", > new double[] > { > row, col, value > @@ -878,8 +896,8 @@ > //public BlankRecord createBlank(short row, short col) > public BlankRecord createBlank(int row, short col) > { > - //log.logFormatted(log.DEBUG, "create blank row,col %,%", new short[] > - log.logFormatted(log.DEBUG, "create blank row,col %,%", new int[] > + //log.logFormatted(POILogger.DEBUG, "create blank row,col %,%", new > short[] > + log.logFormatted(POILogger.DEBUG, "create blank row,col %,%", new > int[] > { > row, col > }); > @@ -905,7 +923,7 @@ > //public FormulaRecord createFormula(short row, short col, String > formula) > public FormulaRecord createFormula(int row, short col, String formula) > { > - log.logFormatted(log.DEBUG, "create formula row,col,formula %,%,%", > + log.logFormatted(POILogger.DEBUG, "create formula row,col,formula > %,%,%", > //new short[] > new int[] > { > @@ -949,7 +967,7 @@ > public void addValueRecord(int row, CellValueRecordInterface col) > { > checkCells(); > - log.logFormatted(log.DEBUG, "add value record row,loc %,%", new > int[] > + log.logFormatted(POILogger.DEBUG, "add value record row,loc %,%", > new int[] > { > row, loc > }); > @@ -1003,7 +1021,7 @@ > public void removeValueRecord(int row, CellValueRecordInterface col) > { > checkCells(); > - log.logFormatted(log.DEBUG, "remove value record row,dimsloc %,%", > + log.logFormatted(POILogger.DEBUG, "remove value record row,dimsloc > %,%", > new int[]{row, dimsloc} ); > loc = dimsloc; > cells.removeCell(col); > @@ -1044,7 +1062,7 @@ > { > checkCells(); > setLoc(dimsloc); > - log.log(log.DEBUG, "replaceValueRecord "); > + log.log(POILogger.DEBUG, "replaceValueRecord "); > cells.insertCell(newval); > > /* > @@ -1080,7 +1098,7 @@ > public void addRow(RowRecord row) > { > checkRows(); > - log.log(log.DEBUG, "addRow "); > + log.log(POILogger.DEBUG, "addRow "); > DimensionsRecord d = ( DimensionsRecord ) records.get(getDimsLoc()); > > if (row.getRowNumber() > d.getLastRow()) > @@ -1134,7 +1152,7 @@ > * } > * } > */ > - log.log(log.DEBUG, "exit addRow"); > + log.log(POILogger.DEBUG, "exit addRow"); > } > > /** > @@ -1194,7 +1212,7 @@ > > public CellValueRecordInterface getNextValueRecord() > { > - log.log(log.DEBUG, "getNextValue loc= " + loc); > + log.log(POILogger.DEBUG, "getNextValue loc= " + loc); > if (valueRecIterator == null) > { > valueRecIterator = cells.getIterator(); > @@ -1241,7 +1259,7 @@ > > /* public Record getNextRowOrValue() > { > - log.debug((new StringBuffer("getNextRow loc= ")).append(loc) > + POILogger.DEBUG((new StringBuffer("getNextRow loc= ")).append(loc) > .toString()); > if (this.getLoc() < records.size()) > { > @@ -1281,7 +1299,7 @@ > > public RowRecord getNextRow() > { > - log.log(log.DEBUG, "getNextRow loc= " + loc); > + log.log(POILogger.DEBUG, "getNextRow loc= " + loc); > if (rowRecIterator == null) > { > rowRecIterator = rows.getIterator(); > @@ -1327,7 +1345,7 @@ > //public RowRecord getRow(short rownum) > public RowRecord getRow(int rownum) > { > - log.log(log.DEBUG, "getNextRow loc= " + loc); > + log.log(POILogger.DEBUG, "getNextRow loc= " + loc); > return rows.getRow(rownum); > > /* > @@ -1543,7 +1561,7 @@ > { > RefModeRecord retval = new RefModeRecord(); > > - retval.setMode(retval.USE_A1_MODE); > + retval.setMode(RefModeRecord.USE_A1_MODE); > return retval; > } > > @@ -2161,7 +2179,7 @@ > > public int getDimsLoc() > { > - log.log(log.DEBUG, "getDimsLoc dimsloc= " + dimsloc); > + log.log(POILogger.DEBUG, "getDimsLoc dimsloc= " + dimsloc); > return dimsloc; > } > > @@ -2533,7 +2551,7 @@ > > protected Record createProtect() > { > - log.log(log.DEBUG, "create protect record with protection > disabled"); > + log.log(POILogger.DEBUG, "create protect record with > protection disabled"); > ProtectRecord retval = new ProtectRecord(); > > retval.setProtect(false); > @@ -2603,5 +2621,138 @@ > if (margins == null) > margins = new Margin[4]; > return margins; > + } > + > + /** > + * Shifts all the page breaks in the range "count" number of rows/columns > + * @param breaks The page record to be shifted > + * @param start Starting "main" value to shift breaks > + * @param stop Ending "main" value to shift breaks > + * @param count number of units (rows/columns) to shift by > + */ > + public void shiftBreaks(PageBreakRecord breaks, short start, short stop, > int count) { > + > + if(rowBreaks == null) > + return; > + Iterator iterator = breaks.getBreaksIterator(); > + List shiftedBreak = new ArrayList(); > + while(iterator.hasNext()) > + { > + PageBreakRecord.Break breakItem = > (PageBreakRecord.Break)iterator.next(); > + short breakLocation = breakItem.main; > + boolean inStart = (breakLocation >= start); > + boolean inEnd = (breakLocation <= stop); > + if(inStart && inEnd) > + shiftedBreak.add(breakItem); > + } > + > + iterator = shiftedBreak.iterator(); > + while (iterator.hasNext()) { > + PageBreakRecord.Break breakItem = (PageBreakRecord.Break)iterator.next(); > + breaks.removeBreak(breakItem.main); > + breaks.addBreak((short)(breakItem.main+count), breakItem.subFrom, > breakItem.subTo); > + } > + } > + > + /** > + * Sets a page break at the indicated row > + * @param row > + */ > + public void setRowBreak(int row, short fromCol, short toCol) { > + rowBreaks.addBreak((short)row, fromCol, toCol); > + } > + > + /** > + * Removes a page break at the indicated row > + * @param row > + */ > + public void removeRowBreak(int row) { > + rowBreaks.removeBreak((short)row); > + } > + > + /** > + * Queries if the specified row has a page break > + * @param row > + * @return true if the specified row has a page break > + */ > + public boolean isRowBroken(int row) { > + return rowBreaks.getBreak((short)row) != null; > + } > + > + /** > + * Sets a page break at the indicated column > + * @param row > + */ > + public void setColumnBreak(short column, short fromRow, short toRow) { > > + colBreaks.addBreak(column, fromRow, toRow); > + } > + > + /** > + * Removes a page break at the indicated column > + * @param row > + */ > + public void removeColumnBreak(short column) { > + colBreaks.removeBreak(column); > + } > + > + /** > + * Queries if the specified column has a page break > + * @param row > + * @return true if the specified column has a page break > + */ > + public boolean isColumnBroken(short column) { > + return colBreaks.getBreak(column) != null; > + } > + > + /** > + * Shifts the horizontal page breaks for the indicated count > + * @param startingRow > + * @param endingRow > + * @param count > + */ > + public void shiftRowBreaks(int startingRow, int endingRow, int count) { > + shiftBreaks(rowBreaks, (short)startingRow, (short)endingRow, > (short)count); > + } > + > + /** > + * Shifts the vertical page breaks for the indicated count > + * @param startingCol > + * @param endingCol > + * @param count > + */ > + public void shiftColumnBreaks(short startingCol, short endingCol, short > count) { > + shiftBreaks(colBreaks, startingCol, endingCol, count); > + } > + > + /** > + * Returns all the row page breaks > + * @return > + */ > + public Iterator getRowBreaks() { > + return rowBreaks.getBreaksIterator(); > + } > + > + /** > + * Returns the number of row page breaks > + * @return > + */ > + public int getNumRowBreaks(){ > + return (int)rowBreaks.getNumBreaks(); > + } > + > + /** > + * Returns all the column page breaks > + * @return > + */ > + public Iterator getColumnBreaks(){ > + return colBreaks.getBreaksIterator(); > + } > + > + /** > + * Returns the number of column page breaks > + * @return > + */ > + public int getNumColumnBreaks(){ > + return (int)colBreaks.getNumBreaks(); > } > } > > > > No revision > No revision > 1.31.2.1 +9 -1 > jakarta-poi/src/java/org/apache/poi/hssf/dev/BiffViewer.java > > Index: BiffViewer.java > =================================================================== > RCS file: > /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/dev/BiffViewer.java,v > retrieving revision 1.31 > retrieving revision 1.31.2.1 > diff -u -r1.31 -r1.31.2.1 > --- BiffViewer.java 8 May 2003 00:02:03 -0000 1.31 > +++ BiffViewer.java 9 Feb 2004 22:41:27 -0000 1.31.2.1 > @@ -2,7 +2,7 @@ > * ==================================================================== > * The Apache Software License, Version 1.1 > * > - * Copyright (c) 2003 The Apache Software Foundation. All rights > + * Copyright (c) 2004 The Apache Software Foundation. All rights > * reserved. > * > * Redistribution and use in source and binary forms, with or without > @@ -633,6 +633,14 @@ > case SharedFormulaRecord.sid: > retval = new SharedFormulaRecord( rectype, size, data); > break; > + case HorizontalPageBreakRecord.sid: > + retval = new HorizontalPageBreakRecord( rectype, size, data); > + break; > + case VerticalPageBreakRecord.sid: > + retval = new VerticalPageBreakRecord( rectype, size, data); > + break; > + > + > default: > retval = new UnknownRecord( rectype, size, data ); > } > > > > No revision > No revision > 1.1.2.1 +23 -0 > jakarta-poi/src/testcases/org/apache/poi/hssf/data/Attic/SimpleWithPageBreaks. > xls > > <> > > > No revision > No revision > 1.21.2.4 +111 -4 > jakarta-poi/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java > > Index: HSSFSheet.java > =================================================================== > RCS file: > /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java,v > retrieving revision 1.21.2.3 > retrieving revision 1.21.2.4 > diff -u -r1.21.2.3 -r1.21.2.4 > --- HSSFSheet.java 23 Aug 2003 18:54:28 -0000 1.21.2.3 > +++ HSSFSheet.java 9 Feb 2004 22:41:27 -0000 1.21.2.4 > @@ -1,7 +1,7 @@ > /* ==================================================================== > * The Apache Software License, Version 1.1 > * > - * Copyright (c) 2003 The Apache Software Foundation. All rights > + * Copyright (c) 2004 The Apache Software Foundation. All rights > * reserved. > * > * Redistribution and use in source and binary forms, with or without > @@ -68,6 +68,7 @@ > import org.apache.poi.hssf.model.Workbook; > import org.apache.poi.hssf.record.CellValueRecordInterface; > import org.apache.poi.hssf.record.HCenterRecord; > +import org.apache.poi.hssf.record.PageBreakRecord; > import org.apache.poi.hssf.record.Record; > import org.apache.poi.hssf.record.RowRecord; > import org.apache.poi.hssf.record.SCLRecord; > @@ -981,6 +982,8 @@ > *

> * Additionally shifts merged regions that are completely defined in > these > * rows (ie. merged 2 cells on a row to be shifted). > + *

> + * TODO Might want to add bounds checking here > * @param startRow the row to start shifting > * @param endRow the row to end shifting > * @param n the number of rows to shift > @@ -1004,7 +1007,8 @@ > } > > shiftMerged(startRow, endRow, n, true); > - > + sheet.shiftRowBreaks(startRow, endRow, n); > + > for ( int rowNum = s; rowNum >= startRow && rowNum <= endRow && > rowNum >= 0 && rowNum < 65536; rowNum += inc ) > { > HSSFRow row = getRow( rowNum ); > @@ -1130,7 +1134,7 @@ > * @return whether formulas are displayed > */ > public boolean isDisplayFormulas() { > - return sheet.isDisplayFormulas(); > + return sheet.isDisplayFormulas(); > } > > /** > @@ -1146,6 +1150,109 @@ > * @return whether RowColHeadings are displayed > */ > public boolean isDisplayRowColHeadings() { > - return sheet.isDisplayRowColHeadings(); > + return sheet.isDisplayRowColHeadings(); > + } > + > + /** > + * Sets a page break at the indicated row > + * @param row > + */ > + public void setRowBreak(int row) { > + validateRow(row); > + sheet.setRowBreak(row, (short)0, (short)255); > + } > + > + /** > + * Determines if there is a page break at the indicated row > + * @param row > + * @return > + */ > + public boolean isRowBroken(int row) { > + return sheet.isRowBroken(row); > + } > + > + /** > + * Removes the page break at the indicated row > + * @param row > + */ > + public void removeRowBreak(int row) { > + sheet.removeRowBreak(row); > + } > + > + /** > + * Retrieves all the horizontal page breaks > + * @return > + */ > + public int[] getRowBreaks(){ > + //we can probably cache this information, but this should be a sparsely > used function > + int[] returnValue = new int[sheet.getNumRowBreaks()]; > + Iterator iterator = sheet.getRowBreaks(); > + int i = 0; > + while (iterator.hasNext()) { > + PageBreakRecord.Break breakItem = > (PageBreakRecord.Break)iterator.next(); > + returnValue[i++] = (int)breakItem.main; > + } > + return returnValue; > + } > + > + /** > + * Retrieves all the vertical page breaks > + * @return > + */ > + public short[] getColumnBreaks(){ > + //we can probably cache this information, but this should be a sparsely > used function > + short[] returnValue = new short[sheet.getNumColumnBreaks()]; > + Iterator iterator = sheet.getColumnBreaks(); > + int i = 0; > + while (iterator.hasNext()) { > + PageBreakRecord.Break breakItem = > (PageBreakRecord.Break)iterator.next(); > + returnValue[i++] = breakItem.main; > + } > + return returnValue; > + } > + > + > + /** > + * Sets a page break at the indicated column > + * @param column > + */ > + public void setColumnBreak(short column) { > + validateColumn(column); > + sheet.setColumnBreak(column, (short)0, (short)65535); > + } > + > + /** > + * Determines if there is a page break at the indicated column > + * @param column > + * @return > + */ > + public boolean isColumnBroken(short column) { > + return sheet.isColumnBroken(column); > + } > + > + /** > + * Removes a page break at the indicated column > + * @param column > + */ > + public void removeColumnBreak(short column) { > + sheet.removeColumnBreak(column); > + } > + > + /** > + * Runs a bounds check for row numbers > + * @param row > + */ > + protected void validateRow(int row) { > + if (row > 65535) throw new IllegalArgumentException("Maximum row number > is 65535"); > + if (row < 0) throw new IllegalArgumentException("Minumum row number is > 0"); > + } > + > + /** > + * Runs a bounds check for column numbers > + * @param column > + */ > + protected void validateColumn(short column) { > + if (column > 255) throw new IllegalArgumentException("Maximum column > number is 255"); > + if (column < 0) throw new IllegalArgumentException("Minimum column > number is 0"); > } > } > > > > No revision > No revision > 1.3.2.2 +121 -0 > jakarta-poi/src/testcases/org/apache/poi/hssf/model/SheetTest.java > > Index: SheetTest.java > =================================================================== > RCS file: > /home/cvs/jakarta-poi/src/testcases/org/apache/poi/hssf/model/SheetTest.java,v > retrieving revision 1.3.2.1 > retrieving revision 1.3.2.2 > diff -u -r1.3.2.1 -r1.3.2.2 > --- SheetTest.java 6 Sep 2003 18:56:29 -0000 1.3.2.1 > +++ SheetTest.java 9 Feb 2004 22:41:27 -0000 1.3.2.2 > @@ -2,12 +2,14 @@ > > import java.lang.reflect.Field; > import java.util.ArrayList; > +import java.util.Iterator; > import java.util.List; > > import junit.framework.TestCase; > > import org.apache.poi.hssf.record.ColumnInfoRecord; > import org.apache.poi.hssf.record.MergeCellsRecord; > +import org.apache.poi.hssf.record.PageBreakRecord; > import org.apache.poi.hssf.record.RowRecord; > import org.apache.poi.hssf.record.StringRecord; > > @@ -171,6 +173,125 @@ > Sheet sheet = Sheet.createSheet(records, 0); > assertNotNull("Row [2] was skipped", sheet.getRow(2)); > > + } > + > + /** > + * Make sure page break functionality works (in memory) > + * > + */ > + public void testRowPageBreaks(){ > + short colFrom = 0; > + short colTo = 255; > + > + Sheet sheet = Sheet.createSheet(); > + sheet.setRowBreak(0, colFrom, colTo); > + > + assertTrue("no row break at 0", sheet.isRowBroken(0)); > + assertEquals("1 row break available", 1, sheet.getNumRowBreaks()); > + > + sheet.setRowBreak(0, colFrom, colTo); > + sheet.setRowBreak(0, colFrom, colTo); > + > + assertTrue("no row break at 0", sheet.isRowBroken(0)); > + assertEquals("1 row break available", 1, sheet.getNumRowBreaks()); > + > + sheet.setRowBreak(10, colFrom, colTo); > + sheet.setRowBreak(11, colFrom, colTo); > + > + assertTrue("no row break at 10", sheet.isRowBroken(10)); > + assertTrue("no row break at 11", sheet.isRowBroken(11)); > + assertEquals("3 row break available", 3, sheet.getNumRowBreaks()); > + > + > + boolean is10 = false; > + boolean is0 = false; > + boolean is11 = false; > + > + Iterator iterator = sheet.getRowBreaks(); > + while (iterator.hasNext()) { > + PageBreakRecord.Break breakItem = (PageBreakRecord.Break)iterator.next(); > + int main = (int)breakItem.main; > + if (main != 0 && main != 10 && main != 11) fail("Invalid page break"); > + if (main == 0) is0 = true; > + if (main == 10) is10= true; > + if (main == 11) is11 = true; > + } > + > + assertTrue("one of the breaks didnt make it", is0 && is10 && is11); > + > + sheet.removeRowBreak(11); > + assertFalse("row should be removed", sheet.isRowBroken(11)); > + > + sheet.removeRowBreak(0); > + assertFalse("row should be removed", sheet.isRowBroken(0)); > + > + sheet.removeRowBreak(10); > + assertFalse("row should be removed", sheet.isRowBroken(10)); > + > + assertEquals("no more breaks", 0, sheet.getNumRowBreaks()); > + > + > + } > + > + /** > + * Make sure column pag breaks works properly (in-memory) > + * > + */ > + public void testColPageBreaks(){ > + short rowFrom = 0; > + short rowTo = (short)65535; > + > + Sheet sheet = Sheet.createSheet(); > + sheet.setColumnBreak((short)0, rowFrom, rowTo); > + > + assertTrue("no col break at 0", sheet.isColumnBroken((short)0)); > + assertEquals("1 col break available", 1, sheet.getNumColumnBreaks()); > + > + sheet.setColumnBreak((short)0, rowFrom, rowTo); > + > + assertTrue("no col break at 0", sheet.isColumnBroken((short)0)); > + assertEquals("1 col break available", 1, sheet.getNumColumnBreaks()); > + > + sheet.setColumnBreak((short)1, rowFrom, rowTo); > + sheet.setColumnBreak((short)10, rowFrom, rowTo); > + sheet.setColumnBreak((short)15, rowFrom, rowTo); > + > + assertTrue("no col break at 1", sheet.isColumnBroken((short)1)); > + assertTrue("no col break at 10", sheet.isColumnBroken((short)10)); > + assertTrue("no col break at 15", sheet.isColumnBroken((short)15)); > + assertEquals("4 col break available", 4, sheet.getNumColumnBreaks()); > + > + boolean is10 = false; > + boolean is0 = false; > + boolean is1 = false; > + boolean is15 = false; > + > + Iterator iterator = sheet.getColumnBreaks(); > + while (iterator.hasNext()) { > + PageBreakRecord.Break breakItem = (PageBreakRecord.Break)iterator.next(); > + int main = (int)breakItem.main; > + if (main != 0 && main != 1 && main != 10 && main != 15) fail("Invalid page > break"); > + if (main == 0) is0 = true; > + if (main == 1) is1 = true; > + if (main == 10) is10= true; > + if (main == 15) is15 = true; > + } > + > + assertTrue("one of the breaks didnt make it", is0 && is1 && is10 && is15); > + > + sheet.removeColumnBreak((short)15); > + assertFalse("column break should not be there", > sheet.isColumnBroken((short)15)); > + > + sheet.removeColumnBreak((short)0); > + assertFalse("column break should not be there", > sheet.isColumnBroken((short)0)); > + > + sheet.removeColumnBreak((short)1); > + assertFalse("column break should not be there", > sheet.isColumnBroken((short)1)); > + > + sheet.removeColumnBreak((short)10); > + assertFalse("column break should not be there", > sheet.isColumnBroken((short)10)); > + > + assertEquals("no more breaks", 0, sheet.getNumColumnBreaks()); > } > > } > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org > For additional commands, e-mail: poi-dev-help@jakarta.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: poi-dev-help@jakarta.apache.org