summaryrefslogtreecommitdiff
path: root/writerfilter/source/doctok/resources.xsl
blob: e1fc68ba5323783212daf076c7b00944a9d4782f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
<!--
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 * 
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

-->
<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#"  
                xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:UML = 'org.omg.xmi.namespace.UML' xml:space="default">
  <xsl:output method="text" />

  <xsl:template match="/">
    <out xml:space="preserve">
      <xsl:text>
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 * 
 * Copyright 2000, 2010 Oracle and/or its affiliates.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * http://www.openoffice.org/license.html
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/
/*      

  THIS FILE IS GENERATED AUTOMATICALLY! DO NOT EDIT!

*/
#ifndef INCLUDED_RESOURCES_HXX
#define INCLUDED_RESOURCES_HXX

#include &lt;vector&gt;
#include &lt;boost/shared_ptr.hpp&gt;

#ifndef INCLUDED_OUTPUT_WITH_DEPTH_HXX
#include &lt;resourcemodel/OutputWithDepth.hxx&gt;
#endif

#ifndef INCLUDED_RESOURCESIDS_HXX
#include &lt;doctok/resourceids.hxx&gt;
#endif

#ifndef INCLUDED_WW8_STRUCT_BASE_HXX
#include &lt;WW8StructBase.hxx&gt;
#endif

#ifndef INCLUDED_WW8_RESOURCE_MODEL_IMPL_HXX
#include &lt;WW8ResourceModelImpl.hxx&gt;
#endif

#ifndef INCLUDED_WW8_PROPERTY_SET_IMPL_HXX
#include &lt;WW8PropertySetImpl.hxx&gt;
#endif

#ifndef INCLUDED_DFF_HXX
#include &lt;Dff.hxx&gt;
#endif

namespace writerfilter {
namespace doctok {

class WW8DocumentImpl;
typedef const WW8DocumentImpl * WW8DocumentImplPointer;

using namespace ::std;&#xa;</xsl:text>
      <xsl:apply-templates select="//UML:Class" mode="class"/>
      <xsl:text>
rtl::OUString getDffOptName(sal_uInt32 nPid);
bool isBooleanDffOpt(sal_uInt32 nId);
}}
#endif // INCLUDED_RESOURCES_HXX&#xa;</xsl:text></out>
</xsl:template>
  
  <xsl:template match="UML:Class" mode="class">
    <xsl:choose>
      <xsl:when test='.//UML:Stereotype[@xmi.idref = "ww8resource"]'>
        <xsl:apply-templates select="." mode="ww8resource"/>
      </xsl:when>
      <xsl:when test='.//UML:Stereotype[@xmi.idref = "dffrecord"]'>
        <xsl:apply-templates select="." mode="dffrecord"/>
      </xsl:when>
      <xsl:when test='.//UML:Stereotype[@xmi.idref = "dffopt"]'>
        <xsl:apply-templates select="." mode="dffopt"/>
      </xsl:when>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="UML:Class" mode="ww8resource">
    <xsl:variable name="parentresource">
      <xsl:call-template name='parenttype'>
        <xsl:with-param name='type'><xsl:value-of select='@xmi.id'/></xsl:with-param>
      </xsl:call-template>
    </xsl:variable>
    <xsl:variable name='size_'><xsl:value-of select='./*/UML:TaggedValue[./*/UML:TagDefinition/@xmi.idref="size"]/UML:TaggedValue.dataValue'/></xsl:variable>
    <xsl:variable name='size'>
      <xsl:choose>
        <xsl:when test='$size_ != ""'><xsl:value-of select='$size_'/></xsl:when>
        <xsl:otherwise>0</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="classname">WW8<xsl:value-of select="@name"/></xsl:variable>
    <xsl:variable name="superclass">
      <xsl:choose>
        <xsl:when test='.//UML:Stereotype[@xmi.idref = "ww8sprm"]'>WW8PropertyImpl</xsl:when>
        <xsl:otherwise>WW8StructBase</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="surroundclass">
      <xsl:choose>
        <xsl:when test='.//UML:Stereotype[@xmi.idref = "ww8sprm"]'>WW8PropertyImpl</xsl:when>
        <xsl:otherwise>WW8StructBase</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:text>
