Fix bug #49253 - When setting repeating rows and columns for XSSF, don't break the print settings if they were already there
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1082961 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5d2184a007
commit
df49838158
@ -34,6 +34,7 @@
|
||||
|
||||
<changes>
|
||||
<release version="3.8-beta2" date="2011-??-??">
|
||||
<action dev="poi-developers" type="fix">49253 - When setting repeating rows and columns for XSSF, don't break the print settings if they were already there</action>
|
||||
<action dev="poi-developers" type="fix">49219 - ExternalNameRecord support for DDE Link entries without an operation</action>
|
||||
<action dev="poi-developers" type="fix">50846 - More XSSFColor theme improvements, this time for Cell Borders</action>
|
||||
<action dev="poi-developers" type="fix">50939 - ChartEndObjectRecord is supposed to have 6 bytes at the end, but handle it not</action>
|
||||
|
@ -1018,9 +1018,18 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
||||
String reference = getReferenceBuiltInRecord(name.getSheetName(), startColumn, endColumn, startRow, endRow);
|
||||
name.setRefersToFormula(reference);
|
||||
|
||||
// If the print setup isn't currently defined, then add it
|
||||
// in but without printer defaults
|
||||
// If it's already there, leave it as-is!
|
||||
CTWorksheet ctSheet = sheet.getCTWorksheet();
|
||||
if(ctSheet.isSetPageSetup() && ctSheet.isSetPageMargins()) {
|
||||
// Everything we need is already there
|
||||
} else {
|
||||
// Have initial ones put in place
|
||||
XSSFPrintSetup printSetup = sheet.getPrintSetup();
|
||||
printSetup.setValidSettings(false);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getReferenceBuiltInRecord(String sheetName, int startC, int endC, int startR, int endR) {
|
||||
//windows excel example for built-in title: 'second sheet'!$E:$F,'second sheet'!$2:$3
|
||||
|
@ -892,4 +892,46 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||
assertEquals("Tabella1", t.getDisplayName());
|
||||
assertEquals("A1:C3", t.getCTTable().getRef());
|
||||
}
|
||||
|
||||
/**
|
||||
* Setting repeating rows and columns shouldn't break
|
||||
* any print settings that were there before
|
||||
*/
|
||||
public void test49253() throws Exception {
|
||||
XSSFWorkbook wb1 = new XSSFWorkbook();
|
||||
XSSFWorkbook wb2 = new XSSFWorkbook();
|
||||
|
||||
// No print settings before repeating
|
||||
XSSFSheet s1 = wb1.createSheet();
|
||||
assertEquals(false, s1.getCTWorksheet().isSetPageSetup());
|
||||
assertEquals(true, s1.getCTWorksheet().isSetPageMargins());
|
||||
|
||||
wb1.setRepeatingRowsAndColumns(0, 2, 3, 1, 2);
|
||||
|
||||
assertEquals(true, s1.getCTWorksheet().isSetPageSetup());
|
||||
assertEquals(true, s1.getCTWorksheet().isSetPageMargins());
|
||||
|
||||
XSSFPrintSetup ps1 = s1.getPrintSetup();
|
||||
assertEquals(false, ps1.getValidSettings());
|
||||
assertEquals(false, ps1.getLandscape());
|
||||
|
||||
|
||||
// Had valid print settings before repeating
|
||||
XSSFSheet s2 = wb2.createSheet();
|
||||
XSSFPrintSetup ps2 = s2.getPrintSetup();
|
||||
assertEquals(true, s2.getCTWorksheet().isSetPageSetup());
|
||||
assertEquals(true, s2.getCTWorksheet().isSetPageMargins());
|
||||
|
||||
ps2.setLandscape(false);
|
||||
assertEquals(true, ps2.getValidSettings());
|
||||
assertEquals(false, ps2.getLandscape());
|
||||
|
||||
wb2.setRepeatingRowsAndColumns(0, 2, 3, 1, 2);
|
||||
|
||||
ps2 = s2.getPrintSetup();
|
||||
assertEquals(true, s2.getCTWorksheet().isSetPageSetup());
|
||||
assertEquals(true, s2.getCTWorksheet().isSetPageMargins());
|
||||
assertEquals(true, ps2.getValidSettings());
|
||||
assertEquals(false, ps2.getLandscape());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user