nicolaken 02/04/08 11:21:51
Modified:
src/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements
EPStyle.java
Log:
[PATCH] Data Format support for HSSF Serializer submitted by
[EMAIL PROTECTED] (Andy Oliver) Bug#: 7830
Revision Changes Path
1.4 +30 -1
xml-cocoon2/src/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/EPStyle.java
Index: EPStyle.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/EPStyle.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- EPStyle.java 7 Mar 2002 07:50:09 -0000 1.3
+++ EPStyle.java 8 Apr 2002 18:21:50 -0000 1.4
@@ -201,6 +201,15 @@
}
style.setWrapText(getWrapText());
style.setLocked(true);
+
+ String format = getFormat();
+ if (format != null) {
+ format = kludgeForGnumericMisformats(format);
+ short nformat =
org.apache.poi.hssf.usermodel.HSSFDataFormat.getFormat(format);
+ getLogger().debug("setting format to "+ nformat);
+ style.setDataFormat(nformat);
+ }
+
} else {
invalid = true;
@@ -625,5 +634,25 @@
}
return retval;
}
-
+
+ /**
+ * Takes in a Gnumeric format string and applies some rules to it. Some
+ * versions of Gnumeric seem to leave off the first parenthesis which
+ * causes them not to match the Excel-style format string. (which of course
+ * makes it a little hard to match)
+ */
+ private String kludgeForGnumericMisformats(String format) {
+ String retval = format;
+ getLogger().debug("going out of the format kludger "+ retval);
+ getLogger().debug("first )="+format.indexOf(')'));
+ getLogger().debug("first (="+format.indexOf('('));
+ if ( (format.indexOf(')') < format.indexOf('(')) &&
+ (format.indexOf(')') != -1 )
+ ) {
+ retval = "("+format;
+ }
+ getLogger().debug("going out of the format kludger "+ retval);
+ return retval;
+ }
+
} // end public class EPStyle
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]