/**
    Automatically generated class: </xsl:text><xsl:value-of select="@name"/><xsl:text>
    </xsl:text>
    <xsl:for-each select='./UML:ModelElement.stereotype/UML:Stereotype'>
      <xsl:text>
    Stereotype </xsl:text>
      <xsl:value-of select='@xmi.idref'/>
      <xsl:text>&#xa;</xsl:text>
    </xsl:for-each>
    <xsl:text>
    Parent Resource: </xsl:text>
    <xsl:value-of select="$parentresource"/>
    <xsl:text>
    Size: </xsl:text><xsl:value-of select='$size'/>
    <xsl:text>
*/
class </xsl:text>
    <xsl:value-of select="$classname"/>
    <xsl:text>: public </xsl:text>
    <xsl:value-of select='$superclass'/>
    <xsl:if test='$parentresource != ""'>
      <xsl:text>, public writerfilter::Reference&lt; </xsl:text>
      <xsl:value-of select='$parentresource'/>
      <xsl:text>&gt;</xsl:text>
    </xsl:if>
    <xsl:text>
{</xsl:text>
    <xsl:if test='.//UML:Stereotype[@xmi.idref ="withindex"]'>
     <xsl:text>    sal_uInt32 mnIndex;</xsl:text>
    </xsl:if>
    <xsl:if test='.//UML:Stereotype[@xmi.idref ="withmembers"]'>
      <xsl:for-each select='.//UML:Attribute[@name!="reserved"]'>
        <xsl:apply-templates select='.' mode='declmembers'/>
      </xsl:for-each>
    </xsl:if>
    <xsl:if test='.//UML:Stereotype[@xmi.idref ="needsdocument"]'>
      <xsl:text>    WW8DocumentImplPointer mpDoc;&#xa;</xsl:text>
    </xsl:if>
    <xsl:if test='.//UML:Stereotype[@xmi.idref ="plcf"]'>
      <xsl:text>
    sal_uInt32 mnPlcfPayloadOffset;
    vector&lt;sal_uInt32&gt; entryOffsets;
    vector&lt;sal_uInt32&gt; payloadOffsets;
    vector&lt;sal_uInt32&gt; payloadIndices;
      </xsl:text>
    </xsl:if>
    <xsl:text>
    public:
    typedef boost::shared_ptr&lt;</xsl:text>
    <xsl:value-of select='$classname'/>
    <xsl:text>&gt; Pointer_t;

    </xsl:text>
    <xsl:value-of select="$classname"/>
    <xsl:text>(
        WW8Stream &amp; rStream, 
        sal_uInt32 nOffset = 0, 
        sal_uInt32 nCount = </xsl:text>
    <xsl:value-of select='$size'/>
    <xsl:text>)
    : </xsl:text><xsl:value-of select='$superclass'/>
    <xsl:text>(rStream, nOffset, nCount)</xsl:text>
    <xsl:if test='.//UML:Stereotype[@xmi.idref ="withindex"]'>
      <xsl:text>, mnIndex(0)</xsl:text>
    </xsl:if>
    <xsl:text>
    {
      init();
    }
    </xsl:text>
    <xsl:value-of select="$classname"/>
    <xsl:text>(
        WW8StructBase * pParent,
        sal_uInt32 nOffset = 0, 
        sal_uInt32 nCount = </xsl:text>
        <xsl:value-of select='$size'/>
        <xsl:text>)
    : </xsl:text>
    <xsl:value-of select='$superclass'/>
    <xsl:text>(pParent, nOffset, nCount)</xsl:text>
    <xsl:if test='.//UML:Stereotype[@xmi.idref ="withindex"]'>
      <xsl:text>, mnIndex(0)</xsl:text>
    </xsl:if>
    <xsl:text>
    {
      init();
    }&#xa;    </xsl:text>
    <xsl:value-of select="$classname"/>
    <xsl:text>( const </xsl:text>
    <xsl:value-of select='$surroundclass'/>
    <xsl:text>&amp; rSurround,
    sal_uInt32 nOffset = 0, sal_uInt32 nCount = </xsl:text>
    <xsl:value-of select='$size'/>)
    <xsl:text>
    : </xsl:text>
    <xsl:value-of select='$superclass'/>
    <xsl:text>(rSurround, nOffset, nCount)</xsl:text>
    <xsl:if test='.//UML:Stereotype[@xmi.idref ="withindex"]'>
      <xsl:text>, mnIndex(0)</xsl:text>
    </xsl:if>
    <xsl:text>
    {
        init();
    }&#xa;
    </xsl:text>
    <xsl:value-of select="$classname"/>
    <xsl:text>(
        const Sequence &amp; 
        rSequence, sal_uInt32 nOffset = 0, 
        sal_uInt32 nCount = </xsl:text>
        <xsl:value-of select='$size'/>
        <xsl:text>)
    : </xsl:text>
    <xsl:value-of select='$superclass'/>
    <xsl:text>(rSequence, nOffset, nCount)</xsl:text>
    <xsl:if test='.//UML:Stereotype[@xmi.idref ="withindex"]'>
      <xsl:text>, mnIndex(0)</xsl:text>
    </xsl:if>
    <xsl:text>
    {
      init();
    }

    virtual ~</xsl:text>
    <xsl:value-of select="$classname"/>
    <xsl:text>();&#xa;</xsl:text>
    <xsl:if test='.//UML:Stereotype[@xmi.idref ="initimpl"]'>
      <xsl:text>    void initImpl();&#xa;</xsl:text>
    </xsl:if>
    <xsl:if test='.//UML:Stereotype[@xmi.idref ="plcf"]'>
      <xsl:text>    void initPayload();</xsl:text>
    </xsl:if>
    <xsl:text>
    void init();

    /**
        Return type of resource.
    */
    virtual string getType() const
    {
        return "</xsl:text>
    <xsl:value-of select="@name"/>
    <xsl:text>";
    }

    /**
        Return static size.
    */
    static sal_uInt32 getSize() { return </xsl:text>
    <xsl:value-of select='$size'/>
    <xsl:text>; }

    /**
        Calculate actual size.
    */  
    sal_uInt32 calcSize();

    </xsl:text>
    <xsl:if test='.//UML:Stereotype[@xmi.idref ="plcf"]'>
      <xsl:text>
    /**
        Return offset for entry of PLCF.

        @param nIndex      index of entry
    */
    sal_uInt32 getEntryOffset(sal_uInt32 nIndex)
    {
        return entryOffsets[nIndex];
    }   

    /**
        Calculate offset for payload.
    */
    sal_uInt32 calcPayloadOffset();

    /**
    Set offset for payloads.

    @param nOffset    the offset to set
    */
    void setPayloadOffset(sal_uInt32 nOffset)
    {
    mnPlcfPayloadOffset = nOffset;
    }

    /**
    Return offset for payload of PLCF.

    @param nIndex      index of entry
    */
    sal_uInt32 getPayloadOffset(sal_uInt32 nIndex)
    {
    return payloadOffsets[nIndex];
    }

    /**
    Return size of payload.
    */
    sal_uInt32 getPayloadSize(sal_uInt32 nIndex) const
    {
    return payloadOffsets[nIndex + 1] - payloadOffsets[nIndex];
    }  


    /**
    Return payload index of an entry.

    */
    sal_uInt32 getPayloadIndex(sal_uInt32 nIndex)
    {
    return payloadIndices[nIndex];
    }
      </xsl:text>
    </xsl:if>
    <xsl:if test='.//UML:Stereotype[@xmi.idref ="withindex"]'>
      <xsl:text>
    /**
        Set index in parent.

        @param    nIndex    the index
    */
    void setIndex(sal_uInt32 nIndex) { mnIndex = nIndex; }
      </xsl:text>
    </xsl:if>
    <xsl:if test='.//UML:Stereotype[@xmi.idref ="ww8sprm"]'>
      <xsl:variable name='propsreftype'>writerfilter::Reference &lt; Properties &gt;::Pointer_t</xsl:variable>      
      <xsl:text>    /**
      Return reference to properties of Sprm.
    */
      </xsl:text>
      <xsl:value-of select='$propsreftype'/>
      <xsl:text> getProps()
    { 
        return </xsl:text>
        <xsl:value-of select='$propsreftype'/>
        <xsl:text> (new </xsl:text>
        <xsl:value-of select='$classname'/>
        <xsl:text>(*this)); 
    }
        </xsl:text>
    </xsl:if>

    <xsl:if test='.//UML:Stereotype[@xmi.idref ="ww8sprmbinary"]'>
      <xsl:text>
        virtual writerfilter::Reference &lt; BinaryObj &gt; ::Pointer_t getBinary();
      </xsl:text>
    </xsl:if>

    <xsl:if test='.//UML:Stereotype[@xmi.idref ="needsdocument"]'>
      <xsl:text>
    void setDoc(WW8DocumentImplPointer pDoc)
    {
        mpDoc = pDoc;
    }
      </xsl:text>
    </xsl:if>
    <xsl:apply-templates select="." mode="declsProperties"/>
    <xsl:if test='$parentresource="Table"'>
      <xsl:apply-templates select="." mode="declsTable"/>
    </xsl:if>
    <xsl:choose>
      <xsl:when test='$parentresource="Properties"'>
        <xsl:apply-templates select="." mode="resolveProperties"/>
      </xsl:when>
      <xsl:when test='$parentresource="Table"'>
        <xsl:apply-templates select="." mode="resolveTable"/>
      </xsl:when>
    </xsl:choose>
    <xsl:text>
  };
    </xsl:text>
  </xsl:template>
  
