Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jelovirt committed Mar 27, 2020
2 parents 5d5a08f + 07f453e commit 519b871
Show file tree
Hide file tree
Showing 457 changed files with 52,942 additions and 69 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ Standard DITA-OT plug-in installation, see [DITA-OT documentation](http://www.di
Only latests stable version of DITA-OT is supported, but older version may work.

```shell
$ dita -install https://github.com/jelovirt/com.elovirta.ooxml/archive/1.3.0.zip
$ dita --install com.elovirta.ooxml
```

For older versions of DITA-OT that do not support plug-in registry:

```shell
$ dita -install https://github.com/jelovirt/com.elovirta.ooxml/archive/1.4.0.zip
```

Running
Expand Down
105 changes: 40 additions & 65 deletions build_template.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:dita="http://dita-ot.sourceforge.net">

<taskdef resource="net/sf/antcontrib/antlib.xml"/>

<target name="docx.init">
<property name="force-unique" value="true"/>
<property name="docx.dir" location="${dita.plugin.com.elovirta.ooxml.dir}/docx"/>
Expand All @@ -21,26 +21,26 @@
<available file="${env.PROGRAMFILES}\Inkscape\Inkscape.exe"/>
</condition>
</target>

<target name="dita2docx"
depends="docx.init,
build-init,
preprocess,
docx.image-metadata,
docx.svg2emf,
docx.template,
docx.merge,
docx.convert,
docx.package"/>
depends="docx.init,
build-init,
preprocess,
docx.image-metadata,
docx.svg2emf,
docx.template,
docx.merge,
docx.convert,
docx.package"/>

<target name="docx.image-metadata" description="Read image metadata">
<pipeline message="Read image metadata." taskname="image-metadata" tempdir="${dita.temp.dir}">
<module class="org.dita.dost.module.ImageMetadataModule">
<param name="outputdir" location="${output.dir}"/>
</module>
</pipeline>
</target>

<target name="docx.svg2emf" if="inkscape.exec" unless="docx.inkscape.skip">
<mkdir dir="${dita.temp.dir}/docx/word/media"/>
<for param="svg.file">
Expand All @@ -56,14 +56,14 @@
<property name="emf.file" location="${dita.temp.dir}/docx/word/media/${svg.name}.emf"/>
<echo taskname="inkscape">Converting @{svg.file} to ${emf.file}</echo>
<exec executable="${inkscape.exec}" taskname="inkscape">
<arg value="-z" />
<arg value="--export-emf=${emf.file}" />
<arg value="-z"/>
<arg value="--export-emf=${emf.file}"/>
<arg file="@{svg.file}"/>
</exec>
</sequential>
</for>
</target>

<target name="docx.template">
<unzip src="${dotx.file}" dest="${dita.temp.dir}/dotx">
<patternset>
Expand All @@ -75,121 +75,96 @@
<fileset dir="${dita.temp.dir}/dotx"/>
</copy>
</target>

<target name="docx.merge">
<dirname property="dita.temp.dir.fullpath" file="${dita.temp.dir}/dummy.file"/>
<property name="topicmerge.xsl" location="${dita.plugin.org.dita.pdf2.dir}/xsl/common/topicmerge.xsl"/>
<pipeline message="topicmerge"
inputmap="${dita.temp.dir.fullpath}/${user.input.file}"
tempdir="${dita.temp.dir.fullpath}">
<pipeline message="topicmerge" inputmap="${dita.temp.dir.fullpath}/${user.input.file}"
tempdir="${dita.temp.dir.fullpath}">
<module class="org.dita.dost.module.TopicMergeModule">
<param name="output" location="${dita.temp.dir.fullpath}/${dita.map.filename.root}_MERGED.xml"/>
<param name="style" location="${topicmerge.xsl}"/>
</module>
</pipeline>
</target>
<target name="docx.convert">

<target name="docx.convert">
<property name="image.dir" location="${user.input.dir}/.."/>
<property name="clean.input.file" location="${dita.temp.dir.fullpath}/${dita.map.filename.root}_CLEANED.xml"/>
<property name="document.flat.xsl" location="${docx.dir}/word/document.flat.xsl"/>
<xslt style="${document.flat.xsl}"
in="${dita.temp.dir.fullpath}/${dita.map.filename.root}_MERGED.xml"
out="${clean.input.file}"
force="true">
<xslt style="${document.flat.xsl}" in="${dita.temp.dir.fullpath}/${dita.map.filename.root}_MERGED.xml"
out="${clean.input.file}" force="true">
<dita:extension id="dita.conductor.docx.param" behavior="org.dita.dost.platform.InsertAction"/>
<xmlcatalog refid="dita.catalog"/>
</xslt>

<makeurl property="dotx.dir.uri" file="${dita.temp.dir}/dotx"/>
<makeurl property="user.input.dir.url" file="${user.input.dir}"/>
<makeurl property="user.input.dir.url" file="${user.input.dir}"/>

<property name="core.xsl" location="${docx.dir}/docProps/core.xsl"/>
<xslt style="${core.xsl}"
in="${clean.input.file}"
out="${dita.temp.dir}/docx/docProps/core.xml"
force="true">
<xslt style="${core.xsl}" in="${clean.input.file}" out="${dita.temp.dir}/docx/docProps/core.xml" force="true">
<dita:extension id="dita.conductor.docx.param" behavior="org.dita.dost.platform.InsertAction"/>
<xmlcatalog refid="dita.catalog"/>
</xslt>
<property name="custom.xsl" location="${docx.dir}/docProps/custom.xsl"/>
<xslt style="${custom.xsl}"
in="${clean.input.file}"
out="${dita.temp.dir}/docx/docProps/custom.xml"
force="true">
<xslt style="${custom.xsl}" in="${clean.input.file}" out="${dita.temp.dir}/docx/docProps/custom.xml" force="true">
<dita:extension id="dita.conductor.docx.param" behavior="org.dita.dost.platform.InsertAction"/>
<xmlcatalog refid="dita.catalog"/>
</xslt>

<property name="document.xsl" location="${docx.dir}/word/document.xsl"/>
<xslt style="${document.xsl}"
in="${clean.input.file}"
out="${dita.temp.dir}/docx/word/document.xml"
force="true">
<xslt style="${document.xsl}" in="${clean.input.file}" out="${dita.temp.dir}/docx/word/document.xml" force="true">
<param name="image.dir" expression="${image.dir}"/>
<param name="template.dir" expression="${dotx.dir.uri}"/>
<param name="input.dir.url" expression="${user.input.dir.url}"/>
<dita:extension id="dita.conductor.docx.param" behavior="org.dita.dost.platform.InsertAction"/>
<xmlcatalog refid="dita.catalog"/>
</xslt>
<property name="comments.xsl" location="${docx.dir}/word/comments.xsl"/>
<xslt style="${comments.xsl}"
in="${clean.input.file}"
out="${dita.temp.dir}/docx/word/comments.xml"
force="true">
<xslt style="${comments.xsl}" in="${clean.input.file}" out="${dita.temp.dir}/docx/word/comments.xml" force="true">
<param name="template.dir" expression="${dotx.dir.uri}"/>
<dita:extension id="dita.conductor.docx.param" behavior="org.dita.dost.platform.InsertAction"/>
<xmlcatalog refid="dita.catalog"/>
</xslt>
<property name="numbering.xsl" location="${docx.dir}/word/numbering.xsl"/>
<xslt style="${numbering.xsl}"
in="${clean.input.file}"
out="${dita.temp.dir}/docx/word/numbering.xml"
force="true">
<xslt style="${numbering.xsl}" in="${clean.input.file}" out="${dita.temp.dir}/docx/word/numbering.xml" force="true">
<param name="template.dir" expression="${dotx.dir.uri}"/>
<dita:extension id="dita.conductor.docx.param" behavior="org.dita.dost.platform.InsertAction"/>
<xmlcatalog refid="dita.catalog"/>
</xslt>
<property name="footnotes.xsl" location="${docx.dir}/word/footnotes.xsl"/>
<xslt style="${footnotes.xsl}"
in="${clean.input.file}"
out="${dita.temp.dir}/docx/word/footnotes.xml"
force="true">
<xslt style="${footnotes.xsl}" in="${clean.input.file}" out="${dita.temp.dir}/docx/word/footnotes.xml" force="true">
<param name="template.dir" expression="${dotx.dir.uri}"/>
<dita:extension id="dita.conductor.docx.param" behavior="org.dita.dost.platform.InsertAction"/>
<xmlcatalog refid="dita.catalog"/>
</xslt>
<property name="document.xml.xsl" location="${docx.dir}/word/_rels/document.xml.xsl"/>
<xslt style="${document.xml.xsl}"
in="${clean.input.file}"
out="${dita.temp.dir}/docx/word/_rels/document.xml.rels"
force="true">
<xslt style="${document.xml.xsl}" in="${clean.input.file}" out="${dita.temp.dir}/docx/word/_rels/document.xml.rels"
force="true">
<param name="template.dir" expression="${dotx.dir.uri}"/>
<dita:extension id="dita.conductor.docx.param" behavior="org.dita.dost.platform.InsertAction"/>
<xmlcatalog refid="dita.catalog"/>
</xslt>
<makeurl property="clean.input.file.uri" file="${clean.input.file}"/>
<xslt style="${docx.dir}/[Content_Types].xsl"
in="${dita.temp.dir}/dotx/[Content_Types].xml"
out="${dita.temp.dir}/docx/[Content_Types].xml"
force="true">
<xslt style="${docx.dir}/[Content_Types].xsl" in="${dita.temp.dir}/dotx/[Content_Types].xml"
out="${dita.temp.dir}/docx/[Content_Types].xml" force="true">
<param name="input.uri" expression="${clean.input.file.uri}"/>
<dita:extension id="dita.conductor.docx.param" behavior="org.dita.dost.platform.InsertAction"/>
<xmlcatalog refid="dita.catalog"/>
</xslt>
</target>

<target name="docx.package" depends="docx.package.media">
<condition property="outputFile.extension" value="docm" else="docx">
<matches string="${dotx.file}" pattern="\.dotm$"/>
<matches string="${dotx.file}" pattern="\.dotm$"/>
</condition>
<property name="outputFile" location="${dita.map.output.dir}/${dita.map.filename.root}.${outputFile.extension}"/>
<delete file="${outputFile}"/>
<zip zipfile="${outputFile}">
<fileset dir="${dita.temp.dir}/docx"/>
</zip>
</target>

<target name="docx.package.media" unless="media.skip">
<!--copy todir="${dita.temp.dir}/docx/word/media">
<fileset dir="${user.input.dir}/" includesfile="${dita.temp.dir}/${imagefile}">
Expand All @@ -207,5 +182,5 @@
</fileset>
</delete>
</target>

</project>
2 changes: 1 addition & 1 deletion docx/docProps/custom.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:opentopic="http://www.idiominc.com/opentopic"
xmlns:cp="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"
xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"
xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:x="com.elovirta.ooxml"
Expand Down
29 changes: 29 additions & 0 deletions docx/word/document.mathml-d.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
xmlns:w10="urn:schemas-microsoft-com:office:word"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml"
xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture"
xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main"
xmlns:x="com.elovirta.ooxml"
exclude-result-prefixes="x xs"
version="2.0">

<xsl:template match="*[contains(@class, ' mathml-d/mathml ')]">
<xsl:apply-templates select="*"/>
</xsl:template>

<xsl:template match="*[contains(@class, ' mathml-d/mathmlref ')]">
<xsl:variable name="href" as="xs:string" select="concat(replace(@xtrf, '^(.+)/.+?$', '$1/'), @href)"/>
<xsl:apply-templates select="document($href)/*"/>
</xsl:template>

</xsl:stylesheet>
Loading

0 comments on commit 519b871

Please sign in to comment.