2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 <xsl:stylesheet version=
"1.0" xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform" 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:
fo=
"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible: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" xmlns:
xforms=
"http://www.w3.org/2002/xforms" xmlns:
xsd=
"http://www.w3.org/2001/XMLSchema" xmlns:
xsi=
"http://www.w3.org/2001/XMLSchema-instance" xmlns:
rdf=
"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
19 xmlns:
rdfs=
"http://www.w3.org/2000/01/rdf-schema#" xmlns:UML = 'org.omg.xmi.namespace.UML' xml:
space=
"default">
20 <xsl:output method=
"text" />
22 <xsl:template name='idtoqname'
>
23 <xsl:param name='id'
/>
24 <xsl:text>NS_
</xsl:text>
25 <xsl:value-of select='substring-before($id,
":")'
/>
26 <xsl:text>::LN_
</xsl:text>
27 <xsl:value-of select='substring-after($id,
":")'
/>
30 <xsl:template name=
"parenttype">
31 <xsl:param name='type'
/>
32 <xsl:for-each select='/XMI/XMI.content/UML:Model/UML:Namespace.ownedElement/UML:Generalization[UML:Generalization.child/UML:Class/@xmi.idref=$type]'
>
33 <xsl:value-of select='./UML:Generalization.parent/UML:Class/@xmi.idref'
/>
37 <xsl:template name='saltype'
>
38 <xsl:param name='type'
/>
39 <xsl:param name='parenttype'
/>
41 <xsl:when test=
"$type='U8'">sal_uInt8
</xsl:when>
42 <xsl:when test=
"$type='S8'">sal_Int8
</xsl:when>
43 <xsl:when test=
"$type='U16'">sal_uInt16
</xsl:when>
44 <xsl:when test=
"$type='S16'">sal_Int16
</xsl:when>
45 <xsl:when test=
"$type='U32'">sal_uInt32
</xsl:when>
46 <xsl:when test=
"$type='S32'">sal_Int32
</xsl:when>
47 <xsl:when test=
"$type='String'">OUString
</xsl:when>
49 <xsl:text>writerfilter::Reference
< </xsl:text>
50 <xsl:value-of select='$parenttype'
/>
51 <xsl:text> >::Pointer_t
</xsl:text>
56 <xsl:template name='typetype'
>
57 <xsl:param name='type'
/><xsl:choose>
58 <xsl:when test=
"$type='U8'">simple
</xsl:when>
59 <xsl:when test=
"$type='S8'">simple
</xsl:when>
60 <xsl:when test=
"$type='U16'">simple
</xsl:when>
61 <xsl:when test=
"$type='S16'">simple
</xsl:when>
62 <xsl:when test=
"$type='U32'">simple
</xsl:when>
63 <xsl:when test=
"$type='S32'">simple
</xsl:when>
64 <xsl:when test=
"$type='String'">string
</xsl:when>
65 <xsl:when test=
"$type='Binary'">binary
</xsl:when>
66 <xsl:otherwise>complex
</xsl:otherwise>
70 <xsl:template name=
"valuetype">
71 <xsl:param name=
"type"/>
73 <xsl:when test='$
type=
"U8"'
>WW8IntValue
</xsl:when>
74 <xsl:when test='$
type=
"S8"'
>WW8IntValue
</xsl:when>
75 <xsl:when test='$
type=
"U16"'
>WW8IntValue
</xsl:when>
76 <xsl:when test='$
type=
"S16"'
>WW8IntValue
</xsl:when>
77 <xsl:when test='$
type=
"U32"'
>WW8IntValue
</xsl:when>
78 <xsl:when test='$
type=
"S32"'
>WW8IntValue
</xsl:when>
79 <xsl:otherwise>WW8PropertiesValue
</xsl:otherwise>
83 <xsl:template match=
"UML:Attribute" mode=
"valuetype">
84 <xsl:call-template name=
"valuetype">
85 <xsl:with-param name=
"type" select='.//UML:DataType/@xmi.idref'
/>
89 <xsl:template name=
"qnametostrattrs">
91 /* Attributes */
</xsl:text>
92 <xsl:for-each select='.//UML:Attribute[@name!=
"reserved"]'
>
93 <xsl:for-each select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.
idref=
"attrid"]'
>
95 <xsl:when test='.//UML:Stereotype[@xmi.
idref=
"noresolve"]'
>
100 <xsl:call-template name='idtoqname'
>
101 <xsl:with-param name='id'
><xsl:value-of select='.//UML:TaggedValue.dataValue'
/></xsl:with-param>
103 <xsl:text>] =
"</xsl:text>
104 <xsl:value-of select='.//UML:TaggedValue.dataValue'/>
105 <xsl:text>";
</xsl:text>
112 <xsl:template name=
"qnametostrops">
114 /* Operations */
</xsl:text>
115 <xsl:for-each select='.//UML:Operation[@name!=
"reserved"]'
>
116 <xsl:for-each select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.
idref=
"opid"]'
>
118 <xsl:when test='.//UML:Stereotype[@xmi.
idref=
"noresolve"]'
>
123 <xsl:call-template name='idtoqname'
>
124 <xsl:with-param name='id'
><xsl:value-of select='.//UML:TaggedValue.dataValue'
/></xsl:with-param>
126 <xsl:text>] =
"</xsl:text>
127 <xsl:value-of select='.//UML:TaggedValue.dataValue'/>
128 <xsl:text>";
</xsl:text>
135 <xsl:template name=
"qnametostrclasses">
137 /* Classes */
</xsl:text>
138 <xsl:for-each select='.//UML:Class[@name!=
"reserved"]'
>
139 <xsl:for-each select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.
idref=
"classid"]'
>
142 <xsl:call-template name='idtoqname'
>
143 <xsl:with-param name='id'
><xsl:value-of select='.//UML:TaggedValue.dataValue'
/></xsl:with-param>
145 <xsl:text>] =
"</xsl:text>
146 <xsl:value-of select='.//UML:TaggedValue.dataValue'/>
147 <xsl:text>";
</xsl:text>
152 <xsl:template match='UML:Model' mode='qnametostr'
>
154 void QNameToString::init_doctok()
156 <xsl:call-template name=
"qnametostrattrs"/>
157 <xsl:call-template name=
"qnametostrops"/>
158 <xsl:call-template name=
"qnametostrclasses"/>
164 <xsl:key name=
"ids" match='UML:Attribute[@name!=
"reserved"]//UML:TaggedValue[.//UML:TagDefinition/@xmi.
idref=
"attrid"]|UML:Operation[@name!=
"reserved"]//UML:TaggedValue[.//UML:TagDefinition/@xmi.
idref=
"opid"]'
use=
".//UML:TaggedValue.dataValue"/>
166 <xsl:template match=
"UML:Model" mode=
"qnametostrfunc">
168 string qnameToString(sal_uInt32 nToken)
174 // Attributes
</xsl:text>
175 <xsl:for-each select='.//UML:Attribute[@name!=
"reserved"]//UML:TaggedValue[.//UML:TagDefinition/@xmi.
idref=
"attrid"]'
>
177 <xsl:when test='.//UML:Stereotype[@xmi.
idref=
"noresolve"]'
>
180 <xsl:if test=
"generate-id(key('ids', .//UML:TaggedValue.dataValue)[1])=generate-id(.)">
183 <xsl:call-template name='idtoqname'
>
184 <xsl:with-param name='id'
><xsl:value-of select='.//UML:TaggedValue.dataValue'
/></xsl:with-param>
187 sResult =
"</xsl:text>
188 <xsl:value-of select='.//UML:TaggedValue.dataValue'/>
196 // Operations
</xsl:text>
197 <xsl:for-each select='.//UML:Operation[@name!=
"reserved"]//UML:TaggedValue[.//UML:TagDefinition/@xmi.
idref=
"opid"]'
>
199 <xsl:when test='.//UML:Stereotype[@xmi.
idref=
"noresolve"]'
>
202 <xsl:if test=
"generate-id(key('ids', .//UML:TaggedValue.dataValue)[1])=generate-id(.)">
205 <xsl:call-template name='idtoqname'
>
206 <xsl:with-param name='id'
><xsl:value-of select='.//UML:TaggedValue.dataValue'
/></xsl:with-param>
209 sResult =
"</xsl:text>
210 <xsl:value-of select='.//UML:TaggedValue.dataValue'/>
218 // Classes:
</xsl:text>
219 <xsl:for-each select='.//UML:Class[@name!=
"reserved"]//UML:TaggedValue[.//UML:TagDefinition/@xmi.
idref=
"classid"]'
>
222 <xsl:call-template name='idtoqname'
>
223 <xsl:with-param name='id'
><xsl:value-of select='.//UML:TaggedValue.dataValue'
/></xsl:with-param>
226 sResult =
"</xsl:text>
227 <xsl:value-of select='.//UML:TaggedValue.dataValue'/>
240 <xsl:template match='UML:Model' mode='sprmcodetostr'
>
242 SprmIdToString::SprmIdToString()
244 <xsl:variable name='tmp'
>map
< sal_uInt32, string
> </xsl:variable>
245 <xsl:for-each select='.//UML:Class[.//UML:Stereotype/@xmi.
idref=
"ww8sprm"]'
>
246 <xsl:variable name=
"sprmconst">
247 <xsl:call-template name=
"sprmCodeOfClass"/>
251 <xsl:value-of select=
"$sprmconst"/>
252 <xsl:text>] =
"</xsl:text>
253 <xsl:value-of select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="sprmid
"]//UML:TaggedValue.dataValue'/>
254 <xsl:text>";
</xsl:text>
261 <xsl:key name=
"classes-with-kind" match=
"UML:TagDefinition[@xmi.idref='kind']"
262 use=
"ancestor::UML:TaggedValue/UML:TaggedValue.dataValue"/>
264 <xsl:template name=
"sprmCodeOfClass">
265 <xsl:variable name=
"tmp">
266 <xsl:text>sprm:
</xsl:text>
267 <xsl:value-of select=
"substring-after(@name, 'sprm')"/>
269 <xsl:call-template name=
"idtoqname">
270 <xsl:with-param name=
"id" select=
"$tmp"/>
274 <xsl:template name=
"sprmkindcase">
275 <xsl:param name=
"kind"/>
276 <xsl:for-each select=
"key('classes-with-kind', $kind)/ancestor::UML:Class">
279 <xsl:call-template name=
"sprmCodeOfClass"/>
280 <xsl:text>:
</xsl:text>
284 <xsl:template match=
"UML:Model" mode='sprmkind'
>
286 Sprm::Kind SprmKind(sal_uInt32 sprmCode)
288 Sprm::Kind nResult = Sprm::UNKNOWN;
292 <xsl:call-template name=
"sprmkindcase">
293 <xsl:with-param name=
"kind">paragraph
</xsl:with-param>
296 nResult = Sprm::PARAGRAPH;
298 <xsl:call-template name=
"sprmkindcase">
299 <xsl:with-param name=
"kind">character
</xsl:with-param>
302 nResult = Sprm::CHARACTER;
304 <xsl:call-template name=
"sprmkindcase">
305 <xsl:with-param name=
"kind">table
</xsl:with-param>
308 nResult = Sprm::TABLE;
320 <xsl:template match=
"UML:Model" mode='sprmids'
>
322 namespace NS_sprm {
</xsl:text>
323 <xsl:for-each select=
".//UML:Class[.//UML:Stereotype/@xmi.idref='ww8sprm']">
324 <xsl:variable name=
"sprmcode">
325 <xsl:value-of select=
".//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref = 'sprmcode']/UML:TaggedValue.dataValue"/>
327 <xsl:variable name=
"sprmcodelower">
328 <xsl:value-of select=
"translate($sprmcode, 'ABCDEF', 'abcdef')"/>
330 <xsl:variable name=
"sprmidname">
331 <xsl:text>LN_
</xsl:text>
332 <xsl:value-of select=
"substring-after(@name, 'sprm')"/>
335 const sal_uInt16
</xsl:text>
336 <xsl:value-of select=
"$sprmidname"/>
337 <xsl:text> =
</xsl:text>
338 <xsl:value-of select=
"$sprmcodelower"/>
339 <xsl:text>;
</xsl:text>
346 <xsl:template match=
"UML:Model" mode='sprmidsed'
>
348 cat $
1 \

</xsl:text>
349 <xsl:for-each select=
".//UML:Class[.//UML:Stereotype/@xmi.idref='ww8sprm']">
350 <xsl:variable name=
"sprmcode">
351 <xsl:value-of select=
".//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref = 'sprmcode']/UML:TaggedValue.dataValue"/>
353 <xsl:variable name=
"sprmcodelower">
354 <xsl:value-of select=
"translate($sprmcode, 'ABCDEF', 'abcdef')"/>
356 <xsl:variable name=
"sprmidname">
357 <xsl:text>NS_sprm::LN_
</xsl:text>
358 <xsl:value-of select=
"substring-after(@name, 'sprm')"/>
360 <xsl:text>| sed
"s/</xsl:text>
361 <xsl:value-of select="$sprmcode
"/>
362 <xsl:text>/</xsl:text>
363 <xsl:value-of select="$sprmidname
"/>
364 <xsl:text>/g" \

</xsl:text>
365 <xsl:text>| sed
"s/</xsl:text>
366 <xsl:value-of select="$sprmcodelower
"/>
367 <xsl:text>/</xsl:text>
368 <xsl:value-of select="$sprmidname
"/>
369 <xsl:text>/g" \

</xsl:text>
371 <xsl:text> | cat

</xsl:text>
374 <xsl:template match=
"UML:Model" mode='sprmreplace'
>
375 <xsl:for-each select=
".//UML:Class[.//UML:Stereotype/@xmi.idref='ww8sprm']">
376 <xsl:variable name=
"pattern">
377 <xsl:value-of select=
".//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref = 'sprmcode']/UML:TaggedValue.dataValue"/>
379 <xsl:variable name=
"lowerpattern">
380 <xsl:value-of select=
"translate($pattern, 'ABCDEF', 'abcdef')"/>
382 <xsl:variable name=
"upperpattern">
383 <xsl:value-of select=
"translate($pattern, 'abcdef', 'ABCDEF')"/>
385 <xsl:variable name=
"tmp">
386 <xsl:text>sprm:
</xsl:text>
387 <xsl:value-of select=
"substring-after(@name, 'sprm')"/>
389 <xsl:variable name=
"constname">
390 <xsl:call-template name=
"idtoqname">
391 <xsl:with-param name=
"id" select=
"$tmp"/>
396 <xsl:value-of select="$lowerpattern
"/>
397 <xsl:text>/</xsl:text>
398 <xsl:value-of select="$constname
"/>
399 <xsl:text>/g" < $
1 > $
1.out
&& mv $
1.out $
1 </xsl:text>
402 <xsl:value-of select="$upperpattern
"/>
403 <xsl:text>/</xsl:text>
404 <xsl:value-of select="$constname
"/>
405 <xsl:text>/g" < $
1 > $
1.out
&& mv $
1.out $
1 </xsl:text>
407 <xsl:text>
</xsl:text>
410 <!-- Key all attributes with the same name and same value -->
411 <xsl:key name=
"same-valued-tagged-data"
412 match=
"UML:TaggedValue.dataValue" use=
"." />
414 <xsl:template name=
"licenseheader">
417 * This file is part of the LibreOffice project.
419 * This Source Code Form is subject to the terms of the Mozilla Public
420 * License, v.
2.0. If a copy of the MPL was not distributed with this
421 * file, You can obtain one at http://mozilla.org/MPL/
2.0/.
423 * This file incorporates work covered by the following license notice:
425 * Licensed to the Apache Software Foundation (ASF) under one or more
426 * contributor license agreements. See the NOTICE file distributed
427 * with this work for additional information regarding copyright
428 * ownership. The ASF licenses this file to you under the Apache
429 * License, Version
2.0 (the
"License"); you may not use this file
430 * except in compliance with the License. You may obtain a copy of
431 * the License at http://www.apache.org/licenses/LICENSE-
2.0 .
434 THIS FILE IS GENERATED AUTOMATICALLY! DO NOT EDIT!