<xsl:template match='UML:Class' mode='declsProperties'>
  <xsl:choose>
    <xsl:when test='.//UML:Stereotype[@xmi.idref ="withmembers"]'>
      <xsl:for-each select='.//UML:Attribute[@name!="reserved"]'>
        <xsl:apply-templates select='.' mode='accessmembers'/>
      </xsl:for-each>
    </xsl:when>
    <xsl:otherwise>
      <xsl:variable name="debug">
        <xsl:choose>
          <xsl:when test='.//UML:Stereotype[@xmi.idref="debug"]'>
            <xsl:text>true</xsl:text>
          </xsl:when>
          <xsl:otherwise>
            <xsl:text>false</xsl:text>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:variable>
      <xsl:for-each select='.//UML:Attribute[@name!="reserved"]'>
        <xsl:apply-templates select='.' mode='access'>
          <xsl:with-param name="debug">
            <xsl:value-of select="$debug"/>
          </xsl:with-param>
        </xsl:apply-templates>
      </xsl:for-each>
    </xsl:otherwise>
  </xsl:choose>
  <xsl:for-each select='.//UML:Operation[@name!="reserved"]'>
    <xsl:apply-templates select='.' mode='declsOperations'/>
  </xsl:for-each>
</xsl:template>

<xsl:template match="UML:Class" mode="resolveProperties">
  <xsl:if test='.//UML:Stereotype[@xmi.idref = "resolvenoauto"]'>
    void resolveNoAuto(Properties &amp; rHandler);
  </xsl:if>

  void dump(OutputWithDepth &lt; string &gt; &amp; o) const;

  void resolve(Properties &amp; rHandler);
