mirror of https://github.com/apache/poi.git
Merged revisions 697559 via svnmerge from
https://svn.apache.org/repos/asf/poi/trunk ........ r697559 | nick | 2008-09-21 18:38:39 +0100 (Sun, 21 Sep 2008) | 1 line Fix bug #45777 - Throw an exception if HSSF Footer or Header is attemped to be set too long, rather than having it break during writing out ........ git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@698250 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6323c282db
commit
301a628efb
|
@ -67,6 +67,7 @@
|
||||||
<action dev="POI-DEVELOPERS" type="add">Created a common interface for handling Excel files, irrespective of if they are .xls or .xlsx</action>
|
<action dev="POI-DEVELOPERS" type="add">Created a common interface for handling Excel files, irrespective of if they are .xls or .xlsx</action>
|
||||||
</release>
|
</release>
|
||||||
<release version="3.2-alpha1" date="2008-??-??">
|
<release version="3.2-alpha1" date="2008-??-??">
|
||||||
|
<action dev="POI-DEVELOPERS" type="fix">45777 - Throw an exception if HSSF Footer or Header is attemped to be set too long, rather than having it break during writing out</action>
|
||||||
<action dev="POI-DEVELOPERS" type="add">45844 - Addtional diagnostics for HSLF SlideShowRecordDumper</action>
|
<action dev="POI-DEVELOPERS" type="add">45844 - Addtional diagnostics for HSLF SlideShowRecordDumper</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">45829 - HSSFPicture.getImageDimension() failed when DPI of image is zero</action>
|
<action dev="POI-DEVELOPERS" type="fix">45829 - HSSFPicture.getImageDimension() failed when DPI of image is zero</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">45815 - Bit mask values in StyleTextPropAtom were not preserved across read-write</action>
|
<action dev="POI-DEVELOPERS" type="fix">45815 - Bit mask values in StyleTextPropAtom were not preserved across read-write</action>
|
||||||
|
|
|
@ -64,6 +64,7 @@
|
||||||
<action dev="POI-DEVELOPERS" type="add">Created a common interface for handling Excel files, irrespective of if they are .xls or .xlsx</action>
|
<action dev="POI-DEVELOPERS" type="add">Created a common interface for handling Excel files, irrespective of if they are .xls or .xlsx</action>
|
||||||
</release>
|
</release>
|
||||||
<release version="3.2-alpha1" date="2008-??-??">
|
<release version="3.2-alpha1" date="2008-??-??">
|
||||||
|
<action dev="POI-DEVELOPERS" type="fix">45777 - Throw an exception if HSSF Footer or Header is attemped to be set too long, rather than having it break during writing out</action>
|
||||||
<action dev="POI-DEVELOPERS" type="add">45844 - Addtional diagnostics for HSLF SlideShowRecordDumper</action>
|
<action dev="POI-DEVELOPERS" type="add">45844 - Addtional diagnostics for HSLF SlideShowRecordDumper</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">45829 - HSSFPicture.getImageDimension() failed when DPI of image is zero</action>
|
<action dev="POI-DEVELOPERS" type="fix">45829 - HSSFPicture.getImageDimension() failed when DPI of image is zero</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">45815 - Bit mask values in StyleTextPropAtom were not preserved across read-write</action>
|
<action dev="POI-DEVELOPERS" type="fix">45815 - Bit mask values in StyleTextPropAtom were not preserved across read-write</action>
|
||||||
|
|
|
@ -118,6 +118,18 @@ public class FooterRecord
|
||||||
field_4_footer = footer;
|
field_4_footer = footer;
|
||||||
field_3_unicode_flag =
|
field_3_unicode_flag =
|
||||||
(byte) (StringUtil.hasMultibyte(field_4_footer) ? 1 : 0);
|
(byte) (StringUtil.hasMultibyte(field_4_footer) ? 1 : 0);
|
||||||
|
// Check it'll fit into the space in the record
|
||||||
|
|
||||||
|
if(field_4_footer == null) return;
|
||||||
|
if(field_3_unicode_flag == 1) {
|
||||||
|
if(field_4_footer.length() > 127) {
|
||||||
|
throw new IllegalArgumentException("Footer string too long (limit is 127 for unicode strings)");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(field_4_footer.length() > 255) {
|
||||||
|
throw new IllegalArgumentException("Footer string too long (limit is 255 for non-unicode strings)");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -117,6 +117,18 @@ public class HeaderRecord
|
||||||
field_4_header = header;
|
field_4_header = header;
|
||||||
field_3_unicode_flag =
|
field_3_unicode_flag =
|
||||||
(byte) (StringUtil.hasMultibyte(field_4_header) ? 1 : 0);
|
(byte) (StringUtil.hasMultibyte(field_4_header) ? 1 : 0);
|
||||||
|
|
||||||
|
// Check it'll fit into the space in the record
|
||||||
|
if(field_4_header == null) return;
|
||||||
|
if(field_3_unicode_flag == 1) {
|
||||||
|
if(field_4_header.length() > 127) {
|
||||||
|
throw new IllegalArgumentException("Header string too long (limit is 127 for unicode strings)");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(field_4_header.length() > 255) {
|
||||||
|
throw new IllegalArgumentException("Header string too long (limit is 255 for non-unicode strings)");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -72,6 +72,11 @@ public class HSSFFooter extends HeaderFooter implements Footer {
|
||||||
createFooterString();
|
createFooterString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getRawFooter() {
|
||||||
|
return footerRecord.getFooter();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the complete footer string based on the left, center, and middle
|
* Creates the complete footer string based on the left, center, and middle
|
||||||
* strings.
|
* strings.
|
||||||
|
|
|
@ -79,6 +79,10 @@ public class HSSFHeader extends HeaderFooter implements Header {
|
||||||
createHeaderString();
|
createHeaderString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getRawHeader() {
|
||||||
|
return headerRecord.getHeader();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the complete header string based on the left, center, and middle
|
* Creates the complete header string based on the left, center, and middle
|
||||||
* strings.
|
* strings.
|
||||||
|
|
|
@ -1416,4 +1416,64 @@ public final class TestBugs extends TestCase {
|
||||||
assertFalse(nwb.isSheetHidden(2));
|
assertFalse(nwb.isSheetHidden(2));
|
||||||
assertTrue(nwb.isSheetVeryHidden(2));
|
assertTrue(nwb.isSheetVeryHidden(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* header / footer text too long
|
||||||
|
*/
|
||||||
|
public void test45777() {
|
||||||
|
HSSFWorkbook wb = new HSSFWorkbook();
|
||||||
|
HSSFSheet s = wb.createSheet();
|
||||||
|
|
||||||
|
String s248 = "";
|
||||||
|
for(int i=0; i<248; i++) {
|
||||||
|
s248 += "x";
|
||||||
|
}
|
||||||
|
String s249 = s248 + "1";
|
||||||
|
String s250 = s248 + "12";
|
||||||
|
String s251 = s248 + "123";
|
||||||
|
assertEquals(248, s248.length());
|
||||||
|
assertEquals(249, s249.length());
|
||||||
|
assertEquals(250, s250.length());
|
||||||
|
assertEquals(251, s251.length());
|
||||||
|
|
||||||
|
|
||||||
|
// Try on headers
|
||||||
|
s.getHeader().setCenter(s248);
|
||||||
|
assertEquals(254, s.getHeader().getRawHeader().length());
|
||||||
|
writeOutAndReadBack(wb);
|
||||||
|
|
||||||
|
s.getHeader().setCenter(s249);
|
||||||
|
assertEquals(255, s.getHeader().getRawHeader().length());
|
||||||
|
writeOutAndReadBack(wb);
|
||||||
|
|
||||||
|
try {
|
||||||
|
s.getHeader().setCenter(s250); // 256
|
||||||
|
fail();
|
||||||
|
} catch(IllegalArgumentException e) {}
|
||||||
|
|
||||||
|
try {
|
||||||
|
s.getHeader().setCenter(s251); // 257
|
||||||
|
fail();
|
||||||
|
} catch(IllegalArgumentException e) {}
|
||||||
|
|
||||||
|
|
||||||
|
// Now try on footers
|
||||||
|
s.getFooter().setCenter(s248);
|
||||||
|
assertEquals(254, s.getFooter().getRawFooter().length());
|
||||||
|
writeOutAndReadBack(wb);
|
||||||
|
|
||||||
|
s.getFooter().setCenter(s249);
|
||||||
|
assertEquals(255, s.getFooter().getRawFooter().length());
|
||||||
|
writeOutAndReadBack(wb);
|
||||||
|
|
||||||
|
try {
|
||||||
|
s.getFooter().setCenter(s250); // 256
|
||||||
|
fail();
|
||||||
|
} catch(IllegalArgumentException e) {}
|
||||||
|
|
||||||
|
try {
|
||||||
|
s.getFooter().setCenter(s251); // 257
|
||||||
|
fail();
|
||||||
|
} catch(IllegalArgumentException e) {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue