1<!--***********************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements.  See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership.  The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License.  You may obtain a copy of the License at
10 *
11 *   http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied.  See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 ***********************************************************-->
21<xsl:stylesheet
22    version="1.0"
23    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
24    xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
25    xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
26    xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
27    xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
28    xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
29    xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
30    xmlns:xlink="http://www.w3.org/1999/xlink"
31    xmlns:dc="http://purl.org/dc/elements/1.1/"
32    xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
33    xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
34    xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
35    xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
36    xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
37    xmlns:math="http://www.w3.org/1998/Math/MathML"
38    xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
39    xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
40    xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
41    xmlns:ooo="http://openoffice.org/2004/office"
42    xmlns:ooow="http://openoffice.org/2004/writer"
43    xmlns:oooc="http://openoffice.org/2004/calc"
44    xmlns:dom="http://www.w3.org/2001/xml-events"
45    xmlns:xforms="http://www.w3.org/2002/xforms"
46    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
47    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
48    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
49    xmlns:rng="http://relaxng.org/ns/structure/1.0"
50    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
51    xmlns:UML = 'org.omg.xmi.namespace.UML' xml:space="default">
52  <xsl:output method="text" />
53  <xsl:param name="prefix"/>
54
55  <xsl:include href="factorytools.xsl"/>
56
57<xsl:template name="factoryactiondecls">
58    <xsl:variable name="ns" select="@name"/>
59    <xsl:for-each select="resource/action[not(@name='characters')]">
60        <xsl:sort select="@name"/>
61        <xsl:if test="generate-id(key('actions', @name)[ancestor::namespace/@name=$ns][1]) = generate-id(.)">
62            <xsl:text>
63    void </xsl:text>
64            <xsl:value-of select="@name"/>
65            <xsl:text>Action(OOXMLFastContextHandler * pHandler</xsl:text>
66            <xsl:text>);</xsl:text>
67        </xsl:if>
68    </xsl:for-each>
69    <xsl:text>
70    virtual void charactersAction(OOXMLFastContextHandler * pHandler, const ::rtl::OUString &amp; sText);</xsl:text>
71</xsl:template>
72
73<!-- factorydecl -->
74<xsl:template name="factorydecl">
75    <xsl:variable name="classname">
76        <xsl:call-template name="factoryclassname"/>
77    </xsl:variable>
78    <xsl:text>
79class </xsl:text>
80    <xsl:value-of select="$classname"/>
81    <xsl:text> : public OOXMLFactory_ns
82{
83public:
84    typedef boost::shared_ptr &lt; OOXMLFactory_ns &gt; Pointer_t;
85
86    static Pointer_t getInstance();
87
88    virtual AttributeToResourceMapPointer createAttributeToResourceMap(Id nId);
89    virtual ListValueMapPointer createListValueMap(Id nId);
90    virtual CreateElementMapPointer createCreateElementMap(Id nId);
91    virtual TokenToIdMapPointer createTokenToIdMap(Id nId);
92    virtual string getDefineName(Id nId) const;</xsl:text>
93    <xsl:call-template name="factoryactiondecls"/>
94    virtual void attributeAction(OOXMLFastContextHandler * pHandler, Token_t nToken, OOXMLValue::Pointer_t pValue);
95
96#ifdef DEBUG_FACTORY
97    virtual string getName() const;
98#endif
99    <xsl:text>
100
101    virtual ~</xsl:text>
102    <xsl:value-of select="$classname"/>
103    <xsl:text>();
104
105protected:
106    static Pointer_t m_pInstance;
107
108    </xsl:text>
109    <xsl:value-of select="$classname"/>
110    <xsl:text>();
111};
112    </xsl:text>
113</xsl:template>
114
115  <xsl:template match="/">
116    <xsl:variable name="ns" select="substring-before(substring-after($file, 'OOXMLFactory_'), '.hxx')"/>
117    <xsl:variable name="incguard">
118      <xsl:text>INCLUDED_OOXML_FACTORY_</xsl:text>
119      <xsl:value-of select="translate($ns, 'abcdefghijklmnopqrstuvwxyz-', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_')"/>
120      <xsl:text>_HXX</xsl:text>
121    </xsl:variable>
122    <xsl:call-template name="licenseheader"/>
123    <xsl:text>
124#ifndef </xsl:text>
125    <xsl:value-of select="$incguard"/>
126    <xsl:text>
127#define </xsl:text>
128    <xsl:value-of select="$incguard"/>
129    <xsl:text>
130#include "OOXMLFactory.hxx"
131#include "OOXMLFactory_generated.hxx"
132#include "OOXMLnamespaceids.hxx"
133#include "resourceids.hxx"
134
135namespace writerfilter {
136namespace ooxml {
137
138/// @cond GENERATED
139    </xsl:text>
140    <xsl:for-each select="/model/namespace[@name=$ns]">
141        <xsl:call-template name="factorydecl"/>
142    </xsl:for-each>
143    <xsl:text>
144/// @endcond
145}}
146#endif //</xsl:text>
147    <xsl:value-of select="$incguard"/>
148    <xsl:text>&#xa;</xsl:text>
149</xsl:template>
150
151</xsl:stylesheet>
152