Changeset 1555
- Timestamp:
- 06/22/11 01:36:38 (11 months ago)
- Location:
- trunk/docx4j/src/main/java/org/docx4j
- Files:
-
- 11 edited
-
XmlUtils.java (modified) (6 diffs)
-
convert/out/html/docx2xhtmlNG2.xslt (modified) (3 diffs)
-
dml/CTBlip.java (modified) (4 diffs)
-
dml/wordprocessingDrawing/Anchor.java (modified) (5 diffs)
-
dml/wordprocessingDrawing/Inline.java (modified) (4 diffs)
-
fonts/IdentityPlusMapper.java (modified) (1 diff)
-
fonts/PhysicalFonts.java (modified) (1 diff)
-
model/properties/PropertyFactory.java (modified) (2 diffs)
-
model/properties/run/Font.java (modified) (1 diff)
-
openpackaging/io/LoadFromZipNG.java (modified) (5 diffs)
-
openpackaging/parts/XmlPart.java (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/docx4j/src/main/java/org/docx4j/XmlUtils.java
r1367 r1555 59 59 60 60 import org.apache.log4j.Logger; 61 import org.apache.xalan.trace.PrintTraceListener; 62 import org.apache.xalan.trace.TraceManager; 63 import org.apache.xalan.transformer.TransformerImpl; 61 64 import org.docx4j.jaxb.Context; 62 65 import org.docx4j.jaxb.NamespacePrefixMapperUtils; … … 81 84 // TRANSFORMER_FACTORY_PROCESSOR_SUN .. JDK/JRE does not include anything like com.sun.org.apache.xalan.TransformerFactoryImpl 82 85 83 //public static String TRANSFORMER_FACTORY_SAXON = "net.sf.saxon.TransformerFactoryImpl";86 // public static String TRANSFORMER_FACTORY_SAXON = "net.sf.saxon.TransformerFactoryImpl"; 84 87 85 88 // *.xsltc.trax.TransformerImpl don't … … 126 129 System.setProperty("javax.xml.transform.TransformerFactory", 127 130 TRANSFORMER_FACTORY_PROCESSOR_XALAN); 131 // TRANSFORMER_FACTORY_SAXON); 128 132 129 133 tfactory = javax.xml.transform.TransformerFactory … … 703 707 return tfactory.newTemplates(xsltSource); 704 708 } 705 709 706 710 /** 707 711 * … … 762 766 } 763 767 768 /* SUPER DEBUGGING 769 // http://xml.apache.org/xalan-j/usagepatterns.html#debugging 770 // debugging 771 // Set up a PrintTraceListener object to print to a file. 772 java.io.FileWriter fw = new java.io.FileWriter("/tmp/xslt-events" + xsltCount++ + ".log"); 773 java.io.PrintWriter pw = new java.io.PrintWriter(fw); 774 PrintTraceListener ptl = new PrintTraceListener(pw); 775 776 // Print information as each node is 'executed' in the stylesheet. 777 ptl.m_traceElements = true; 778 // Print information after each result-tree generation event. 779 ptl.m_traceGeneration = true; 780 // Print information after each selection event. 781 ptl.m_traceSelection = true; 782 // Print information whenever a template is invoked. 783 ptl.m_traceTemplates = true; 784 // Print information whenever an extension is called. 785 ptl.m_traceExtension = true; 786 TransformerImpl transformerImpl = (TransformerImpl)xformer; 787 788 // Register the TraceListener with the TraceManager associated 789 // with the TransformerImpl. 790 TraceManager trMgr = transformerImpl.getTraceManager(); 791 trMgr.addTraceListener(ptl); 792 793 */ 764 794 // DEBUGGING 765 795 // use the identity transform if you want to send wordDocument; 766 796 // otherwise you'll get the XHTML 767 797 // javax.xml.transform.Transformer xformer = tfactory.newTransformer(); 768 769 xformer.transform(source, result); 798 try { 799 xformer.transform(source, result); 800 } finally { 801 //pw.flush(); 802 } 770 803 771 804 } … … 832 865 } catch (XPathExpressionException e) { 833 866 e.printStackTrace(); 834 return Collections.emptyList();867 throw new RuntimeException(e); 835 868 } 836 869 } -
trunk/docx4j/src/main/java/org/docx4j/convert/out/html/docx2xhtmlNG2.xslt
r1450 r1555 79 79 /*font definitions*/ 80 80 81 /*element styles*/ del81 /*element styles*/ .del 82 82 {text-decoration:line-through;color:red;} 83 83 <xsl:choose> 84 84 <xsl:when test="/w:document/w:settings/w:trackRevisions"> 85 ins 86 {text-decoration:underline;color:teal;} 85 .ins {text-decoration:none;background:#c0ffc0;padding:1px;} 87 86 </xsl:when> 88 87 <xsl:otherwise> 89 ins {text-decoration:none;}88 .ins {text-decoration:none;background:#c0ffc0;padding:1px;} 90 89 </xsl:otherwise> 91 90 </xsl:choose> … … 592 591 593 592 <xsl:template match="w:ins"> 594 <span style="color:blue; text-decoration:underline">593 <span class="ins"> 595 594 <xsl:apply-templates/> 596 595 </span> … … 602 601 603 602 <xsl:template match="w:delText"> 604 <span style="color:red; text-decoration:line-through">603 <span class="del"> 605 604 <xsl:apply-templates/> 606 605 </span> -
trunk/docx4j/src/main/java/org/docx4j/dml/CTBlip.java
r1201 r1555 22 22 package org.docx4j.dml; 23 23 24 import org.jvnet.jaxb2_commons.ppp.Child; 25 24 26 import java.util.ArrayList; 25 27 import java.util.List; 26 import javax.xml.bind.annotation.XmlAccessType; 27 import javax.xml.bind.annotation.XmlAccessorType; 28 import javax.xml.bind.annotation.XmlAttribute; 29 import javax.xml.bind.annotation.XmlElement; 30 import javax.xml.bind.annotation.XmlElements; 31 import javax.xml.bind.annotation.XmlType; 28 import javax.xml.bind.Unmarshaller; 29 import javax.xml.bind.annotation.*; 32 30 33 31 … … 77 75 "extLst" 78 76 }) 79 public class CTBlip {77 public class CTBlip implements Child { 80 78 81 79 @XmlElements({ … … 106 104 @XmlAttribute(namespace = "http://schemas.openxmlformats.org/officeDocument/2006/relationships") 107 105 protected String link; 106 @XmlTransient 107 private Object parent; 108 108 109 109 /** … … 259 259 this.link = value; 260 260 } 261 261 /** 262 * Gets the parent object in the object tree representing the unmarshalled xml document. 263 * 264 * @return 265 * The parent object. 266 */ 267 public Object getParent() { 268 return this.parent; 269 } 270 271 public void setParent(Object parent) { 272 this.parent = parent; 273 } 274 275 /** 276 * This method is invoked by the JAXB implementation on each instance when unmarshalling completes. 277 * 278 * @param parent 279 * The parent object in the object tree. 280 * @param unmarshaller 281 * The unmarshaller that generated the instance. 282 */ 283 public void afterUnmarshal(Unmarshaller unmarshaller, Object parent) { 284 setParent(parent); 285 } 262 286 } -
trunk/docx4j/src/main/java/org/docx4j/dml/wordprocessingDrawing/Anchor.java
r1041 r1555 22 22 package org.docx4j.dml.wordprocessingDrawing; 23 23 24 import javax.xml.bind.annotation.XmlAccessType; 25 import javax.xml.bind.annotation.XmlAccessorType; 26 import javax.xml.bind.annotation.XmlAttribute; 27 import javax.xml.bind.annotation.XmlElement; 28 import javax.xml.bind.annotation.XmlSchemaType; 29 import javax.xml.bind.annotation.XmlType; 24 import javax.xml.bind.Unmarshaller; 25 import javax.xml.bind.annotation.*; 26 30 27 import org.docx4j.dml.CTNonVisualDrawingProps; 31 28 import org.docx4j.dml.CTNonVisualGraphicFrameProperties; … … 33 30 import org.docx4j.dml.CTPositiveSize2D; 34 31 import org.docx4j.dml.Graphic; 32 import org.jvnet.jaxb2_commons.ppp.Child; 35 33 36 34 … … 89 87 "graphic" 90 88 }) 91 public class Anchor {89 public class Anchor implements Child { 92 90 93 91 @XmlElement(required = true) … … 133 131 @XmlAttribute(required = true) 134 132 protected boolean allowOverlap; 135 133 @XmlTransient 134 private Object parent; 136 135 /** 137 136 * Gets the value of the simplePos property. … … 670 669 } 671 670 671 /** 672 * Gets the parent object in the object tree representing the unmarshalled xml document. 673 * 674 * @return 675 * The parent object. 676 */ 677 public Object getParent() { 678 return this.parent; 679 } 680 681 public void setParent(Object parent) { 682 this.parent = parent; 683 } 684 685 /** 686 * This method is invoked by the JAXB implementation on each instance when unmarshalling completes. 687 * 688 * @param parent 689 * The parent object in the object tree. 690 * @param unmarshaller 691 * The unmarshaller that generated the instance. 692 */ 693 public void afterUnmarshal(Unmarshaller unmarshaller, Object parent) { 694 setParent(parent); 695 } 672 696 } -
trunk/docx4j/src/main/java/org/docx4j/dml/wordprocessingDrawing/Inline.java
r1041 r1555 22 22 package org.docx4j.dml.wordprocessingDrawing; 23 23 24 import javax.xml.bind.annotation.XmlAccessType; 25 import javax.xml.bind.annotation.XmlAccessorType; 26 import javax.xml.bind.annotation.XmlAttribute; 27 import javax.xml.bind.annotation.XmlElement; 28 import javax.xml.bind.annotation.XmlType; 24 import javax.xml.bind.Unmarshaller; 25 import javax.xml.bind.annotation.*; 26 29 27 import org.docx4j.dml.CTNonVisualDrawingProps; 30 28 import org.docx4j.dml.CTNonVisualGraphicFrameProperties; 31 29 import org.docx4j.dml.CTPositiveSize2D; 32 30 import org.docx4j.dml.Graphic; 31 import org.jvnet.jaxb2_commons.ppp.Child; 33 32 34 33 … … 68 67 "graphic" 69 68 }) 70 public class Inline {69 public class Inline implements Child { 71 70 72 71 @XmlElement(required = true) … … 86 85 @XmlAttribute 87 86 protected Long distR; 88 87 @XmlTransient 88 private Object parent; 89 89 /** 90 90 * Gets the value of the extent property. … … 302 302 this.distR = value; 303 303 } 304 304 /** 305 * Gets the parent object in the object tree representing the unmarshalled xml document. 306 * 307 * @return 308 * The parent object. 309 */ 310 public Object getParent() { 311 return this.parent; 312 } 313 314 public void setParent(Object parent) { 315 this.parent = parent; 316 } 317 318 /** 319 * This method is invoked by the JAXB implementation on each instance when unmarshalling completes. 320 * 321 * @param parent 322 * The parent object in the object tree. 323 * @param unmarshaller 324 * The unmarshaller that generated the instance. 325 */ 326 public void afterUnmarshal(Unmarshaller unmarshaller, Object parent) { 327 setParent(parent); 328 } 305 329 } -
trunk/docx4j/src/main/java/org/docx4j/fonts/IdentityPlusMapper.java
r995 r1555 59 59 60 60 if (System.getProperty("os.name").toLowerCase().indexOf("windows")<0) { 61 log. error("WARNING! SubstituterWindowsPlatformImpl works best " +61 log.warn("WARNING! SubstituterWindowsPlatformImpl works best " + 62 62 "on Windows. To get good results on other platforms, you'll probably " + 63 63 "need to have installed Windows fonts."); -
trunk/docx4j/src/main/java/org/docx4j/fonts/PhysicalFonts.java
r1383 r1555 160 160 // Quite a few fonts exist that we can't seem to get 161 161 // EmbedFontInfo for. To be investigated. 162 log. error("Aborting: " + fontUrl.toString() + " (can't get EmbedFontInfo[] .. try deleting fop-fonts.cache?)");162 log.warn("Aborting: " + fontUrl.toString() + " (can't get EmbedFontInfo[] .. try deleting fop-fonts.cache?)"); 163 163 return; 164 164 } -
trunk/docx4j/src/main/java/org/docx4j/model/properties/PropertyFactory.java
r1398 r1555 403 403 if (wmlPackage instanceof WordprocessingMLPackage) { 404 404 NumberingDefinitionsPart ndp = ((WordprocessingMLPackage)wmlPackage).getMainDocumentPart().getNumberingDefinitionsPart(); 405 if (ndp != null) { 405 406 ind = ndp.getInd(pPr.getNumPr()); 406 407 if (ind!=null) { … … 408 409 log.debug("Using w:ind from list level"); 409 410 } 411 } 410 412 } 411 413 } -
trunk/docx4j/src/main/java/org/docx4j/model/properties/run/Font.java
r1056 r1555 57 57 return composeCss(CSS_NAME, font ); 58 58 } else { 59 log. error("No mapping from " + font);59 log.warn("No mapping from " + font); 60 60 return CSS_NULL; 61 61 } -
trunk/docx4j/src/main/java/org/docx4j/openpackaging/io/LoadFromZipNG.java
r1493 r1555 425 425 String relationshipType = r.getType(); 426 426 427 Part part = getRawPart(partByteArrays, ctm, resolvedPartUri, r); 427 Part part = getRawPart(partByteArrays, ctm, resolvedPartUri, r); // will throw exception if null 428 428 429 if (part instanceof BinaryPart 429 430 || part instanceof DefaultXmlPart) { … … 492 493 * @see To get a Part and all its related parts, and add all to a package, use 493 494 * getPart. 494 * @param zf 495 * @param partByteArrays 496 * @param ctm 495 497 * @param resolvedPartUri 498 * @param rel 496 499 * @return 497 * @throws URISyntaxException 498 * @throws InvalidFormatException 500 * @throws Docx4JException including if result is null 499 501 */ 500 //public static Part getRawPart(ZipFile zf, ContentTypeManager ctm, String resolvedPartUri)501 502 public static Part getRawPart(HashMap<String, ByteArray> partByteArrays, 502 503 ContentTypeManager ctm, String resolvedPartUri, Relationship rel) … … 617 618 } else if (part instanceof org.docx4j.openpackaging.parts.XmlPart ) { 618 619 619 try {620 // try { 620 621 ((XmlPart)part).setDocument(is); 621 } catch (Docx4JException d) { 622 // This isn't an XML part after all, 623 // even though ContentTypeManager detected it as such 624 // So get it as a binary part 625 part = getBinaryPart(partByteArrays, ctm, resolvedPartUri); 626 log.warn("Could not parse as XML, so using BinaryPart for " 627 + resolvedPartUri); 628 ((BinaryPart)part).setBinaryData(is); 629 } 622 623 // Experimental 22/6/2011; don't fall back to binary (which we used to) 624 625 // } catch (Docx4JException d) { 626 // // This isn't an XML part after all, 627 // // even though ContentTypeManager detected it as such 628 // // So get it as a binary part 629 // part = getBinaryPart(partByteArrays, ctm, resolvedPartUri); 630 // log.warn("Could not parse as XML, so using BinaryPart for " 631 // + resolvedPartUri); 632 // ((BinaryPart)part).setBinaryData(is); 633 // } 630 634 631 635 } else { … … 639 643 640 644 } catch (PartUnrecognisedException e) { 641 log. warn("PartUnrecognisedException shouldn't happen anymore!");645 log.error("PartUnrecognisedException shouldn't happen anymore!", e); 642 646 // Try to get it as a binary part 643 647 part = getBinaryPart(partByteArrays, ctm, resolvedPartUri); … … 660 664 } 661 665 } 666 667 if (part == null) { 668 throw new Docx4JException("cannot find part " + resolvedPartUri + " from rel "+ rel.getId() + "=" + rel.getTarget()); 669 } 670 662 671 return part; 663 672 } -
trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/XmlPart.java
r1399 r1555 70 70 super(); 71 71 } 72 72 73 73 /** 74 74 * This part's XML contents. Not guaranteed to be up to date. … … 80 80 private static XPathFactory xPathFactory; 81 81 private static XPath xPath; 82 82 83 83 private static DocumentBuilderFactory documentFactory; 84 private static DocumentBuilder documentBuilder; 84 85 85 86 86 static { … … 109 109 110 110 documentFactory.setNamespaceAware(true); 111 try { 112 documentBuilder = documentFactory.newDocumentBuilder(); 113 } catch (ParserConfigurationException e) { 114 e.printStackTrace(); 115 } 116 111 117 112 } 118 113 … … 129 124 public void setDocument(InputStream is) throws Docx4JException { 130 125 try { 131 doc = documentBuilder.parse(is); 126 DocumentBuilder documentBuilder = documentFactory.newDocumentBuilder(); // DocumentBuilder is not thread safe, so it needs to be local 127 doc = documentBuilder.parse(is); 132 128 } catch (Exception e) { 133 129 throw new Docx4JException("Problems parsing InputStream for part " + this.partName.getName(), e);
Note: See TracChangeset
for help on using the changeset viewer.