</xsl:template>

<xsl:template match="UML:Class" mode="declsTable">
  sal_uInt32 getEntryCount();
  writerfilter::Reference&lt; Properties &gt;::Pointer_t getEntry(sal_uInt32 nIndex);
</xsl:template>

<xsl:template match="UML:Class" mode="resolveTable">
  void resolve(Table &amp; rHandler);
</xsl:template>

<xsl:template match="UML:Attribute" mode="access">
  <xsl:param name="debug"/>
  <xsl:variable name="stereotype"><xsl:value-of select=".//UML:Stereotype[1]/@xmi.idref"/></xsl:variable>
  <xsl:variable name="offset_"><xsl:value-of select='translate(.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="offset"]/UML:TaggedValue.dataValue, "ABCDEFX", "abcdefx")'/></xsl:variable>
  <xsl:variable name="offset">
    <xsl:value-of select='$offset_'/>
  </xsl:variable>
  <xsl:variable name="shift"><xsl:value-of select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="shift"]/UML:TaggedValue.dataValue'/></xsl:variable>
  <xsl:variable name="mask_"><xsl:value-of select='translate(.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="mask"]/UML:TaggedValue.dataValue, "ABCDEFX", "abcdefx")'/></xsl:variable>
  <xsl:variable name="mask">
    <xsl:if test='$mask_ != "" and not(starts-with($mask_, "0x"))'>0x</xsl:if>
    <xsl:value-of select='$mask_'/>
  </xsl:variable>
  <xsl:variable name='type'>
    <xsl:value-of select="UML:StructuralFeature.type/UML:DataType/@xmi.idref"/>
  </xsl:variable>
  <xsl:variable name="completetype">
    <xsl:text>WW8</xsl:text>
    <xsl:value-of select="$type"/>
  </xsl:variable>
  <xsl:variable name="saltype">
    <xsl:apply-templates select="." mode="returntype"/>
  </xsl:variable>
  <xsl:variable name='typetype'>
    <xsl:call-template name='typetype'>
      <xsl:with-param name='type'><xsl:value-of select="$type"/></xsl:with-param>
    </xsl:call-template>
  </xsl:variable>
  
    /**
        <xsl:value-of select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="comment"]/UML:TaggedValue.dataValue'/>
        
        &lt;table&gt;
        &lt;tr&gt;
        &lt;th&gt;
        Name
        &lt;/th&gt;
        &lt;td&gt;
        <xsl:value-of select='@name'/>(<xsl:value-of select='$stereotype'/>)
        &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
        &lt;th&gt;
        Offset
        &lt;/th&gt;
        &lt;td&gt;
        <xsl:value-of select='$offset'/>
        &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
        &lt;th&gt;
        Mask
        &lt;/th&gt;
        &lt;td&gt;
        <xsl:value-of select='$mask'/>
        &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
        &lt;th&gt;
        Shift
        &lt;/th&gt;
        &lt;td&gt;
        <xsl:value-of select='$shift'/>
        &lt;/td&gt;
        &lt;/tr&gt;
        &lt;/table&gt;
        */
        
