Page 1 of 1

Vertical Alignment and Conversion hooks

PostPosted: Thu Apr 25, 2013 11:28 pm
by mothergoose
When converting from XHTML to docx, the vertical-align style property is ignored.

I have a
Code: Select all
<span style="vertical-align: super">text</span>
which isn't rendered as a superscript.

Maybe is not supported but I'm wondering, since I also need to generate some additional stuff into the docx based on the XHTML input, is there any sort of hook or filter that can be used to sneak into the conversion process and add additional elements to the docx while parsing the XHTML document?

Re: Vertical Alignment and Conversion hooks

PostPosted: Fri Apr 26, 2013 8:58 am
by jason
Looking at the code, org.docx4j.model.properties.run.VerticalAlignment, the reason it doesn't work is that a value of "top" is supported, but not "super". Assuming super is a legal value in CSS land (I haven't checked), then the required change is:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
@@ -59,10 +59,13 @@ public class VerticalAlignment extends AbstractRunProperty {
                CTVerticalAlignRun vAlign = Context.getWmlObjectFactory().createCTVerticalAlignRun();
               
                if (value.getCssText().toLowerCase().equals("top")) {                  
                        vAlign.setVal(STVerticalAlignRun.SUPERSCRIPT);                 
                        this.setObject( vAlign );
+               } else if (value.getCssText().toLowerCase().equals("super")) {                 
+                       vAlign.setVal(STVerticalAlignRun.SUPERSCRIPT);                 
+                       this.setObject( vAlign );
                } else if (value.getCssText().toLowerCase().equals("bottom")) {
                        vAlign.setVal(STVerticalAlignRun.SUBSCRIPT);                   
                        this.setObject( vAlign );
                } else {
                        log.warn("What to do with value: " + value.getCssText());
 
Parsed in 0.016 seconds, using GeSHi 1.0.8.4


mothergoose wrote:is there any sort of hook or filter that can be used to sneak into the conversion process and add additional elements to the docx while parsing the XHTML document?


No, there isn't at the moment. We have that sort of tag handler thing for output, and I can see the use for XHTML Import, especially for custom (ie foreign) element names.

Re: Vertical Alignment and Conversion hooks

PostPosted: Fri Apr 26, 2013 8:25 pm
by mothergoose
what's that 'tag handler thing'? :o

Re: Vertical Alignment and Conversion hooks

PostPosted: Tue Apr 30, 2013 9:31 am
by jason
For what its worth, its the ModelConverter interface, used for outputting tables and various other things in PDF, HTML. But it can't just be re-used for XHTML import.