bump product version to 4.1.6.2
[LibreOffice.git] / writerfilter / source / doctok / resourcesimpl.xsl
blobd0b714dc36fc9af1dc2ba9ed5d3ba8039b46b963
1 <!--
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 .
17 -->
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:include href="resourcetools.xsl"/>
24 <xsl:template match="/">
25 <xsl:call-template name="licenseheader"/>
26 <xsl:text>
27 #include &lt;doctok/resources.hxx&gt;
29 #ifndef WW8_OUTPUT_WITH_DEPTH
30 #include &lt;doctok/WW8OutputWithDepth.hxx&gt;
31 #endif
33 #ifndef INCLUDED_SPRMIDS_HXX
34 #include &lt;doctok/sprmids.hxx&gt;
35 #endif
37 namespace writerfilter {
38 namespace doctok {
40 extern WW8OutputWithDepth output;
42 using namespace ::std;
43 </xsl:text>
44 <xsl:apply-templates select='/XMI/XMI.content/UML:Model' mode="sprmkind"/>
45 <xsl:apply-templates select='.//UML:Class' mode='class'/>
46 <xsl:apply-templates select='//UML:Model' mode='createsprmprops'/>
47 <xsl:apply-templates select='/XMI/XMI.content/UML:Model'
48 mode='createsprmbinary'/>
49 <xsl:apply-templates select='/XMI/XMI.content/UML:Model'
50 mode='createdffrecord'/>
51 <xsl:apply-templates select='/XMI/XMI.content/UML:Model' mode='ww8foptename'/>
52 <xsl:apply-templates select='/XMI/XMI.content/UML:Model'
53 mode='isbooleandffopt'/>
54 <xsl:text>
56 </xsl:text>
57 </xsl:template>
59 <xsl:template match="UML:Class" mode="class">
60 <xsl:choose>
61 <xsl:when test='.//UML:Stereotype[@xmi.idref = "ww8resource"]'>
62 <xsl:apply-templates select="." mode="ww8resource">
63 <xsl:with-param name="classprefix">WW8</xsl:with-param>
64 <xsl:with-param name="needsinit">true</xsl:with-param>
65 </xsl:apply-templates>
66 </xsl:when>
67 <xsl:when test='.//UML:Stereotype[@xmi.idref = "dffrecord"]'>
68 <xsl:apply-templates select="." mode="ww8resource">
69 <xsl:with-param name="classprefix">Dff</xsl:with-param>
70 </xsl:apply-templates>
71 </xsl:when>
72 </xsl:choose>
73 </xsl:template>
75 <xsl:template match="UML:Class" mode="ww8resource">
76 <xsl:param name="classprefix"/>
77 <xsl:param name="needsinit"/>
78 <xsl:variable name="parentresource">
79 <xsl:call-template name='parenttype'>
80 <xsl:with-param name='type'><xsl:value-of select='@xmi.id'/></xsl:with-param>
81 </xsl:call-template>
82 </xsl:variable>
83 <xsl:variable name='size_'><xsl:value-of select='./*/UML:TaggedValue[./*/UML:TagDefinition/@xmi.idref="size"]/UML:TaggedValue.dataValue'/></xsl:variable>
84 <xsl:variable name='size'>
85 <xsl:choose>
86 <xsl:when test='$size_ != ""'><xsl:value-of select='$size_'/></xsl:when>
87 <xsl:otherwise>0</xsl:otherwise>
88 </xsl:choose>
89 </xsl:variable>
90 <xsl:variable name="classname"><xsl:value-of select="$classprefix"/><xsl:value-of select="@name"/></xsl:variable>
91 <xsl:variable name="superclass">
92 <xsl:choose>
93 <xsl:when test='.//UML:Stereotype[@xmi.idref = "ww8sprm"]'>WW8PropertyImpl</xsl:when>
94 <xsl:otherwise>WW8StructBase</xsl:otherwise>
95 </xsl:choose>
96 </xsl:variable>
97 <xsl:variable name="surroundclass">
98 <xsl:choose>
99 <xsl:when test='.//UML:Stereotype[@xmi.idref = "ww8sprm"]'>WW8PropertyImpl</xsl:when>
100 <xsl:otherwise>WW8StructBase</xsl:otherwise>
101 </xsl:choose>
102 </xsl:variable>
103 <xsl:text>
105 Automatically generated class: </xsl:text><xsl:value-of select="@name"/><xsl:text>
106 </xsl:text>
107 <xsl:for-each select='./UML:ModelElement.stereotype/UML:Stereotype'>
108 <xsl:text>
109 Stereotype </xsl:text>
110 <xsl:value-of select='@xmi.idref'/>
111 <xsl:text>&#xa;</xsl:text>
112 </xsl:for-each>
113 <xsl:text>
114 Parent Resource: </xsl:text>
115 <xsl:value-of select="$parentresource"/>
116 <xsl:text>
117 Size: </xsl:text><xsl:value-of select='$size'/>
118 <xsl:text>
120 </xsl:text>
122 <xsl:value-of select="$classname"/>
123 <xsl:text>::~</xsl:text>
124 <xsl:value-of select="$classname"/>
125 <xsl:text>()
128 </xsl:text>
129 <xsl:if test="$needsinit='true'">
130 <xsl:text>
131 void </xsl:text>
132 <xsl:value-of select="$classname"/>
133 <xsl:text>::init()
135 </xsl:text>
136 <xsl:if test='.//UML:Stereotype[@xmi.idref ="withmembers"]'>
137 <xsl:for-each select='.//UML:Attribute[@name!="reserved"]'>
138 <xsl:apply-templates select='.' mode='initmembers'/>
139 </xsl:for-each>
140 </xsl:if>
141 <xsl:if test='.//UML:Stereotype[@xmi.idref ="initimpl"]'>
142 <xsl:text> initImpl();&#xa;</xsl:text>
143 </xsl:if>
144 <xsl:text>
145 }&#xa;</xsl:text>
146 </xsl:if>
148 <xsl:choose>
149 <xsl:when test='$parentresource="Properties"'>
150 <xsl:apply-templates select="." mode="resolveProperties">
151 <xsl:with-param name="classname" select="$classname"/>
152 </xsl:apply-templates>
153 </xsl:when>
154 <xsl:when test='$parentresource="Table"'>
155 <xsl:apply-templates select="." mode="resolveTable">
156 <xsl:with-param name="classname" select="$classname"/>
157 </xsl:apply-templates>
158 </xsl:when>
159 </xsl:choose>
161 </xsl:template>
163 <xsl:template match="UML:Class" mode="resolveProperties">
164 <xsl:param name="classname"/>
165 <xsl:variable name="rHandler">
166 <xsl:choose>
167 <xsl:when test='.//UML:Attribute[@name!="reserved"]'>
168 <xsl:if test='.//UML:Stereotype[@xmi.idref != "noresolve"]'>
169 <xsl:text>rHandler</xsl:text>
170 </xsl:if>
171 </xsl:when>
172 <xsl:when test='.//UML:Operation[@name!="reserved"]'>
173 <xsl:if test='.//UML:Stereotype[@xmi.idref != "noresolve"]'>
174 <xsl:text>rHandler</xsl:text>
175 </xsl:if>
176 </xsl:when>
177 <xsl:when test='.//UML:Stereotype[@xmi.idref = "resolvenoauto"]'>
178 <xsl:text>rHandler</xsl:text>
179 </xsl:when>
180 </xsl:choose>
181 </xsl:variable>
182 <xsl:text>
183 void </xsl:text>
184 <xsl:value-of select="$classname"/>
185 <xsl:choose>
186 <xsl:when test=".//UML:Stereotype[@xmi.idref='ww8resource']">
187 <xsl:text>::resolve(Properties &amp; </xsl:text>
188 <xsl:value-of select="$rHandler"/>
189 <xsl:text>)</xsl:text>
190 </xsl:when>
191 <xsl:when test=".//UML:Stereotype[@xmi.idref='dffrecord']">
192 <xsl:text>::resolveLocal(Properties &amp; </xsl:text>
193 <xsl:value-of select="$rHandler"/>
194 <xsl:text>)</xsl:text>
195 </xsl:when>
196 </xsl:choose>
197 <xsl:text>
198 {</xsl:text>
199 <xsl:if test='.//UML:Stereotype[@xmi.idref="debug"]'>
200 <xsl:text>
201 dump(output);</xsl:text>
202 </xsl:if>
203 <xsl:text>
204 try
205 {</xsl:text>
206 <xsl:for-each select='.//UML:Attribute[@name!="reserved"]'>
207 <xsl:choose>
208 <xsl:when test='.//UML:Stereotype[@xmi.idref="noresolve"]'>
209 </xsl:when>
210 <xsl:otherwise>
211 <xsl:apply-templates select='.' mode='resolveAttribute'/>
212 </xsl:otherwise>
213 </xsl:choose>
214 </xsl:for-each>
215 <xsl:for-each select='.//UML:Operation[@name!="reserved"]'>
216 <xsl:choose>
217 <xsl:when test='.//UML:Stereotype[@xmi.idref="noresolve"]'>
218 </xsl:when>
219 <xsl:otherwise>
220 <xsl:apply-templates select='.' mode='resolveOperation'/>
221 </xsl:otherwise>
222 </xsl:choose>
223 </xsl:for-each>
225 <xsl:if test='.//UML:Stereotype[@xmi.idref = "resolvenoauto"]'>
226 resolveNoAuto(rHandler);
227 </xsl:if>
228 <xsl:text>
229 } catch (const Exception &amp; e) {
230 clog &lt;&lt; e.getText() &lt;&lt; endl;
234 void
235 </xsl:text>
236 <xsl:value-of select="$classname"/>
237 <xsl:text>::dump(OutputWithDepth &lt; string &gt; &amp; o) const
239 o.addItem("&lt;dump type='</xsl:text>
240 <xsl:value-of select='@name'/>
241 <xsl:text>'&gt;");
243 WW8StructBase::dump(o);</xsl:text>
244 <xsl:for-each select='.//UML:Attribute[@name!="reserved"]'>
245 <xsl:apply-templates select='.' mode='dumpAttribute'/>
246 </xsl:for-each>
248 <xsl:text>
249 o.addItem("&lt;/dump&gt;");
250 }&#xa;</xsl:text>
251 </xsl:template>
253 <xsl:template match='UML:Attribute' mode='resolveAttribute'>
254 <xsl:variable name="attrid">
255 <xsl:for-each select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="attrid"]'>
256 <xsl:value-of select='UML:TaggedValue.dataValue'/>
257 </xsl:for-each>
258 </xsl:variable>
259 <xsl:variable name="qname">
260 <xsl:call-template name='idtoqname'>
261 <xsl:with-param name='id'>
262 <xsl:value-of select='$attrid'/>
263 </xsl:with-param>
264 </xsl:call-template>
265 </xsl:variable>
266 <xsl:choose>
267 <xsl:when test='.//UML:Stereotype/@xmi.idref = "attribute"'>
268 <xsl:text>
270 WW8Value::Pointer_t pVal = createValue(get_</xsl:text>
271 <xsl:value-of select="@name"/>
272 <xsl:text>());
273 rHandler.attribute(</xsl:text>
274 <xsl:value-of select="$qname"/>
275 <xsl:text>, *pVal);
276 }</xsl:text>
277 </xsl:when>
278 <xsl:when test='.//UML:Stereotype/@xmi.idref = "array"'>
279 <xsl:variable name="elementtype">
280 <xsl:value-of select='.//UML:DataType/@xmi.idref'/>
281 </xsl:variable>
282 <xsl:variable name="parentclass">
283 <xsl:call-template name='parenttype'>
284 <xsl:with-param name='type'>
285 <xsl:value-of select='$elementtype'/>
286 </xsl:with-param>
287 </xsl:call-template>
288 </xsl:variable>
289 <xsl:text>
291 sal_uInt32 nCount = get_</xsl:text>
292 <xsl:value-of select="@name"/>
293 <xsl:text>_count();
294 for (sal_uInt32 n = 0; n &lt; nCount; ++n)
296 WW8Value::Pointer_t pVal = createValue(get_</xsl:text>
297 <xsl:value-of select="@name"/>
298 <xsl:text>(n));
299 rHandler.attribute(</xsl:text>
300 <xsl:value-of select="$qname"/>
301 <xsl:text>, *pVal);
303 }</xsl:text>
304 </xsl:when>
305 <xsl:when test='.//UML:Stereotype/@xmi.idref = "string"'>
306 <xsl:text>
308 WW8StringValue aVal(get_</xsl:text>
309 <xsl:value-of select='@name'/>
310 <xsl:text>());
311 rHandler.attribute(</xsl:text>
312 <xsl:value-of select="$qname"/>
313 <xsl:text>, aVal);
314 }</xsl:text>
315 </xsl:when>
316 </xsl:choose>
317 </xsl:template>
319 <xsl:template match='UML:Attribute' mode='dumpAttribute'>
320 <xsl:variable name="type">
321 <xsl:value-of select='.//UML:DataType/@xmi.idref'/>
322 </xsl:variable><xsl:variable name="saltype">
323 <xsl:call-template name='saltype'>
324 <xsl:with-param name='type'>
325 <xsl:value-of select='$type'/>
326 </xsl:with-param>
327 <xsl:with-param name='parenttype'>
328 <xsl:apply-templates select="." mode="parentclass"/>
329 </xsl:with-param>
330 </xsl:call-template>
331 </xsl:variable>
332 <xsl:variable name="name" select="@name"/>
333 <xsl:for-each select=".//UML:Stereotype">
334 <xsl:choose>
335 <xsl:when test='@xmi.idref = "attributeremainder"'/>
336 <xsl:when test='@xmi.idref = "array"'>
337 <xsl:text>
339 sal_uInt32 nCount = get_</xsl:text>
340 <xsl:value-of select='$name'/>
341 <xsl:text>_count();
343 for (sal_uInt32 n = 0; n &lt; nCount; ++n)
345 writerfilter::dump(o, "</xsl:text>
346 <xsl:value-of select='$name'/>
347 <xsl:text>", get_</xsl:text>
348 <xsl:value-of select="$name"/>
349 <xsl:text>(n));
351 }</xsl:text>
352 </xsl:when>
353 <xsl:when test='@xmi.idref = "string"'>
354 <xsl:text>
356 WW8StringValue aVal(get_</xsl:text>
357 <xsl:value-of select='$name'/>
358 <xsl:text>());
360 o.addItem("</xsl:text>
361 <xsl:value-of select='$name'/>
362 <xsl:text>" &lt;&lt; "=\"" + aVal.toString() + "\"");
363 }</xsl:text>
364 </xsl:when>
365 <xsl:otherwise>
366 <xsl:text>
367 writerfilter::dump(o, "</xsl:text>
368 <xsl:value-of select='$name'/>
369 <xsl:text>", get_</xsl:text>
370 <xsl:value-of select="$name"/>
371 <xsl:text>());</xsl:text>
372 </xsl:otherwise>
373 </xsl:choose>
374 </xsl:for-each>
375 </xsl:template>
377 <xsl:template name="resolveOperationAttribute">
378 <xsl:variable name="opid">
379 <xsl:for-each select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="opid"]'>
380 <xsl:value-of select='./UML:TaggedValue.dataValue'/>
381 </xsl:for-each>
382 </xsl:variable>
383 <xsl:text>
385 WW8Value::Pointer_t pVal = createValue(get_</xsl:text>
386 <xsl:value-of select="@name"/>
387 <xsl:text>());
388 rHandler.attribute(</xsl:text>
389 <xsl:call-template name='idtoqname'>
390 <xsl:with-param name='id'><xsl:value-of select='$opid'/></xsl:with-param>
391 </xsl:call-template>
392 <xsl:text>, *pVal);
393 }&#xa;</xsl:text>
394 </xsl:template>
396 <xsl:template name="resolveOperationArray">
397 <xsl:variable name="elementtype">
398 <xsl:value-of select='.//UML:Parameter.type/@xmi.idref'/>
399 </xsl:variable>
400 <xsl:variable name="opid">
401 <xsl:for-each select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="opid"]'>
402 <xsl:value-of select='./UML:TaggedValue.dataValue'/>
403 </xsl:for-each>
404 </xsl:variable>
405 <xsl:variable name="parentclass">
406 <xsl:for-each select='/XMI/XMI.content/UML:Model/UML:Namespace.ownedElement/UML:Generalization[UML:Generalization.child/UML:Class/@xmi.idref=$elementtype]'>
407 <xsl:value-of select='./UML:Generalization.parent/UML:Class/@xmi.idref'/>
408 </xsl:for-each>
409 </xsl:variable>
410 <xsl:text>
412 sal_uInt32 nCount = get_</xsl:text>
413 <xsl:value-of select="@name"/>
414 <xsl:text>_count();
416 for (sal_uInt32 n = 0; n &lt; nCount; ++n)
418 WW8Value::Pointer_t pVal = createValue(get_</xsl:text>
419 <xsl:value-of select="@name"/>
420 <xsl:text>(n));
421 rHandler.attribute(</xsl:text>
422 <xsl:call-template name='idtoqname'>
423 <xsl:with-param name='id'><xsl:value-of select='$opid'/></xsl:with-param>
424 </xsl:call-template>
425 <xsl:text>, *pVal);
427 }&#xa;</xsl:text>
428 </xsl:template>
430 <xsl:template name="resolveOperationBinary">
431 <xsl:text>
433 WW8BinaryObjReference::Pointer_t pRef(get_</xsl:text>
434 <xsl:value-of select="@name"/>
435 <xsl:text>());
436 WW8Sprm aSprm(pRef);
438 rHandler.sprm(aSprm);
439 }&#xa;</xsl:text>
440 </xsl:template>
442 <xsl:template match='UML:Operation' mode='resolveOperation'>
443 <xsl:choose>
444 <xsl:when test='.//UML:Stereotype/@xmi.idref = "attribute"'>
445 <xsl:call-template name="resolveOperationAttribute"/>
446 </xsl:when>
447 <xsl:when test='.//UML:Stereotype/@xmi.idref = "array"'>
448 <xsl:call-template name="resolveOperationArray"/>
449 </xsl:when>
450 <xsl:when test='.//UML:Stereotype/@xmi.idref = "binary"'>
451 <xsl:call-template name="resolveOperationBinary"/>
452 </xsl:when>
453 </xsl:choose>
454 </xsl:template>
456 <xsl:template match="UML:Class" mode="resolveTable">
457 <xsl:param name="classname"/>
458 <xsl:text>void </xsl:text>
459 <xsl:value-of select="$classname"/>
460 <xsl:text>::resolve(Table &amp; rHandler)
462 sal_uInt32 nCount = getEntryCount();
463 writerfilter::Reference&lt; Properties &gt;::Pointer_t pEntry;
464 for (sal_uInt32 n = 0; n &lt; nCount; ++n)
466 pEntry = getEntry(n);
468 if (pEntry.get() != 0x0)
470 try
472 rHandler.entry(n, pEntry);
474 catch (const ExceptionOutOfBounds&amp;)
480 </xsl:text>
481 </xsl:template>
483 <xsl:template match='UML:Model' mode='createsprmprops'>
484 writerfilter::Reference &lt; Properties &gt; ::Pointer_t createSprmProps
485 (WW8PropertyImpl &amp; rProp)
487 writerfilter::Reference &lt; Properties &gt; ::Pointer_t pResult;
489 switch (rProp.getId())
491 <xsl:for-each select='.//UML:Class[.//UML:Stereotype/@xmi.idref="ww8sprm" and .//UML:Stereotype/@xmi.idref="ww8resource"]'>
492 case <xsl:value-of select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="sprmcode"]//UML:TaggedValue.dataValue'/>:
493 pResult = writerfilter::Reference &lt; Properties &gt; ::Pointer_t(new WW8<xsl:value-of select='@name'/>(rProp, 0, rProp.getCount()));
495 break;
496 </xsl:for-each>
497 default:
498 break;
501 return pResult;
503 </xsl:template>
505 <xsl:template match='UML:Model' mode='createsprmbinary'>
506 <xsl:text>
507 writerfilter::Reference &lt; BinaryObj &gt; ::Pointer_t createSprmBinary
508 (WW8PropertyImpl &amp; rProp)
510 writerfilter::Reference &lt; BinaryObj &gt; ::Pointer_t pResult;
512 switch (rProp.getId())
513 {&#xa;
514 // warnings....
515 case 0:
516 break;
517 </xsl:text>
518 <xsl:for-each select='.//UML:Class[.//UML:Stereotype/@xmi.idref="ww8sprmbinary" and .//UML:Stereotype/@xmi.idref="ww8resource"]'>
519 case <xsl:value-of select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="sprmcode"]//UML:TaggedValue.dataValue'/>:
521 WW8<xsl:value-of select='@name'/>::Pointer_t p(new WW8<xsl:value-of select='@name'/>(rProp, 0, rProp.getCount()));
523 pResult = p->getBinary();
526 break;
527 </xsl:for-each>
528 <xsl:text>
529 default:
530 break;
533 return pResult;
535 </xsl:text>
536 </xsl:template>
538 <!-- returns optname of UML:Class -->
539 <xsl:template name="optname">
540 <xsl:for-each select="./UML:ModelElement.taggedValue/UML:TaggedValue">
541 <xsl:if test=".//UML:TagDefinition/@xmi.idref='optname'">
542 <xsl:value-of select="./UML:TaggedValue.dataValue"/>
543 </xsl:if>
544 </xsl:for-each>
545 </xsl:template>
547 <xsl:template name="ww8foptenamecase">
548 <xsl:text>
549 case </xsl:text>
550 <xsl:variable name="optname">
551 <xsl:call-template name="optname"/>
552 </xsl:variable>
553 <xsl:call-template name="idtoqname">
554 <xsl:with-param name="id" select="$optname"/>
555 </xsl:call-template>
556 <xsl:text>:
557 result = "</xsl:text>
558 <xsl:value-of select="$optname"/>
559 <xsl:text>";
560 break;</xsl:text>
561 </xsl:template>
563 <xsl:template name="getdffoptname">
564 <xsl:text>
565 OUString getDffOptName(sal_uInt32 nPid)
567 OUString result;
569 switch (nPid)
570 {&#xa;</xsl:text>
571 <xsl:for-each select="./UML:Class[./UML:ModelElement.stereotype/UML:Stereotype/@xmi.idref='dffopt']">
572 <xsl:call-template name="ww8foptenamecase"/>
573 </xsl:for-each>
574 <xsl:text>
575 default:
576 break;
579 return result;
580 }</xsl:text>
581 </xsl:template>
583 <xsl:template name="ww8foptegetvalue">
584 <xsl:text>
585 WW8Value::Pointer_t WW8FOPTE::get_value()
587 WW8Value::Pointer_t pResult;
589 switch (get_pid())
590 {</xsl:text>
591 <xsl:for-each select=".//UML:Class[./UML:ModelElement.stereotype/UML:Stereotype/@xmi.idref='dffopt']">
592 <xsl:variable name="type">
593 <xsl:for-each select="./UML:ModelElement.taggedValue/UML:TaggedValue[./UML:TaggedValue.type/UML:TagDefinition/@xmi.idref='type']">
594 <xsl:value-of select="UML:TaggedValue.dataValue"/>
595 </xsl:for-each>
596 </xsl:variable>
597 <xsl:if test="$type != 'unknown'">
598 <xsl:variable name="typetype">
599 <xsl:call-template name="typetype">
600 <xsl:with-param name="type" select="$type"/>
601 </xsl:call-template>
602 </xsl:variable>
603 <xsl:variable name="valuetype">
604 <xsl:call-template name="valuetype">
605 <xsl:with-param name="type" select="$type"/>
606 </xsl:call-template>
607 </xsl:variable>
608 <xsl:text>
609 case </xsl:text>
610 <xsl:for-each select="./UML:ModelElement.taggedValue/UML:TaggedValue[./UML:TaggedValue.type/UML:TagDefinition/@xmi.idref='dffid']">
611 <xsl:value-of select="UML:TaggedValue.dataValue"/>
612 </xsl:for-each>
613 <xsl:variable name="optname">
614 <xsl:for-each select="./UML:ModelElement.taggedValue/UML:TaggedValue[./UML:TaggedValue.type/UML:TagDefinition/@xmi.idref='optname']">
615 <xsl:value-of select="UML:TaggedValue.dataValue"/>
616 </xsl:for-each>
617 </xsl:variable>
618 <xsl:call-template name="idtoqname">
619 <xsl:with-param name="id" select="$optname"/>
620 </xsl:call-template>
621 <xsl:text>:</xsl:text>
622 <xsl:choose>
623 <xsl:when test="./UML:ModelElement.taggedValue/UML:TaggedValue[./UML:TaggedValue.type/UML:TagDefinition/@xmi.idref='isbool']">
624 <xsl:text>
625 pResult = createValue(getU32(0x2) &amp; 1);</xsl:text>
626 </xsl:when>
627 <xsl:when test="$typetype='complex'">
628 <xsl:text>
629 pResult = createValue(new </xsl:text>
630 <xsl:value-of select="$valuetype"/>
631 <xsl:text>(getU32(0x2)));</xsl:text>
632 </xsl:when>
633 <xsl:when test="$typetype='string'">
634 <xsl:text>
635 pResult = get_stringValue();&#xa;</xsl:text>
636 </xsl:when>
637 <xsl:otherwise>
638 <xsl:text>
639 pResult = createValue(getU32(0x2));</xsl:text>
640 </xsl:otherwise>
641 </xsl:choose>
642 <xsl:text>
643 break;</xsl:text>
644 </xsl:if>
645 </xsl:for-each>
646 <xsl:text>
647 default:
648 pResult = createValue(getU32(0x2));
650 break;
653 return pResult;
654 }</xsl:text>
655 </xsl:template>
657 <xsl:template match='UML:Model/UML:Namespace.ownedElement' mode='ww8foptename'>
658 <xsl:text>
659 OUString WW8FOPTE::get_name()
661 return getDffOptName(get_pid());
662 }</xsl:text>
663 <xsl:call-template name="getdffoptname"/>
664 <xsl:text>
666 WW8Value::Pointer_t WW8FOPTE::get_stringValue()
668 WW8Value::Pointer_t pResult;
669 DffOPT * pOpt = dynamic_cast &lt; DffOPT * &gt;(mpParent);
670 sal_uInt32 nExtraOffset = pOpt->get_extraoffset(mnIndex);
671 sal_uInt32 nExtraLength = pOpt->get_extraoffset(mnIndex + 1) - nExtraOffset;
672 pResult = createValue(mpParent->getString(nExtraOffset, nExtraLength / 2));
674 return pResult;
676 </xsl:text>
677 <xsl:call-template name="ww8foptegetvalue"/>
678 </xsl:template>
680 <xsl:template match="UML:Model" mode="createdffrecord">
681 <xsl:text>
682 DffRecord * createDffRecord
683 (WW8StructBase * pParent, sal_uInt32 nOffset, sal_uInt32 * pCount)
685 DffRecord * pResult = NULL;
686 DffRecord aTmpRec(pParent, nOffset, 8);
687 sal_uInt32 nSize = aTmpRec.calcSize();
689 if (pCount != NULL)
690 *pCount = nSize;
692 switch (aTmpRec.getRecordType())
693 {&#xa;</xsl:text>
694 <xsl:for-each select='.//UML:Class[.//UML:Stereotype/@xmi.idref="dffrecord"]'>
695 <xsl:text> case </xsl:text>
696 <xsl:value-of select=".//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref='dffid']//UML:TaggedValue.dataValue"/>
697 <xsl:text>:
698 pResult = new Dff</xsl:text>
699 <xsl:value-of select="@name"/>
700 <xsl:text>(pParent, nOffset, nSize);
702 break;&#xa;</xsl:text>
703 </xsl:for-each>
704 <xsl:text>
705 default:
706 pResult = new DffRecord(pParent, nOffset, nSize);
708 break;
711 return pResult;
714 DffRecord * createDffRecord
715 (WW8Stream &amp; rStream, sal_uInt32 nOffset, sal_uInt32 * pCount)
717 DffRecord * pResult = NULL;
718 DffRecord aTmpRec(rStream, nOffset, 8);
719 sal_uInt32 nSize = aTmpRec.calcSize();
721 if (pCount != NULL)
722 *pCount = nSize;
724 switch (aTmpRec.getRecordType())
725 {&#xa;</xsl:text>
726 <xsl:for-each select='.//UML:Class[.//UML:Stereotype/@xmi.idref="dffrecord"]'>
727 <xsl:text> case </xsl:text>
728 <xsl:value-of select=".//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref='dffid']//UML:TaggedValue.dataValue"/>
729 <xsl:text>:
730 pResult = new Dff</xsl:text>
731 <xsl:value-of select="@name"/>
732 <xsl:text>(rStream, nOffset, nSize);
734 break;&#xa;</xsl:text>
735 </xsl:for-each>
736 <xsl:text>
737 default:
738 pResult = new DffRecord(rStream, nOffset, nSize);
740 break;
743 return pResult;
745 </xsl:text>
746 </xsl:template>
748 <xsl:template match="UML:Attribute" mode="initmembers">
749 <xsl:variable name="stereotype"><xsl:value-of select=".//UML:Stereotype/@xmi.idref"/></xsl:variable>
750 <xsl:variable name="offset_"><xsl:value-of select='translate(.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="offset"]/UML:TaggedValue.dataValue, "ABCDEFX", "abcdefx")'/></xsl:variable>
751 <xsl:variable name="offset">
752 <xsl:if test='$offset_ != "" and not(starts-with($offset_, "0x"))'>0x</xsl:if>
753 <xsl:value-of select='$offset_'/>
754 </xsl:variable>
755 <xsl:variable name="shift"><xsl:value-of select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="shift"]/UML:TaggedValue.dataValue'/></xsl:variable>
756 <xsl:variable name="mask_"><xsl:value-of select='translate(.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="mask"]/UML:TaggedValue.dataValue, "ABCDEFX", "abcdefx")'/></xsl:variable>
757 <xsl:variable name="mask">
758 <xsl:if test='$mask_ != "" and not(starts-with($mask_, "0x"))'>0x</xsl:if>
759 <xsl:value-of select='$mask_'/>
760 </xsl:variable>
761 <xsl:variable name="type"><xsl:value-of select='.//UML:DataType/@xmi.idref'/></xsl:variable><xsl:variable name="saltype">
762 <xsl:call-template name='saltype'>
763 <xsl:with-param name='type'>
764 <xsl:value-of select='$type'/>
765 </xsl:with-param>
766 </xsl:call-template>
767 </xsl:variable>
770 <xsl:value-of select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="comment"]/UML:TaggedValue.dataValue'/>
772 Name: <xsl:value-of select='@name'/>(<xsl:value-of select='$stereotype'/>)
773 Offset: <xsl:value-of select='$offset'/>
774 Mask: <xsl:value-of select='$mask'/>
775 Shift: <xsl:value-of select='$shift'/>
778 <xsl:choose>
779 <xsl:when test='$stereotype = "attribute"'>
780 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>;
781 </xsl:when>
782 <xsl:when test='$stereotype = "array"'>
783 <xsl:text>
785 sal_uInt32 nCount = </xsl:text>
786 <xsl:value-of select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref = "arraycount"]/UML:TaggedValue.dataValue'/>
787 <xsl:text>;
788 m</xsl:text>
789 <xsl:value-of select='@name'/>
790 <xsl:text> = new </xsl:text><xsl:value-of select='$saltype'/><xsl:text>[nCount];
792 for (sal_uInt32 n = 0; n &lt; nCount; ++n)
793 m</xsl:text><xsl:value-of select='@name'/><xsl:text>[n] = get</xsl:text>
794 <xsl:value-of select='$type'/>
795 <xsl:text>(</xsl:text>
796 <xsl:value-of select='$offset'/>
797 <xsl:text> + nIndex * sizeof(</xsl:text>
798 <xsl:value-of select='$saltype'/>
799 <xsl:text>));
801 </xsl:text>
802 </xsl:when>
803 <xsl:when test='$stereotype = "string"'>
804 m<xsl:value-of select='@name'/> = getString(<xsl:value-of select='$offset'/>)
805 </xsl:when>
806 </xsl:choose>
807 </xsl:template>
809 <xsl:template match="UML:Model" mode="isbooleandffopt">
810 <xsl:text>
811 bool isBooleanDffOpt(sal_uInt32 nId)
813 bool bResult = false;
815 switch (nId)
816 {&#xa;</xsl:text>
817 <xsl:for-each select='.//UML:Class[.//UML:Stereotype/@xmi.idref="dffopt"]'>
818 <xsl:if test=".//UML:TagDefinition[@xmi.idref='isbool']">
819 <xsl:text> case </xsl:text>
820 <xsl:variable name="optname">
821 <xsl:value-of select=".//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref='optname']//UML:TaggedValue.dataValue"/>
822 </xsl:variable>
823 <xsl:call-template name="idtoqname">
824 <xsl:with-param name="id" select="$optname"/>
825 </xsl:call-template>
826 <xsl:text>:&#xa;</xsl:text>
827 </xsl:if>
828 </xsl:for-each>
829 <xsl:text>
830 bResult = true;
831 break;
833 default:
834 break;
837 return bResult;
839 </xsl:text>
840 </xsl:template>
842 </xsl:stylesheet>