Ignore:
Timestamp:
03/13/08 04:52:50 (4 years ago)
Author:
jojada
Message:

Added fontSubstituter setter

File:
1 edited

Legend:

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

    r184 r186  
    2222 
    2323import java.io.OutputStream; 
    24  
    2524import java.util.Iterator; 
    2625import java.util.Map; 
     
    2928import javax.xml.bind.Marshaller; 
    3029 
    31 import org.apache.fop.fonts.EmbedFontInfo; 
    3230import org.apache.log4j.Logger; 
    3331import org.docx4j.fonts.Substituter; 
    3432import org.docx4j.jaxb.Context; 
     33import org.docx4j.openpackaging.contenttype.ContentType; 
     34import org.docx4j.openpackaging.contenttype.ContentTypeManager; 
     35import org.docx4j.openpackaging.contenttype.ContentTypes; 
     36import org.docx4j.openpackaging.exceptions.Docx4JException; 
     37import org.docx4j.openpackaging.exceptions.InvalidFormatException; 
     38import org.docx4j.openpackaging.io.LoadFromZipFile; 
     39import org.docx4j.openpackaging.io.SaveToZipFile; 
    3540import org.docx4j.openpackaging.parts.DocPropsCorePart; 
    3641import org.docx4j.openpackaging.parts.DocPropsCustomPart; 
     
    4146import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart; 
    4247import org.docx4j.openpackaging.parts.relationships.Namespaces; 
    43  
    44 import org.docx4j.openpackaging.contenttype.ContentType; 
    45 import org.docx4j.openpackaging.contenttype.ContentTypeManager; 
    46 import org.docx4j.openpackaging.contenttype.ContentTypes; 
    47 import org.docx4j.openpackaging.exceptions.Docx4JException; 
    48 import org.docx4j.openpackaging.exceptions.InvalidFormatException; 
    49 import org.docx4j.openpackaging.io.LoadFromZipFile; 
    50 import org.docx4j.openpackaging.io.SaveToZipFile; 
    51 import org.xhtmlrenderer.pdf.ITextRenderer; 
    52  
    53 import com.lowagie.text.DocumentException; 
    5448 
    5549 
     
    293287                //     possibly via an extension function in the XSLT 
    294288                if (fontSubstituter==null) { 
    295                         setFontSubstituter(); 
     289                        setFontSubstituter(new Substituter()); 
    296290                } 
    297291                xformer.setParameter("substituterInstance", fontSubstituter); 
     
    309303    } 
    310304     
    311     public void setFontSubstituter() throws Exception { 
    312          
     305    public void setFontSubstituter(Substituter fs) throws Exception { 
     306        if (fs == null) { 
     307                throw new IllegalArgumentException("Font Substituter cannot be null."); 
     308        } 
    313309                // 1.  Get a list of all the fonts in the document 
    314310                java.util.Map fontsInUse = this.getMainDocumentPart().fontsInUse(); 
     
    316312                // 2.  For each font, find the closest match on the system (use OO's VCL.xcu to do this) 
    317313                //     - do this in a general way, since docx4all needs this as well to display fonts            
    318                 fontSubstituter = new Substituter(); 
     314                fontSubstituter = fs; 
    319315                org.docx4j.wml.Fonts fonts = null; 
    320316                FontTablePart fontTablePart= this.getMainDocumentPart().getFontTablePart();      
     
    323319                        log.warn("FontTable missing; creating default part."); 
    324320                        fontTablePart= new org.docx4j.openpackaging.parts.WordprocessingML.FontTablePart(); 
    325                         fontTablePart.unmarshalDefaultFonts();                                   
     321                        fontTablePart.unmarshalDefaultFonts(); 
     322                        fontTablePart.processEmbeddings(); 
    326323                } 
    327324                 
Note: See TracChangeset for help on using the changeset viewer.