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