<xsl:choose>
  <xsl:when test='$stereotype = "attribute"'>
    <xsl:if test='././/UML:Stereotype[@xmi.idref="virtual"]'>
      <xsl:text>virtual </xsl:text>
    </xsl:if>
    <xsl:value-of select='$saltype'/> get_<xsl:value-of select='@name'/>() const
    {
    <xsl:if test='$debug="true"'>
      <xsl:text>
        clog &lt;&lt; "&lt;called&gt;</xsl:text>
      <xsl:value-of select="@name"/>
      <xsl:text>&lt;/called&gt;" 
        &lt;&lt; endl;&#xa;
      </xsl:text>
    </xsl:if>
    <xsl:choose>
      <xsl:when test='././/UML:Stereotype[@xmi.idref="attributeremainder"]'>
        <xsl:text>return writerfilter::Reference &lt; BinaryObj &gt;::Pointer_t(new WW8BinaryObjReference(getRemainder(</xsl:text>
        <xsl:value-of select="$offset"/>
        <xsl:text>)));&#xa;</xsl:text>
      </xsl:when>
      <xsl:otherwise>
        <xsl:choose>
          <xsl:when test='$typetype = "complex"'>
            <xsl:text>        return </xsl:text>
            <xsl:value-of select="$saltype"/>
            <xsl:text>(new </xsl:text>
            <xsl:value-of select="$completetype"/>
            <xsl:text>(*this, </xsl:text>
            <xsl:value-of select="$offset"/>
            <xsl:text>));&#xa;</xsl:text>
          </xsl:when>
          <xsl:otherwise>
            <xsl:text>        return (get</xsl:text>
            <xsl:value-of select="$type"/>
            <xsl:text>(</xsl:text>
            <xsl:value-of select="$offset"/>
            <xsl:text>)</xsl:text>
            <xsl:if test="string-length($mask)>0">
              <xsl:text>&amp; </xsl:text>
              <xsl:value-of select="$mask"/>
            </xsl:if>
            <xsl:text>)</xsl:text>
            <xsl:if test="$shift>0">
              <xsl:text>&gt;&gt; </xsl:text>
              <xsl:value-of select="$shift"/>
            </xsl:if>
            <xsl:text>;</xsl:text>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:otherwise>
    </xsl:choose>
    }
  </xsl:when>
  <xsl:when test='$stereotype = "array"'>
    <xsl:text>sal_uInt32 get_</xsl:text>
    <xsl:value-of select='@name'/>
    <xsl:text>_count() const </xsl:text>
    <xsl:choose>
      <xsl:when test='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref = "arraycount"]'>
        <xsl:text>{ return </xsl:text>
        <xsl:value-of select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref = "arraycount"]/UML:TaggedValue.dataValue'/>
        <xsl:text>; }&#xa;</xsl:text>
      </xsl:when>
      <xsl:otherwise>
        <xsl:text>;&#xa;</xsl:text>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:value-of select='$saltype'/>
    <xsl:text> get_</xsl:text>
    <xsl:value-of select='@name'/>
    <xsl:text>(sal_uInt32 nIndex) const {</xsl:text>
    <xsl:choose>
      <xsl:when test="$typetype='complex'">
        <xsl:text> return </xsl:text>
        <xsl:value-of select="$saltype"/>
        <xsl:text>( new </xsl:text>
        <xsl:value-of select="$completetype"/>
        <xsl:text>(static_cast&lt;const WW8StructBase &gt;(*this), </xsl:text>
        <xsl:value-of select="$offset"/>
        <xsl:text> + nIndex * </xsl:text>
        <xsl:value-of select="$completetype"/>
        <xsl:text>::getSize()));</xsl:text>
      </xsl:when>
      <xsl:otherwise>
        <xsl:text> return get</xsl:text>
        <xsl:value-of select='$type'/>
        <xsl:text>(</xsl:text><xsl:value-of select='$offset'/>
        <xsl:text> + nIndex * sizeof(</xsl:text>
        <xsl:value-of select='$saltype'/>
        <xsl:text>))</xsl:text>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:text>; }&#xa;</xsl:text>
  </xsl:when>
  <xsl:when test='$stereotype = "string"'>
    rtl::OUString get_<xsl:value-of select='@name'/>() const { return getString(<xsl:value-of select='$offset'/>); }
  </xsl:when>
