2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2008 by Sun Microsystems, Inc.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * $RCSfile: resourcetools.xsl,v $
14 * This file is part of OpenOffice.org.
16 * OpenOffice.org is free software: you can redistribute it and/or modify
17 * it under the terms of the GNU Lesser General Public License version 3
18 * only, as published by the Free Software Foundation.
20 * OpenOffice.org is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU Lesser General Public License version 3 for more details
24 * (a copy is included in the LICENSE file that accompanied this code).
26 * You should have received a copy of the GNU Lesser General Public License
27 * version 3 along with OpenOffice.org. If not, see
28 * <http://www.openoffice.org/license.html>
29 * for a copy of the LGPLv3 License.
31 ************************************************************************/
34 <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#"
35 xmlns:
rdfs=
"http://www.w3.org/2000/01/rdf-schema#" xmlns:UML = 'org.omg.xmi.namespace.UML' xml:
space=
"default">
36 <xsl:output method=
"text" />
38 <xsl:template name='idtoqname'
>
39 <xsl:param name='id'
/>
40 <xsl:text>NS_
</xsl:text>
41 <xsl:value-of select='substring-before($id,
":")'
/>
42 <xsl:text>::LN_
</xsl:text>
43 <xsl:value-of select='substring-after($id,
":")'
/>
46 <xsl:template name=
"parenttype">
47 <xsl:param name='type'
/>
48 <xsl:for-each select='/XMI/XMI.content/UML:Model/UML:Namespace.ownedElement/UML:Generalization[UML:Generalization.child/UML:Class/@xmi.idref=$type]'
>
49 <xsl:value-of select='./UML:Generalization.parent/UML:Class/@xmi.idref'
/>
53 <xsl:template name='saltype'
>
54 <xsl:param name='type'
/>
55 <xsl:param name='parenttype'
/>
57 <xsl:when test=
"$type='U8'">sal_uInt8
</xsl:when>
58 <xsl:when test=
"$type='S8'">sal_Int8
</xsl:when>
59 <xsl:when test=
"$type='U16'">sal_uInt16
</xsl:when>
60 <xsl:when test=
"$type='S16'">sal_Int16
</xsl:when>
61 <xsl:when test=
"$type='U32'">sal_uInt32
</xsl:when>
62 <xsl:when test=
"$type='S32'">sal_Int32
</xsl:when>
63 <xsl:when test=
"$type='String'">rtl::OUString
</xsl:when>
65 <xsl:text>writerfilter::Reference
< </xsl:text>
66 <xsl:value-of select='$parenttype'
/>
67 <xsl:text> >::Pointer_t
</xsl:text>
72 <xsl:template name='typetype'
>
73 <xsl:param name='type'
/><xsl:choose>
74 <xsl:when test=
"$type='U8'">simple
</xsl:when>
75 <xsl:when test=
"$type='S8'">simple
</xsl:when>
76 <xsl:when test=
"$type='U16'">simple
</xsl:when>
77 <xsl:when test=
"$type='S16'">simple
</xsl:when>
78 <xsl:when test=
"$type='U32'">simple
</xsl:when>
79 <xsl:when test=
"$type='S32'">simple
</xsl:when>
80 <xsl:when test=
"$type='String'">string
</xsl:when>
81 <xsl:when test=
"$type='Binary'">binary
</xsl:when>
82 <xsl:otherwise>complex
</xsl:otherwise>
86 <xsl:template name=
"valuetype">
87 <xsl:param name=
"type"/>
89 <xsl:when test='$
type=
"U8"'
>WW8IntValue
</xsl:when>
90 <xsl:when test='$
type=
"S8"'
>WW8IntValue
</xsl:when>
91 <xsl:when test='$
type=
"U16"'
>WW8IntValue
</xsl:when>
92 <xsl:when test='$
type=
"S16"'
>WW8IntValue
</xsl:when>
93 <xsl:when test='$
type=
"U32"'
>WW8IntValue
</xsl:when>
94 <xsl:when test='$
type=
"S32"'
>WW8IntValue
</xsl:when>
95 <xsl:otherwise>WW8PropertiesValue
</xsl:otherwise>
99 <xsl:template match=
"UML:Attribute" mode=
"valuetype">
100 <xsl:call-template name=
"valuetype">
101 <xsl:with-param name=
"type" select='.//UML:DataType/@xmi.idref'
/>
105 <xsl:template name=
"qnametostrattrs">
107 /* Attributes */
</xsl:text>
108 <xsl:for-each select='.//UML:Attribute[@name!=
"reserved"]'
>
109 <xsl:for-each select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.
idref=
"attrid"]'
>
111 <xsl:when test='.//UML:Stereotype[@xmi.
idref=
"noresolve"]'
>
116 <xsl:call-template name='idtoqname'
>
117 <xsl:with-param name='id'
><xsl:value-of select='.//UML:TaggedValue.dataValue'
/></xsl:with-param>
119 <xsl:text>] =
"</xsl:text>
120 <xsl:value-of select='.//UML:TaggedValue.dataValue'/>
121 <xsl:text>";
</xsl:text>
128 <xsl:template name=
"qnametostrops">
130 /* Operations */
</xsl:text>
131 <xsl:for-each select='.//UML:Operation[@name!=
"reserved"]'
>
132 <xsl:for-each select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.
idref=
"opid"]'
>
134 <xsl:when test='.//UML:Stereotype[@xmi.
idref=
"noresolve"]'
>
139 <xsl:call-template name='idtoqname'
>
140 <xsl:with-param name='id'
><xsl:value-of select='.//UML:TaggedValue.dataValue'
/></xsl:with-param>
142 <xsl:text>] =
"</xsl:text>
143 <xsl:value-of select='.//UML:TaggedValue.dataValue'/>
144 <xsl:text>";
</xsl:text>
151 <xsl:template name=
"qnametostrclasses">
153 /* Classes */
</xsl:text>
154 <xsl:for-each select='.//UML:Class[@name!=
"reserved"]'
>
155 <xsl:for-each select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.
idref=
"classid"]'
>
158 <xsl:call-template name='idtoqname'
>
159 <xsl:with-param name='id'
><xsl:value-of select='.//UML:TaggedValue.dataValue'
/></xsl:with-param>
161 <xsl:text>] =
"</xsl:text>
162 <xsl:value-of select='.//UML:TaggedValue.dataValue'/>
163 <xsl:text>";
</xsl:text>
168 <xsl:template match='UML:Model' mode='qnametostr'
>
170 void QNameToString::init_doctok()
172 <xsl:call-template name=
"qnametostrattrs"/>
173 <xsl:call-template name=
"qnametostrops"/>
174 <xsl:call-template name=
"qnametostrclasses"/>
180 <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"/>
182 <xsl:template match=
"UML:Model" mode=
"qnametostrfunc">
184 string qnameToString(sal_uInt32 nToken)
190 // Attributes
</xsl:text>
191 <xsl:for-each select='.//UML:Attribute[@name!=
"reserved"]//UML:TaggedValue[.//UML:TagDefinition/@xmi.
idref=
"attrid"]'
>
193 <xsl:when test='.//UML:Stereotype[@xmi.
idref=
"noresolve"]'
>
196 <xsl:if test=
"generate-id(key('ids', .//UML:TaggedValue.dataValue)[1])=generate-id(.)">
199 <xsl:call-template name='idtoqname'
>
200 <xsl:with-param name='id'
><xsl:value-of select='.//UML:TaggedValue.dataValue'
/></xsl:with-param>
203 sResult =
"</xsl:text>
204 <xsl:value-of select='.//UML:TaggedValue.dataValue'/>
212 // Operations
</xsl:text>
213 <xsl:for-each select='.//UML:Operation[@name!=
"reserved"]//UML:TaggedValue[.//UML:TagDefinition/@xmi.
idref=
"opid"]'
>
215 <xsl:when test='.//UML:Stereotype[@xmi.
idref=
"noresolve"]'
>
218 <xsl:if test=
"generate-id(key('ids', .//UML:TaggedValue.dataValue)[1])=generate-id(.)">
221 <xsl:call-template name='idtoqname'
>
222 <xsl:with-param name='id'
><xsl:value-of select='.//UML:TaggedValue.dataValue'
/></xsl:with-param>
225 sResult =
"</xsl:text>
226 <xsl:value-of select='.//UML:TaggedValue.dataValue'/>
234 // Classes:
</xsl:text>
235 <xsl:for-each select='.//UML:Class[@name!=
"reserved"]//UML:TaggedValue[.//UML:TagDefinition/@xmi.
idref=
"classid"]'
>
238 <xsl:call-template name='idtoqname'
>
239 <xsl:with-param name='id'
><xsl:value-of select='.//UML:TaggedValue.dataValue'
/></xsl:with-param>
242 sResult =
"</xsl:text>
243 <xsl:value-of select='.//UML:TaggedValue.dataValue'/>
256 <xsl:template match='UML:Model' mode='sprmcodetostr'
>
258 SprmIdToString::SprmIdToString()
260 <xsl:variable name='tmp'
>map
< sal_uInt32, string
> </xsl:variable>
261 <xsl:for-each select='.//UML:Class[.//UML:Stereotype/@xmi.
idref=
"ww8sprm"]'
>
262 <xsl:variable name=
"sprmconst">
263 <xsl:call-template name=
"sprmCodeOfClass"/>
267 <xsl:value-of select=
"$sprmconst"/>
268 <xsl:text>] =
"</xsl:text>
269 <xsl:value-of select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="sprmid
"]//UML:TaggedValue.dataValue'/>
270 <xsl:text>";
</xsl:text>
277 <xsl:key name=
"classes-with-kind" match=
"UML:TagDefinition[@xmi.idref='kind']"
278 use=
"ancestor::UML:TaggedValue/UML:TaggedValue.dataValue"/>
280 <xsl:template name=
"sprmCodeOfClass">
281 <xsl:variable name=
"tmp">
282 <xsl:text>sprm:
</xsl:text>
283 <xsl:value-of select=
"substring-after(@name, 'sprm')"/>
285 <xsl:call-template name=
"idtoqname">
286 <xsl:with-param name=
"id" select=
"$tmp"/>
290 <xsl:template name=
"sprmkindcase">
291 <xsl:param name=
"kind"/>
292 <xsl:for-each select=
"key('classes-with-kind', $kind)/ancestor::UML:Class">
295 <xsl:call-template name=
"sprmCodeOfClass"/>
296 <xsl:text>:
</xsl:text>
300 <xsl:template match=
"UML:Model" mode='sprmkind'
>
302 Sprm::Kind SprmKind(sal_uInt32 sprmCode)
304 Sprm::Kind nResult = Sprm::UNKNOWN;
308 <xsl:call-template name=
"sprmkindcase">
309 <xsl:with-param name=
"kind">paragraph
</xsl:with-param>
312 nResult = Sprm::PARAGRAPH;
314 <xsl:call-template name=
"sprmkindcase">
315 <xsl:with-param name=
"kind">character
</xsl:with-param>
318 nResult = Sprm::CHARACTER;
320 <xsl:call-template name=
"sprmkindcase">
321 <xsl:with-param name=
"kind">table
</xsl:with-param>
324 nResult = Sprm::TABLE;
336 <xsl:template match=
"UML:Model" mode='sprmids'
>
338 namespace NS_sprm {
</xsl:text>
339 <xsl:for-each select=
".//UML:Class[.//UML:Stereotype/@xmi.idref='ww8sprm']">
340 <xsl:variable name=
"sprmcode">
341 <xsl:value-of select=
".//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref = 'sprmcode']/UML:TaggedValue.dataValue"/>
343 <xsl:variable name=
"sprmcodelower">
344 <xsl:value-of select=
"translate($sprmcode, 'ABCDEF', 'abcdef')"/>
346 <xsl:variable name=
"sprmidname">
347 <xsl:text>LN_
</xsl:text>
348 <xsl:value-of select=
"substring-after(@name, 'sprm')"/>
351 const sal_uInt16
</xsl:text>
352 <xsl:value-of select=
"$sprmidname"/>
353 <xsl:text> =
</xsl:text>
354 <xsl:value-of select=
"$sprmcodelower"/>
355 <xsl:text>;
</xsl:text>
362 <xsl:template match=
"UML:Model" mode='sprmidsed'
>
364 cat $
1 \

</xsl:text>
365 <xsl:for-each select=
".//UML:Class[.//UML:Stereotype/@xmi.idref='ww8sprm']">
366 <xsl:variable name=
"sprmcode">
367 <xsl:value-of select=
".//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref = 'sprmcode']/UML:TaggedValue.dataValue"/>
369 <xsl:variable name=
"sprmcodelower">
370 <xsl:value-of select=
"translate($sprmcode, 'ABCDEF', 'abcdef')"/>
372 <xsl:variable name=
"sprmidname">
373 <xsl:text>NS_sprm::LN_
</xsl:text>
374 <xsl:value-of select=
"substring-after(@name, 'sprm')"/>
376 <xsl:text>| sed
"s/</xsl:text>
377 <xsl:value-of select="$sprmcode
"/>
378 <xsl:text>/</xsl:text>
379 <xsl:value-of select="$sprmidname
"/>
380 <xsl:text>/g" \

</xsl:text>
381 <xsl:text>| sed
"s/</xsl:text>
382 <xsl:value-of select="$sprmcodelower
"/>
383 <xsl:text>/</xsl:text>
384 <xsl:value-of select="$sprmidname
"/>
385 <xsl:text>/g" \

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

</xsl:text>
390 <xsl:template match=
"UML:Model" mode=
"sprmidstoxml">
392 void sprmidsToXML(::std::ostream
& out)
395 <xsl:for-each select=
".//UML:Class[.//UML:Stereotype/@xmi.idref='ww8sprm']">
396 <xsl:variable name=
"sprmcode">
397 <xsl:value-of select=
".//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref = 'sprmcode']/UML:TaggedValue.dataValue"/>
399 <xsl:variable name=
"sprmcodelower">
400 <xsl:value-of select=
"translate($sprmcode, 'ABCDEF', 'abcdef')"/>
402 <xsl:variable name=
"sprmidname">
403 <xsl:text>sprm:
</xsl:text>
404 <xsl:value-of select=
"substring-after(@name, 'sprm')"/>
407 out
<< "<theid name=\"</xsl:text>
408 <xsl:value-of select=
"$sprmidname"/>
409 <xsl:text>\
"></xsl:text>
410 <xsl:value-of select="$sprmcodelower
"/>
411 <xsl:text></theid>" << endl;
</xsl:text>
418 <xsl:template match=
"UML:Model" mode='sprmreplace'
>
419 <xsl:for-each select=
".//UML:Class[.//UML:Stereotype/@xmi.idref='ww8sprm']">
420 <xsl:variable name=
"pattern">
421 <xsl:value-of select=
".//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref = 'sprmcode']/UML:TaggedValue.dataValue"/>
423 <xsl:variable name=
"lowerpattern">
424 <xsl:value-of select=
"translate($pattern, 'ABCDEF', 'abcdef')"/>
426 <xsl:variable name=
"upperpattern">
427 <xsl:value-of select=
"translate($pattern, 'abcdef', 'ABCDEF')"/>
429 <xsl:variable name=
"tmp">
430 <xsl:text>sprm:
</xsl:text>
431 <xsl:value-of select=
"substring-after(@name, 'sprm')"/>
433 <xsl:variable name=
"constname">
434 <xsl:call-template name=
"idtoqname">
435 <xsl:with-param name=
"id" select=
"$tmp"/>
440 <xsl:value-of select="$lowerpattern
"/>
441 <xsl:text>/</xsl:text>
442 <xsl:value-of select="$constname
"/>
443 <xsl:text>/g" < $
1 > $
1.out
&& mv $
1.out $
1 </xsl:text>
446 <xsl:value-of select="$upperpattern
"/>
447 <xsl:text>/</xsl:text>
448 <xsl:value-of select="$constname
"/>
449 <xsl:text>/g" < $
1 > $
1.out
&& mv $
1.out $
1 </xsl:text>
451 <xsl:text>
</xsl:text>
454 <!-- Key all attributes with the same name and same value -->
455 <xsl:key name=
"same-valued-tagged-data"
456 match=
"UML:TaggedValue.dataValue" use=
"." />
458 <xsl:template name=
"analyzerdoctokidsattrs">
460 /* Attributes */
</xsl:text>
461 <xsl:for-each select='.//UML:Attribute[@name!=
"reserved"]'
>
462 <xsl:if test='count(.//UML:Stereotype[@xmi.
idref=
"noqname"]) =
0'
>
463 <xsl:for-each select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.
idref=
"attrid"]'
>
465 <xsl:when test='generate-id(UML:TaggedValue.dataValue) != generate-id(key(
"same-valued-tagged-data", UML:TaggedValue.dataValue)[
1])'
/>
468 out
<< "<theid name=\"</xsl:text>
469 <xsl:value-of select=
".//UML:TaggedValue.dataValue"/>
470 <xsl:text>\
"></xsl:text>
471 <xsl:value-of select='10000 + position()'/>
472 <xsl:text></theid>" << endl;
</xsl:text>
480 <xsl:template name=
"analyzerdoctokidsops">
482 /* Operations */
</xsl:text>
483 <xsl:for-each select='.//UML:Operation[@name!=
"reserved"]'
>
484 <xsl:if test='count(.//UML:Stereotype[@xmi.
idref=
"noqname"]) =
0'
>
485 <xsl:for-each select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.
idref=
"opid"]'
>
487 <xsl:when test='generate-id(UML:TaggedValue.dataValue) != generate-id(key(
"same-valued-tagged-data", UML:TaggedValue.dataValue)[
1])'
/>
490 out
<< "<theid name=\"</xsl:text>
491 <xsl:value-of select=
".//UML:TaggedValue.dataValue"/>
492 <xsl:text>\
"></xsl:text>
493 <xsl:value-of select='20000 + position()'/>
494 <xsl:text></theid>" << endl;
</xsl:text>
502 <xsl:template name=
"analyzerdoctokidsclasses">
504 /* clases */
</xsl:text>
505 <xsl:for-each select='.//UML:Class[@name!=
"reserved"]'
>
506 <xsl:for-each select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.
idref=
"classid"]'
>
508 <xsl:when test='.//UML:Stereotype[@xmi.
idref=
"noqname"]'
/>
509 <xsl:when test='generate-id(UML:TaggedValue.dataValue) != generate-id(key(
"same-valued-tagged-data", UML:TaggedValue.dataValue)[
1])'
/>
512 out
<< "<theid name=\"</xsl:text>
513 <xsl:value-of select=
".//UML:TaggedValue.dataValue"/>
514 <xsl:text>\
"></xsl:text>
515 <xsl:value-of select='30000 + position()'/>
516 <xsl:text></theid>" << endl;
</xsl:text>
523 <xsl:template match=
"UML:Model" mode=
"analyzerdoctokids">
525 void doctokidsToXML(::std::ostream
& out)
527 <xsl:call-template name=
"analyzerdoctokidsattrs"/>
528 <xsl:call-template name=
"analyzerdoctokidsops"/>
529 <xsl:call-template name=
"analyzerdoctokidsclasses"/>
535 <xsl:template name=
"licenseheader">
537 /*************************************************************************
539 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
541 * Copyright
2008 by Sun Microsystems, Inc.
543 * OpenOffice.org - a multi-platform office productivity suite
545 * $RCSfile: resourcetools.xsl,v $
549 * This file is part of OpenOffice.org.
551 * OpenOffice.org is free software: you can redistribute it and/or modify
552 * it under the terms of the GNU Lesser General Public License version
3
553 * only, as published by the Free Software Foundation.
555 * OpenOffice.org is distributed in the hope that it will be useful,
556 * but WITHOUT ANY WARRANTY; without even the implied warranty of
557 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
558 * GNU Lesser General Public License version
3 for more details
559 * (a copy is included in the LICENSE file that accompanied this code).
561 * You should have received a copy of the GNU Lesser General Public License
562 * version
3 along with OpenOffice.org. If not, see
563 * http://www.openoffice.org/license.html
564 * for a copy of the LGPLv3 License.
566 ************************************************************************/
569 THIS FILE IS GENERATED AUTOMATICALLY! DO NOT EDIT!