Changeset 1700 for trunk/docx4j


Ignore:
Timestamp:
11/01/11 09:56:15 (7 months ago)
Author:
jharrop
Message:

Basic XHTML import proof of concept, using modified flying saucer library. No support for images or tables yet.
WARNING: Until the modified flying saucer jar is in Maven Central, you'll need to satisfy this dependency yourself,
by building the jar from the source code which is available from  https://github.com/plutext/flyingsaucer

Location:
trunk/docx4j
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/docx4j/build.xml

    r1671 r1700  
    3232        <pathelement location="${m2Repository}/org/antlr/antlr-runtime/3.3/antlr-runtime-3.3.jar"/>     
    3333        <pathelement location="${m2Repository}/antlr/antlr/2.7.7/antlr-2.7.7.jar"/>     
    34         <pathelement location="${m2Repository}/org/antlr/stringtemplate/3.2.1/stringtemplate-3.2.1.jar"/>     
     34        <pathelement location="${m2Repository}/org/antlr/stringtemplate/3.2.1/stringtemplate-3.2.1.jar"/>  
     35         
     36        <pathelement location="${m2Repository}/org/docx4j/xhtmlrenderer/1.0.0-SNAPSHOT/xhtmlrenderer-1.0.0-SNAPSHOT.jar"/>     
     37         
    3538 
    3639        <!--<pathelement location="${m2Repository}/junit/junit/4.8/junit-4.8.jar"/>--> 
  • trunk/docx4j/legals/NOTICE

    r1548 r1700  
    11   docx4j 
    2    Copyright 2007-2010 Plutext Pty Ltd 
     2   Copyright 2007-2011 Plutext Pty Ltd 
    33    
    44   Portions of the package org.docx4j.openpackaging are 
     
    3737        on 2011-06-18 from  
    3838        http://blog.jwbroek.com/2010/07/antlr-grammar-for-parsing-xpath-10.html 
    39         That page said "Do with this code as you will."          
     39        That page said "Do with this code as you will."  
     40         
     41        The jar containing package org.docx4j.org.xhtmlrenderer is an LGPL library. 
     42        Source may be found at https://github.com/plutext/flyingsaucer           
    4043         
    4144        TODO reference xsd license 
  • trunk/docx4j/pom.xml

    r1696 r1700  
    329329  -->                              
    330330                        <!--  nothing newer in the repository! --> 
     331 
     332                <!--  xhtmlrenderer, below, is new for docx4j 2.8.0; 
     333                          it supports (x)html import.  
     334                 
     335                          It will not be in Maven Central until docx4j 2.8.0 is released. 
     336                 
     337                          Currently, you can get it from:   
     338                           
     339                                        https://github.com/plutext/flyingsaucer 
     340                                         
     341                          and install it to your local repository using: 
     342                           
     343                                        mvn install 
     344                 --> 
     345                <dependency> 
     346                        <groupId>org.docx4j</groupId> 
     347                        <artifactId>xhtmlrenderer</artifactId> 
     348                        <version>1.0.0-SNAPSHOT</version> 
     349                                <exclusions> 
     350                                        <exclusion> 
     351                                                <groupId>com.lowagie</groupId> 
     352                                                <artifactId>itext</artifactId> 
     353                                        </exclusion> 
     354                                </exclusions> 
     355                </dependency> 
    331356         
    332357                <dependency> 
  • trunk/docx4j/src/main/java/org/docx4j/model/properties/PropertyFactory.java

    r1665 r1700  
    488488        public static Property createPropertyFromCssName(String name, CSSValue value) { 
    489489                 
    490                 // Run properties 
    491                 if (name.equals(Font.CSS_NAME )) { 
    492                         // font-family 
    493                         return new Font(value); 
    494                 } else if (name.equals(Bold.CSS_NAME )) { 
    495                         // font-weight 
    496                         return new Bold(value); 
    497                 } else if (name.equals(Italics.CSS_NAME )) { 
    498                         // font-style 
    499                         return new Italics(value); 
    500                 } else if (name.equals("text-decoration")) { 
    501                         if (value.getCssText().toLowerCase().equals("line-through")) { 
    502                                 return new Strike(value); 
    503                         } else if (value.getCssText().toLowerCase().equals("underline")) { 
    504                                 return new Underline(value); 
    505                         } else { 
    506                                 log.error("What to do for " + name + ":" + value.getCssText()); 
    507                         } 
    508                 } else if (name.equals(FontColor.CSS_NAME )) { 
    509                         // color 
    510                         return new FontColor(value); 
    511                 } else if (name.equals(FontSize.CSS_NAME )) { 
    512                         // font-size 
    513                         return new FontSize(value); 
    514                 }  
    515                  
    516                 // Paragraph properties 
    517                 if (name.equals(Indent.CSS_NAME )) { 
    518                         // left 
    519                         return new Indent(value); 
    520                 } else if (name.equals(Justification.CSS_NAME )) { 
    521                         // text-align 
    522                         return new Justification(value); 
    523                 } else if (name.equals(KeepNext.CSS_NAME )) { 
    524                         // page-break-after 
    525                         return new KeepNext(value); 
    526                 } else if (name.equals(PageBreakBefore.CSS_NAME)) { 
    527                         // page-break-before 
    528                         return new PageBreakBefore(value); 
    529                 } else if (name.equals(TextAlignmentVertical.CSS_NAME )) { 
    530                         // vertical-align 
    531                         return new TextAlignmentVertical(value); 
    532                 }                
    533                  
    534                 log.warn("How to handle: " + name + "?"); 
     490                try { 
     491                        // Run properties 
     492                        if (name.equals(Font.CSS_NAME )) { 
     493                                // font-family 
     494                                return new Font(value); 
     495                        } else if (name.equals(Bold.CSS_NAME )) { 
     496                                // font-weight 
     497                                return new Bold(value); 
     498                        } else if (name.equals(Italics.CSS_NAME )) { 
     499                                // font-style 
     500                                return new Italics(value); 
     501                        } else if (name.equals("text-decoration")) { 
     502                                if (value.getCssText().toLowerCase().equals("line-through")) { 
     503                                        return new Strike(value); 
     504                                } else if (value.getCssText().toLowerCase().equals("underline")) { 
     505                                        return new Underline(value); 
     506                                } else { 
     507                                        log.error("What to do for " + name + ":" + value.getCssText()); 
     508                                } 
     509                        } else if (name.equals(FontColor.CSS_NAME )) { 
     510                                // color 
     511                                return new FontColor(value); 
     512                        } else if (name.equals(FontSize.CSS_NAME )) { 
     513                                // font-size 
     514                                return new FontSize(value); 
     515                        }  
     516                         
     517                        // Paragraph properties 
     518                        if (name.equals(Indent.CSS_NAME )) { 
     519                                // left 
     520                                return new Indent(value); 
     521                        } else if (name.equals(Justification.CSS_NAME )) { 
     522                                // text-align 
     523                                return new Justification(value); 
     524                        } else if (name.equals(KeepNext.CSS_NAME )) { 
     525                                // page-break-after 
     526                                return new KeepNext(value); 
     527                        } else if (name.equals(PageBreakBefore.CSS_NAME)) { 
     528                                // page-break-before 
     529                                return new PageBreakBefore(value); 
     530                        } else if (name.equals(TextAlignmentVertical.CSS_NAME )) { 
     531                                // vertical-align 
     532                                return new TextAlignmentVertical(value); 
     533                        }                
     534                } catch (java.lang.UnsupportedOperationException uoe) { 
     535                        // TODO: consider whether it is right to catch this, 
     536                        // or whether calling code should handle a docx4j exception wrapping this 
     537                        log.error("Can't create property from: " + name + ":" + value.getCssText() ); 
     538                        return null; 
     539                } 
     540                log.debug("How to handle: " + name + "?"); 
    535541                return null; 
    536542        } 
Note: See TracChangeset for help on using the changeset viewer.