</xsl:choose>
</xsl:template>

<xsl:template match='UML:Attribute' mode='accessmembers'>
  <xsl:text>    </xsl:text>
  <xsl:call-template name='saltype'>
    <xsl:with-param name='type'>
      <xsl:value-of select='.//UML:DataType/@xmi.idref'/>
    </xsl:with-param>
  </xsl:call-template>
  <xsl:text> get_</xsl:text>
  <xsl:value-of select='@name'/>
  <xsl:text>() const { return m</xsl:text>
  <xsl:value-of select='@name'/>
  <xsl:text>; }
  </xsl:text>
</xsl:template>


<xsl:template match="UML:Operation" mode="declsOperations">
  <xsl:choose>
    <xsl:when test='.//UML:Stereotype/@xmi.idref = "array"'>
      <xsl:variable name="elementtype">
        <xsl:value-of select='.//UML:Parameter.type/UML:Class/@xmi.idref'/>
      </xsl:variable>
      <xsl:variable name="parentclass">
        <xsl:call-template name='parenttype'>
          <xsl:with-param name='type'>
            <xsl:value-of select='$elementtype'/>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:variable>
      <xsl:variable name='saltype'>
        <xsl:call-template name='saltype'>
          <xsl:with-param name='type'>
            <xsl:value-of select='$elementtype'/>
          </xsl:with-param>
          <xsl:with-param name='parenttype'>
            <xsl:value-of select='$parentclass'/>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:variable>
      /**
      Array: <xsl:value-of select="@name"/>
      ElementType: <xsl:value-of select="$elementtype"/>(<xsl:value-of select="$parentclass"/>)
      */

      sal_uInt32 get_<xsl:value-of select="@name"/>_count();

      <xsl:text>    </xsl:text><xsl:value-of select='$saltype'/> get_<xsl:value-of select="@name"/>(sal_uInt32 pos);
    </xsl:when>
    <xsl:when test='.//UML:Stereotype/@xmi.idref = "attribute" or .//UML:Stereotype/@xmi.idref = "binary"'>
      <xsl:variable name="returntype_">
        <xsl:value-of select='.//UML:Parameter.type/UML:Class/@xmi.idref'/>
      </xsl:variable>
      <xsl:variable name="returntype">
        <xsl:call-template name='saltype'>
          <xsl:with-param name='type'>
            <xsl:value-of select='$returntype_'/>
          </xsl:with-param>
          <xsl:with-param name='parenttype'>
            <xsl:call-template name='parenttype'>
              <xsl:with-param name='type'>
                <xsl:value-of select='$returntype_'/>
              </xsl:with-param>
            </xsl:call-template>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:variable>
      /**
      Operation: <xsl:value-of select="@name"/>
      */

      <xsl:text>    </xsl:text>
      <xsl:value-of select='$returntype'/>
      <xsl:text> get_</xsl:text>
      <xsl:value-of select='@name'/>
      <xsl:text>();&#xa;</xsl:text>
    </xsl:when>
  </xsl:choose>
