2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2008 by Sun Microsystems, Inc.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * $RCSfile: resourcestools.xsl,v $
14 * This file is part of OpenOffice.org.
16 * OpenOffice.org is free software: you can redistribute it and/or modify
17 * it under the terms of the GNU Lesser General Public License version 3
18 * only, as published by the Free Software Foundation.
20 * OpenOffice.org is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU Lesser General Public License version 3 for more details
24 * (a copy is included in the LICENSE file that accompanied this code).
26 * You should have received a copy of the GNU Lesser General Public License
27 * version 3 along with OpenOffice.org. If not, see
28 * <http://www.openoffice.org/license.html>
29 * for a copy of the LGPLv3 License.
31 ************************************************************************/
36 xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
37 xmlns:
office=
"urn:oasis:names:tc:opendocument:xmlns:office:1.0"
38 xmlns:
style=
"urn:oasis:names:tc:opendocument:xmlns:style:1.0"
39 xmlns:
text=
"urn:oasis:names:tc:opendocument:xmlns:text:1.0"
40 xmlns:
table=
"urn:oasis:names:tc:opendocument:xmlns:table:1.0"
41 xmlns:
draw=
"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
42 xmlns:
fo=
"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
43 xmlns:
xlink=
"http://www.w3.org/1999/xlink"
44 xmlns:
dc=
"http://purl.org/dc/elements/1.1/"
45 xmlns:
meta=
"urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
46 xmlns:
number=
"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
47 xmlns:
svg=
"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
48 xmlns:
chart=
"urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
49 xmlns:
dr3d=
"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
50 xmlns:
math=
"http://www.w3.org/1998/Math/MathML"
51 xmlns:
form=
"urn:oasis:names:tc:opendocument:xmlns:form:1.0"
52 xmlns:
script=
"urn:oasis:names:tc:opendocument:xmlns:script:1.0"
53 xmlns:
config=
"urn:oasis:names:tc:opendocument:xmlns:config:1.0"
54 xmlns:
ooo=
"http://openoffice.org/2004/office"
55 xmlns:
ooow=
"http://openoffice.org/2004/writer"
56 xmlns:
oooc=
"http://openoffice.org/2004/calc"
57 xmlns:
dom=
"http://www.w3.org/2001/xml-events"
58 xmlns:
xforms=
"http://www.w3.org/2002/xforms"
59 xmlns:
xsd=
"http://www.w3.org/2001/XMLSchema"
60 xmlns:
xsi=
"http://www.w3.org/2001/XMLSchema-instance"
61 xmlns:
rdf=
"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
62 xmlns:
rng=
"http://relaxng.org/ns/structure/1.0"
63 xmlns:
rdfs=
"http://www.w3.org/2000/01/rdf-schema#"
64 xmlns:
xalan=
"http://xml.apache.org/xalan"
65 xmlns:UML = 'org.omg.xmi.namespace.UML'
66 exclude-result-prefixes =
"xalan"
68 <xsl:output method=
"text" />
70 <xsl:key name=
"same-attribute"
71 match=
"rng:attribute" use=
"@name" />
73 <xsl:key name=
"same-element"
74 match=
"rng:element" use=
"@name" />
76 <xsl:key name=
"defines-with-name"
77 match=
"rng:define" use=
"@name" />
79 <xsl:key name=
"same-element-enum"
80 match=
"rng:element" use=
"@enumname"/>
82 <xsl:key name=
"same-attribute-enum"
83 match=
"rng:attribute" use=
"@enumname"/>
85 <xsl:key name=
"same-element-or-attribute-enum"
86 match=
"rng:attribute|rng:element" use=
"@enumname"/>
88 <xsl:key name=
"context-resource"
89 match=
"resource" use=
"@name"/>
91 <xsl:key name=
"defines-with-application"
92 match=
"rng:define" use=
"ancestor::rng:grammar/@application"/>
94 <xsl:key name=
"namespace-aliases" match=
"//namespace-alias" use=
"@name"/>
96 <xsl:template name=
"licenseheader">
100 THIS FILE IS GENERATED AUTOMATICALLY! DO NOT EDIT!
106 <xsl:template name=
"hasrefs">
108 <xsl:when test=
".//rng:ref[not(ancestor::rng:element or ancestor::rng:attribute)]">
109 <xsl:text>1</xsl:text>
112 <xsl:text>0</xsl:text>
118 Returns <define> for the current <ref>.
120 The current node must be a <ref>!
122 <xsl:template name=
"defineforref">
123 <xsl:variable name=
"mygrammarid" select=
"generate-id(ancestor::rng:grammar)"/>
124 <xsl:value-of select=
"key('defines-with-name', @name)[generate-id(ancestor::rng:grammar) = $mygrammarid]"/>
128 Create name with prefix.
130 The result is <prefix>:<name>.
132 Exception: If <name> contains a ':' the prefix is ignored.
134 @param prefix the prefix
137 <xsl:template name=
"prefixname">
138 <xsl:param name=
"prefix"/>
139 <xsl:param name=
"name"/>
141 <xsl:when test=
"contains($name, ':')">
142 <xsl:value-of select=
"$name"/>
145 <xsl:value-of select=
"$prefix"/>
146 <xsl:text>:
</xsl:text>
147 <xsl:value-of select=
"$name"/>
152 <xsl:template name=
"fastnamespace">
153 <xsl:if test=
"string-length(@prefix) > 0">
154 <xsl:text>NS_
</xsl:text>
155 <xsl:value-of select=
"@prefix"/>
159 <xsl:template name=
"fastlocalname">
160 <xsl:text>OOXML_
</xsl:text>
161 <xsl:value-of select=
"@localname"/>
165 Create entries in enum definition for fast tokens.
167 For each occurrence of rng:element an entry
171 is generated, but only if the element is the first named <name>.
173 <xsl:template name=
"enumfasttokens">
174 <xsl:param name=
"prefix"/>
175 <xsl:for-each select=
".//rng:element|.//rng:attribute">
176 <xsl:if test=
"generate-id(.) = generate-id(key('same-token-name', @localname)[1])">
177 <xsl:call-template name=
"fastlocalname"/>
178 <xsl:text>,

 </xsl:text>
183 <xsl:template name=
"fasttokens">
185 typedef sal_Int32 Token_t;
187 <xsl:for-each select=
"/model/fasttoken">
189 const Token_t OOXML_
</xsl:text>
190 <xsl:value-of select=
"translate(., '-', '_')"/>
191 <xsl:text> =
</xsl:text>
192 <xsl:value-of select=
"position() - 1"/>
193 <xsl:text>;
</xsl:text>
196 const Token_t OOXML_FAST_TOKENS_END =
</xsl:text>
197 <xsl:value-of select=
"count(/model/fasttoken)"/>
198 <xsl:text>;

