You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by bu...@apache.org on 2002/03/07 06:06:50 UTC
DO NOT REPLY [Bug 6946] New: -
[PATCH] Fix EPStyle in the HSSF Serializer text alignment problem
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6946>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6946
[PATCH] Fix EPStyle in the HSSF Serializer text alignment problem
Summary: [PATCH] Fix EPStyle in the HSSF Serializer text
alignment problem
Product: Cocoon 2
Version: Current CVS
Platform: All
OS/Version: All
Status: NEW
Severity: Normal
Priority: Other
Component: general components
AssignedTo: cocoon-dev@xml.apache.org
ReportedBy: acoliver@apache.org
CC: nicolaken@apache.org
Patch fixes the problem where the text appears over and over again until you set
an alignment. The problem resulted from me being out in laa laa land (or up
late) when I wrote this and failing to notice the vertical alignment constants
did not match between Excel and Gnumeric. Sorry bout that. .. Anyhow this
fixes it and the vertical alignment was wrong too...
----
Index:
src/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/EPStyle.java
===================================================================
RCS file:
/home/cvspublic/xml-cocoon2/src/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/EPStyle.java,v
retrieving revision 1.2
diff -u -r1.2 EPStyle.java
--- src/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/EPStyle.java 6 Mar 2002 21:02:19 -0000 1.2
+++ src/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/EPStyle.java 7 Mar 2002 04:55:11 -0000
@@ -163,12 +163,16 @@
Hashtable colorhash = sregion.getColorHash();
HSSFCellStyle style = sregion.getStyle();
- style.setAlignment(getHorizontalAlignment().getCode());
- style.setVerticalAlignment(getVerticalAlignment().getCode());
+ short cnvhalign =
+ convertAlignment(getHorizontalAlignment().getCode());
+ style.setAlignment(cnvhalign);
+ short cnvvalign =
+ convertVAlignment(getVerticalAlignment().getCode());
+ style.setVerticalAlignment(cnvvalign);
style.setFillPattern((short)getShade());
- if (getShade() == 1) { //normally this fill is set to true and the
colors are "reversed"
- //according to Gnumeric sources
+ if (getShade() == 1) { //TODO: change to constant when upgrade to
new HSSF
+ //solid w/foreground, bg doesn't matter
getLogger().debug("shade = 1");
HSSFColor color = (HSSFColor)
colorhash.get(getBackgroundColor().toString());
if (color == null) {
@@ -202,11 +206,6 @@
invalid = true;
}
-
-
-
-
- //style.setFillForegroundColor(
}
@@ -567,6 +566,67 @@
public boolean isValid () {
return (!invalid);
}
+
+ /**
+ * deal with mismatch between gnumeric align and Excel
+ */
+ private short convertAlignment(short alignment) {
+ short retval=HSSFCellStyle.ALIGN_GENERAL; // its 0
+
+ switch (alignment) {
+ case 1:
+ retval = HSSFCellStyle.ALIGN_GENERAL;
+ break;
+ case 2:
+ retval = HSSFCellStyle.ALIGN_LEFT;
+ break;
+ case 4:
+ retval = HSSFCellStyle.ALIGN_RIGHT;
+ break;
+ case 8:
+ retval = HSSFCellStyle.ALIGN_CENTER;
+ break;
+ case 16:
+ retval = HSSFCellStyle.ALIGN_FILL;
+ break;
+ case 32:
+ retval = HSSFCellStyle.ALIGN_JUSTIFY;
+ break;
+ case 64:
+ retval = HSSFCellStyle.ALIGN_CENTER_SELECTION;
+ break;
+ default:
+ retval = HSSFCellStyle.ALIGN_GENERAL;
+ }
+
+ return retval;
+ }
+
+
+ /**
+ * deal with mismatch between gnumeric valign and Excel
+ */
+ private short convertVAlignment(short alignment) {
+ short retval=HSSFCellStyle.VERTICAL_TOP; // its 0
+
+ switch (alignment) {
+ case 1:
+ retval = HSSFCellStyle.VERTICAL_TOP;
+ break;
+ case 2:
+ retval = HSSFCellStyle.VERTICAL_BOTTOM;
+ break;
+ case 4:
+ retval = HSSFCellStyle.VERTICAL_CENTER;
+ break;
+ case 8:
+ retval = HSSFCellStyle.VERTICAL_JUSTIFY;
+ break;
+ default:
+ retval = HSSFCellStyle.VERTICAL_TOP;
+ }
+ return retval;
+ }
} // end public class EPStyle
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org