update dev300-m58
[ooovba.git] / writerfilter / source / doctok / resourcesimpl.xsl
blob2a52b58c4ab7de4a2ed8558d4f02a1003b7e7f5d
1 <!--
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: resourcesimpl.xsl,v $
12 $Revision: 1.12 $
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 ************************************************************************/
33 -->
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:include href="resourcetools.xsl"/>
40 <xsl:template match="/">
41 <xsl:call-template name="licenseheader"/>
42 <xsl:text>
43 #include &lt;resources.hxx&gt;
45 #ifndef WW8_OUTPUT_WITH_DEPTH
46 #include &lt;WW8OutputWithDepth.hxx&gt;
47 #endif
49 #ifndef INCLUDED_SPRMIDS_HXX
50 #include &lt;sprmids.hxx&gt;
51 #endif
53 namespace writerfilter {
54 namespace doctok {
56 extern WW8OutputWithDepth output;
58 using namespace ::std;
59 </xsl:text>
60 <xsl:apply-templates select='/XMI/XMI.content/UML:Model' mode="sprmkind"/>
61 <xsl:apply-templates select='.//UML:Class' mode='class'/>
62 <xsl:apply-templates select='//UML:Model' mode='createsprmprops'/>
63 <xsl:apply-templates select='/XMI/XMI.content/UML:Model'
64 mode='createsprmbinary'/>
65 <xsl:apply-templates select='/XMI/XMI.content/UML:Model'
66 mode='createdffrecord'/>
67 <xsl:apply-templates select='/XMI/XMI.content/UML:Model' mode='ww8foptename'/>
68 <xsl:apply-templates select='/XMI/XMI.content/UML:Model'
69 mode='isbooleandffopt'/>
70 <xsl:text>
72 </xsl:text>
73 </xsl:template>
75 <xsl:template match="UML:Class" mode="class">
76 <xsl:choose>
77 <xsl:when test='.//UML:Stereotype[@xmi.idref = "ww8resource"]'>
78 <xsl:apply-templates select="." mode="ww8resource">
79 <xsl:with-param name="classprefix">WW8</xsl:with-param>
80 <xsl:with-param name="needsinit">true</xsl:with-param>
81 </xsl:apply-templates>
82 </xsl:when>
83 <xsl:when test='.//UML:Stereotype[@xmi.idref = "dffrecord"]'>
84 <xsl:apply-templates select="." mode="ww8resource">
85 <xsl:with-param name="classprefix">Dff</xsl:with-param>
86 </xsl:apply-templates>
87 </xsl:when>
88 </xsl:choose>
89 </xsl:template>
91 <xsl:template match="UML:Class" mode="ww8resource">
92 <xsl:param name="classprefix"/>
93 <xsl:param name="needsinit"/>
94 <xsl:variable name="parentresource">
95 <xsl:call-template name='parenttype'>
96 <xsl:with-param name='type'><xsl:value-of select='@xmi.id'/></xsl:with-param>
97 </xsl:call-template>
98 </xsl:variable>
99 <xsl:variable name='size_'><xsl:value-of select='./*/UML:TaggedValue[./*/UML:TagDefinition/@xmi.idref="size"]/UML:TaggedValue.dataValue'/></xsl:variable>
100 <xsl:variable name='size'>
101 <xsl:choose>
102 <xsl:when test='$size_ != ""'><xsl:value-of select='$size_'/></xsl:when>
103 <xsl:otherwise>0</xsl:otherwise>
104 </xsl:choose>
105 </xsl:variable>
106 <xsl:variable name="classname"><xsl:value-of select="$classprefix"/><xsl:value-of select="@name"/></xsl:variable>
107 <xsl:variable name="superclass">
108 <xsl:choose>
109 <xsl:when test='.//UML:Stereotype[@xmi.idref = "ww8sprm"]'>WW8PropertyImpl</xsl:when>
110 <xsl:otherwise>WW8StructBase</xsl:otherwise>
111 </xsl:choose>
112 </xsl:variable>
113 <xsl:variable name="surroundclass">
114 <xsl:choose>
115 <xsl:when test='.//UML:Stereotype[@xmi.idref = "ww8sprm"]'>WW8PropertyImpl</xsl:when>
116 <xsl:otherwise>WW8StructBase</xsl:otherwise>
117 </xsl:choose>
118 </xsl:variable>
119 <xsl:text>
121 Automatically generated class: </xsl:text><xsl:value-of select="@name"/><xsl:text>
122 </xsl:text>
123 <xsl:for-each select='./UML:ModelElement.stereotype/UML:Stereotype'>
124 <xsl:text>
125 Stereotype </xsl:text>
126 <xsl:value-of select='@xmi.idref'/>
127 <xsl:text>&#xa;</xsl:text>
128 </xsl:for-each>
129 <xsl:text>
130 Parent Resource: </xsl:text>
131 <xsl:value-of select="$parentresource"/>
132 <xsl:text>
133 Size: </xsl:text><xsl:value-of select='$size'/>
134 <xsl:text>
136 </xsl:text>
138 <xsl:value-of select="$classname"/>
139 <xsl:text>::~</xsl:text>
140 <xsl:value-of select="$classname"/>
141 <xsl:text>()
144 </xsl:text>
145 <xsl:if test="$needsinit='true'">
146 <xsl:text>
147 void </xsl:text>
148 <xsl:value-of select="$classname"/>
149 <xsl:text>::init()
151 </xsl:text>
152 <xsl:if test='.//UML:Stereotype[@xmi.idref ="withmembers"]'>
153 <xsl:for-each select='.//UML:Attribute[@name!="reserved"]'>
154 <xsl:apply-templates select='.' mode='initmembers'/>
155 </xsl:for-each>
156 </xsl:if>
157 <xsl:if test='.//UML:Stereotype[@xmi.idref ="initimpl"]'>
158 <xsl:text> initImpl();&#xa;</xsl:text>
159 </xsl:if>
160 <xsl:text>
161 }&#xa;</xsl:text>
162 </xsl:if>
164 <xsl:choose>
165 <xsl:when test='$parentresource="Properties"'>
166 <xsl:apply-templates select="." mode="resolveProperties">
167 <xsl:with-param name="classname" select="$classname"/>
168 </xsl:apply-templates>
169 </xsl:when>
170 <xsl:when test='$parentresource="Table"'>
171 <xsl:apply-templates select="." mode="resolveTable">
172 <xsl:with-param name="classname" select="$classname"/>
173 </xsl:apply-templates>
174 </xsl:when>
175 </xsl:choose>
177 </xsl:template>
179 <xsl:template match="UML:Class" mode="resolveProperties">
180 <xsl:param name="classname"/>
181 <xsl:variable name="rHandler">
182 <xsl:choose>
183 <xsl:when test='.//UML:Attribute[@name!="reserved"]'>
184 <xsl:if test='.//UML:Stereotype[@xmi.idref != "noresolve"]'>
185 <xsl:text>rHandler</xsl:text>
186 </xsl:if>
187 </xsl:when>
188 <xsl:when test='.//UML:Operation[@name!="reserved"]'>
189 <xsl:if test='.//UML:Stereotype[@xmi.idref != "noresolve"]'>
190 <xsl:text>rHandler</xsl:text>
191 </xsl:if>
192 </xsl:when>
193 <xsl:when test='.//UML:Stereotype[@xmi.idref = "resolvenoauto"]'>
194 <xsl:text>rHandler</xsl:text>
195 </xsl:when>
196 </xsl:choose>
197 </xsl:variable>
198 <xsl:text>
199 void </xsl:text>
200 <xsl:value-of select="$classname"/>
201 <xsl:choose>
202 <xsl:when test=".//UML:Stereotype[@xmi.idref='ww8resource']">
203 <xsl:text>::resolve(Properties &amp; </xsl:text>
204 <xsl:value-of select="$rHandler"/>
205 <xsl:text>)</xsl:text>
206 </xsl:when>
207 <xsl:when test=".//UML:Stereotype[@xmi.idref='dffrecord']">
208 <xsl:text>::resolveLocal(Properties &amp; </xsl:text>
209 <xsl:value-of select="$rHandler"/>
210 <xsl:text>)</xsl:text>
211 </xsl:when>
212 </xsl:choose>
213 <xsl:text>
214 {</xsl:text>
215 <xsl:if test='.//UML:Stereotype[@xmi.idref="debug"]'>
216 <xsl:text>
217 dump(output);</xsl:text>
218 </xsl:if>
219 <xsl:text>
220 try
221 {</xsl:text>
222 <xsl:for-each select='.//UML:Attribute[@name!="reserved"]'>
223 <xsl:choose>
224 <xsl:when test='.//UML:Stereotype[@xmi.idref="noresolve"]'>
225 </xsl:when>
226 <xsl:otherwise>
227 <xsl:apply-templates select='.' mode='resolveAttribute'/>
228 </xsl:otherwise>
229 </xsl:choose>
230 </xsl:for-each>
231 <xsl:for-each select='.//UML:Operation[@name!="reserved"]'>
232 <xsl:choose>
233 <xsl:when test='.//UML:Stereotype[@xmi.idref="noresolve"]'>
234 </xsl:when>
235 <xsl:otherwise>
236 <xsl:apply-templates select='.' mode='resolveOperation'/>
237 </xsl:otherwise>
238 </xsl:choose>
239 </xsl:for-each>
241 <xsl:if test='.//UML:Stereotype[@xmi.idref = "resolvenoauto"]'>
242 resolveNoAuto(rHandler);
243 </xsl:if>
244 <xsl:text>
245 } catch (Exception &amp; e) {
246 clog &lt;&lt; e.getText() &lt;&lt; endl;
250 void
251 </xsl:text>
252 <xsl:value-of select="$classname"/>
253 <xsl:text>::dump(OutputWithDepth &lt; string &gt; &amp; o) const
255 o.addItem("&lt;dump type='</xsl:text>
256 <xsl:value-of select='@name'/>
257 <xsl:text>'&gt;");
259 WW8StructBase::dump(o);</xsl:text>
260 <xsl:for-each select='.//UML:Attribute[@name!="reserved"]'>
261 <xsl:apply-templates select='.' mode='dumpAttribute'/>
262 </xsl:for-each>
264 <xsl:text>
265 o.addItem("&lt;/dump&gt;");
266 }&#xa;</xsl:text>
267 </xsl:template>
269 <xsl:template match='UML:Attribute' mode='resolveAttribute'>
270 <xsl:variable name="attrid">
271 <xsl:for-each select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="attrid"]'>
272 <xsl:value-of select='UML:TaggedValue.dataValue'/>
273 </xsl:for-each>
274 </xsl:variable>
275 <xsl:variable name="qname">
276 <xsl:call-template name='idtoqname'>
277 <xsl:with-param name='id'>
278 <xsl:value-of select='$attrid'/>
279 </xsl:with-param>
280 </xsl:call-template>
281 </xsl:variable>
282 <xsl:choose>
283 <xsl:when test='.//UML:Stereotype/@xmi.idref = "attribute"'>
284 <xsl:text>
286 WW8Value::Pointer_t pVal = createValue(get_</xsl:text>
287 <xsl:value-of select="@name"/>
288 <xsl:text>());
289 rHandler.attribute(</xsl:text>
290 <xsl:value-of select="$qname"/>
291 <xsl:text>, *pVal);
292 }</xsl:text>
293 </xsl:when>
294 <xsl:when test='.//UML:Stereotype/@xmi.idref = "array"'>
295 <xsl:variable name="elementtype">
296 <xsl:value-of select='.//UML:DataType/@xmi.idref'/>
297 </xsl:variable>
298 <xsl:variable name="parentclass">
299 <xsl:call-template name='parenttype'>
300 <xsl:with-param name='type'>
301 <xsl:value-of select='$elementtype'/>
302 </xsl:with-param>
303 </xsl:call-template>
304 </xsl:variable>
305 <xsl:text>
307 sal_uInt32 nCount = get_</xsl:text>
308 <xsl:value-of select="@name"/>
309 <xsl:text>_count();
310 for (sal_uInt32 n = 0; n &lt; nCount; ++n)
312 WW8Value::Pointer_t pVal = createValue(get_</xsl:text>
313 <xsl:value-of select="@name"/>
314 <xsl:text>(n));
315 rHandler.attribute(</xsl:text>
316 <xsl:value-of select="$qname"/>
317 <xsl:text>, *pVal);
319 }</xsl:text>
320 </xsl:when>
321 <xsl:when test='.//UML:Stereotype/@xmi.idref = "string"'>
322 <xsl:text>
324 WW8StringValue aVal(get_</xsl:text>
325 <xsl:value-of select='@name'/>
326 <xsl:text>());
327 rHandler.attribute(</xsl:text>
328 <xsl:value-of select="$qname"/>
329 <xsl:text>, aVal);
330 }</xsl:text>
331 </xsl:when>
332 </xsl:choose>
333 </xsl:template>
335 <xsl:template match='UML:Attribute' mode='dumpAttribute'>
336 <xsl:variable name="type">
337 <xsl:value-of select='.//UML:DataType/@xmi.idref'/>
338 </xsl:variable><xsl:variable name="saltype">
339 <xsl:call-template name='saltype'>
340 <xsl:with-param name='type'>
341 <xsl:value-of select='$type'/>
342 </xsl:with-param>
343 <xsl:with-param name='parenttype'>
344 <xsl:apply-templates select="." mode="parentclass"/>
345 </xsl:with-param>
346 </xsl:call-template>
347 </xsl:variable>
348 <xsl:variable name="name" select="@name"/>
349 <xsl:for-each select=".//UML:Stereotype">
350 <xsl:choose>
351 <xsl:when test='@xmi.idref = "attributeremainder"'/>
352 <xsl:when test='@xmi.idref = "array"'>
353 <xsl:text>
355 sal_uInt32 nCount = get_</xsl:text>
356 <xsl:value-of select='$name'/>
357 <xsl:text>_count();
359 for (sal_uInt32 n = 0; n &lt; nCount; ++n)
361 writerfilter::dump(o, "</xsl:text>
362 <xsl:value-of select='$name'/>
363 <xsl:text>", get_</xsl:text>
364 <xsl:value-of select="$name"/>
365 <xsl:text>(n));
367 }</xsl:text>
368 </xsl:when>
369 <xsl:when test='@xmi.idref = "string"'>
370 <xsl:text>
372 WW8StringValue aVal(get_</xsl:text>
373 <xsl:value-of select='$name'/>
374 <xsl:text>());
376 o.addItem("</xsl:text>
377 <xsl:value-of select='$name'/>
378 <xsl:text>" &lt;&lt; "=\"" + aVal.toString() + "\"");
379 }</xsl:text>
380 </xsl:when>
381 <xsl:otherwise>
382 <xsl:text>
383 writerfilter::dump(o, "</xsl:text>
384 <xsl:value-of select='$name'/>
385 <xsl:text>", get_</xsl:text>
386 <xsl:value-of select="$name"/>
387 <xsl:text>());</xsl:text>
388 </xsl:otherwise>
389 </xsl:choose>
390 </xsl:for-each>
391 </xsl:template>
393 <xsl:template name="resolveOperationAttribute">
394 <xsl:variable name="opid">
395 <xsl:for-each select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="opid"]'>
396 <xsl:value-of select='./UML:TaggedValue.dataValue'/>
397 </xsl:for-each>
398 </xsl:variable>
399 <xsl:text>
401 WW8Value::Pointer_t pVal = createValue(get_</xsl:text>
402 <xsl:value-of select="@name"/>
403 <xsl:text>());
404 rHandler.attribute(</xsl:text>
405 <xsl:call-template name='idtoqname'>
406 <xsl:with-param name='id'><xsl:value-of select='$opid'/></xsl:with-param>
407 </xsl:call-template>
408 <xsl:text>, *pVal);
409 }&#xa;</xsl:text>
410 </xsl:template>
412 <xsl:template name="resolveOperationArray">
413 <xsl:variable name="elementtype">
414 <xsl:value-of select='.//UML:Parameter.type/@xmi.idref'/>
415 </xsl:variable>
416 <xsl:variable name="opid">
417 <xsl:for-each select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="opid"]'>
418 <xsl:value-of select='./UML:TaggedValue.dataValue'/>
419 </xsl:for-each>
420 </xsl:variable>
421 <xsl:variable name="parentclass">
422 <xsl:for-each select='/XMI/XMI.content/UML:Model/UML:Namespace.ownedElement/UML:Generalization[UML:Generalization.child/UML:Class/@xmi.idref=$elementtype]'>
423 <xsl:value-of select='./UML:Generalization.parent/UML:Class/@xmi.idref'/>
424 </xsl:for-each>
425 </xsl:variable>
426 <xsl:text>
428 sal_uInt32 nCount = get_</xsl:text>
429 <xsl:value-of select="@name"/>
430 <xsl:text>_count();
432 for (sal_uInt32 n = 0; n &lt; nCount; ++n)
434 WW8Value::Pointer_t pVal = createValue(get_</xsl:text>
435 <xsl:value-of select="@name"/>
436 <xsl:text>(n));
437 rHandler.attribute(</xsl:text>
438 <xsl:call-template name='idtoqname'>
439 <xsl:with-param name='id'><xsl:value-of select='$opid'/></xsl:with-param>
440 </xsl:call-template>
441 <xsl:text>, *pVal);
443 }&#xa;</xsl:text>
444 </xsl:template>
446 <xsl:template name="resolveOperationBinary">
447 <xsl:text>
449 WW8BinaryObjReference::Pointer_t pRef(get_</xsl:text>
450 <xsl:value-of select="@name"/>
451 <xsl:text>());
452 WW8Sprm aSprm(pRef);
454 rHandler.sprm(aSprm);
455 }&#xa;</xsl:text>
456 </xsl:template>
458 <xsl:template match='UML:Operation' mode='resolveOperation'>
459 <xsl:choose>
460 <xsl:when test='.//UML:Stereotype/@xmi.idref = "attribute"'>
461 <xsl:call-template name="resolveOperationAttribute"/>
462 </xsl:when>
463 <xsl:when test='.//UML:Stereotype/@xmi.idref = "array"'>
464 <xsl:call-template name="resolveOperationArray"/>
465 </xsl:when>
466 <xsl:when test='.//UML:Stereotype/@xmi.idref = "binary"'>
467 <xsl:call-template name="resolveOperationBinary"/>
468 </xsl:when>
469 </xsl:choose>
470 </xsl:template>
472 <xsl:template match="UML:Class" mode="resolveTable">
473 <xsl:param name="classname"/>
474 <xsl:text>void </xsl:text>
475 <xsl:value-of select="$classname"/>
476 <xsl:text>::resolve(Table &amp; rHandler)
478 sal_uInt32 nCount = getEntryCount();
479 writerfilter::Reference&lt; Properties &gt;::Pointer_t pEntry;
480 for (sal_uInt32 n = 0; n &lt; nCount; ++n)
482 pEntry = getEntry(n);
484 if (pEntry.get() != 0x0)
486 try
488 rHandler.entry(n, pEntry);
490 catch (ExceptionOutOfBounds e)
496 </xsl:text>
497 </xsl:template>
499 <xsl:template match='UML:Model' mode='createsprmprops'>
500 writerfilter::Reference &lt; Properties &gt; ::Pointer_t createSprmProps
501 (WW8PropertyImpl &amp; rProp)
503 writerfilter::Reference &lt; Properties &gt; ::Pointer_t pResult;
505 switch (rProp.getId())
507 <xsl:for-each select='.//UML:Class[.//UML:Stereotype/@xmi.idref="ww8sprm" and .//UML:Stereotype/@xmi.idref="ww8resource"]'>
508 case <xsl:value-of select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="sprmcode"]//UML:TaggedValue.dataValue'/>:
509 pResult = writerfilter::Reference &lt; Properties &gt; ::Pointer_t(new WW8<xsl:value-of select='@name'/>(rProp, 0, rProp.getCount()));
511 break;
512 </xsl:for-each>
513 default:
514 break;
517 return pResult;
519 </xsl:template>
521 <xsl:template match='UML:Model' mode='createsprmbinary'>
522 <xsl:text>
523 writerfilter::Reference &lt; BinaryObj &gt; ::Pointer_t createSprmBinary
524 (WW8PropertyImpl &amp; rProp)
526 writerfilter::Reference &lt; BinaryObj &gt; ::Pointer_t pResult;
528 switch (rProp.getId())
529 {&#xa;
530 // warnings....
531 case 0:
532 break;
533 </xsl:text>
534 <xsl:for-each select='.//UML:Class[.//UML:Stereotype/@xmi.idref="ww8sprmbinary" and .//UML:Stereotype/@xmi.idref="ww8resource"]'>
535 case <xsl:value-of select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="sprmcode"]//UML:TaggedValue.dataValue'/>:
537 WW8<xsl:value-of select='@name'/>::Pointer_t p(new WW8<xsl:value-of select='@name'/>(rProp, 0, rProp.getCount()));
539 pResult = p->getBinary();
542 break;
543 </xsl:for-each>
544 <xsl:text>
545 default:
546 break;
549 return pResult;
551 </xsl:text>
552 </xsl:template>
554 <!-- returns optname of UML:Class -->
555 <xsl:template name="optname">
556 <xsl:for-each select="./UML:ModelElement.taggedValue/UML:TaggedValue">
557 <xsl:if test=".//UML:TagDefinition/@xmi.idref='optname'">
558 <xsl:value-of select="./UML:TaggedValue.dataValue"/>
559 </xsl:if>
560 </xsl:for-each>
561 </xsl:template>
563 <xsl:template name="ww8foptenamecase">
564 <xsl:text>
565 case </xsl:text>
566 <xsl:variable name="optname">
567 <xsl:call-template name="optname"/>
568 </xsl:variable>
569 <xsl:call-template name="idtoqname">
570 <xsl:with-param name="id" select="$optname"/>
571 </xsl:call-template>
572 <xsl:text>:
573 result = rtl::OUString::createFromAscii("</xsl:text>
574 <xsl:value-of select="$optname"/>
575 <xsl:text>");
576 break;</xsl:text>
577 </xsl:template>
579 <xsl:template name="getdffoptname">
580 <xsl:text>
581 rtl::OUString getDffOptName(sal_uInt32 nPid)
583 rtl::OUString result;
585 switch (nPid)
586 {&#xa;</xsl:text>
587 <xsl:for-each select="./UML:Class[./UML:ModelElement.stereotype/UML:Stereotype/@xmi.idref='dffopt']">
588 <xsl:call-template name="ww8foptenamecase"/>
589 </xsl:for-each>
590 <xsl:text>
591 default:
592 break;
595 return result;
596 }</xsl:text>
597 </xsl:template>
599 <xsl:template name="ww8foptegetvalue">
600 <xsl:text>
601 WW8Value::Pointer_t WW8FOPTE::get_value()
603 WW8Value::Pointer_t pResult;
605 switch (get_pid())
606 {</xsl:text>
607 <xsl:for-each select=".//UML:Class[./UML:ModelElement.stereotype/UML:Stereotype/@xmi.idref='dffopt']">
608 <xsl:variable name="type">
609 <xsl:for-each select="./UML:ModelElement.taggedValue/UML:TaggedValue[./UML:TaggedValue.type/UML:TagDefinition/@xmi.idref='type']">
610 <xsl:value-of select="UML:TaggedValue.dataValue"/>
611 </xsl:for-each>
612 </xsl:variable>
613 <xsl:if test="$type != 'unknown'">
614 <xsl:variable name="typetype">
615 <xsl:call-template name="typetype">
616 <xsl:with-param name="type" select="$type"/>
617 </xsl:call-template>
618 </xsl:variable>
619 <xsl:variable name="valuetype">
620 <xsl:call-template name="valuetype">
621 <xsl:with-param name="type" select="$type"/>
622 </xsl:call-template>
623 </xsl:variable>
624 <xsl:text>
625 case </xsl:text>
626 <xsl:for-each select="./UML:ModelElement.taggedValue/UML:TaggedValue[./UML:TaggedValue.type/UML:TagDefinition/@xmi.idref='dffid']">
627 <xsl:value-of select="UML:TaggedValue.dataValue"/>
628 </xsl:for-each>
629 <xsl:variable name="optname">
630 <xsl:for-each select="./UML:ModelElement.taggedValue/UML:TaggedValue[./UML:TaggedValue.type/UML:TagDefinition/@xmi.idref='optname']">
631 <xsl:value-of select="UML:TaggedValue.dataValue"/>
632 </xsl:for-each>
633 </xsl:variable>
634 <xsl:call-template name="idtoqname">
635 <xsl:with-param name="id" select="$optname"/>
636 </xsl:call-template>
637 <xsl:text>:</xsl:text>
638 <xsl:choose>
639 <xsl:when test="./UML:ModelElement.taggedValue/UML:TaggedValue[./UML:TaggedValue.type/UML:TagDefinition/@xmi.idref='isbool']">
640 <xsl:text>
641 pResult = createValue(getU32(0x2) &amp; 1);</xsl:text>
642 </xsl:when>
643 <xsl:when test="$typetype='complex'">
644 <xsl:text>
645 pResult = createValue(new </xsl:text>
646 <xsl:value-of select="$valuetype"/>
647 <xsl:text>(getU32(0x2)));</xsl:text>
648 </xsl:when>
649 <xsl:when test="$typetype='string'">
650 <xsl:text>
651 pResult = get_stringValue();&#xa;</xsl:text>
652 </xsl:when>
653 <xsl:otherwise>
654 <xsl:text>
655 pResult = createValue(getU32(0x2));</xsl:text>
656 </xsl:otherwise>
657 </xsl:choose>
658 <xsl:text>
659 break;</xsl:text>
660 </xsl:if>
661 </xsl:for-each>
662 <xsl:text>
663 default:
664 pResult = createValue(getU32(0x2));
666 break;
669 return pResult;
670 }</xsl:text>
671 </xsl:template>
673 <xsl:template match='UML:Model/UML:Namespace.ownedElement' mode='ww8foptename'>
674 <xsl:text>
675 rtl::OUString WW8FOPTE::get_name()
677 return getDffOptName(get_pid());
678 }</xsl:text>
679 <xsl:call-template name="getdffoptname"/>
680 <xsl:text>
682 WW8Value::Pointer_t WW8FOPTE::get_stringValue()
684 WW8Value::Pointer_t pResult;
685 DffOPT * pOpt = dynamic_cast &lt; DffOPT * &gt;(mpParent);
686 sal_uInt32 nExtraOffset = pOpt->get_extraoffset(mnIndex);
687 sal_uInt32 nExtraLength = pOpt->get_extraoffset(mnIndex + 1) - nExtraOffset;
688 pResult = createValue(mpParent->getString(nExtraOffset, nExtraLength / 2));
690 return pResult;
692 </xsl:text>
693 <xsl:call-template name="ww8foptegetvalue"/>
694 </xsl:template>
696 <xsl:template match="UML:Model" mode="createdffrecord">
697 <xsl:text>
698 DffRecord * createDffRecord
699 (WW8StructBase * pParent, sal_uInt32 nOffset, sal_uInt32 * pCount)
701 DffRecord * pResult = NULL;
702 DffRecord aTmpRec(pParent, nOffset, 8);
703 sal_uInt32 nSize = aTmpRec.calcSize();
705 if (pCount != NULL)
706 *pCount = nSize;
708 switch (aTmpRec.getRecordType())
709 {&#xa;</xsl:text>
710 <xsl:for-each select='.//UML:Class[.//UML:Stereotype/@xmi.idref="dffrecord"]'>
711 <xsl:text> case </xsl:text>
712 <xsl:value-of select=".//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref='dffid']//UML:TaggedValue.dataValue"/>
713 <xsl:text>:
714 pResult = new Dff</xsl:text>
715 <xsl:value-of select="@name"/>
716 <xsl:text>(pParent, nOffset, nSize);
718 break;&#xa;</xsl:text>
719 </xsl:for-each>
720 <xsl:text>
721 default:
722 pResult = new DffRecord(pParent, nOffset, nSize);
724 break;
727 return pResult;
730 DffRecord * createDffRecord
731 (WW8Stream &amp; rStream, sal_uInt32 nOffset, sal_uInt32 * pCount)
733 DffRecord * pResult = NULL;
734 DffRecord aTmpRec(rStream, nOffset, 8);
735 sal_uInt32 nSize = aTmpRec.calcSize();
737 if (pCount != NULL)
738 *pCount = nSize;
740 switch (aTmpRec.getRecordType())
741 {&#xa;</xsl:text>
742 <xsl:for-each select='.//UML:Class[.//UML:Stereotype/@xmi.idref="dffrecord"]'>
743 <xsl:text> case </xsl:text>
744 <xsl:value-of select=".//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref='dffid']//UML:TaggedValue.dataValue"/>
745 <xsl:text>:
746 pResult = new Dff</xsl:text>
747 <xsl:value-of select="@name"/>
748 <xsl:text>(rStream, nOffset, nSize);
750 break;&#xa;</xsl:text>
751 </xsl:for-each>
752 <xsl:text>
753 default:
754 pResult = new DffRecord(rStream, nOffset, nSize);
756 break;
759 return pResult;
761 </xsl:text>
762 </xsl:template>
764 <xsl:template match="UML:Attribute" mode="initmembers">
765 <xsl:variable name="stereotype"><xsl:value-of select=".//UML:Stereotype/@xmi.idref"/></xsl:variable>
766 <xsl:variable name="offset_"><xsl:value-of select='translate(.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="offset"]/UML:TaggedValue.dataValue, "ABCDEFX", "abcdefx")'/></xsl:variable>
767 <xsl:variable name="offset">
768 <xsl:if test='$offset_ != "" and not(starts-with($offset_, "0x"))'>0x</xsl:if>
769 <xsl:value-of select='$offset_'/>
770 </xsl:variable>
771 <xsl:variable name="shift"><xsl:value-of select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="shift"]/UML:TaggedValue.dataValue'/></xsl:variable>
772 <xsl:variable name="mask_"><xsl:value-of select='translate(.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="mask"]/UML:TaggedValue.dataValue, "ABCDEFX", "abcdefx")'/></xsl:variable>
773 <xsl:variable name="mask">
774 <xsl:if test='$mask_ != "" and not(starts-with($mask_, "0x"))'>0x</xsl:if>
775 <xsl:value-of select='$mask_'/>
776 </xsl:variable>
777 <xsl:variable name="type"><xsl:value-of select='.//UML:DataType/@xmi.idref'/></xsl:variable><xsl:variable name="saltype">
778 <xsl:call-template name='saltype'>
779 <xsl:with-param name='type'>
780 <xsl:value-of select='$type'/>
781 </xsl:with-param>
782 </xsl:call-template>
783 </xsl:variable>
786 <xsl:value-of select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="comment"]/UML:TaggedValue.dataValue'/>
788 Name: <xsl:value-of select='@name'/>(<xsl:value-of select='$stereotype'/>)
789 Offset: <xsl:value-of select='$offset'/>
790 Mask: <xsl:value-of select='$mask'/>
791 Shift: <xsl:value-of select='$shift'/>
794 <xsl:choose>
795 <xsl:when test='$stereotype = "attribute"'>
796 m<xsl:value-of select='@name'/> = (get<xsl:value-of select="$type"/>(<xsl:value-of select="$offset"/>)<xsl:if test="string-length($mask)>0"> &amp; <xsl:value-of select="$mask"/></xsl:if>)<xsl:if test="$shift>0"> &gt;&gt; <xsl:value-of select="$shift"/></xsl:if>;
797 </xsl:when>
798 <xsl:when test='$stereotype = "array"'>
799 <xsl:text>
801 sal_uInt32 nCount = </xsl:text>
802 <xsl:value-of select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref = "arraycount"]/UML:TaggedValue.dataValue'/>
803 <xsl:text>;
804 m</xsl:text>
805 <xsl:value-of select='@name'/>
806 <xsl:text> = new </xsl:text><xsl:value-of select='$saltype'/><xsl:text>[nCount];
808 for (sal_uInt32 n = 0; n &lt; nCount; ++n)
809 m</xsl:text><xsl:value-of select='@name'/><xsl:text>[n] = get</xsl:text>
810 <xsl:value-of select='$type'/>
811 <xsl:text>(</xsl:text>
812 <xsl:value-of select='$offset'/>
813 <xsl:text> + nIndex * sizeof(</xsl:text>
814 <xsl:value-of select='$saltype'/>
815 <xsl:text>));
817 </xsl:text>
818 </xsl:when>
819 <xsl:when test='$stereotype = "string"'>
820 m<xsl:value-of select='@name'/> = getString(<xsl:value-of select='$offset'/>)
821 </xsl:when>
822 </xsl:choose>
823 </xsl:template>
825 <xsl:template match="UML:Model" mode="isbooleandffopt">
826 <xsl:text>
827 bool isBooleanDffOpt(sal_uInt32 nId)
829 bool bResult = false;
831 switch (nId)
832 {&#xa;</xsl:text>
833 <xsl:for-each select='.//UML:Class[.//UML:Stereotype/@xmi.idref="dffopt"]'>
834 <xsl:if test=".//UML:TagDefinition[@xmi.idref='isbool']">
835 <xsl:text> case </xsl:text>
836 <xsl:variable name="optname">
837 <xsl:value-of select=".//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref='optname']//UML:TaggedValue.dataValue"/>
838 </xsl:variable>
839 <xsl:call-template name="idtoqname">
840 <xsl:with-param name="id" select="$optname"/>
841 </xsl:call-template>
842 <xsl:text>:&#xa;</xsl:text>
843 </xsl:if>
844 </xsl:for-each>
845 <xsl:text>
846 bResult = true;
847 break;
849 default:
850 break;
853 return bResult;
855 </xsl:text>
856 </xsl:template>
858 </xsl:stylesheet>