</xsl:text>
202 Returns prefix for the rng:grammar of the current node.
204 <xsl:template name=
"prefixforgrammar">
205 <xsl:variable name=
"ns" select=
"ancestor::rng:grammar/@ns"/>
206 <xsl:variable name=
"nsalias"><xsl:value-of select=
"key('namespace-aliases', $ns)/@alias"/></xsl:variable>
207 <!--<xsl:variable name="nsalias">test</xsl:variable>-->
209 <xsl:when test=
"string-length($nsalias) > 0">
210 <xsl:value-of select=
"$nsalias"/>
213 <xsl:value-of select=
"translate(substring-after($ns, 'http://'), '/.', '__')"/>
219 Returns prefix for the rng:grammar of the matching nodes.
221 <xsl:template match=
"*" mode=
"grammar-prefix">
222 <xsl:call-template name=
"prefixforgrammar"/>
226 Generates name for fast context class for this <define>
228 <xsl:template name=
"fastcontextname">
229 <xsl:variable name=
"do">
230 <xsl:call-template name=
"classfordefine"/>
232 <xsl:if test=
"$do = '1'">
233 <xsl:variable name=
"definename">
234 <xsl:call-template name=
"searchdefinenamespace">
235 <xsl:with-param name=
"name" select=
"@name"/>
238 <xsl:for-each select=
"/model/namespace[@name=substring-before($definename, ':')]">
239 <xsl:text>OOXMLFastContextHandler_
</xsl:text>
240 <xsl:value-of select=
"@namespacealias"/>
241 <xsl:text>_
</xsl:text>
242 <xsl:value-of select=
"substring-after($definename, ':')"/>
248 Returns the value of the @resource attribute of the <resource>
249 node according to the current <define>.
251 <xsl:template name=
"contextresource">
252 <xsl:variable name=
"mynsid" select=
"generate-id(ancestor::namespace)"/>
254 <xsl:when test=
"count(key('context-resource', @name)) = 1">
255 <xsl:value-of select=
"key('context-resource', @name)/@resource"/>
258 <xsl:value-of select=
"key('context-resource', @name)[generate-id(ancestor::namespace)=$mynsid]/@resource"/>
264 Returns a value name.
266 The resulting value name is
268 OOXMLValue_$prefix_$name
273 <xsl:template name=
"valuename">
274 <xsl:param name=
"prefix"/>
275 <xsl:param name=
"name"/>
276 <xsl:text>OOXMLValue_
</xsl:text>
277 <xsl:value-of select=
"$prefix"/>
278 <xsl:text>_
</xsl:text>
279 <xsl:value-of select=
"$name"/>
283 Returns the value name for the current <define>.
285 <xsl:template name=
"valuenamefordefine">
286 <xsl:call-template name=
"valuename">
287 <xsl:with-param name=
"prefix" select=
"key('namespace-aliases', ancestor::namespace/rng:grammar/@ns)/@alias"/>
288 <xsl:with-param name=
"name" select=
"translate(@name, '-', '_')"/>
293 Returns the name of the parent class of the class for the
296 Precondition: The class for the current <define> is derived
297 indirectly from OOXMLValue.
300 <xsl:template name=
"valueparent">
301 <xsl:variable name=
"resource">
302 <xsl:call-template name=
"contextresource"/>
304 <xsl:text>OOXML
</xsl:text>
305 <xsl:value-of select=
"$resource"/>
306 <xsl:text>Value
</xsl:text>
310 Generates declaration for a value class.
312 Precondition: <resource> for current <define> indicates that the
313 class is derived directly or indirectly from OOXMLValue.
315 <xsl:template name=
"valuedecl">
316 <xsl:variable name=
"classname">
317 <xsl:call-template name=
"valuenamefordefine"/>
319 <xsl:variable name=
"resource">
320 <xsl:call-template name=
"contextresource"/>
324 <xsl:value-of select=
"$classname"/>
325 <xsl:text> : public
</xsl:text>
326 <xsl:call-template name=
"valueparent"/>
332 <xsl:when test=
"$resource='List'">
333 <xsl:value-of select=
"$classname"/>
334 <xsl:text>(
</xsl:text>
335 <xsl:text>const rtl::OUString
& rValue
</xsl:text>
336 <xsl:text>);
</xsl:text>
339 <xsl:value-of select=
"$classname"/>
340 <xsl:text>(const rtl::OUString
& rValue) :
</xsl:text>
341 <xsl:call-template name=
"valueparent"/>
342 <xsl:text>(rValue) {}
</xsl:text>
347 <xsl:value-of select=
"$classname"/>
354 Checks if a class derived from OOXMLContex shall be defined for
355 the current <define>.
357 @retval 1 the class shall be defined.
360 <xsl:template name=
"classfordefine">
362 <xsl:variable name="name" select="@name"/>
364 <xsl:when test="(starts-with(@name, 'CT_') or starts-with(@name, 'EG_') or starts-with(@name, 'AG_'))">1</xsl:when>
365 <xsl:when test="ancestor::namespace//start[@name=$name]">1</xsl:when>
366 <xsl:otherwise>0</xsl:otherwise>
369 <xsl:value-of select=
"@classfordefine"/>
373 Checks if a class derived from OOXMLValue shall be defined for
374 the current <define>.
376 @retval 1 the class shall be defined
379 <xsl:template name=
"valuefordefine">
381 <xsl:when test=
"starts-with(@name, 'ST_')">1</xsl:when>
382 <xsl:otherwise>0</xsl:otherwise>
386 <xsl:template name=
"valuedecls">
387 <xsl:for-each select=
".//rng:grammar/rng:define">
388 <xsl:variable name=
"dovalue">
389 <xsl:call-template name=
"valuefordefine"/>
391 <xsl:if test=
"$dovalue = '1'">
392 <xsl:call-template name=
"valuedecl"/>
398 Generate switch body for createFastChildContext
400 <xsl:template name=
"switchbodycreatechildcontext">
401 <xsl:for-each select=
".//rng:element[@name]">
402 <xsl:call-template name=
"caselabelfasttoken"/>
403 <xsl:variable name=
"createstatement">
404 <xsl:call-template name=
"fastelementcreatestatement"/>
406 <xsl:if test=
"string-length($createstatement) > 0">
408 xContextHandler.set(
</xsl:text>
409 <xsl:value-of select=
"$createstatement"/>
419 <xsl:template name=
"fastelementcreatefromrefstatement">
420 <xsl:variable name=
"definename">
421 <xsl:call-template name=
"searchdefinenamespace">
422 <xsl:with-param name=
"name" select=
"@name"/>
425 <xsl:for-each select=
"/model/namespace[@name=substring-before($definename, ':')]">
426 <xsl:for-each select=
"./rng:grammar/rng:define[@name=substring-after($definename, ':')]">
427 <xsl:variable name=
"do">
428 <xsl:call-template name=
"classfordefine"/>
430 <xsl:if test=
"$do = '1'">
431 <xsl:text>OOXMLFastHelper
<</xsl:text>
432 <xsl:call-template name=
"fastcontextname"/>
433 <xsl:text>>::createAndSetParentRef(this, Element, Attribs)
</xsl:text>
439 <xsl:template name=
"switchbodycreatechildcontextrefs">
440 <xsl:for-each select=
".//rng:ref[not (ancestor::rng:element or ancestor::rng:attribute)]">
441 <xsl:variable name=
"createstatement">
442 <xsl:call-template name=
"fastelementcreatefromrefstatement"/>
444 <xsl:if test=
"string-length($createstatement) > 0">
446 if (! xContextHandler.is() || dynamic_cast
<OOXMLFastContextHandler *
>(xContextHandler.get())-
>isFallback())
448 xContextHandler.set(
</xsl:text>
449 <xsl:value-of select=
"$createstatement"/>
455 <xsl:for-each select=
".//rng:element[rng:anyName]">
456 <xsl:variable name=
"createstatement">
457 <xsl:call-template name=
"fastelementcreatestatement"/>
459 <xsl:if test=
"string-length($createstatement) > 0">
461 if (! xContextHandler.is() || dynamic_cast
<OOXMLFastContextHandler *
>(xContextHandler.get())-
>isFallback())
463 xContextHandler.set(
</xsl:text>
464 <xsl:value-of select=
"$createstatement"/>
473 Generates definition of method createFastChildContext for current <define>
475 <xsl:template name=
"createfastchildcontext">
476 <xsl:variable name=
"resource">
477 <xsl:call-template name=
"contextresource"/>
479 <xsl:if test=
"not($resource='Shape')">
480 <xsl:variable name=
"switchbody">
481 <xsl:call-template name=
"switchbodycreatechildcontext"/>
483 <xsl:variable name=
"switchbodyrefs">
484 <xsl:call-template name=
"switchbodycreatechildcontextrefs"/>
486 <xsl:if test=
"string-length($switchbody) > 0 or string-length($switchbodyrefs) > 0">
488 uno::Reference
< xml::sax::XFastContextHandler
>
490 <xsl:call-template name=
"fastcontextname"/>
491 <xsl:text>::lcl_createFastChildContext
492 (::sal_Int32 Element,
493 const uno::Reference
< xml::sax::XFastAttributeList
> &</xsl:text>
494 <xsl:if test=
"contains($switchbody, 'Attribs') or contains($switchbodyrefs, 'Attribs')">
495 <xsl:text> Attribs
</xsl:text>
498 throw (uno::RuntimeException, xml::sax::SAXException)
500 uno::Reference
< xml::sax::XFastContextHandler
> xContextHandler;
502 <xsl:if test=
"string-length($switchbody) > 0">
507 <xsl:value-of select=
"$switchbody"/>
514 <xsl:if test=
"string-length($switchbodyrefs) > 0">
515 <xsl:value-of select=
"$switchbodyrefs"/>
519 return xContextHandler;
526 <xsl:template name=
"idforattr">
527 <xsl:variable name=
"name" select=
"@name"/>
528 <xsl:for-each select=
"ancestor::rng:define">
529 <xsl:variable name=
"definename" select=
"@name"/>
530 <xsl:for-each select=
"ancestor::namespace/resource[@name=$definename]">
531 <xsl:for-each select=
"./attribute[@name=$name]">
532 <xsl:call-template name=
"idtoqname">
533 <xsl:with-param name=
"id" select=
"@tokenid"/>
540 <xsl:template name=
"idforelement">
541 <xsl:variable name=
"name" select=
"@name"/>
542 <xsl:for-each select=
"ancestor::rng:define">
543 <xsl:variable name=
"definename" select=
"@name"/>
544 <xsl:for-each select=
"ancestor::namespace/resource[@name=$definename]">
545 <xsl:for-each select=
"./element[@name=$name]">
546 <xsl:call-template name=
"idtoqname">
547 <xsl:with-param name=
"id" select=
"@tokenid"/>
555 Processes token id given in <resource> elements.
557 The result is the identifier for the tokenid.
559 <xsl:template name=
"processtokenid">
561 <xsl:when test=
"contains(@tokenid, ':')">
562 <xsl:call-template name=
"idtoqname">
563 <xsl:with-param name=
"id" select=
"@tokenid"/>
567 <xsl:value-of select=
"@tokenid"/>
572 <xsl:template name=
"getidcaseimpl">
573 <xsl:for-each select=
"attribute|element">
576 <xsl:call-template name=
"caselabelfasttoken"/>
578 nResult =
</xsl:text>
579 <xsl:call-template name=
"processtokenid"/>
585 <xsl:template name=
"attributeproptype">
586 <xsl:variable name=
"mynsid" select=
"generate-id(ancestor::namespace)"/>
587 <xsl:variable name=
"name" select=
"@name"/>
588 <xsl:variable name=
"resource" select=
"key('context-resource', @name)[generate-id(ancestor::namespace)=$mynsid]"/>
590 <xsl:when test=
"$resource/element[@name=$name]">
591 <xsl:text>OOXMLPropertyImpl::SPRM
</xsl:text>
594 <xsl:text>OOXMLPropertyImpl::ATTRIBUTE
</xsl:text>
600 Check if a default is defined for a define.
602 Returns if the <resource> for the current <define> has a
605 @retval 0 there is no default
606 @retval 1 there is a default
608 <xsl:template name=
"contexthasdefault">
609 <xsl:variable name=
"name" select=
"@name"/>
611 <xsl:when test=
"ancestor::namespace/resource[@name=$name]//default">1</xsl:when>
612 <xsl:otherwise>0</xsl:otherwise>
617 Chooses the action for the current <action> element.
619 <xsl:template name=
"chooseaction">
620 <xsl:if test=
"@tokenid">
622 if (sal::static_int_cast
<Id
>(getId()) ==
</xsl:text>
623 <xsl:call-template name=
"idtoqname">
624 <xsl:with-param name=
"id" select=
"@tokenid"/>
629 <xsl:for-each select=
"./cond">
632 OOXMLPropertySetEntryToInteger aHandler(
</xsl:text>
633 <xsl:call-template name=
"idtoqname">
634 <xsl:with-param name=
"id" select=
"@tokenid"/>
637 getPropertySetAttrs()-
>resolve(aHandler);
639 if (sal::static_int_cast
<Id
>(aHandler.getValue()) ==
</xsl:text>
640 <xsl:call-template name=
"idtoqname">
641 <xsl:with-param name=
"id" select=
"@value"/>
647 <xsl:when test=
"@action='sendTableDepth'">
649 sendTableDepth();
</xsl:text>
651 <xsl:when test=
"@action='startCell'">
653 startCell();
</xsl:text>
655 <xsl:when test=
"@action='startParagraphGroup'">
657 startParagraphGroup();
</xsl:text>
659 <xsl:when test=
"@action='startCharacterGroup'">
661 startCharacterGroup();
</xsl:text>
663 <xsl:when test=
"@action='startSectionGroup'">
665 startSectionGroup();
</xsl:text>
667 <xsl:when test=
"@action='fieldstart'">
669 startField();
</xsl:text>
671 <xsl:when test=
"@action='fieldsep'">
673 fieldSeparator();
</xsl:text>
675 <xsl:when test=
"@action='fieldend'">
677 endField();
</xsl:text>
679 <xsl:when test=
"@action='ftnednref'">
681 ftnednref();
</xsl:text>
683 <xsl:when test=
"@action='ftnednsep'">
685 ftnednsep();
</xsl:text>
687 <xsl:when test=
"@action='ftnedncont'">
689 ftnedncont();
</xsl:text>
691 <xsl:when test=
"@action='pgNum'">
695 <xsl:when test=
"@action='tab'">
699 <xsl:when test=
"@action='cr'">
703 <xsl:when test=
"@action='noBreakHyphen'">
705 noBreakHyphen();
</xsl:text>
707 <xsl:when test=
"@action='softHyphen'">
709 softHyphen();
</xsl:text>
711 <xsl:when test=
"@action='endOfParagraph'">
713 endOfParagraph();
</xsl:text>
715 <xsl:when test=
"@action='handleLastParagraphInSection'">
717 handleLastParagraphInSection();
</xsl:text>
719 <xsl:when test=
"@action='setLastParagraphInSection'">
721 setLastParagraphInSection();
</xsl:text>
723 <xsl:when test=
"@action='endCell'">
725 endCell();
</xsl:text>
727 <xsl:when test=
"@action='endParagraphGroup'">
729 endParagraphGroup();
</xsl:text>
731 <xsl:when test=
"@action='endCharacterGroup'">
733 endCharacterGroup();
</xsl:text>
735 <xsl:when test=
"@action='endSectionGroup'">
737 endSectionGroup();
</xsl:text>
739 <xsl:when test=
"@action='handleXNotes'">
740 handleXNotes();
</xsl:when>
741 <xsl:when test=
"@action='handleHdrFtr'">
742 handleHdrFtr();
</xsl:when>
743 <xsl:when test=
"@action='handleComment'">
744 handleComment();
</xsl:when>
745 <xsl:when test=
"@action='handlePicture'">
746 handlePicture();
</xsl:when>
747 <xsl:when test=
"@action='handleHyperlink'">
748 handleHyperlink();
</xsl:when>
749 <xsl:when test=
"@action='handleBreak'">
750 handleBreak();
</xsl:when>
751 <xsl:when test=
"@action='handleOLE'">
752 handleOLE();
</xsl:when>
753 <xsl:when test=
"@action='printproperty'">
755 sendProperty(
</xsl:text>
756 <xsl:call-template name=
"idtoqname">
757 <xsl:with-param name=
"id" select=
"@sendtokenid"/>
759 <xsl:text>);
</xsl:text>
761 <xsl:when test=
"@action='propagateCharacterProperties'">
762 propagateCharacterProperties();
764 <xsl:when test=
"@action='propagateCharacterPropertiesAsSet'">
766 propagateCharacterPropertiesAsSet(
</xsl:text>
767 <xsl:call-template name=
"idtoqname">
768 <xsl:with-param name=
"id" select=
"@sendtokenid"/>
770 <xsl:text>);
</xsl:text>
772 <xsl:when test=
"@action='propagateTableProperties'">
773 propagateTableProperties();
775 <xsl:when test=
"@action='sendPropertiesWithId'">
777 sendPropertiesWithId(
</xsl:text>
778 <xsl:call-template name=
"idtoqname">
779 <xsl:with-param name=
"id" select=
"@sendtokenid"/>
781 <xsl:text>);
</xsl:text>
783 <xsl:when test=
"@action='clearProps'">
786 <xsl:when test=
"@action='text'">
789 <xsl:when test=
"@action='setHandle'">
793 <xsl:when test=
"@action='footnoteSeparator'">
796 <xsl:when test=
"@action='footnoteCont'">
799 <xsl:when test=
"@action='endnoteSeparator'">
802 <xsl:when test=
"@action='endnoteCont'">
805 <xsl:when test=
"@action='newProperty'">
807 OOXMLFastHelper
<OOXMLIntegerValue
>::newProperty(this,
</xsl:text>
808 <xsl:call-template name=
"idtoqname">
809 <xsl:with-param name=
"id" select=
"@tokenid"/>
811 <xsl:text>, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
"</xsl:text>
812 <xsl:value-of select="@value
"/>
813 <xsl:text>")));
</xsl:text>
815 <xsl:when test=
"@action='mark'">
817 OOXMLFastHelper
<OOXMLIntegerValue
>::mark(this,
</xsl:text>
818 <xsl:call-template name=
"idtoqname">
819 <xsl:with-param name=
"id" select=
"@sendtokenid"/>
821 <xsl:text>, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
"</xsl:text>
822 <xsl:value-of select="@value
"/>
823 <xsl:text>")));
</xsl:text>
825 <xsl:when test=
"@action='tokenproperty'">
827 OOXMLFastHelper
<OOXMLIntegerValue
>::newProperty(this,
</xsl:text>
828 <xsl:call-template name=
"idtoqname">
829 <xsl:with-param name=
"id">ooxml:token
</xsl:with-param>
831 <xsl:text>, getToken());
</xsl:text>
834 <xsl:for-each select=
"./cond">
839 <xsl:if test=
"@tokenid">
846 Generates the definitions of the methods of the fast context class
847 for the current <define>.
849 <xsl:template name=
"fastcontextimpls">
850 <xsl:param name=
"ns"/>
851 <xsl:for-each select=
".//namespace[@name=$ns]">
854 <xsl:for-each select=
"./rng:grammar/rng:define">
855 <xsl:variable name=
"do">
856 <xsl:call-template name=
"classfordefine"/>
858 <xsl:if test=
"$do = '1'">
859 <xsl:variable name=
"classname">
860 <xsl:call-template name=
"fastcontextname"/>
865 <xsl:value-of select=
"$classname"/>
869 <xsl:call-template name=
"fastcontextconstructor"/>
870 <xsl:call-template name=
"fastcontextdestructor"/>
871 <xsl:call-template name=
"faststartaction"/>
872 <xsl:call-template name=
"fastendaction"/>
873 <xsl:call-template name=
"createfastchildcontext"/>
874 <xsl:call-template name=
"fastattribute"/>
875 <xsl:call-template name=
"fastcharacters"/>
876 <xsl:call-template name=
"propagatesproperties"/>
882 <xsl:key name=
"value-with-content" match=
"//rng:value"
886 Generates name for a value string.
888 Value strings are possible values for attributes in OOXML.
890 @param string the string as present in the according <rng:value>
892 <xsl:template name=
"valuestringname">
893 <xsl:param name=
"string"/>
894 <xsl:text>OOXMLValueString_
</xsl:text>
895 <xsl:value-of select=
"translate($string, '-+ ,', 'mp__')"/>
899 Generates constant definitions for attribute values.
901 <xsl:template name=
"valueconstants">
903 rtl::OUString
</xsl:text>
904 <xsl:call-template name=
"valuestringname">
905 <xsl:with-param name=
"string"></xsl:with-param>
907 <xsl:text>(RTL_CONSTASCII_USTRINGPARAM(
""));
</xsl:text>
908 <xsl:for-each select=
"//rng:value[generate-id(key('value-with-content', text())[1]) = generate-id(.)]">
910 rtl::OUString
</xsl:text>
911 <xsl:call-template name=
"valuestringname">
912 <xsl:with-param name=
"string" select=
"."/>
914 <xsl:text>(RTL_CONSTASCII_USTRINGPARAM(
"</xsl:text>
915 <xsl:value-of select=".
"/>
916 <xsl:text>"));
</xsl:text>
921 Generates constant declarations for attribute values.
923 <xsl:template name=
"valueconstantdecls">
927 <xsl:call-template name=
"valuestringname">
928 <xsl:with-param name=
"string"></xsl:with-param>
930 <xsl:text>;
</xsl:text>
931 <xsl:for-each select=
"//rng:value[generate-id(key('value-with-content', text())[1]) = generate-id(.)]">
933 extern rtl::OUString
</xsl:text>
934 <xsl:call-template name=
"valuestringname">
935 <xsl:with-param name=
"string" select=
"."/>
937 <xsl:text>;
</xsl:text>
942 Generates definition of constructor for attribute value class
943 for current <define>.
945 <xsl:template name=
"valueconstructorimpl">
946 <xsl:variable name=
"name" select=
"@name"/>
947 <xsl:variable name=
"resource">
948 <xsl:call-template name=
"contextresource"/>
951 <xsl:when test=
"$resource = 'List'">
952 <xsl:variable name=
"classname">
953 <xsl:call-template name=
"valuenamefordefine"/>
955 <xsl:text>
</xsl:text>
956 <xsl:value-of select=
"$classname"/>
957 <xsl:text>::
</xsl:text>
958 <xsl:value-of select=
"$classname"/>
959 <xsl:text>(const rtl::OUString
& </xsl:text>
961 <xsl:when test=
"count(ancestor::namespace/resource[@name=$name]/value) > 0">
962 <xsl:text>rValue
</xsl:text>
965 <xsl:text>/* rValue */
</xsl:text>
971 <xsl:for-each select=
"ancestor::namespace/resource[@name=$name]">
972 <xsl:for-each select=
"./default">
974 mnValue =
</xsl:text>
976 <xsl:when test=
"@tokenid">
977 <xsl:call-template name=
"idtoqname">
978 <xsl:with-param name=
"id" select=
"@tokenid"/>
982 <xsl:value-of select=
"."/>
985 <xsl:text>;
</xsl:text>
987 <xsl:for-each select=
"./value">
989 if (rValue.compareTo(
</xsl:text>
990 <xsl:call-template name=
"valuestringname">
991 <xsl:with-param name=
"string" select=
"text()"/>
995 mnValue =
</xsl:text>
996 <xsl:call-template name=
"idtoqname">
997 <xsl:with-param name=
"id" select=
"@tokenid"/>
1012 Generates definition of destructor of attribute value class for
1015 <xsl:template name=
"valuedestructorimpl">
1016 <xsl:variable name=
"classname">
1017 <xsl:call-template name=
"valuenamefordefine"/>
1019 <xsl:text>
</xsl:text>
1020 <xsl:value-of select=
"$classname"/>
1021 <xsl:text>::~
</xsl:text>
1022 <xsl:value-of select=
"$classname"/>
1030 Generates definitions for attribute value class for current
1033 <xsl:template name=
"valueimpls">
1034 <xsl:for-each select=
".//rng:grammar/rng:define">
1035 <xsl:variable name=
"do">
1036 <xsl:call-template name=
"valuefordefine"/>
1038 <xsl:if test=
"$do = 1">
1039 <xsl:variable name=
"classname">
1040 <xsl:call-template name=
"valuenamefordefine"/>
1045 <xsl:value-of select=
"$classname"/>
1049 <xsl:call-template name=
"valueconstructorimpl"/>
1054 <xsl:key name=
"tokenids" match=
"@tokenid|@sendtokenid" use=
"."/>
1057 Generates contant definitions for tokenids.
1059 <xsl:template name=
"defineooxmlids">
1063 <xsl:for-each select=
"//@tokenid|//@sendtokenid">
1064 <xsl:if test=
"contains(., 'ooxml:') and generate-id(.) = generate-id(key('tokenids', .)[1])">
1066 const Id LN_
</xsl:text>
1067 <xsl:value-of select=
"substring-after(., 'ooxml:')"/>
1068 <xsl:text> =
</xsl:text>
1069 <xsl:value-of select=
"90000 + position()"/>
1070 <xsl:text>;
</xsl:text>
1076 <xsl:template name=
"ooxmlidstoxml">
1078 void ooxmlsprmidsToXML(::std::ostream
& out)
1080 <xsl:for-each select=
"//@tokenid">
1081 <xsl:if test=
"contains(., 'ooxml:') and generate-id(.) = generate-id(key('tokenids', .)[1]) and ancestor::element">
1083 out
<< "<theid name=\"</xsl:text>
1084 <xsl:value-of select=
"."/>
1085 <xsl:text>\
"></xsl:text>
1086 <xsl:value-of select="90000 + position()
"/>
1087 <xsl:text></theid>" << endl;
</xsl:text>
1093 void ooxmlidsToXML(::std::ostream
& out)
1095 <xsl:for-each select=
"//@tokenid">
1096 <xsl:if test=
"contains(., 'ooxml:') and generate-id(.) = generate-id(key('tokenids', .)[1]) and ancestor::attribute">
1098 out
<< "<theid name=\"</xsl:text>
1099 <xsl:value-of select=
"."/>
1100 <xsl:text>\
"></xsl:text>
1101 <xsl:value-of select="90000 + position()
"/>
1102 <xsl:text></theid>" << endl;
</xsl:text>
1110 Generates mapping from tokenids to strings. (DEBUG)
1112 <xsl:template name=
"qnametostr">
1114 void QNameToString::init_ooxml()
1118 <xsl:for-each select=
"//@tokenid">
1119 <xsl:if test=
"generate-id(.) = generate-id(key('tokenids', .)[1]) and contains(., 'ooxml:')">
1122 <xsl:call-template name=
"idtoqname">
1123 <xsl:with-param name=
"id" select=
"."/>
1124 </xsl:call-template>
1125 <xsl:text>] =
"</xsl:text>
1126 <xsl:value-of select=".
"/>
1127 <xsl:text>";
</xsl:text>
1135 <xsl:template name=
"qnametostrfunc">
1137 string qnameToString(sal_uInt32 nToken)
1143 <xsl:for-each select=
"//resource">
1144 <xsl:variable name=
"name" select=
"@name"/>
1145 <xsl:for-each select=
"attribute|element">
1146 <xsl:if test=
"contains(@tokenid, 'ooxml:')">
1149 <xsl:call-template name=
"idtoqname">
1150 <xsl:with-param name=
"id" select=
"@tokenid"/>
1151 </xsl:call-template>
1153 sResult =
"</xsl:text>
1154 <xsl:value-of select="@token
"/>
1169 <xsl:key name=
"resources-with-kind" match=
"resource[.//kind]"
1170 use=
".//kind/@name"/>
1172 <xsl:key name=
"sprms-with-code" match=
"element" use=
"@tokenid"/>
1175 Generates case labels for mapping from token ids to a single kind
1178 @param kind the sprm kind for which to generate the case labels
1180 <xsl:template name=
"sprmkindcase">
1181 <xsl:param name=
"kind"/>
1182 <xsl:for-each select=
"key('resources-with-kind', $kind)/element">
1183 <xsl:if test=
"generate-id(.) = generate-id(key('sprms-with-code', @tokenid))">
1186 <xsl:call-template name=
"idtoqname">
1187 <xsl:with-param name=
"id" select=
"@tokenid"/>
1188 </xsl:call-template>
1189 <xsl:text>: //
</xsl:text>
1190 <xsl:value-of select=
"ancestor::resource/@name"/>
1191 <xsl:text>,
</xsl:text>
1192 <xsl:value-of select=
"@name"/>
1200 <xsl:template name=
"sprmkind">
1202 Sprm::Kind SprmKind(sal_uInt32 nSprmCode)
1204 Sprm::Kind nResult = Sprm::UNKNOWN;
1208 <xsl:call-template name=
"sprmkindcase">
1209 <xsl:with-param name=
"kind">paragraph
</xsl:with-param>
1210 </xsl:call-template>
1212 nResult = Sprm::PARAGRAPH;
1214 <xsl:call-template name=
"sprmkindcase">
1215 <xsl:with-param name=
"kind">character
</xsl:with-param>
1216 </xsl:call-template>
1218 nResult = Sprm::CHARACTER;
1220 <xsl:call-template name=
"sprmkindcase">
1221 <xsl:with-param name=
"kind">table
</xsl:with-param>
1222 </xsl:call-template>
1224 nResult = Sprm::TABLE;
1236 Generates qname for id.
1238 @param id the id to generate qname for
1240 If id is of format <prefix>:<localname> the result is
1242 NS_<prefix>::LN_<localname>
1244 If id does not contain ":" the result is just id.
1246 <xsl:template name='idtoqname'
>
1247 <xsl:param name='id'
/>
1249 <xsl:when test=
"contains($id, ':')">
1250 <xsl:text>NS_
</xsl:text>
1251 <xsl:value-of select='substring-before($id,
":")'
/>
1252 <xsl:text>::LN_
</xsl:text>
1253 <xsl:value-of select='substring-after($id,
":")'
/>
1256 <xsl:value-of select=
"$id"/>
1261 <xsl:key name=
"same-token-name" match=
"rng:element|rng:attribute" use=
"@localname"/>
1264 Generates input for gperf to genreate hash map for OOXMLFastTokenHandler
1266 <xsl:template name=
"gperfinputfasttokenhandler">
1269 #include
"OOXMLFastTokens.hxx"
1271 namespace writerfilter { namespace ooxml { namespace tokenmap {
1273 struct token { const char * name; Token_t nToken; };
1275 <xsl:for-each select=
".//rng:element|.//rng:attribute">
1276 <xsl:if test=
"generate-id(.) = generate-id(key('same-token-name', @localname)[1])">
1277 <xsl:text>
</xsl:text>
1278 <xsl:value-of select=
"@localname"/>
1279 <xsl:text>,
</xsl:text>
1280 <xsl:call-template name=
"fastlocalname"/>
1285 }}}

</xsl:template>
1287 <xsl:template name=
"namespaceid">
1288 <xsl:text>NS_
</xsl:text>
1289 <xsl:value-of select=
"@alias"/>
1292 <xsl:template name=
"namespaceids">
1293 <xsl:for-each select=
"//namespace-alias">
1295 const sal_uInt32
</xsl:text>
1296 <xsl:call-template name=
"namespaceid"/>
1297 <xsl:text> =
</xsl:text>
1298 <xsl:value-of select=
"@id"/>
1299 <xsl:text> << 16;
</xsl:text>
1303 <xsl:template name=
"fasttoken">
1304 <xsl:variable name=
"ns">
1305 <xsl:call-template name=
"fastnamespace"/>
1307 <xsl:if test=
"string-length($ns) > 0">
1308 <xsl:value-of select=
"$ns"/>
1309 <xsl:text>|
</xsl:text>
1311 <xsl:call-template name=
"fastlocalname"/>
1314 <xsl:template name=
"fasttokenwithattr">
1315 <xsl:if test=
"local-name(.)='attribute'">
1316 <xsl:text>F_Attribute|
</xsl:text>
1318 <xsl:call-template name=
"fasttoken"/>
1321 <xsl:template name=
"caselabelfasttoken">
1322 <xsl:text>case
</xsl:text>
1323 <xsl:call-template name=
"fasttokenwithattr"/>
1324 <xsl:text>:
</xsl:text>
1327 <xsl:key name=
"elementsattrsbynamespace"
1328 match=
"rng:element[@name]|rng:attribute[@name]" use=
"ancestor::rng:grammar/@ns"/>
1330 <xsl:template name=
"fasttokentoid">
1332 namespace tokenmap {
1333 struct token { const char * name; Token_t nToken; };
1337 static inline unsigned int hash (const char *str, unsigned int len);
1339 static struct token *in_word_set (const char *str, unsigned int len);
1343 string fastTokenToId(sal_uInt32 nToken)
1349 switch (nToken
& 0xffff0000)
1351 <xsl:for-each select=
"//namespace-alias">
1354 <xsl:value-of select=
"@alias"/>
1356 sResult +=
"</xsl:text>
1357 <xsl:value-of select="@alias
"/>
1364 switch (nToken
& 0xffff)
1366 <xsl:for-each select=
".//rng:element[@localname]|.//rng:attribute[@localname]">
1367 <xsl:variable name=
"localname" select=
"@localname"/>
1368 <xsl:if test=
"generate-id(.) = generate-id(key('same-token-name', $localname)[1])">
1371 <xsl:call-template name=
"fastlocalname"/>
1373 sResult +=
"</xsl:text>
1374 <xsl:value-of select="$localname
"/>
1387 <xsl:template name=
"getfastparser">
1389 uno::Reference
< xml::sax::XFastParser
> OOXMLStreamImpl::getFastParser()
1391 if (! mxFastParser.is())
1393 uno::Reference
< lang::XMultiComponentFactory
> xFactory =
1394 uno::Reference
< lang::XMultiComponentFactory
>
1395 (mxContext-
>getServiceManager());
1397 mxFastParser.set(xFactory-
>createInstanceWithContext
1398 ( ::rtl::OUString::createFromAscii
1399 (
"com.sun.star.xml.sax.FastParser" ),
1400 mxContext ), uno::UNO_QUERY_THROW);
1402 <xsl:for-each select=
"//namespace-alias">
1404 mxFastParser-
>registerNamespace(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
"</xsl:text>
1405 <xsl:value-of select="@name
"/>
1406 <xsl:text>")),
</xsl:text>
1407 <xsl:call-template name=
"namespaceid"/>
1408 <xsl:text>);
</xsl:text>
1413 return mxFastParser;
1418 <xsl:template name=
"searchdefinenamespace">
1419 <xsl:param name=
"name"/>
1420 <xsl:variable name=
"tmp">
1421 <xsl:for-each select=
"ancestor::namespace">
1422 <xsl:call-template name=
"searchdefinenamespacerec">
1423 <xsl:with-param name=
"name" select=
"$name"/>
1424 </xsl:call-template>
1428 <xsl:when test=
"string-length($tmp) > 0">
1429 <xsl:value-of select=
"$tmp"/>
1432 <xsl:for-each select=
"key('defines-with-name', $name)[1]">
1433 <xsl:value-of select=
"ancestor::namespace/@name"/>
1434 <xsl:text>:
</xsl:text>
1435 <xsl:value-of select=
"@name"/>
1441 <xsl:template name=
"searchdefinenamespacerec">
1442 <xsl:param name=
"name"/>
1443 <xsl:variable name=
"nsname" select=
"@name"/>
1444 <xsl:variable name=
"nsid" select=
"generate-id(.)"/>
1445 <xsl:variable name=
"tmp">
1446 <xsl:for-each select=
"key('defines-with-name', $name)">
1447 <xsl:if test=
"generate-id(ancestor::namespace)=$nsid">
1448 <xsl:value-of select=
"$nsname"/>
1449 <xsl:text>:
</xsl:text>
1450 <xsl:value-of select=
"$name"/>
1455 <xsl:when test=
"string-length($tmp) > 0">
1456 <xsl:value-of select=
"$tmp"/>
1459 <xsl:for-each select=
"./rng:include">
1460 <xsl:for-each select=
"/model/namespace[@file=@href]">
1461 <xsl:call-template name=
"searchdefinenamespacerec">
1462 <xsl:with-param name=
"name" select=
"$name"/>
1463 </xsl:call-template>
1470 <xsl:template name=
"fastattributescheckattr">
1471 <xsl:text>if (Attribs-
>hasAttribute(
</xsl:text>
1472 <xsl:call-template name=
"fastlocalname"/>
1473 <xsl:text>))
</xsl:text>
1476 <xsl:template name=
"fastattributescheckattrwithns">
1477 <xsl:text>if (Attribs-
>hasAttribute(
</xsl:text>
1478 <xsl:call-template name=
"fasttoken"/>
1479 <xsl:text>))
</xsl:text>
1482 <xsl:template name=
"fastcontextnameforattribute">
1484 <xsl:when test=
"./rng:ref">
1485 <xsl:for-each select=
"./rng:ref">
1486 <xsl:call-template name=
"valuenameforref"/>
1489 <xsl:when test=
"./rng:data/@type = 'boolean'">
1490 <xsl:text>OOXMLBooleanValue
</xsl:text>
1492 <xsl:when test=
"./rng:data/@type = 'unsignedInt'">
1493 <xsl:text>OOXMLIntegerValue
</xsl:text>
1495 <xsl:when test=
"./rng:text or ./rng:data/@type = 'string' or ./rng:data/@type = 'token'">
1496 <xsl:text>OOXMLStringValue
</xsl:text>
1501 <xsl:template name=
"fastattributesproperties">
1502 <xsl:variable name=
"definename" select=
"@name"/>
1503 <xsl:for-each select=
".//rng:attribute">
1504 <xsl:variable name=
"attrname" select=
"@name"/>
1505 <xsl:variable name=
"contextname">
1506 <xsl:call-template name=
"fastcontextnameforattribute"/>
1508 <xsl:variable name=
"attrid">
1509 <xsl:call-template name=
"idforattr"/>
1511 <xsl:if test=
"string-length($contextname) > 0 and string-length($attrid) > 0">
1514 <xsl:call-template name=
"fastattributescheckattrwithns"/>
1517 ::rtl::OUString aValue(Attribs-
>getValue(
</xsl:text>
1518 <xsl:call-template name=
"fasttoken"/>
1520 OOXMLFastHelper
< </xsl:text>
1521 <xsl:value-of select=
"$contextname"/>
1522 <xsl:text> >::newProperty(this,
</xsl:text>
1523 <xsl:value-of select=
"$attrid"/>
1524 <xsl:text>, aValue);
</xsl:text>
1525 <xsl:for-each select=
"ancestor::namespace/resource[@name=$definename]">
1526 <xsl:for-each select=
"./attribute[@name=$attrname]">
1528 <xsl:when test=
"@action='checkId'">
1530 checkId(aValue);
</xsl:text>
1532 <xsl:when test=
"@action='checkXNoteType'">
1534 <xsl:when test=
"@action='setXNoteId'">
1536 setXNoteId(aValue);
</xsl:text>
1547 <xsl:template name=
"fastattributesstringvalue">
1548 <xsl:for-each select=
".//rng:attribute">
1551 <xsl:call-template name=
"fastattributescheckattrwithns"/>
1553 msValue = Attribs-
>getValue(
</xsl:text>
1554 <xsl:call-template name=
"fasttoken"/>
1555 <xsl:text>);
</xsl:text>
1559 <xsl:template name=
"fastattributesintvalue">
1560 <xsl:for-each select=
".//rng:attribute">
1563 <xsl:call-template name=
"fastattributescheckattrwithns"/>
1565 mnValue = Attribs-
>getValue(
</xsl:text>
1566 <xsl:call-template name=
"fasttoken"/>
1567 <xsl:text>).toInt32();
</xsl:text>
1571 <xsl:template name=
"fastattributeshexvalue">
1572 <xsl:for-each select=
".//rng:attribute">
1575 <xsl:call-template name=
"fastattributescheckattrwithns"/>
1577 mnValue = Attribs-
>getValue(
</xsl:text>
1578 <xsl:call-template name=
"fasttoken"/>
1579 <xsl:text>).toInt32(
16);
</xsl:text>
1583 <xsl:template name=
"fastattributesboolvalue">
1584 <xsl:for-each select=
".//rng:attribute">
1587 <xsl:call-template name=
"fastattributescheckattrwithns"/>
1589 setValue(Attribs-
>getValue(
</xsl:text>
1590 <xsl:call-template name=
"fasttoken"/>
1591 <xsl:text>));
</xsl:text>
1595 <xsl:template name=
"fastattributeslistvalue">
1596 <xsl:for-each select=
".//rng:attribute">
1597 <xsl:variable name=
"myfasttoken">
1598 <xsl:call-template name=
"fastlocalname"/>
1600 <xsl:variable name=
"myfasttokenwithns">
1601 <xsl:call-template name=
"fasttoken"/>
1603 <xsl:variable name=
"bodywithns">
1604 <xsl:for-each select=
"rng:ref">
1605 <xsl:variable name=
"refname" select=
"@name"/>
1606 <xsl:variable name=
"refns">
1607 <xsl:call-template name=
"searchdefinenamespace">
1608 <xsl:with-param name=
"name" select=
"@name"/>
1609 </xsl:call-template>
1611 <xsl:variable name=
"valname">
1612 <xsl:for-each select=
"/model/namespace[@name=substring-before($refns, ':')]">
1613 <xsl:for-each select=
"./rng:grammar/rng:define[@name=substring-after($refns, ':')]">
1614 <xsl:call-template name=
"valuenamefordefine"/>
1619 mpValue = OOXMLValue::Pointer_t (new
</xsl:text>
1620 <xsl:value-of select=
"$valname"/>
1621 <xsl:text>(Attribs-
>getValue(
</xsl:text>
1622 <xsl:value-of select=
"$myfasttokenwithns"/>
1623 <xsl:text>)));
</xsl:text>
1626 <xsl:if test=
"string-length($bodywithns) > 0">
1629 <xsl:call-template name=
"fastattributescheckattrwithns"/>
1630 <xsl:value-of select=
"$bodywithns"/>
1635 <xsl:template name=
"fastattributebody">
1636 <xsl:variable name=
"resource">
1637 <xsl:call-template name=
"contextresource"/>
1640 <xsl:when test=
"$resource = 'Properties' or $resource = 'Stream' or $resource='XNote' or $resource='Shape'" >
1641 <xsl:call-template name=
"fastattributesproperties"/>
1643 <xsl:when test=
"$resource = 'StringValue'">
1644 <xsl:call-template name=
"fastattributesstringvalue"/>
1646 <xsl:when test=
"$resource = 'IntegerValue'">
1647 <xsl:call-template name=
"fastattributesintvalue"/>
1649 <xsl:when test=
"$resource = 'HexValue'">
1650 <xsl:call-template name=
"fastattributeshexvalue"/>
1652 <xsl:when test=
"$resource = 'BooleanValue'">
1653 <xsl:call-template name=
"fastattributesboolvalue"/>
1655 <xsl:when test=
"$resource = 'ListValue'">
1656 <xsl:call-template name=
"fastattributeslistvalue"/>
1661 <xsl:template name=
"valuenameforref">
1662 <xsl:variable name=
"definename">
1663 <xsl:call-template name=
"searchdefinenamespace">
1664 <xsl:with-param name=
"name" select=
"@name"/>
1665 </xsl:call-template>
1667 <xsl:for-each select=
"/model/namespace[@name=substring-before($definename, ':')]">
1668 <xsl:for-each select=
"./rng:grammar/rng:define[@name=substring-after($definename, ':')]">
1669 <xsl:call-template name=
"valuenamefordefine"/>
1674 <xsl:template name=
"fastcontextnameforref">
1675 <xsl:variable name=
"definename">
1676 <xsl:call-template name=
"searchdefinenamespace">
1677 <xsl:with-param name=
"name" select=
"@name"/>
1678 </xsl:call-template>
1681 <xsl:text>/* </xsl:text>
1682 <xsl:value-of select="@name"/>
1683 <xsl:text>, </xsl:text>
1684 <xsl:value-of select="$definename"/>
1685 <xsl:text> */</xsl:text>
1687 <xsl:for-each select=
"/model/namespace[@name=substring-before($definename, ':')]">
1688 <xsl:for-each select=
"./rng:grammar/rng:define[@name=substring-after($definename, ':')]">
1689 <xsl:call-template name=
"fastcontextname"/>
1694 <xsl:template name=
"fastattributebodyrefs">
1695 <xsl:for-each select=
".//rng:ref[not(ancestor::rng:element or ancestor::rng:attribute)]">
1696 <xsl:variable name=
"contextname">
1697 <xsl:call-template name=
"fastcontextnameforref"/>
1699 <xsl:if test=
"string-length($contextname) > 0">
1701 OOXMLFastHelper
<</xsl:text>
1702 <xsl:value-of select=
"$contextname"/>
1703 <xsl:text>>::attributes(this, Attribs);
</xsl:text>
1709 Generates definition of method attributes for current <define>
1711 <xsl:template name=
"fastattribute">
1712 <xsl:variable name=
"resource">
1713 <xsl:call-template name=
"contextresource"/>
1715 <!--<xsl:if test="not($resource='Shape')"> -->
1716 <xsl:variable name=
"body">
1717 <xsl:call-template name=
"fastattributebody"/>
1719 <xsl:variable name=
"bodyrefs">
1720 <xsl:call-template name=
"fastattributebodyrefs"/>
1722 <xsl:if test=
"string-length($body) > 0 or string-length($bodyrefs) > 0">
1725 <xsl:call-template name=
"fastcontextname"/>
1726 <xsl:text>::attributes
1727 (const uno::Reference
< xml::sax::XFastAttributeList
> & Attribs)
1728 throw (uno::RuntimeException, xml::sax::SAXException)
1730 #ifdef DEBUG_DUMP_ATTRIBUTES
1731 dumpAttribs(Attribs);
1734 <xsl:value-of select=
"$body"/>
1735 <xsl:value-of select=
"$bodyrefs"/>
1743 <xsl:template name=
"fastelementcreatestatement">
1744 <xsl:for-each select=
".//rng:ref">
1746 <xsl:when test=
"@name='BUILT_IN_ANY_TYPE'">
1747 <xsl:text>createFromStart(Element, Attribs)
</xsl:text>
1750 <xsl:variable name=
"classname">
1751 <xsl:call-template name=
"fastcontextname"/>
1753 <xsl:if test=
"string-length($classname) > 0">
1754 <xsl:text>OOXMLFastHelper
<</xsl:text>
1755 <xsl:value-of select=
"$classname"/>
1756 <xsl:text>>::createAndSetParent(this, Element,
</xsl:text>
1757 <xsl:for-each select=
"ancestor::rng:element">
1758 <xsl:variable name=
"id">
1759 <xsl:call-template name=
"idforelement"/>
1762 <xsl:when test=
"string-length($id) > 0">
1763 <xsl:value-of select=
"$id"/>
1766 <xsl:text>0</xsl:text>
1770 <xsl:text>)
</xsl:text>
1778 Generates name for parent class of fast context.
1780 <xsl:template name=
"fastresourceclass">
1781 <xsl:text>OOXMLFastContextHandler
</xsl:text>
1782 <xsl:call-template name=
"contextresource"/>
1786 Generates the declaration of the fast context for the current <define>
1788 <xsl:template name=
"fastcontextdecl">
1789 <xsl:variable name=
"classname">
1790 <xsl:call-template name=
"fastcontextname"/>
1793 class WRITERFILTER_DLLPRIVATE
</xsl:text>
1794 <xsl:value-of select=
"$classname"/>
1795 <xsl:text>: public
</xsl:text>
1796 <xsl:call-template name=
"fastresourceclass"/>
1800 explicit
</xsl:text>
1801 <xsl:value-of select=
"$classname"/>
1803 (OOXMLFastContextHandler * context);
1804 virtual ~
</xsl:text>
1805 <xsl:value-of select=
"$classname"/>
1808 <xsl:variable name=
"createchildcontextbody">
1809 <xsl:call-template name=
"createfastchildcontext"/>
1811 <xsl:if test=
"string-length($createchildcontextbody) > 0">
1812 virtual uno::Reference
< xml::sax::XFastContextHandler
>
1813 lcl_createFastChildContext
1814 (::sal_Int32 Element,
1815 const uno::Reference
< xml::sax::XFastAttributeList
> & Attribs)
1816 throw (uno::RuntimeException, xml::sax::SAXException);
1818 <xsl:variable name=
"fastattributebody">
1819 <xsl:call-template name=
"fastattribute"/>
1821 <xsl:if test=
"string-length($fastattributebody) > 0">
1822 virtual void attributes
1823 (const uno::Reference
< xml::sax::XFastAttributeList
> & Attribs)
1824 throw (uno::RuntimeException, xml::sax::SAXException);
1826 <xsl:variable name=
"faststartactionbody">
1827 <xsl:call-template name=
"faststartaction"/>
1829 <xsl:if test=
"string-length($faststartactionbody)">
1830 virtual void lcl_startAction(Token_t nElement);
1832 <xsl:variable name=
"fastendactionbody">
1833 <xsl:call-template name=
"fastendaction"/>
1835 <xsl:if test=
"string-length($fastendactionbody)">
1836 virtual void lcl_endAction(Token_t nElement);
1838 <xsl:variable name=
"fastcharactersbody">
1839 <xsl:call-template name=
"fastcharacters"/>
1841 <xsl:if test=
"string-length($fastcharactersbody)">
1842 virtual void lcl_characters(const ::rtl::OUString
& aChars)
1843 throw (uno::RuntimeException, xml::sax::SAXException);
1846 virtual string getType() const { return
"</xsl:text>
1847 <xsl:value-of select="$classname
"/>
1848 <xsl:text>"; }
</xsl:text>
1849 <xsl:variable name=
"propagatespropsbody">
1850 <xsl:call-template name=
"propagatesproperties"/>
1852 <xsl:if test=
"string-length($propagatespropsbody)">
1854 virtual bool propagatesProperties() const;
</xsl:text>
1861 <xsl:template name=
"fastcontextdecls">
1862 <xsl:param name=
"namespace"/>
1863 <xsl:for-each select=
"/model/namespace[@name=$namespace]">
1864 <xsl:for-each select=
"./rng:grammar/rng:define">
1865 <xsl:variable name=
"do">
1866 <xsl:call-template name=
"classfordefine"/>
1871 <xsl:value-of select=
"ancestor::namespace/@name"/>
1872 <xsl:text>:
</xsl:text>
1873 <xsl:value-of select=
"@name"/>
1876 <xsl:if test=
"$do = '1'">
1877 <xsl:call-template name=
"fastcontextdecl"/>
1883 <xsl:template name=
"fastcontextconstructor">
1884 <xsl:variable name=
"classname">
1885 <xsl:call-template name=
"fastcontextname"/>
1887 <xsl:value-of select=
"$classname"/>
1888 <xsl:text>::
</xsl:text>
1889 <xsl:value-of select=
"$classname"/>
1891 (OOXMLFastContextHandler * pContext)
1893 <xsl:call-template name=
"fastresourceclass"/>
1894 <xsl:text>(pContext)
1899 <xsl:template name=
"fastcontextdestructor">
1900 <xsl:variable name=
"classname">
1901 <xsl:call-template name=
"fastcontextname"/>
1903 <xsl:value-of select=
"$classname"/>
1904 <xsl:text>::~
</xsl:text>
1905 <xsl:value-of select=
"$classname"/>
1912 <xsl:template name=
"faststartactionbodysetid">
1913 <xsl:if test=
"@resource = 'Table' or @resource='PropertyTable'">
1916 <xsl:call-template name=
"idtoqname">
1917 <xsl:with-param name=
"id" select=
"@tokenid"/>
1918 </xsl:call-template>
1919 <xsl:text>);
</xsl:text>
1923 <xsl:template name=
"faststartactionbodychooseaction">
1924 <xsl:for-each select=
"./action[@name='start']">
1925 <xsl:call-template name=
"chooseaction"/>
1929 <xsl:template name=
"faststartactionbody">
1930 <xsl:variable name=
"name" select=
"@name"/>
1931 <xsl:for-each select=
"ancestor::namespace/resource[@name = $name]">
1932 <xsl:call-template name=
"faststartactionbodysetid"/>
1933 <xsl:call-template name=
"faststartactionbodychooseaction"/>
1937 <xsl:template name=
"faststartaction">
1938 <xsl:variable name=
"body">
1939 <xsl:call-template name=
"faststartactionbody"/>
1941 <xsl:variable name=
"name" select=
"@name"/>
1942 <xsl:if test=
"string-length($body) > 0">
1943 <xsl:variable name=
"classname">
1944 <xsl:call-template name=
"fastcontextname"/>
1948 <xsl:value-of select=
"$classname"/>
1949 <xsl:text>::lcl_startAction(Token_t
</xsl:text>
1950 <xsl:for-each select=
"ancestor::namespace/resource[@name=$name]">
1951 <xsl:if test=
"./element/action[@name='start']">
1952 <xsl_text> nElement
</xsl_text>
1957 <xsl:value-of select=
"$body"/>
1964 <xsl:template name=
"fastendactionbody">
1965 <xsl:variable name=
"name" select=
"@name"/>
1966 <xsl:for-each select=
"ancestor::namespace/resource[@name = $name]">
1967 <xsl:for-each select=
"./action[@name='end']">
1968 <xsl:call-template name=
"chooseaction"/>
1973 <xsl:template name=
"fastendaction">
1974 <xsl:variable name=
"body">
1975 <xsl:call-template name=
"fastendactionbody"/>
1977 <xsl:variable name=
"name" select=
"@name"/>
1978 <xsl:if test=
"string-length($body) > 0">
1979 <xsl:variable name=
"classname">
1980 <xsl:call-template name=
"fastcontextname"/>
1984 <xsl:value-of select=
"$classname"/>
1985 <xsl:text>::lcl_endAction(Token_t
</xsl:text>
1986 <xsl:for-each select=
"ancestor::namespace/resource[@name=$name]">
1987 <xsl:if test=
"./element/action[@name='end']">
1988 <xsl_text> nElement
</xsl_text>
1993 <xsl:value-of select=
"$body"/>
2000 <xsl:template name=
"fastcharactersbody">
2001 <xsl:variable name=
"name" select=
"@name"/>
2002 <xsl:for-each select=
"ancestor::namespace/resource[@name = $name]//action[@name='characters']">
2003 <xsl:call-template name=
"chooseaction"/>
2007 <xsl:template name=
"fastcharacters">
2008 <xsl:variable name=
"body">
2009 <xsl:call-template name=
"fastcharactersbody"/>
2011 <xsl:if test=
"string-length($body) > 0">
2012 <xsl:variable name=
"classname">
2013 <xsl:call-template name=
"fastcontextname"/>
2017 <xsl:value-of select=
"$classname"/>
2018 <xsl:text>::lcl_characters(const ::rtl::OUString
& sText)
2019 throw (uno::RuntimeException, xml::sax::SAXException)
2021 <xsl:value-of select=
"$body"/>
2028 <xsl:template name=
"propagatespropertiesbody">
2029 <xsl:variable name=
"name" select=
"@name"/>
2030 <xsl:for-each select=
"ancestor::namespace/resource[@name=$name]">
2031 <xsl:for-each select=
".//action">
2033 <xsl:when test=
"@name='propagateCharacterProperties'">
2035 return true;
</xsl:text>
2037 <xsl:when test=
"@name='propagateTableProperties'">
2039 return true;
</xsl:text>
2046 <xsl:template name=
"propagatesproperties">
2047 <xsl:variable name=
"body">
2048 <xsl:call-template name=
"propagatespropertiesbody"/>
2050 <xsl:if test=
"string-length($body) > 0">
2051 <xsl:variable name=
"classname">
2052 <xsl:call-template name=
"fastcontextname"/>
2056 <xsl:value-of select=
"$classname"/>
2057 <xsl:text>::propagatesProperties() const
2059 <xsl:value-of select=
"$body"/>
2066 <xsl:template name=
"fastcontextcreatefromstart">
2068 uno::Reference
< xml::sax::XFastContextHandler
>
2069 OOXMLFastContextHandler::createFromStart
2070 (::sal_Int32 Element,
2071 const uno::Reference
< xml::sax::XFastAttributeList
> & Attribs)
2074 debug_logger-
>startElement(
"createfromstart");
2075 debug_logger-
>attribute(
"element", fastTokenToId(Element));
2077 uno::Reference
< xml::sax::XFastContextHandler
> xResult;
</xsl:text>
2079 <xsl:for-each select=
"//namespace/start">
2080 <xsl:variable name=
"name" select=
"@name"/>
2081 <xsl:for-each select=
"ancestor::namespace/rng:grammar/rng:define[@name=$name]">
2083 if (! xResult.is() || dynamic_cast
<OOXMLFastContextHandler *
>(xResult.get())-
>isFallback())
2085 xResult = OOXMLFastHelper
< </xsl:text>
2086 <xsl:call-template name=
"fastcontextname"/>
2087 <xsl:text> >::createAndSetParentRef(this, Element, Attribs);
2094 debug_logger-
>endElement(
"createfromstart");
2102 <xsl:key name=
"attribs-qnames" match=
"rng:attribute" use=
"@qname"/>
2104 <xsl:template name=
"dumpattribs">
2106 void dumpAttrib(const char * sToken, sal_uInt32 nToken,
2107 const uno::Reference
< xml::sax::XFastAttributeList
2112 if (Attribs-
>hasAttribute(nToken))
2114 debug_logger-
>startElement(
"attrib");
2115 debug_logger-
>attribute(
"id", sToken);
2116 debug_logger-
>chars(Attribs-
>getValue(nToken));
2117 debug_logger-
>endElement(
"attrib");
2122 debug_logger-
>startElement(
"error");
2123 debug_logger-
>chars(sToken);
2124 debug_logger-
>endElement(
"error");
2129 (const uno::Reference
< xml::sax::XFastAttributeList
> & Attribs)
2130 throw (uno::RuntimeException, xml::sax::SAXException)
2132 debug_logger-
>startElement(
"attribs");
2134 <xsl:for-each select=
"//rng:attribute[@name]">
2135 <xsl:if test=
"generate-id(.) = generate-id(key('attribs-qnames', @qname)[1]
2138 dumpAttrib(
"</xsl:text>
2139 <xsl:call-template name="fastlocalname
"/>
2140 <xsl:text>",
</xsl:text>
2141 <xsl:call-template name=
"fastlocalname"/>
2142 <xsl:text>, Attribs);
</xsl:text>
2144 dumpAttrib(
"</xsl:text>
2145 <xsl:call-template name="fasttoken
"/>
2146 <xsl:text>",
</xsl:text>
2147 <xsl:call-template name=
"fasttoken"/>
2148 <xsl:text>, Attribs);
</xsl:text>
2152 debug_logger-
>endElement(
"attribs");
2156 <xsl:template name=
"createfastchildcontextname">
2157 <xsl:text>createFastContextHandler_
</xsl:text>
2158 <xsl:value-of select=
"@name"/>
2161 <xsl:template name=
"caselabeldefine">
2162 <xsl:text>case CLASS_
</xsl:text>
2163 <xsl:value-of select=
"translate(ancestor::namespace/@name, '-', '_')"/>
2164 <xsl:text>_
</xsl:text>
2165 <xsl:value-of select=
"@name"/>
2166 <xsl:text>:
</xsl:text>
2169 <xsl:template name=
"createfastchildcontextswitchbodyref">
2170 <xsl:variable name=
"definename">
2171 <xsl:call-template name=
"searchdefinenamespace">
2172 <xsl:with-param name=
"name" select=
"@name"/>
2173 </xsl:call-template>
2175 <xsl:for-each select=
"/model/namespace[@name=substring-before($definename, ':')]">
2176 <xsl:for-each select=
"./rng:grammar/rng:define[@name=substring-after($definename, ':')]">
2177 <xsl:call-template name=
"createfastchildcontextswitchbody"/>
2182 <xsl:template name=
"createfastchildcontextswitchbody">
2183 <xsl:for-each select=
".//rng:element">
2186 <xsl:call-template name=
"caselabelfasttoken"/>
2188 xResult.set(
</xsl:text>
2189 <xsl:call-template name=
"fastelementcreatestatement"/>
2194 select=
".//rng:ref[not(ancestor::rng:element or ancestor::rng:attribute)]">
2195 <xsl:call-template name=
"createfastchildcontextswitchbodyref"/>
2199 <xsl:template name=
"createfastchildcontextswitch">
2200 <xsl:variable name=
"body">
2201 <xsl:call-template name=
"createfastchildcontextswitchbody"/>
2203 <xsl:if test=
"string-length($body) > 0">
2207 <xsl:value-of select=
"$body"/>
2215 <xsl:template name=
"createfastchildcontextlookup">
2217 uno::Reference
<XFastContextHandler
> </xsl:text>
2218 <xsl:call-template name=
"createfastchildcontextname"/>
2219 <xsl:text>(Id parent, Token_t Element)
2221 uno::Reference
<XFastContextHandler
> xResult;
2224 <xsl:for-each select=
"./rng:grammar/rng:define">
2225 <xsl:variable name=
"do">
2226 <xsl:call-template name=
"classfordefine"/>
2228 <xsl:if test=
"$do='1'">
2229 <xsl:variable name=
"casebody">
2230 <xsl:call-template name=
"createfastchildcontextswitch"/>
2232 <xsl:if test=
"string-length($casebody) > 0">
2235 <xsl:call-template name=
"caselabeldefine"/>
2236 <xsl:value-of select=
"$casebody"/>