Skip to content

Commit

Permalink
prep for 3.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
plutext committed Feb 8, 2014
1 parent b86792e commit 62c96c2
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 54 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/target/
/bin/
/dist/
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,37 @@ CHANGELOG
=========


Version 3.0.1
=============


Release date
------------

8 Feb 2014

Contributors to this release
----------------------------

ai-github
Jason Harrop
leedavidr


Notable Changes in Version 3.0.1
---------------------------------

Nil

Other Changes (non-exhaustive)
------------------------------

0d6c106 - if (color.startsWith("#")) .. Fix for plutext/docx4j#101
a452b43 - BindingTraverser.XHTML.Block.rStyle.Adopt handling in list items
6a7b6fc - NPE in indent handling fixed
e902f20 - xhtml to pptx
Very rudimentary support for h1-3, ol|ul, li
Write all paragraphs <a:p> into a single <p:txBody>


Version 3.0.0
Expand Down
4 changes: 2 additions & 2 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<property name="source" value="1.5"/>
<property name="dist" value="./dist"/>

<property name="version" value="3.0.0"/>
<property name="version" value="3.0.1"/>

<property name="src.main.java.dir" value="src/main/java"/>

Expand Down Expand Up @@ -62,7 +62,7 @@
<property name="m2Repository" value="../../.m2/repository"/>

<path id="Maven Dependencies.libraryclasspath">
<pathelement location="${m2Repository}/org/docx4j/docx4j/3.0.0/docx4j-3.0.0.jar"/>
<pathelement location="${m2Repository}/org/docx4j/docx4j/3.0.1/docx4j-3.0.1.jar"/>
<pathelement location="${m2Repository}/org/docx4j/xhtmlrenderer/3.0.0/xhtmlrenderer-3.0.0.jar"/>
<pathelement location="${m2Repository}/com/lowagie/itext/2.1.7/itext-2.1.7.jar"/>
<pathelement location="${m2Repository}/org/slf4j/slf4j-api/1.7.5/slf4j-api-1.7.5.jar"/>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<outputDirectory>bin-mvn</outputDirectory>
<outputDirectory>bin</outputDirectory> <!-- bin-mvn -->
<testOutputDirectory>bin</testOutputDirectory>
<plugins>
<!--
Expand Down Expand Up @@ -305,7 +305,7 @@
<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j</artifactId>
<version>3.0.0</version>
<version>3.0.1</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.docx4j.XmlUtils;
import org.docx4j.dml.CTBlip;
import org.docx4j.model.datastorage.BindingHandler;
import org.docx4j.model.datastorage.CustomXmlDataStoragePartSelector;
import org.docx4j.model.datastorage.OpenDoPEHandler;
import org.docx4j.model.datastorage.OpenDoPEIntegrity;
import org.docx4j.model.datastorage.RemovalHandler;
Expand All @@ -41,6 +42,7 @@
import org.docx4j.utils.SingleTraversalUtilVisitorCallback;
import org.docx4j.utils.TraversalUtilVisitor;
import org.docx4j.wml.SdtElement;
import org.opendope.xpaths.Xpaths.Xpath;


/**
Expand Down Expand Up @@ -76,15 +78,11 @@ public static void main(String[] args) throws Exception {
// Load input_template.docx
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(
new java.io.File(input_DOCX));

// Find custom xml item id
String itemId = getCustomXmlItemId(wordMLPackage).toLowerCase();
System.out.println("Looking for item id: " + itemId);


// Inject data_file.xml
// (this code assumes it is not a StandardisedAnswersPart)
CustomXmlDataStoragePart customXmlDataStoragePart
= (CustomXmlDataStoragePart)wordMLPackage.getCustomXmlDataStorageParts().get(itemId);
= CustomXmlDataStoragePartSelector.getCustomXmlDataStoragePart(wordMLPackage);
if (customXmlDataStoragePart==null) {
System.out.println("Couldn't find CustomXmlDataStoragePart! exiting..");
return;
Expand Down Expand Up @@ -141,48 +139,5 @@ public static void main(String[] args) throws Exception {

}

/**
* We need the item id of the custom xml part.
*
* There are several strategies we could use to find it,
* including searching the docx for a bind element, but
* here, we simply look in the xpaths part.
*
* @param wordMLPackage
* @return
*/
private static String getCustomXmlItemId(WordprocessingMLPackage wordMLPackage) throws Docx4JException {

MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();
if (wordMLPackage.getMainDocumentPart().getXPathsPart()==null) {
// Can't do it the easy way, so look up the binding on the first content control
TraversalUtilCCVisitor visitor = new TraversalUtilCCVisitor();
SingleTraversalUtilVisitorCallback ccFinder
= new SingleTraversalUtilVisitorCallback(visitor);
ccFinder.walkJAXBElements(
wordMLPackage.getMainDocumentPart().getJaxbElement().getBody());
return visitor.storeItemID;

} else {

org.opendope.xpaths.Xpaths xPaths = wordMLPackage.getMainDocumentPart().getXPathsPart().getJaxbElement();
return xPaths.getXpath().get(0).getDataBinding().getStoreItemID();
}
}

public static class TraversalUtilCCVisitor extends TraversalUtilVisitor<SdtElement> {

String storeItemID = null;

@Override
public void apply(SdtElement element, Object parent, List<Object> siblings) {

if (element.getSdtPr()!=null
&& element.getSdtPr().getDataBinding()!=null) {
storeItemID = element.getSdtPr().getDataBinding().getStoreItemID();
}
}

}

}
3 changes: 2 additions & 1 deletion src/samples/java/org/docx4j/samples/ConvertInXHTMLFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ public static void main(String[] args) throws Exception {
XHTMLImporterImpl.addFontMapping("Century Gothic", rfonts);

// Create an empty docx package
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
// WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new File(System.getProperty("user.dir") + "/styled.docx"));


NumberingDefinitionsPart ndp = new NumberingDefinitionsPart();
Expand Down

0 comments on commit 62c96c2

Please sign in to comment.