Fix for bug #43058 - handle setting row grouping for sheets that lacked gutsrecords at that point
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@610384 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9726aea084
commit
0f4d8d90ed
@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
<!-- Don't forget to update status.xml too! -->
|
<!-- Don't forget to update status.xml too! -->
|
||||||
<release version="3.0.2-FINAL" date="2008-??-??">
|
<release version="3.0.2-FINAL" date="2008-??-??">
|
||||||
|
<action dev="POI-DEVELOPERS" type="fix">43058 - Support setting row grouping on files from CR IX, which lack GutsRecords</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">31795 - Support cloning of sheets with certain drawing objects on them</action>
|
<action dev="POI-DEVELOPERS" type="fix">31795 - Support cloning of sheets with certain drawing objects on them</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">43902 - Don't consider merged regions when auto-sizing columns</action>
|
<action dev="POI-DEVELOPERS" type="fix">43902 - Don't consider merged regions when auto-sizing columns</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">42464 - Avoid "Expected ExpPtg to be converted from Shared to Non-Shared Formula" on large, formula heavy worksheets</action>
|
<action dev="POI-DEVELOPERS" type="fix">42464 - Avoid "Expected ExpPtg to be converted from Shared to Non-Shared Formula" on large, formula heavy worksheets</action>
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
<!-- Don't forget to update changes.xml too! -->
|
<!-- Don't forget to update changes.xml too! -->
|
||||||
<changes>
|
<changes>
|
||||||
<release version="3.0.2-FINAL" date="2008-??-??">
|
<release version="3.0.2-FINAL" date="2008-??-??">
|
||||||
|
<action dev="POI-DEVELOPERS" type="fix">43058 - Support setting row grouping on files from CR IX, which lack GutsRecords</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">31795 - Support cloning of sheets with certain drawing objects on them</action>
|
<action dev="POI-DEVELOPERS" type="fix">31795 - Support cloning of sheets with certain drawing objects on them</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">43902 - Don't consider merged regions when auto-sizing columns</action>
|
<action dev="POI-DEVELOPERS" type="fix">43902 - Don't consider merged regions when auto-sizing columns</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">42464 - Avoid "Expected ExpPtg to be converted from Shared to Non-Shared Formula" on large, formula heavy worksheets</action>
|
<action dev="POI-DEVELOPERS" type="fix">42464 - Avoid "Expected ExpPtg to be converted from Shared to Non-Shared Formula" on large, formula heavy worksheets</action>
|
||||||
|
@ -3144,7 +3144,13 @@ public class Sheet implements Model
|
|||||||
maxLevel = Math.max(rowRecord.getOutlineLevel(), maxLevel);
|
maxLevel = Math.max(rowRecord.getOutlineLevel(), maxLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Grab the guts record, adding if needed
|
||||||
GutsRecord guts = (GutsRecord) findFirstRecordBySid( GutsRecord.sid );
|
GutsRecord guts = (GutsRecord) findFirstRecordBySid( GutsRecord.sid );
|
||||||
|
if(guts == null) {
|
||||||
|
guts = new GutsRecord();
|
||||||
|
records.add(guts);
|
||||||
|
}
|
||||||
|
// Set the levels onto it
|
||||||
guts.setRowLevelMax( (short) ( maxLevel + 1 ) );
|
guts.setRowLevelMax( (short) ( maxLevel + 1 ) );
|
||||||
guts.setLeftRowGutter( (short) ( 29 + (12 * (maxLevel)) ) );
|
guts.setLeftRowGutter( (short) ( 29 + (12 * (maxLevel)) ) );
|
||||||
}
|
}
|
||||||
|
@ -223,6 +223,16 @@ public class HSSFRow
|
|||||||
{
|
{
|
||||||
return rowNum;
|
return rowNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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() {
|
||||||
|
return row.getOutlineLevel();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* used internally to add a cell.
|
* used internally to add a cell.
|
||||||
|
BIN
src/testcases/org/apache/poi/hssf/data/NoGutsRecords.xls
Normal file
BIN
src/testcases/org/apache/poi/hssf/data/NoGutsRecords.xls
Normal file
Binary file not shown.
@ -309,6 +309,104 @@ public class TestHSSFSheet
|
|||||||
assertEquals(1, sheetLS.getPrintSetup().getCopies());
|
assertEquals(1, sheetLS.getPrintSetup().getCopies());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testGroupRows() throws Exception {
|
||||||
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||||
|
HSSFSheet s = workbook.createSheet();
|
||||||
|
HSSFRow r1 = s.createRow(0);
|
||||||
|
HSSFRow r2 = s.createRow(1);
|
||||||
|
HSSFRow r3 = s.createRow(2);
|
||||||
|
HSSFRow r4 = s.createRow(3);
|
||||||
|
HSSFRow r5 = s.createRow(4);
|
||||||
|
|
||||||
|
assertEquals(0, r1.getOutlineLevel());
|
||||||
|
assertEquals(0, r2.getOutlineLevel());
|
||||||
|
assertEquals(0, r3.getOutlineLevel());
|
||||||
|
assertEquals(0, r4.getOutlineLevel());
|
||||||
|
assertEquals(0, r5.getOutlineLevel());
|
||||||
|
|
||||||
|
s.groupRow(2,3);
|
||||||
|
|
||||||
|
assertEquals(0, r1.getOutlineLevel());
|
||||||
|
assertEquals(0, r2.getOutlineLevel());
|
||||||
|
assertEquals(1, r3.getOutlineLevel());
|
||||||
|
assertEquals(1, r4.getOutlineLevel());
|
||||||
|
assertEquals(0, r5.getOutlineLevel());
|
||||||
|
|
||||||
|
// Save and re-open
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
workbook.write(baos);
|
||||||
|
workbook = new HSSFWorkbook(
|
||||||
|
new ByteArrayInputStream(baos.toByteArray())
|
||||||
|
);
|
||||||
|
|
||||||
|
s = workbook.getSheetAt(0);
|
||||||
|
r1 = s.getRow(0);
|
||||||
|
r2 = s.getRow(1);
|
||||||
|
r3 = s.getRow(2);
|
||||||
|
r4 = s.getRow(3);
|
||||||
|
r5 = s.getRow(4);
|
||||||
|
|
||||||
|
assertEquals(0, r1.getOutlineLevel());
|
||||||
|
assertEquals(0, r2.getOutlineLevel());
|
||||||
|
assertEquals(1, r3.getOutlineLevel());
|
||||||
|
assertEquals(1, r4.getOutlineLevel());
|
||||||
|
assertEquals(0, r5.getOutlineLevel());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGroupRowsExisting() throws Exception {
|
||||||
|
String filename = System.getProperty("HSSF.testdata.path");
|
||||||
|
filename = filename + "/NoGutsRecords.xls";
|
||||||
|
HSSFWorkbook workbook =
|
||||||
|
new HSSFWorkbook(new FileInputStream(filename));
|
||||||
|
|
||||||
|
HSSFSheet s = workbook.getSheetAt(0);
|
||||||
|
HSSFRow r1 = s.getRow(0);
|
||||||
|
HSSFRow r2 = s.getRow(1);
|
||||||
|
HSSFRow r3 = s.getRow(2);
|
||||||
|
HSSFRow r4 = s.getRow(3);
|
||||||
|
HSSFRow r5 = s.getRow(4);
|
||||||
|
HSSFRow r6 = s.getRow(5);
|
||||||
|
|
||||||
|
assertEquals(0, r1.getOutlineLevel());
|
||||||
|
assertEquals(0, r2.getOutlineLevel());
|
||||||
|
assertEquals(0, r3.getOutlineLevel());
|
||||||
|
assertEquals(0, r4.getOutlineLevel());
|
||||||
|
assertEquals(0, r5.getOutlineLevel());
|
||||||
|
assertEquals(0, r6.getOutlineLevel());
|
||||||
|
|
||||||
|
// This used to complain about lacking guts records
|
||||||
|
s.groupRow(2, 4);
|
||||||
|
|
||||||
|
assertEquals(0, r1.getOutlineLevel());
|
||||||
|
assertEquals(0, r2.getOutlineLevel());
|
||||||
|
assertEquals(1, r3.getOutlineLevel());
|
||||||
|
assertEquals(1, r4.getOutlineLevel());
|
||||||
|
assertEquals(1, r5.getOutlineLevel());
|
||||||
|
assertEquals(0, r6.getOutlineLevel());
|
||||||
|
|
||||||
|
// Save and re-open
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
workbook.write(baos);
|
||||||
|
workbook = new HSSFWorkbook(
|
||||||
|
new ByteArrayInputStream(baos.toByteArray())
|
||||||
|
);
|
||||||
|
|
||||||
|
s = workbook.getSheetAt(0);
|
||||||
|
r1 = s.getRow(0);
|
||||||
|
r2 = s.getRow(1);
|
||||||
|
r3 = s.getRow(2);
|
||||||
|
r4 = s.getRow(3);
|
||||||
|
r5 = s.getRow(4);
|
||||||
|
r6 = s.getRow(5);
|
||||||
|
|
||||||
|
assertEquals(0, r1.getOutlineLevel());
|
||||||
|
assertEquals(0, r2.getOutlineLevel());
|
||||||
|
assertEquals(1, r3.getOutlineLevel());
|
||||||
|
assertEquals(1, r4.getOutlineLevel());
|
||||||
|
assertEquals(1, r5.getOutlineLevel());
|
||||||
|
assertEquals(0, r6.getOutlineLevel());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that the ProtectRecord is included when creating or cloning a sheet
|
* Test that the ProtectRecord is included when creating or cloning a sheet
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user