From: Nick Burch Date: Sat, 13 Sep 2008 14:00:53 +0000 (+0000) Subject: Fix from bug #45676 - Handle very long cells in the XSSF EventUserModel example X-Git-Tag: REL_3_5_BETA3~25 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7a7295d1b9a0b23abbe014e6a545f8da7a3700f7;p=poi.git Fix from bug #45676 - Handle very long cells in the XSSF EventUserModel example git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@694949 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml index 6025906757..f07ad2f350 100644 --- a/src/documentation/content/xdocs/changes.xml +++ b/src/documentation/content/xdocs/changes.xml @@ -41,6 +41,7 @@ --> + 45676 - Handle very long cells in the XSSF EventUserModel example Initial ExtractorFactory support for building TextExtractors for embeded documents Support stripping XSSF header and footer fields (eg page number) out of header and footer text if required Add POIXMLPropertiesTextExtractor, which provides to the OOXML file formats a similar function to HPSF's HPSFPropertiesExtractor diff --git a/src/documentation/content/xdocs/spreadsheet/how-to.xml b/src/documentation/content/xdocs/spreadsheet/how-to.xml index 970482cef9..5d70b08345 100644 --- a/src/documentation/content/xdocs/spreadsheet/how-to.xml +++ b/src/documentation/content/xdocs/spreadsheet/how-to.xml @@ -587,10 +587,19 @@ public class ExampleEventUserModel { nextIsString = false; } } + // Clear contents cache + lastContents = ""; } public void endElement(String uri, String localName, String name) throws SAXException { + // Process the last contents as required. + // Do now, as characters() may be called more than once + if(nextIsString) { + int idx = Integer.parseInt(lastContents); + lastContents = sst.getSharedStringAt(idx); + } + // v => contents of a cell // Output after we've seen the string contents if(name.equals("v")) { @@ -600,11 +609,7 @@ public class ExampleEventUserModel { public void characters(char[] ch, int start, int length) throws SAXException { - lastContents = new String(ch, start, length); - if(nextIsString) { - int idx = Integer.parseInt(lastContents); - lastContents = sst.getSharedStringAt(idx); - } + lastContents += new String(ch, start, length); } } diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 9eaab3dad1..0adf13d18c 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -38,6 +38,7 @@ --> + 45676 - Handle very long cells in the XSSF EventUserModel example Initial ExtractorFactory support for building TextExtractors for embeded documents Support stripping XSSF header and footer fields (eg page number) out of header and footer text if required Add POIXMLPropertiesTextExtractor, which provides to the OOXML file formats a similar function to HPSF's HPSFPropertiesExtractor diff --git a/src/examples/src/org/apache/poi/xssf/eventusermodel/examples/FromHowTo.java b/src/examples/src/org/apache/poi/xssf/eventusermodel/examples/FromHowTo.java index d2d78c0943..f298ee10f6 100644 --- a/src/examples/src/org/apache/poi/xssf/eventusermodel/examples/FromHowTo.java +++ b/src/examples/src/org/apache/poi/xssf/eventusermodel/examples/FromHowTo.java @@ -103,10 +103,19 @@ public class FromHowTo { nextIsString = false; } } + // Clear contents cache + lastContents = ""; } public void endElement(String uri, String localName, String name) throws SAXException { + // Process the last contents as required. + // Do now, as characters() may be called more than once + if(nextIsString) { + int idx = Integer.parseInt(lastContents); + lastContents = sst.getSharedStringAt(idx); + } + // v => contents of a cell // Output after we've seen the string contents if(name.equals("v")) { @@ -116,11 +125,7 @@ public class FromHowTo { public void characters(char[] ch, int start, int length) throws SAXException { - lastContents = new String(ch, start, length); - if(nextIsString) { - int idx = Integer.parseInt(lastContents); - lastContents = sst.getSharedStringAt(idx); - } + lastContents += new String(ch, start, length); } }