| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--***********************************************************
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- ***********************************************************-->
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" exclude-result-prefixes="w wx aml o dt v" xmlns:fla="urn:experimental:fla">
- <xsl:output method="xml" indent="no" encoding="UTF-8" version="1.0"/>
- <xsl:include href="../../common/measure_conversion.xsl"/>
- <xsl:include href="../common/ms2ooo_docpr.xsl"/>
- <xsl:include href="wordml2ooo_text.xsl"/>
- <xsl:include href="wordml2ooo_settings.xsl"/>
- <xsl:include href="wordml2ooo_table.xsl"/>
- <xsl:include href="wordml2ooo_page.xsl"/>
- <xsl:include href="wordml2ooo_list.xsl"/>
- <xsl:include href="wordml2ooo_draw.xsl"/>
- <xsl:include href="wordml2ooo_field.xsl"/>
- <xsl:include href="wordml2ooo_props.xsl"/>
- <xsl:key name="paragraph-style" match="w:style[@w:type = 'paragraph']" use="@w:styleId"/>
- <xsl:key name="heading-style" match="w:style[@w:type = 'paragraph' and w:pPr/w:outlineLvl]" use="@w:styleId"/>
- <xsl:variable name="preserve-alien-markup">no</xsl:variable>
- <xsl:variable name="native-namespace-prefixes">,w,o,v,wx,aml,w10,dt,</xsl:variable>
- <xsl:variable name="to-dispatch-elements">,wx:sect,wx:sub-section,w:p,w:tbl,w:sectPr,w:r,w:fldSimple,w:hlink,w:t,w:pict,w:br,w:instrText,w:fldChar,w:tab,w:footnote,w:endnote,aml:annotation,w:hlink,w:footnote,w:endnote,w:tblGrid,w:tr,w:tc,wx:pBdrGroup,</xsl:variable>
- <xsl:template match="/">
- <xsl:apply-templates select="w:wordDocument"/>
- </xsl:template>
- <xsl:template match="*" mode="dispatch">
- <xsl:choose>
- <xsl:when test="not(contains($native-namespace-prefixes, concat(',', substring-before(name(), ':'), ',')))">
- <!-- if alien namespace dispatch -->
- <xsl:choose>
- <xsl:when test="$preserve-alien-markup = 'yes'">
- <xsl:copy>
- <xsl:copy-of select="@*"/>
- <xsl:apply-templates mode="dispatch"/>
- </xsl:copy>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates mode="dispatch"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="contains($to-dispatch-elements, concat(',',name(),','))">
- <xsl:apply-templates select="current()"/>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="w:wordDocument">
- <office:document office:mimetype="application/vnd.oasis.opendocument.text" office:version="1.0">
- <fla:fla.activate/>
- <xsl:apply-templates select="o:DocumentProperties"/>
- <xsl:apply-templates select="w:docOleData" mode="init"/>
- <xsl:apply-templates select="w:docPr"/>
- <xsl:apply-templates select="w:fonts"/>
- <xsl:apply-templates select="w:styles"/>
- <xsl:apply-templates select="w:body"/>
- <xsl:apply-templates select="w:docOleData" mode="exit"/>
- </office:document>
- </xsl:template>
- <xsl:template match="w:fonts">
- <xsl:element name="office:font-face-decls">
- <!-- MS Word's default font declaration, added for Writer automatically. glu -->
- <style:font-face style:name="Arial" svg:font-family="Arial" style:font-family-generic="roman" style:font-pitch="variable"/>
- <style:font-face style:name="Times New Roman" svg:font-family="'Times New Roman'" style:font-family-generic="roman" style:font-pitch="variable"/>
- <style:font-face style:name="Symbol" svg:font-family="Symbol" style:font-family-generic="roman" style:font-pitch="variable" style:font-charset="x-symbol"/>
- <style:font-face style:name="Courier New" svg:font-family="'Courier New'" style:font-family-generic="modern" style:font-pitch="fixed"/>
- <xsl:if test="not(w:font[@w:name='StarSymbol'])">
- <style:font-face style:name="StarSymbol" svg:font-family="StarSymbol" style:font-charset="x-symbol"/>
- </xsl:if>
- <xsl:for-each select="w:font">
- <xsl:element name="style:font-face">
- <xsl:attribute name="style:name">
- <xsl:value-of select="@w:name"/>
- </xsl:attribute>
- <xsl:attribute name="svg:font-family">
- <xsl:value-of select="@w:name"/>
- </xsl:attribute>
- <!-- added by glu, for process special fonts e.g. Marlett, -->
- <xsl:if test="w:charset/@w:val = '02'">
- <xsl:attribute name="style:font-charset">x-symbol</xsl:attribute>
- </xsl:if>
- <xsl:if test="w:family">
- <xsl:choose>
- <xsl:when test="w:family/@w:val = 'Swiss'">
- <xsl:attribute name="style:font-family-generic">swiss</xsl:attribute>
- </xsl:when>
- <xsl:when test="w:family/@w:val='Modern'">
- <xsl:attribute name="style:font-family-generic">modern</xsl:attribute>
- </xsl:when>
- <xsl:when test="w:family/@w:val='Roman'">
- <xsl:attribute name="style:font-family-generic">roman</xsl:attribute>
- </xsl:when>
- <xsl:when test="w:family/@w:val='Script'">
- <xsl:attribute name="style:font-family-generic">script</xsl:attribute>
- </xsl:when>
- <xsl:when test="w:family/@w:val='Decorative'">
- <xsl:attribute name="style:font-family-generic">decorative</xsl:attribute>
- </xsl:when>
- <xsl:when test="w:family/@w:val='System'">
- <xsl:attribute name="style:font-family-generic">system</xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="style:font-family-generic">system</xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
- <xsl:if test="w:pitch and string-length(w:pitch/@w:val) > 0">
- <xsl:attribute name="style:font-pitch">
- <xsl:choose>
- <xsl:when test="w:pitch/@w:val = 'default'">variable</xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="w:pitch/@w:val"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:if>
- </xsl:element>
- </xsl:for-each>
- </xsl:element>
- </xsl:template>
- <xsl:template match="w:styles">
- <office:styles>
- <!--The next statement Added by wguo,collect the pict's dash and mark-style.The template is implemented in file wordml2ooo_draw.xsl-->
- <xsl:apply-templates select="/w:wordDocument/w:body//w:pict" mode="style4dash_mark"/>
- <xsl:apply-templates select="//v:fill" mode="office-style"/>
- <xsl:call-template name="create-default-paragraph-styles"/>
- <xsl:call-template name="create-default-text-styles"/>
- <xsl:call-template name="create-default-frame-style"/>
- <!-- StarWriter has no default style family 'list'. glu -->
- <xsl:if test="w:style[@w:type = 'paragraph' and w:pPr/w:outlineLvl and w:pPr/w:listPr]">
- <xsl:call-template name="create-outline-style"/>
- </xsl:if>
- <xsl:apply-templates select="w:style[@w:type='table']" mode="table"/>
- <xsl:apply-templates select="w:style[@w:type='list']" mode="list"/>
- <xsl:apply-templates select="w:style[@w:type!='list']"/>
- <xsl:apply-templates select="/w:wordDocument/w:docPr/w:footnotePr" mode="config"/>
- <xsl:apply-templates select="/w:wordDocument/w:docPr/w:endnotePr" mode="config"/>
- </office:styles>
- <office:automatic-styles>
- <xsl:apply-templates select="/w:wordDocument/w:body//w:p" mode="style"/>
- <xsl:apply-templates select="/w:wordDocument/w:body//w:rPr[not(parent::w:pPr)]" mode="style"/>
- <!--The next statement Added by wguo for the pict's draw-style.The template is implemented in file wordml2ooo_draw.xsl-->
- <xsl:apply-templates select="/w:wordDocument/w:body//w:pict" mode="style"/>
- <xsl:apply-templates select="/w:wordDocument/w:body//w:tblPr" mode="style"/>
- <xsl:apply-templates select="/w:wordDocument/w:body//w:gridCol" mode="style"/>
- <xsl:apply-templates select="/w:wordDocument/w:body//w:trPr" mode="style"/>
- <xsl:apply-templates select="/w:wordDocument/w:body//w:tcPr" mode="style"/>
- <xsl:apply-templates select="/w:wordDocument/w:body//w:listPr" mode="style"/>
- <xsl:apply-templates select="/w:wordDocument/w:body//w:sectPr" mode="page-layout"/>
- <xsl:call-template name="default_date_style"/>
- <!--add for generate the date , time style for date , time field G.Y.-->
- <xsl:apply-templates select="/w:wordDocument/w:body//w:instrText | /w:wordDocument/w:body//w:fldSimple " mode="style"/>
- </office:automatic-styles>
- <office:master-styles>
- <xsl:apply-templates select="/w:wordDocument/w:body//w:sectPr" mode="master-page"/>
- </office:master-styles>
- </xsl:template>
- <xsl:template match="w:style">
- <style:style>
- <xsl:attribute name="style:name">
- <xsl:value-of select="concat('w',translate(@w:styleId,' ~`!@#$%^*(&)+/,;?<>{}[]:','_'))"/>
- </xsl:attribute>
- <xsl:if test="w:basedOn">
- <xsl:attribute name="style:parent-style-name">
- <xsl:value-of select="concat('w',translate(w:basedOn/@w:val,' ~`!@#$%^*(&)+/,;?<>{}[]:','_'))"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="w:next">
- <xsl:attribute name="style:next-style-name">
- <xsl:value-of select="concat('w',translate(w:basedOn/@w:val,' ~`!@#$%^*(&)+/,;?<>{}[]:','_'))"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:choose>
- <xsl:when test="@w:type = 'character'">
- <xsl:attribute name="style:family">text</xsl:attribute>
- </xsl:when>
- <!-- table, paragraph are the same as in Writer . glu -->
- <xsl:when test="@w:type">
- <xsl:attribute name="style:family">
- <xsl:value-of select="@w:type"/>
- </xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="style:family">text</xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:choose>
- <xsl:when test="@w:type = 'table'">
- <xsl:element name="style:table-properties">
- <!-- xsl:apply-templates select="w:tblPr" mode="style"/ -->
- </xsl:element>
- </xsl:when>
- <xsl:when test="@w:type = 'character' ">
- <xsl:element name="style:text-properties">
- <!--
- <xsl:apply-templates select="w:pPr/w:rPr"/>
- <xsl:apply-templates select="w:rPr"/>
- -->
- <xsl:for-each select="w:rPr">
- <xsl:call-template name="text-properties"/>
- </xsl:for-each>
- </xsl:element>
- </xsl:when>
- <xsl:otherwise>
- <xsl:element name="style:paragraph-properties">
- <xsl:apply-templates select="w:pPr"/>
- </xsl:element>
- <xsl:element name="style:text-properties">
- <xsl:apply-templates select="w:rPr"/>
- <xsl:apply-templates select="w:pPr/w:rPr"/>
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose>
- </style:style>
- </xsl:template>
- <xsl:template match="w:body">
- <xsl:element name="office:body">
- <xsl:element name="office:text">
- <!-- to add the sequece variable declaration at the begining of the office:body G.Y.-->
- <text:sequence-decls>
- <xsl:call-template name="default_seqence_declaration"/>
- <xsl:apply-templates select="/w:wordDocument/w:body//w:instrText[substring(normalize-space(text()),1,3) = 'SEQ' ] | /w:wordDocument/w:body//w:fldSimple[substring(normalize-space(@w:instr),1,3) = 'SEQ' ] " mode="sequence_declare"/>
- </text:sequence-decls>
- <!-- add the user field variables declare for Docpropety fields importing G.Y.-->
- <text:user-field-decls>
- <xsl:call-template name="user_fields_declare_docproperty"/>
- </text:user-field-decls>
- <xsl:apply-templates mode="dispatch"/>
- </xsl:element>
- </xsl:element>
- </xsl:template>
- <xsl:template match="wx:sect">
- <xsl:apply-templates mode="dispatch"/>
- </xsl:template>
- <xsl:template match="wx:sub-section">
- <xsl:apply-templates mode="dispatch"/>
- </xsl:template>
- <xsl:template name="create-default-frame-style">
- <!--add for default frame style -->
- <style:style style:name="Frame" style:family="graphic">
- <style:graphic-properties text:anchor-type="paragraph" svg:x="0in" svg:y="0in" style:wrap="parallel" style:number-wrapped-paragraphs="no-limit" style:wrap-contour="false" style:vertical-pos="top" style:vertical-rel="paragraph-content" style:horizontal-pos="center" style:horizontal-rel="paragraph-content"/>
- </style:style>
- </xsl:template>
- <xsl:template name="ConvertMeasure">
- <xsl:param name="TargetMeasure" select="'cm'"/>
- <xsl:param name="TargetTruncate" select=" 'all' "/>
- <xsl:param name="value"/>
- <!-- When TargetTruncate ='all' it returns the number whichsoever the return value is negative or positive
- When TargetTruncate ='nonNegative' it only returns nonNegative number, all negative number to be returned as 0
- When TargetTruncate ='positive" it only returns positive number, all nonPositive number to be returned as 1 -->
- <xsl:variable name="return_value">
- <xsl:choose>
- <!-- remove the measure mark, if the value is null, the result should be 0. Must be the first case -->
- <xsl:when test="string-length(translate($value,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ','')) = 0">0</xsl:when>
- <xsl:when test="string-length(translate($value,'-.0123456789 ','')) = 0">
- <xsl:value-of select="$value"/>
- </xsl:when>
- <xsl:when test="$TargetMeasure = 'cm'">
- <xsl:call-template name="convert2cm">
- <xsl:with-param name="value" select="$value"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="$TargetMeasure = 'pt'">
- <xsl:call-template name="convert2pt">
- <xsl:with-param name="value" select="$value"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="$TargetMeasure = 'twip'">
- <xsl:call-template name="convert2twip">
- <xsl:with-param name="value" select="$value"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="$TargetMeasure = 'in'">
- <xsl:call-template name="convert2in">
- <xsl:with-param name="value" select="$value"/>
- </xsl:call-template>
- </xsl:when>
- </xsl:choose>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="$TargetTruncate = 'all' ">
- <xsl:choose>
- <xsl:when test="number($TargetMeasure) = 'NaN' ">
- <xsl:value-of select=" '0' "/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$return_value"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="$TargetTruncate = 'nonNegative' ">
- <xsl:choose>
- <xsl:when test="number($TargetMeasure) = 'NaN' ">
- <xsl:value-of select=" '0' "/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test=" $return_value < 0 ">
- <xsl:value-of select=" '0' "/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$return_value"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="$TargetTruncate = 'positive' ">
- <xsl:choose>
- <xsl:when test="number($TargetMeasure) = 'NaN' ">
- <xsl:value-of select=" '1' "/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test=" $return_value <= 0 ">
- <xsl:value-of select=" '1' "/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$return_value"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
- </xsl:stylesheet>
|