You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Krystian Nowak <kr...@man.poznan.pl> on 2004/12/16 16:15:25 UTC

Cocoon-POI question

Hi There!

I saw Victor's modification to Cocoon-POI:
http://cvs.apache.org/viewcvs.cgi/cocoon-2.1/src/blocks/poi/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/EP_Orientation.java?r1=1.5&r2=1.6&diff_format=h
relased in Cocoon 2.1.6

Can you tell me what is the level of activity of block POI right now?
(commits or functional points per month ;)). I am interested in
gmr:Style's Orient attibute ("The text orientation" - accoring to
http://www.jfree.org/jworkbook/gnumeric-xml.pdf) which defaults to "1".
It is a kind of weird attribute:

1) There is a class that represents the attribute:
org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.StyleOrientation
having following methods:

public boolean isHoriz()
public boolean isVertHorizText()
public boolean isVertVertText()
public boolean isVertVertText2()


2) It is used by:

having methods calling representants in StyleOrientation:
public boolean isStyleOrientationHoriz() throws IOException
{
         return getStyleOrientation().isHoriz();
}

public boolean isStyleOrientationVertHorizText() throws IOException
{
         return getStyleOrientation().isVertHorizText();
}

public boolean isStyleOrientationVertVertText() throws IOException
{
         return getStyleOrientation().isVertVertText();
}

public boolean isStyleOrientationVertVertText2() throws IOException 	{
        return getStyleOrientation().isVertVertText2();
}

3) It could have been used on org.apache.poi.hssf.usermodel.HSSFCellStyle
calling its setRotation(short rotation) method

4) BUT no one calls those methods!!!


So what the !@?%^*# is going on?

Recent Gnumeric still seems not to implement text rotation:
http://gnomedesktop.org/node/2020#comment-32238

and it was a problem since a while:
http://mail.gnome.org/archives/gnome-office-list/2003-December/msg00008.html

so I couldn't find good explanation for "Orient" attibute values.
Also the only value written by Gnumeric in Orient attribute is of course
"1", since there is no option in Gnumeric's menu to rotate cell's text.

According to
org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.StyleOrientation 

class it seems to be a 4-bit number:

"Style orientation is written as an integer, and each bit in the
integer specifies a particular boolean attribute. This class deals
with all that information in an easily digested form"

So there are the bits:
0-bit is horiz - default value ( == 1 )
1-bit is vert_horiz_text
2-bit is vert_vert_text
3-bit is vert_vert_text2

What do the three upper bits mean?


Those bits are also mentioned in
http://cvs.gnome.org/viewcvs/gnumeric/gnumeric.xsd?rev=1.11&view=markup
as:
     <xsd:simpleType name="style_orientation">
         <xsd:restriction base="xsd:integer">
             <!-- this is a bit map as follows:
                  1 = HORIZ
                  2 = VERT_HORIZ_TEXT
                  4 = VERT_VERT_TEXT
                  8 = VERT_VERT_TEXT2
             -->
             <xsd:minInclusive value="0"/>
             <xsd:maxInclusive value="15"/>
         </xsd:restriction>
     </xsd:simpleType>



I guess that to set cell text orientation/rotation there is enough to
code it like that:

public abstract class EPStyle
     extends
org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements.EPStyle
{
     public void initialize(Attribute[] attributes, ElementProcessor parent)
         throws IOException
     {
         super.initialize(attributes, parent);

         EPStyleRegion sregion = (EPStyleRegion)parent;

         if (sregion.isValid()) {
             HSSFCellStyle style = sregion.getStyle();

             boolean horiz = isStyleOrientationHoriz();
             boolean vert_horiz_text = isStyleOrientationVertHorizText();
             boolean vert_vert_text = isStyleOrientationVertVertText();
             boolean vert_vert_text2 = isStyleOrientationVertVertText2();

             short rotation = magicallMetodCreatingRotationValue(
                     horiz, vert_horiz_text, vert_vert_text,
vert_vert_text2);
             style.setRotation(rotation);
         }
     }


     public abstract short magicallMetodCreatingRotationValue(
         boolean horiz, boolean vert_horiz_text, boolean vert_vert_text,
         boolean vert_vert_text2);
}

But I need to know how to write magicallMetodCreatingRotationValue!!!
Do you know what can help me?



BTW - what is http://cvs.apache.org/viewcvs.cgi/cocoon-2.2/ repository
points to? There are no blocks - especially my beloved poi one ;)




Regards,
Krystian


-- 
Krystian Nowak
krystian@man.poznan.pl
===========================================
Poznan Supercomputing and Networking Center
Poland, 60-814 Poznan, Zwierzyniecka 20
tel. (+48 61) 8582164 fax. (+48 61) 8582151
http://www.man.poznan.pl
===========================================
BlueEyes - Human-Operator Monitoring System
http://www.blueeyes.prv.pl
http://www.cs.put.poznan.pl/csidc/2001
===========================================

Cocoon-POI enhancements

Posted by Krystian Nowak <kr...@man.poznan.pl>.
In an attachment there is a patch that:
1. Makes vertical text orientation possible.
2. Caches fonts used in workbook, since there could be an error in MS 
Excel that maximal numer of fonts used in workbook is exceeded.

Please, if there is a POI-block developer on the list, could you look at 
that code and think if it is good enough to include it in next Cocoon 
release?

Regards,
Krystian


-- 
Krystian Nowak
krystian@man.poznan.pl
===========================================
Poznan Supercomputing and Networking Center
Poland, 60-814 Poznan, Zwierzyniecka 20
tel. (+48 61) 8582159 fax. (+48 61) 8582151
http://www.man.poznan.pl
===========================================
BlueEyes - Human-Operator Monitoring System
http://www.blueeyes.prv.pl
http://www.cs.put.poznan.pl/csidc/2001
===========================================

Re: Cocoon-POI question

Posted by Krystian Nowak <kr...@man.poznan.pl>.
What do you all think about this simple (_TEMPORARY_) solution (in 
attachment as EPStyle.java.diff)?


Regards,
Krystian


-- 
Krystian Nowak
krystian@man.poznan.pl
===========================================
Poznan Supercomputing and Networking Center
Poland, 60-814 Poznan, Zwierzyniecka 20
tel. (+48 61) 8582164 fax. (+48 61) 8582151
http://www.man.poznan.pl
===========================================
BlueEyes - Human-Operator Monitoring System
http://www.blueeyes.prv.pl
http://www.cs.put.poznan.pl/csidc/2001
===========================================