Ignore:
Timestamp:
03/11/08 10:00:49 (4 years ago)
Author:
jharrop
Message:

Set up fontSubstituter outside of html method, so can use object already created by docx4all.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/packages/WordprocessingMLPackage.java

    r172 r176  
    253253                javax.xml.transform.Transformer xformer = template.newTransformer(); 
    254254                 
    255                 log.error(xformer.getClass().getName() ); 
     255                if (!xformer.getClass().getName().equals("org.apache.xalan.transformer.TransformerImpl")) { 
     256                        log.error("Detected " + xformer.getClass().getName()  
     257                                        + ", but require org.apache.xalan.transformer.TransformerImpl. " + 
     258                                                        "Ensure Xalan 2.7.0 is on your classpath!" ); 
     259                } 
    256260                // com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl won't work 
    257261                // with our extension function. 
    258262 
    259                 // Handle fonts - this is platform specific 
    260                 // Algorithm - to be implemented: 
     263                 
     264                // 3.  Ensure that the font names in the XHTML have been mapped to these matches 
     265                //     possibly via an extension function in the XSLT 
     266                if (fontSubstituter==null) { 
     267                        setFontSubstituter(); 
     268                } 
     269                xformer.setParameter("substituterInstance", fontSubstituter); 
     270                xformer.setParameter("fontFamilyStack", fontFamilyStack); 
     271                 
     272                 
     273                //DEBUGGING  
     274                // use the identity transform if you want to send wordDocument; 
     275                // otherwise you'll get the XHTML 
     276                //javax.xml.transform.Transformer xformer = tfactory.newTransformer(); 
     277                 
     278                xformer.transform(domSource, result); 
     279 
     280                log.info("wordDocument transformed to xhtml .."); 
     281         
     282    } 
     283     
     284    public void setFontSubstituter() throws Exception { 
     285         
    261286                // 1.  Get a list of all the fonts in the document 
    262287                java.util.Map fontsInUse = this.getMainDocumentPart().fontsInUse(); 
     
    275300                 
    276301                fonts = (org.docx4j.wml.Fonts)fontTablePart.getJaxbElement(); 
    277                 fontSubstituter.populateFontMappings(fontsInUse, fonts); 
    278                  
    279                 // 3.  Ensure that the font names in the XHTML have been mapped to these matches 
    280                 //     possibly via an extension function in the XSLT 
    281                 xformer.setParameter("substituterInstance", fontSubstituter); 
    282                 xformer.setParameter("fontFamilyStack", fontFamilyStack); 
    283                  
    284                  
    285                 //DEBUGGING  
    286                 // use the identity transform if you want to send wordDocument; 
    287                 // otherwise you'll get the XHTML 
    288                 //javax.xml.transform.Transformer xformer = tfactory.newTransformer(); 
    289                  
    290                 xformer.transform(domSource, result); 
    291  
    292                 log.info("wordDocument transformed to xhtml .."); 
     302                fontSubstituter.populateFontMappings(fontsInUse, fonts);         
    293303         
    294304    } 
Note: See TracChangeset for help on using the changeset viewer.