Ignore:
Timestamp:
02/26/10 03:41:23 (2 years ago)
Author:
jharrop
Message:

Basic character formatting in SVG output

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/docx4j/src/pptx4j/java/org/pptx4j/convert/out/svginhtml/SvgExporter.java

    r1086 r1087  
    2222import org.docx4j.convert.out.html.HtmlExporterNG; 
    2323import org.docx4j.convert.out.html.AbstractHtmlExporter.HtmlSettings; 
     24import org.docx4j.dml.CTTextCharacterProperties; 
    2425import org.docx4j.dml.CTTextListStyle; 
    2526import org.docx4j.dml.CTTextParagraphProperties; 
     
    3637import org.docx4j.wml.PPr; 
    3738import org.docx4j.wml.Pict; 
     39import org.docx4j.wml.RPr; 
     40//import org.docx4j.wml.RPr; 
    3841import org.docx4j.wml.Style; 
    3942import org.plutext.jaxb.svg11.Line; 
     
    131134                String pStyleVal; 
    132135         
     136                System.out.println("cNvPrName: " + cNvPrName + "; " + "phType: " + phType ); 
     137                 
    133138                if (cNvPrName.toLowerCase().indexOf("subtitle")>-1 
    134139                                || phType.toLowerCase().indexOf("subtitle")>-1) { 
     
    139144                        pStyleVal = "Lvl" + level + "Master" + rl.getMasterNumber() + "Title"; 
    140145                } else { 
    141                         pStyleVal = "Lvl" + level + "Master" + rl.getMasterNumber() + "Body";                    
    142                 } 
     146                        // eg cNvPrName: TextBox 2; phType: 
     147                        pStyleVal = "Lvl" + level + "Master" + rl.getMasterNumber() + "Other";                   
     148                } 
     149                System.out.println("--> " + pStyleVal ); 
    143150                 
    144151        try { 
     
    291298         
    292299} 
    293      
    294 //    public static CTTextListStyle unmarshalFormatting(NodeIterator lstStyleNodeIt ) { 
     300 
     301        public static DocumentFragment createBlockForR( 
     302                        PresentationMLPackage pmlPackage, NodeIterator rPrNodeIt, 
     303                        NodeIterator childResults) { 
     304 
     305                DocumentFragment docfrag = null; 
     306                Document d = null; 
     307                Element span = null; 
     308 
     309                try { 
     310 
     311                        // Create a DOM builder and parse the fragment 
     312                        DocumentBuilderFactory factory = DocumentBuilderFactory 
     313                                        .newInstance(); 
     314                        d = factory.newDocumentBuilder().newDocument(); 
     315 
     316                        span = d.createElement("span"); 
     317                        d.appendChild(span); 
     318 
     319                        CTTextCharacterProperties textCharProps = (CTTextCharacterProperties) nodeToObjectModel( 
     320                                        rPrNodeIt.nextNode(), CTTextCharacterProperties.class); 
     321 
     322                        RPr rPr = TextStyles.getWmlRPr(textCharProps); 
     323 
     324                        // Does our rPr contain anything else? 
     325                        StringBuffer inlineStyle = new StringBuffer(); 
     326                        HtmlExporterNG.createCss(pmlPackage, rPr, inlineStyle); 
     327                        if (!inlineStyle.toString().equals("")) { 
     328                                span.setAttribute("style", inlineStyle.toString()); 
     329                        } 
     330 
     331                        Node n = childResults.nextNode(); 
     332                        XmlUtils.treeCopy((DTMNodeProxy) n, span); 
     333 
     334                } catch (Exception e) { 
     335                        e.printStackTrace(); 
     336                        log.error(e); 
     337                        // If something went wrong with the formatting, 
     338                        // still try to display the text! 
     339                        Node n = childResults.nextNode(); 
     340                        XmlUtils.treeCopy((DTMNodeProxy) n, span); 
     341                } 
     342 
     343                // Machinery 
     344                docfrag = d.createDocumentFragment(); 
     345                docfrag.appendChild(d.getDocumentElement()); 
     346                return docfrag; 
     347 
     348        } 
     349 
     350        //    public static CTTextListStyle unmarshalFormatting(NodeIterator lstStyleNodeIt ) { 
    295351//               
    296352//      // Get the pPr node as a JAXB object, 
     
    467523 
    468524    public static Object nodeToObjectModel(Node n, Class declaredType) throws Docx4JException { 
     525         
     526        if (n==null) { 
     527                throw new Docx4JException("null input"); 
     528        } 
     529         
     530//      if (log.isDebugEnabled() ) { 
     531//              System.out.println("IN: " + XmlUtils.w3CDomNodeToString(n)); 
     532//      } 
     533         
    469534                Object jaxb=null; 
    470535                try { 
Note: See TracChangeset for help on using the changeset viewer.