</xsl:template>

<xsl:template match="UML:Attribute" mode='declmembers'>
  <xsl:text>    </xsl:text>
  <xsl:call-template name='saltype'>
    <xsl:with-param name='type'>
      <xsl:value-of select='.//UML:DataType/@xmi.idref'/>
    </xsl:with-param>
  </xsl:call-template>
  <xsl:text> m</xsl:text>
  <xsl:value-of select="@name"/>
  <xsl:text>;
  </xsl:text>
</xsl:template>

<xsl:template name='idtoqname'>
  <xsl:param name='id'/>NS_<xsl:value-of select='substring-before($id, ":")'/>::LN_<xsl:value-of select='substring-after($id, ":")'/>
</xsl:template>

<xsl:template name='saltype'>
  <xsl:param name='type'/>
  <xsl:param name='parenttype'/>
  <xsl:choose>
    <xsl:when test="$type='U8'">sal_uInt8</xsl:when>
    <xsl:when test="$type='S8'">sal_Int8</xsl:when>
    <xsl:when test="$type='U16'">sal_uInt16</xsl:when>
    <xsl:when test="$type='S16'">sal_Int16</xsl:when>
    <xsl:when test="$type='U32'">sal_uInt32</xsl:when>
    <xsl:when test="$type='S32'">sal_Int32</xsl:when>
    <xsl:when test="$type='String'">rtl::OUString</xsl:when>
    <xsl:when test="$type='Value'">WW8Value::Pointer_t</xsl:when>
    <xsl:when test="$type='Binary'">WW8BinaryObjReference::Pointer_t</xsl:when>
    <xsl:when test="$parenttype=''">
      <xsl:value-of select="$type"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:text>writerfilter::Reference &lt; </xsl:text>
      <xsl:value-of select='$parenttype'/>
      <xsl:text> &gt;::Pointer_t</xsl:text>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template name='typetype'>
  <xsl:param name='type'/><xsl:choose>
  <xsl:when test="$type='U8'">simple</xsl:when>
  <xsl:when test="$type='S8'">simple</xsl:when>
  <xsl:when test="$type='U16'">simple</xsl:when>
  <xsl:when test="$type='S16'">simple</xsl:when>
  <xsl:when test="$type='U32'">simple</xsl:when>
  <xsl:when test="$type='S32'">simple</xsl:when>
  <xsl:when test="$type='String'">string</xsl:when>
  <xsl:when test="$type='Value'">value</xsl:when>
  <xsl:otherwise>complex</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template match="UML:Attribute" mode="valuetype">
  <xsl:variable name='type'>
    <xsl:value-of select='.//UML:DataType/@xmi.idref'/>
  </xsl:variable>
  <xsl:choose>
    <xsl:when test='$type="U8"'>WW8IntValue</xsl:when>
    <xsl:when test='$type="S8"'>WW8IntValue</xsl:when>
    <xsl:when test='$type="U16"'>WW8IntValue</xsl:when>
    <xsl:when test='$type="S16"'>WW8IntValue</xsl:when>
    <xsl:when test='$type="U32"'>WW8IntValue</xsl:when>
    <xsl:when test='$type="S32"'>WW8IntValue</xsl:when>
    <xsl:otherwise>WW8PropertiesValue</xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template match="UML:Class" mode="dffrecord">
  <xsl:variable name="classname">
  <xsl:text>Dff</xsl:text><xsl:value-of select="@name"/>
  </xsl:variable>
  <xsl:text>
/** 
    Automaticallay generated class:
  </xsl:text>
  <xsl:value-of select="$classname"/>
  <xsl:text>&#xa;
*/&#xa;
class </xsl:text>
<xsl:value-of select="$classname"/>
<xsl:text> : public DffRecord
{
public:
    typedef boost::shared_ptr &lt; </xsl:text>
    <xsl:value-of select="$classname"/>
    <xsl:text> &gt; Pointer_t;&#xa;
    </xsl:text>
    <xsl:value-of select="$classname"/>
    <xsl:text>(WW8StructBase * pParent, sal_uInt32 nOffset, sal_uInt32 nCount)&#xa;
    : DffRecord(pParent, nOffset, nCount) {}&#xa;
    </xsl:text>
    <xsl:value-of select="$classname"/>
    <xsl:text>(WW8Stream &amp; rStream, sal_uInt32 nOffset, sal_uInt32 nCount)&#xa;
    : DffRecord(rStream, nOffset, nCount) {}&#xa;
    </xsl:text>
    <xsl:value-of select="$classname"/>
    <xsl:text>(DffRecord &amp; rRecord)&#xa;
    : DffRecord(rRecord) {}
    virtual ~</xsl:text>
    <xsl:value-of select="$classname"/>
    <xsl:text>();

    virtual void resolveLocal(Properties &amp; props);</xsl:text>
    <xsl:if test='.//UML:Stereotype[@xmi.idref = "resolvenoauto"]'>
      void resolveNoAuto(Properties &amp; rHandler);
    </xsl:if>
    <xsl:text>
    virtual void dump(OutputWithDepth &lt; string &gt; &amp; o) const;

    virtual DffRecord * clone() const { return new </xsl:text>
    <xsl:value-of select="$classname"/>
    <xsl:text>(*this); }&#xa;
    virtual string getType() const 
    {
        return "</xsl:text>
        <xsl:value-of select="$classname"/>
        <xsl:text>";
    }

    virtual string getName() const { return ""; }
    </xsl:text>
    <xsl:apply-templates select="." mode="declsProperties"/>
    <xsl:text>
};
</xsl:text>
</xsl:template>


<xsl:template match="UML:Class" mode="dffopt">
<!--
  <xsl:variable name="classname">
  <xsl:text>DffOpt</xsl:text><xsl:value-of select="@name"/>
  </xsl:variable>
  <xsl:text>
/** 
    Automaticallay generated class:
  </xsl:text>
  <xsl:value-of select="$classname"/>
  <xsl:text>&#xa;
*/&#xa;
class </xsl:text>
<xsl:value-of select="$classname"/>
<xsl:text> : public WW8FOPTE
{
    </xsl:text>
    <xsl:value-of select="$classname"/>
    <xsl:text>(WW8FOPTE &amp; rOpt) : WW8FOPTE(rOpt) {}

    virtual string getName() const
    {
       return "</xsl:text>
       <xsl:value-of select="@name"/>
       <xsl:text>";
     }&#xa;</xsl:text>

     <xsl:text>
};
</xsl:text> 
-->
</xsl:template>

<xsl:template name="parenttype">
  <xsl:param name='type'/>
  <xsl:for-each select='/XMI/XMI.content/UML:Model/UML:Namespace.ownedElement/UML:Generalization[UML:Generalization.child/UML:Class/@xmi.idref=$type]'>
    <xsl:value-of select='./UML:Generalization.parent/UML:Class/@xmi.idref'/>
  </xsl:for-each>
</xsl:template>

<xsl:template match="UML:Attribute" mode="returntype">
  <xsl:variable name='type'>
    <xsl:value-of select="UML:StructuralFeature.type/UML:DataType/@xmi.idref"/>
  </xsl:variable>
  <xsl:call-template name='saltype'>
    <xsl:with-param name='type'>
      <xsl:value-of select="$type"/>
    </xsl:with-param>
    <xsl:with-param name='parenttype'>
      <xsl:call-template name='parenttype'>
        <xsl:with-param name='type'><xsl:value-of select='$type'/></xsl:with-param>
      </xsl:call-template>
    </xsl:with-param>
  </xsl:call-template>
</xsl:template>

</xsl:stylesheet>