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 <!-- Tiny template helping devs to debug -->
97 <xsl:template name=
"dbg_path">
98 <xsl:text>/*
</xsl:text>
99 <xsl:for-each select=
"ancestor::*">
100 <xsl:value-of select=
"name(.)"/>
101 <xsl:text>/
</xsl:text>
103 <xsl:value-of select=
"name(.)"/>
104 <xsl:text>[@name=
</xsl:text>
105 <xsl:value-of select=
"@name"/>
106 <xsl:text>]
</xsl:text>
107 <xsl:text>*/
</xsl:text>
110 <xsl:template name=
"licenseheader">
114 THIS FILE IS GENERATED AUTOMATICALLY! DO NOT EDIT!
120 <xsl:template name=
"hasrefs">
122 <xsl:when test=
".//rng:ref[not(ancestor::rng:element or ancestor::rng:attribute)]">
123 <xsl:text>1</xsl:text>
126 <xsl:text>0</xsl:text>
132 Returns <define> for the current <ref>.
134 The current node must be a <ref>!
136 <xsl:template name=
"defineforref">
137 <xsl:variable name=
"mygrammarid" select=
"generate-id(ancestor::rng:grammar)"/>
138 <xsl:value-of select=
"key('defines-with-name', @name)[generate-id(ancestor::rng:grammar) = $mygrammarid]"/>
142 Create name with prefix.
144 The result is <prefix>:<name>.
146 Exception: If <name> contains a ':' the prefix is ignored.
148 @param prefix the prefix
151 <xsl:template name=
"prefixname">
152 <xsl:param name=
"prefix"/>
153 <xsl:param name=
"name"/>
155 <xsl:when test=
"contains($name, ':')">
156 <xsl:value-of select=
"$name"/>
159 <xsl:value-of select=
"$prefix"/>
160 <xsl:text>:
</xsl:text>
161 <xsl:value-of select=
"$name"/>
166 <xsl:template name=
"fastnamespace">
167 <xsl:if test=
"string-length(@prefix) > 0">
168 <xsl:text>NS_
</xsl:text>
169 <xsl:value-of select=
"@prefix"/>
173 <xsl:template name=
"fastlocalname">
174 <xsl:text>OOXML_
</xsl:text>
175 <xsl:value-of select=
"@localname"/>
179 Create entries in enum definition for fast tokens.
181 For each occurrence of rng:element an entry
185 is generated, but only if the element is the first named <name>.
187 <xsl:template name=
"enumfasttokens">
188 <xsl:param name=
"prefix"/>
189 <xsl:for-each select=
".//rng:element|.//rng:attribute">
190 <xsl:if test=
"generate-id(.) = generate-id(key('same-token-name', @localname)[1])">
191 <xsl:call-template name=
"fastlocalname"/>
192 <xsl:text>,

 </xsl:text>
197 <xsl:template name=
"fasttokens">
199 typedef sal_Int32 Token_t;
201 <xsl:for-each select=
"/model/fasttoken">
203 const Token_t OOXML_
</xsl:text>
204 <xsl:value-of select=
"translate(., '-', '_')"/>
205 <xsl:text> =
</xsl:text>
206 <xsl:value-of select=
"position() - 1"/>
207 <xsl:text>;
</xsl:text>
210 const Token_t OOXML_FAST_TOKENS_END =
</xsl:text>
211 <xsl:value-of select=
"count(/model/fasttoken)"/>
212 <xsl:text>;

</xsl:text>
216 Returns prefix for the rng:grammar of the current node.
218 <xsl:template name=
"prefixforgrammar">
219 <xsl:variable name=
"ns" select=
"ancestor::rng:grammar/@ns"/>
220 <xsl:variable name=
"nsalias"><xsl:value-of select=
"key('namespace-aliases', $ns)/@alias"/></xsl:variable>
221 <!--<xsl:variable name="nsalias">test</xsl:variable>-->
223 <xsl:when test=
"string-length($nsalias) > 0">
224 <xsl:value-of select=
"$nsalias"/>
227 <xsl:value-of select=
"translate(substring-after($ns, 'http://'), '/.', '__')"/>
233 Returns prefix for the rng:grammar of the matching nodes.
235 <xsl:template match=
"*" mode=
"grammar-prefix">
236 <xsl:call-template name=
"prefixforgrammar"/>
240 Generates name for fast context class for this <define>
242 <xsl:template name=
"fastcontextname">
243 <xsl:variable name=
"do">
244 <xsl:call-template name=
"classfordefine"/>
246 <xsl:if test=
"$do = '1'">
247 <xsl:variable name=
"definename">
248 <xsl:call-template name=
"searchdefinenamespace">
249 <xsl:with-param name=
"name" select=
"@name"/>
252 <xsl:for-each select=
"/model/namespace[@name=substring-before($definename, ':')]">
253 <xsl:text>OOXMLFastContextHandler_
</xsl:text>
254 <xsl:value-of select=
"@namespacealias"/>
255 <xsl:text>_
</xsl:text>
256 <xsl:value-of select=
"substring-after($definename, ':')"/>
262 Returns the value of the @resource attribute of the <resource>
263 node according to the current <define>.
265 <xsl:template name=
"contextresource">
266 <xsl:variable name=
"mynsid" select=
"generate-id(ancestor::namespace)"/>
268 <xsl:when test=
"count(key('context-resource', @name)) = 1">
269 <xsl:value-of select=
"key('context-resource', @name)/@resource"/>
272 <xsl:value-of select=
"key('context-resource', @name)[generate-id(ancestor::namespace)=$mynsid]/@resource"/>
278 Returns a value name.
280 The resulting value name is
282 OOXMLValue_$prefix_$name
287 <xsl:template name=
"valuename">
288 <xsl:param name=
"prefix"/>
289 <xsl:param name=
"name"/>
290 <xsl:text>OOXMLValue_
</xsl:text>
291 <xsl:value-of select=
"$prefix"/>
292 <xsl:text>_
</xsl:text>
293 <xsl:value-of select=
"$name"/>
297 Returns the value name for the current <define>.
299 <xsl:template name=
"valuenamefordefine">
300 <xsl:call-template name=
"valuename">
301 <xsl:with-param name=
"prefix" select=
"key('namespace-aliases', ancestor::namespace/rng:grammar/@ns)/@alias"/>
302 <xsl:with-param name=
"name" select=
"translate(@name, '-', '_')"/>
307 Returns the name of the parent class of the class for the
310 Precondition: The class for the current <define> is derived
311 indirectly from OOXMLValue.
314 <xsl:template name=
"valueparent">
315 <xsl:variable name=
"resource">
316 <xsl:call-template name=
"contextresource"/>
318 <xsl:text>OOXML
</xsl:text>
319 <xsl:value-of select=
"$resource"/>
320 <xsl:text>Value
</xsl:text>
324 Generates declaration for a value class.
326 Precondition: <resource> for current <define> indicates that the
327 class is derived directly or indirectly from OOXMLValue.
329 <xsl:template name=
"valuedecl">
330 <xsl:variable name=
"classname">
331 <xsl:call-template name=
"valuenamefordefine"/>
333 <xsl:variable name=
"resource">
334 <xsl:call-template name=
"contextresource"/>
338 <xsl:value-of select=
"$classname"/>
339 <xsl:text> : public
</xsl:text>
340 <xsl:call-template name=
"valueparent"/>
346 <xsl:when test=
"$resource='List'">
347 <xsl:value-of select=
"$classname"/>
348 <xsl:text>(
</xsl:text>
349 <xsl:text>const rtl::OUString
& rValue
</xsl:text>
350 <xsl:text>);
</xsl:text>
353 <xsl:value-of select=
"$classname"/>
354 <xsl:text>(const rtl::OUString
& rValue) :
</xsl:text>
355 <xsl:call-template name=
"valueparent"/>
356 <xsl:text>(rValue) {}
</xsl:text>
361 <xsl:value-of select=
"$classname"/>
368 Checks if a class derived from OOXMLContex shall be defined for
369 the current <define>.
371 @retval 1 the class shall be defined.
374 <xsl:template name=
"classfordefine">
376 <xsl:variable name="name" select="@name"/>
378 <xsl:when test="(starts-with(@name, 'CT_') or starts-with(@name, 'EG_') or starts-with(@name, 'AG_'))">1</xsl:when>
379 <xsl:when test="ancestor::namespace//start[@name=$name]">1</xsl:when>
380 <xsl:otherwise>0</xsl:otherwise>
383 <xsl:value-of select=
"@classfordefine"/>
387 Checks if a class derived from OOXMLValue shall be defined for
388 the current <define>.
390 @retval 1 the class shall be defined
393 <xsl:template name=
"valuefordefine">
395 <xsl:when test=
"starts-with(@name, 'ST_')">1</xsl:when>
396 <xsl:otherwise>0</xsl:otherwise>
400 <xsl:template name=
"valuedecls">
401 <xsl:for-each select=
".//rng:grammar/rng:define">
402 <xsl:variable name=
"dovalue">
403 <xsl:call-template name=
"valuefordefine"/>
405 <xsl:if test=
"$dovalue = '1'">
406 <xsl:call-template name=
"valuedecl"/>
412 Generate switch body for createFastChildContext
414 <xsl:template name=
"switchbodycreatechildcontext">
415 <xsl:for-each select=
".//rng:element[@name]">
416 <xsl:call-template name=
"caselabelfasttoken"/>
417 <xsl:variable name=
"createstatement">
418 <xsl:call-template name=
"fastelementcreatestatement"/>
420 <xsl:if test=
"string-length($createstatement) > 0">
422 xContextHandler.set(
</xsl:text>
423 <xsl:value-of select=
"$createstatement"/>
433 <xsl:template name=
"fastelementcreatefromrefstatement">
434 <xsl:variable name=
"definename">
435 <xsl:call-template name=
"searchdefinenamespace">
436 <xsl:with-param name=
"name" select=
"@name"/>
439 <xsl:for-each select=
"/model/namespace[@name=substring-before($definename, ':')]">
440 <xsl:for-each select=
"./rng:grammar/rng:define[@name=substring-after($definename, ':')]">
441 <xsl:variable name=
"do">
442 <xsl:call-template name=
"classfordefine"/>
444 <xsl:if test=
"$do = '1'">
445 <xsl:text>OOXMLFastHelper
<</xsl:text>
446 <xsl:call-template name=
"fastcontextname"/>
447 <xsl:text>>::createAndSetParentRef(this, Element, Attribs)
</xsl:text>
453 <xsl:template name=
"switchbodycreatechildcontextrefs">
454 <xsl:for-each select=
".//rng:ref[not (ancestor::rng:element or ancestor::rng:attribute)]">
455 <xsl:variable name=
"createstatement">
456 <xsl:call-template name=
"fastelementcreatefromrefstatement"/>
458 <xsl:if test=
"string-length($createstatement) > 0">
460 if (! xContextHandler.is() || dynamic_cast
<OOXMLFastContextHandler *
>(xContextHandler.get())-
>isFallback())
462 xContextHandler.set(
</xsl:text>
463 <xsl:value-of select=
"$createstatement"/>
469 <xsl:for-each select=
".//rng:element[rng:anyName]">
470 <xsl:variable name=
"createstatement">
471 <xsl:call-template name=
"fastelementcreatestatement"/>
473 <xsl:if test=
"string-length($createstatement) > 0">
475 if (! xContextHandler.is() || dynamic_cast
<OOXMLFastContextHandler *
>(xContextHandler.get())-
>isFallback())
477 xContextHandler.set(
</xsl:text>
478 <xsl:value-of select=
"$createstatement"/>
487 Generates definition of method createFastChildContext for current <define>
489 <xsl:template name=
"createfastchildcontext">
490 <xsl:variable name=
"resource">
491 <xsl:call-template name=
"contextresource"/>
493 <xsl:if test=
"not($resource='Shape')">
494 <xsl:variable name=
"switchbody">
495 <xsl:call-template name=
"switchbodycreatechildcontext"/>
497 <xsl:variable name=
"switchbodyrefs">
498 <xsl:call-template name=
"switchbodycreatechildcontextrefs"/>
500 <xsl:if test=
"string-length($switchbody) > 0 or string-length($switchbodyrefs) > 0">
502 uno::Reference
< xml::sax::XFastContextHandler
>
504 <xsl:call-template name=
"fastcontextname"/>
505 <xsl:text>::lcl_createFastChildContext
506 (::sal_Int32 Element,
507 const uno::Reference
< xml::sax::XFastAttributeList
> &</xsl:text>
508 <xsl:if test=
"contains($switchbody, 'Attribs') or contains($switchbodyrefs, 'Attribs')">
509 <xsl:text> Attribs
</xsl:text>
512 throw (uno::RuntimeException, xml::sax::SAXException)
514 uno::Reference
< xml::sax::XFastContextHandler
> xContextHandler;
516 <xsl:if test=
"string-length($switchbody) > 0">
521 <xsl:value-of select=
"$switchbody"/>
528 <xsl:if test=
"string-length($switchbodyrefs) > 0">
529 <xsl:value-of select=
"$switchbodyrefs"/>
533 return xContextHandler;
540 <xsl:template name=
"idforattr">
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=
"./attribute[@name=$name]">
546 <xsl:call-template name=
"idtoqname">
547 <xsl:with-param name=
"id" select=
"@tokenid"/>
554 <xsl:template name=
"idforelement">
555 <xsl:variable name=
"name" select=
"@name"/>
556 <xsl:for-each select=
"ancestor::rng:define">
557 <xsl:variable name=
"definename" select=
"@name"/>
558 <xsl:for-each select=
"ancestor::namespace/resource[@name=$definename]">
559 <xsl:for-each select=
"./element[@name=$name]">
560 <xsl:call-template name=
"idtoqname">
561 <xsl:with-param name=
"id" select=
"@tokenid"/>
569 Processes token id given in <resource> elements.
571 The result is the identifier for the tokenid.
573 <xsl:template name=
"processtokenid">
575 <xsl:when test=
"contains(@tokenid, ':')">
576 <xsl:call-template name=
"idtoqname">
577 <xsl:with-param name=
"id" select=
"@tokenid"/>
581 <xsl:value-of select=
"@tokenid"/>
586 <xsl:template name=
"getidcaseimpl">
587 <xsl:for-each select=
"attribute|element">
590 <xsl:call-template name=
"caselabelfasttoken"/>
592 nResult =
</xsl:text>
593 <xsl:call-template name=
"processtokenid"/>
599 <xsl:template name=
"attributeproptype">
600 <xsl:variable name=
"mynsid" select=
"generate-id(ancestor::namespace)"/>
601 <xsl:variable name=
"name" select=
"@name"/>
602 <xsl:variable name=
"resource" select=
"key('context-resource', @name)[generate-id(ancestor::namespace)=$mynsid]"/>
604 <xsl:when test=
"$resource/element[@name=$name]">
605 <xsl:text>OOXMLPropertyImpl::SPRM
</xsl:text>
608 <xsl:text>OOXMLPropertyImpl::ATTRIBUTE
</xsl:text>
614 Check if a default is defined for a define.
616 Returns if the <resource> for the current <define> has a
619 @retval 0 there is no default
620 @retval 1 there is a default
622 <xsl:template name=
"contexthasdefault">
623 <xsl:variable name=
"name" select=
"@name"/>
625 <xsl:when test=
"ancestor::namespace/resource[@name=$name]//default">1</xsl:when>
626 <xsl:otherwise>0</xsl:otherwise>
631 Chooses the action for the current <action> element.
633 <xsl:template name=
"chooseaction">
634 <xsl:if test=
"@tokenid">
636 if (sal::static_int_cast
<Id
>(getId()) ==
</xsl:text>
637 <xsl:call-template name=
"idtoqname">
638 <xsl:with-param name=
"id" select=
"@tokenid"/>
643 <xsl:for-each select=
"./cond">
646 OOXMLPropertySetEntryToInteger aHandler(
</xsl:text>
647 <xsl:call-template name=
"idtoqname">
648 <xsl:with-param name=
"id" select=
"@tokenid"/>
651 getPropertySetAttrs()-
>resolve(aHandler);
653 if (sal::static_int_cast
<Id
>(aHandler.getValue()) ==
</xsl:text>
654 <xsl:call-template name=
"idtoqname">
655 <xsl:with-param name=
"id" select=
"@value"/>
661 <xsl:when test=
"@action='sendTableDepth'">
663 sendTableDepth();
</xsl:text>
665 <xsl:when test=
"@action='startCell'">
667 startCell();
</xsl:text>
669 <xsl:when test=
"@action='startParagraphGroup'">
671 startParagraphGroup();
</xsl:text>
673 <xsl:when test=
"@action='startCharacterGroup'">
675 startCharacterGroup();
</xsl:text>
677 <xsl:when test=
"@action='startSectionGroup'">
679 startSectionGroup();
</xsl:text>
681 <xsl:when test=
"@action='fieldstart'">
683 startField();
</xsl:text>
685 <xsl:when test=
"@action='fieldsep'">
687 fieldSeparator();
</xsl:text>
689 <xsl:when test=
"@action='fieldend'">
691 endField();
</xsl:text>
693 <xsl:when test=
"@action='ftnednref'">
695 ftnednref();
</xsl:text>
697 <xsl:when test=
"@action='ftnednsep'">
699 ftnednsep();
</xsl:text>
701 <xsl:when test=
"@action='ftnedncont'">
703 ftnedncont();
</xsl:text>
705 <xsl:when test=
"@action='pgNum'">
709 <xsl:when test=
"@action='tab'">
713 <xsl:when test=
"@action='cr'">
717 <xsl:when test=
"@action='noBreakHyphen'">
719 noBreakHyphen();
</xsl:text>
721 <xsl:when test=
"@action='softHyphen'">
723 softHyphen();
</xsl:text>
725 <xsl:when test=
"@action='endOfParagraph'">
727 endOfParagraph();
</xsl:text>
729 <xsl:when test=
"@action='handleLastParagraphInSection'">
731 handleLastParagraphInSection();
</xsl:text>
733 <xsl:when test=
"@action='setLastParagraphInSection'">
735 setLastParagraphInSection();
</xsl:text>
737 <xsl:when test=
"@action='endCell'">
739 endCell();
</xsl:text>
741 <xsl:when test=
"@action='endParagraphGroup'">
743 endParagraphGroup();
</xsl:text>
745 <xsl:when test=
"@action='endCharacterGroup'">
747 endCharacterGroup();
</xsl:text>
749 <xsl:when test=
"@action='endSectionGroup'">
751 endSectionGroup();
</xsl:text>
753 <xsl:when test=
"@action='handleXNotes'">
754 handleXNotes();
</xsl:when>
755 <xsl:when test=
"@action='handleHdrFtr'">
756 handleHdrFtr();
</xsl:when>
757 <xsl:when test=
"@action='handleComment'">
758 handleComment();
</xsl:when>
759 <xsl:when test=
"@action='handlePicture'">
760 handlePicture();
</xsl:when>
761 <xsl:when test=
"@action='handleHyperlink'">
762 handleHyperlink();
</xsl:when>
763 <xsl:when test=
"@action='handleBreak'">
764 handleBreak();
</xsl:when>
765 <xsl:when test=
"@action='handleOLE'">
766 handleOLE();
</xsl:when>
767 <xsl:when test=
"@action='printproperty'">
769 sendProperty(
</xsl:text>
770 <xsl:call-template name=
"idtoqname">
771 <xsl:with-param name=
"id" select=
"@sendtokenid"/>
773 <xsl:text>);
</xsl:text>
775 <xsl:when test=
"@action='propagateCharacterProperties'">
776 propagateCharacterProperties();
778 <xsl:when test=
"@action='propagateCharacterPropertiesAsSet'">
780 propagateCharacterPropertiesAsSet(
</xsl:text>
781 <xsl:call-template name=
"idtoqname">
782 <xsl:with-param name=
"id" select=
"@sendtokenid"/>
784 <xsl:text>);
</xsl:text>
786 <xsl:when test=
"@action='propagateTableProperties'">
787 propagateTableProperties();
789 <xsl:when test=
"@action='sendPropertiesWithId'">
791 sendPropertiesWithId(
</xsl:text>
792 <xsl:call-template name=
"idtoqname">
793 <xsl:with-param name=
"id" select=
"@sendtokenid"/>
795 <xsl:text>);
</xsl:text>
797 <xsl:when test=
"@action='clearProps'">
800 <xsl:when test=
"@action='text'">
803 <xsl:when test=
"@action='setHandle'">
807 <xsl:when test=
"@action='footnoteSeparator'">
810 <xsl:when test=
"@action='footnoteCont'">
813 <xsl:when test=
"@action='endnoteSeparator'">
816 <xsl:when test=
"@action='endnoteCont'">
819 <xsl:when test=
"@action='newProperty'">
821 OOXMLFastHelper
<OOXMLIntegerValue
>::newProperty(this,
</xsl:text>
822 <xsl:call-template name=
"idtoqname">
823 <xsl:with-param name=
"id" select=
"@tokenid"/>
825 <xsl:text>, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
"</xsl:text>
826 <xsl:value-of select="@value
"/>
827 <xsl:text>")));
</xsl:text>
829 <xsl:when test=
"@action='mark'">
831 OOXMLFastHelper
<OOXMLIntegerValue
>::mark(this,
</xsl:text>
832 <xsl:call-template name=
"idtoqname">
833 <xsl:with-param name=
"id" select=
"@sendtokenid"/>
835 <xsl:text>, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
"</xsl:text>
836 <xsl:value-of select="@value
"/>
837 <xsl:text>")));
</xsl:text>
839 <xsl:when test=
"@action='tokenproperty'">
841 OOXMLFastHelper
<OOXMLIntegerValue
>::newProperty(this,
</xsl:text>
842 <xsl:call-template name=
"idtoqname">
843 <xsl:with-param name=
"id">ooxml:token
</xsl:with-param>
845 <xsl:text>, getToken());
</xsl:text>
848 <xsl:for-each select=
"./cond">
853 <xsl:if test=
"@tokenid">
860 Generates the definitions of the methods of the fast context class
861 for the current <define>.
863 <xsl:template name=
"fastcontextimpls">
864 <xsl:param name=
"ns"/>
865 <xsl:for-each select=
".//namespace[@name=$ns]">
868 <xsl:for-each select=
"./rng:grammar/rng:define">
869 <xsl:variable name=
"do">
870 <xsl:call-template name=
"classfordefine"/>
872 <xsl:if test=
"$do = '1'">
873 <xsl:variable name=
"classname">
874 <xsl:call-template name=
"fastcontextname"/>
879 <xsl:value-of select=
"$classname"/>
883 <xsl:call-template name=
"fastcontextconstructor"/>
884 <xsl:call-template name=
"fastcontextdestructor"/>
885 <xsl:call-template name=
"faststartaction"/>
886 <xsl:call-template name=
"fastendaction"/>
887 <xsl:call-template name=
"createfastchildcontext"/>
888 <xsl:call-template name=
"fastattribute"/>
889 <xsl:call-template name=
"fastcharacters"/>
890 <xsl:call-template name=
"propagatesproperties"/>
896 <xsl:key name=
"value-with-content" match=
"//rng:value"
900 Generates name for a value string.
902 Value strings are possible values for attributes in OOXML.
904 @param string the string as present in the according <rng:value>
906 <xsl:template name=
"valuestringname">
907 <xsl:param name=
"string"/>
908 <xsl:text>OOXMLValueString_
</xsl:text>
909 <xsl:value-of select=
"translate($string, '-+ ,', 'mp__')"/>
913 Generates constant definitions for attribute values.
915 <xsl:template name=
"valueconstants">
917 rtl::OUString
</xsl:text>
918 <xsl:call-template name=
"valuestringname">
919 <xsl:with-param name=
"string"></xsl:with-param>
921 <xsl:text>(RTL_CONSTASCII_USTRINGPARAM(
""));
</xsl:text>
922 <xsl:for-each select=
"//rng:value[generate-id(key('value-with-content', text())[1]) = generate-id(.)]">
924 rtl::OUString
</xsl:text>
925 <xsl:call-template name=
"valuestringname">
926 <xsl:with-param name=
"string" select=
"."/>
928 <xsl:text>(RTL_CONSTASCII_USTRINGPARAM(
"</xsl:text>
929 <xsl:value-of select=".
"/>
930 <xsl:text>"));
</xsl:text>
935 Generates constant declarations for attribute values.
937 <xsl:template name=
"valueconstantdecls">
941 <xsl:call-template name=
"valuestringname">
942 <xsl:with-param name=
"string"></xsl:with-param>
944 <xsl:text>;
</xsl:text>
945 <xsl:for-each select=
"//rng:value[generate-id(key('value-with-content', text())[1]) = generate-id(.)]">
947 extern rtl::OUString
</xsl:text>
948 <xsl:call-template name=
"valuestringname">
949 <xsl:with-param name=
"string" select=
"."/>
951 <xsl:text>;
</xsl:text>
956 Generates definition of constructor for attribute value class
957 for current <define>.
959 <xsl:template name=
"valueconstructorimpl">
960 <xsl:variable name=
"name" select=
"@name"/>
961 <xsl:variable name=
"resource">
962 <xsl:call-template name=
"contextresource"/>
965 <xsl:when test=
"$resource = 'List'">
966 <xsl:variable name=
"classname">
967 <xsl:call-template name=
"valuenamefordefine"/>
969 <xsl:text>
</xsl:text>
970 <xsl:value-of select=
"$classname"/>
971 <xsl:text>::
</xsl:text>
972 <xsl:value-of select=
"$classname"/>
973 <xsl:text>(const rtl::OUString
& </xsl:text>
975 <xsl:when test=
"count(ancestor::namespace/resource[@name=$name]/value) > 0">
976 <xsl:text>rValue
</xsl:text>
979 <xsl:text>/* rValue */
</xsl:text>
985 <xsl:for-each select=
"ancestor::namespace/resource[@name=$name]">
986 <xsl:for-each select=
"./default">
988 mnValue =
</xsl:text>
990 <xsl:when test=
"@tokenid">
991 <xsl:call-template name=
"idtoqname">
992 <xsl:with-param name=
"id" select=
"@tokenid"/>
996 <xsl:value-of select=
"."/>
999 <xsl:text>;
</xsl:text>
1001 <xsl:for-each select=
"./value">
1003 if (rValue.compareTo(
</xsl:text>
1004 <xsl:call-template name=
"valuestringname">
1005 <xsl:with-param name=
"string" select=
"text()"/>
1006 </xsl:call-template>
1009 mnValue =
</xsl:text>
1010 <xsl:call-template name=
"idtoqname">
1011 <xsl:with-param name=
"id" select=
"@tokenid"/>
1012 </xsl:call-template>
1026 Generates definition of destructor of attribute value class for
1029 <xsl:template name=
"valuedestructorimpl">
1030 <xsl:variable name=
"classname">
1031 <xsl:call-template name=
"valuenamefordefine"/>
1033 <xsl:text>
</xsl:text>
1034 <xsl:value-of select=
"$classname"/>
1035 <xsl:text>::~
</xsl:text>
1036 <xsl:value-of select=
"$classname"/>
1044 Generates definitions for attribute value class for current
1047 <xsl:template name=
"valueimpls">
1048 <xsl:for-each select=
".//rng:grammar/rng:define">
1049 <xsl:variable name=
"do">
1050 <xsl:call-template name=
"valuefordefine"/>
1052 <xsl:if test=
"$do = 1">
1053 <xsl:variable name=
"classname">
1054 <xsl:call-template name=
"valuenamefordefine"/>
1059 <xsl:value-of select=
"$classname"/>
1063 <xsl:call-template name=
"valueconstructorimpl"/>
1068 <xsl:key name=
"tokenids" match=
"@tokenid|@sendtokenid" use=
"."/>
1071 Generates contant definitions for tokenids.
1073 <xsl:template name=
"defineooxmlids">
1077 <xsl:for-each select=
"//@tokenid|//@sendtokenid">
1078 <xsl:if test=
"contains(., 'ooxml:') and generate-id(.) = generate-id(key('tokenids', .)[1])">
1080 const Id LN_
</xsl:text>
1081 <xsl:value-of select=
"substring-after(., 'ooxml:')"/>
1082 <xsl:text> =
</xsl:text>
1083 <xsl:value-of select=
"90000 + position()"/>
1084 <xsl:text>;
</xsl:text>
1090 <xsl:template name=
"ooxmlidstoxml">
1092 void ooxmlsprmidsToXML(::std::ostream
& out)
1094 <xsl:for-each select=
"//@tokenid">
1095 <xsl:if test=
"contains(., 'ooxml:') and generate-id(.) = generate-id(key('tokenids', .)[1]) and ancestor::element">
1097 out
<< "<theid name=\"</xsl:text>
1098 <xsl:value-of select=
"."/>
1099 <xsl:text>\
"></xsl:text>
1100 <xsl:value-of select="90000 + position()
"/>
1101 <xsl:text></theid>" << endl;
</xsl:text>
1107 void ooxmlidsToXML(::std::ostream
& out)
1109 <xsl:for-each select=
"//@tokenid">
1110 <xsl:if test=
"contains(., 'ooxml:') and generate-id(.) = generate-id(key('tokenids', .)[1]) and ancestor::attribute">
1112 out
<< "<theid name=\"</xsl:text>
1113 <xsl:value-of select=
"."/>
1114 <xsl:text>\
"></xsl:text>
1115 <xsl:value-of select="90000 + position()
"/>
1116 <xsl:text></theid>" << endl;
</xsl:text>
1124 Generates mapping from tokenids to strings. (DEBUG)
1126 <xsl:template name=
"qnametostr">
1128 void QNameToString::init_ooxml()
1132 <xsl:for-each select=
"//@tokenid">
1133 <xsl:if test=
"generate-id(.) = generate-id(key('tokenids', .)[1]) and contains(., 'ooxml:')">
1136 <xsl:call-template name=
"idtoqname">
1137 <xsl:with-param name=
"id" select=
"."/>
1138 </xsl:call-template>
1139 <xsl:text>] =
"</xsl:text>
1140 <xsl:value-of select=".
"/>
1141 <xsl:text>";
</xsl:text>
1149 <xsl:template name=
"qnametostrfunc">
1151 string qnameToString(sal_uInt32 nToken)
1157 <xsl:for-each select=
"//resource">
1158 <xsl:variable name=
"name" select=
"@name"/>
1159 <xsl:for-each select=
"attribute|element">
1160 <xsl:if test=
"contains(@tokenid, 'ooxml:')">
1163 <xsl:call-template name=
"idtoqname">
1164 <xsl:with-param name=
"id" select=
"@tokenid"/>
1165 </xsl:call-template>
1167 sResult =
"</xsl:text>
1168 <xsl:value-of select="@token
"/>
1183 <xsl:key name=
"resources-with-kind" match=
"resource[.//kind]"
1184 use=
".//kind/@name"/>
1186 <xsl:key name=
"sprms-with-code" match=
"element" use=
"@tokenid"/>
1189 Generates case labels for mapping from token ids to a single kind
1192 @param kind the sprm kind for which to generate the case labels
1194 <xsl:template name=
"sprmkindcase">
1195 <xsl:param name=
"kind"/>
1196 <xsl:for-each select=
"key('resources-with-kind', $kind)/element">
1197 <xsl:if test=
"generate-id(.) = generate-id(key('sprms-with-code', @tokenid))">
1200 <xsl:call-template name=
"idtoqname">
1201 <xsl:with-param name=
"id" select=
"@tokenid"/>
1202 </xsl:call-template>
1203 <xsl:text>: //
</xsl:text>
1204 <xsl:value-of select=
"ancestor::resource/@name"/>
1205 <xsl:text>,
</xsl:text>
1206 <xsl:value-of select=
"@name"/>
1214 <xsl:template name=
"sprmkind">
1216 Sprm::Kind SprmKind(sal_uInt32 nSprmCode)
1218 Sprm::Kind nResult = Sprm::UNKNOWN;
1222 <xsl:call-template name=
"sprmkindcase">
1223 <xsl:with-param name=
"kind">paragraph
</xsl:with-param>
1224 </xsl:call-template>
1226 nResult = Sprm::PARAGRAPH;
1228 <xsl:call-template name=
"sprmkindcase">
1229 <xsl:with-param name=
"kind">character
</xsl:with-param>
1230 </xsl:call-template>
1232 nResult = Sprm::CHARACTER;
1234 <xsl:call-template name=
"sprmkindcase">
1235 <xsl:with-param name=
"kind">table
</xsl:with-param>
1236 </xsl:call-template>
1238 nResult = Sprm::TABLE;
1250 Generates qname for id.
1252 @param id the id to generate qname for
1254 If id is of format <prefix>:<localname> the result is
1256 NS_<prefix>::LN_<localname>
1258 If id does not contain ":" the result is just id.
1260 <xsl:template name='idtoqname'
>
1261 <xsl:param name='id'
/>
1263 <xsl:when test=
"contains($id, ':')">
1264 <xsl:text>NS_
</xsl:text>
1265 <xsl:value-of select='substring-before($id,
":")'
/>
1266 <xsl:text>::LN_
</xsl:text>
1267 <xsl:value-of select='substring-after($id,
":")'
/>
1270 <xsl:value-of select=
"$id"/>
1275 <xsl:key name=
"same-token-name" match=
"rng:element|rng:attribute" use=
"@localname"/>
1278 Generates input for gperf to genreate hash map for OOXMLFastTokenHandler
1280 <xsl:template name=
"gperfinputfasttokenhandler">
1283 #include
"OOXMLFastTokens.hxx"
1285 namespace writerfilter { namespace ooxml { namespace tokenmap {
1287 struct token { const char * name; Token_t nToken; };
1289 <xsl:for-each select=
".//rng:element|.//rng:attribute">
1290 <xsl:if test=
"generate-id(.) = generate-id(key('same-token-name', @localname)[1])">
1291 <xsl:text>
</xsl:text>
1292 <xsl:value-of select=
"@localname"/>
1293 <xsl:text>,
</xsl:text>
1294 <xsl:call-template name=
"fastlocalname"/>
1299 }}}

</xsl:template>
1301 <xsl:template name=
"namespaceid">
1302 <xsl:text>NS_
</xsl:text>
1303 <xsl:value-of select=
"@alias"/>
1306 <xsl:template name=
"namespaceids">
1307 <xsl:for-each select=
"//namespace-alias">
1309 const sal_uInt32
</xsl:text>
1310 <xsl:call-template name=
"namespaceid"/>
1311 <xsl:text> =
</xsl:text>
1312 <xsl:value-of select=
"@id"/>
1313 <xsl:text> << 16;
</xsl:text>
1317 <xsl:template name=
"fasttoken">
1318 <xsl:variable name=
"ns">
1319 <xsl:call-template name=
"fastnamespace"/>
1321 <xsl:if test=
"string-length($ns) > 0">
1322 <xsl:value-of select=
"$ns"/>
1323 <xsl:text>|
</xsl:text>
1325 <xsl:call-template name=
"fastlocalname"/>
1328 <xsl:template name=
"fasttokenwithattr">
1329 <xsl:if test=
"local-name(.)='attribute'">
1330 <xsl:text>F_Attribute|
</xsl:text>
1332 <xsl:call-template name=
"fasttoken"/>
1335 <xsl:template name=
"caselabelfasttoken">
1336 <xsl:text>case
</xsl:text>
1337 <xsl:call-template name=
"fasttokenwithattr"/>
1338 <xsl:text>:
</xsl:text>
1341 <xsl:key name=
"elementsattrsbynamespace"
1342 match=
"rng:element[@name]|rng:attribute[@name]" use=
"ancestor::rng:grammar/@ns"/>
1344 <xsl:template name=
"fasttokentoid">
1346 namespace tokenmap {
1347 struct token { const char * name; Token_t nToken; };
1351 static inline unsigned int hash (const char *str, unsigned int len);
1353 static struct token *in_word_set (const char *str, unsigned int len);
1357 string fastTokenToId(sal_uInt32 nToken)
1363 switch (nToken
& 0xffff0000)
1365 <xsl:for-each select=
"//namespace-alias">
1368 <xsl:value-of select=
"@alias"/>
1370 sResult +=
"</xsl:text>
1371 <xsl:value-of select="@alias
"/>
1378 switch (nToken
& 0xffff)
1380 <xsl:for-each select=
".//rng:element[@localname]|.//rng:attribute[@localname]">
1381 <xsl:variable name=
"localname" select=
"@localname"/>
1382 <xsl:if test=
"generate-id(.) = generate-id(key('same-token-name', $localname)[1])">
1385 <xsl:call-template name=
"fastlocalname"/>
1387 sResult +=
"</xsl:text>
1388 <xsl:value-of select="$localname
"/>
1401 <xsl:template name=
"getfastparser">
1403 uno::Reference
< xml::sax::XFastParser
> OOXMLStreamImpl::getFastParser()
1405 if (! mxFastParser.is())
1407 uno::Reference
< lang::XMultiComponentFactory
> xFactory =
1408 uno::Reference
< lang::XMultiComponentFactory
>
1409 (mxContext-
>getServiceManager());
1411 mxFastParser.set(xFactory-
>createInstanceWithContext
1412 ( ::rtl::OUString::createFromAscii
1413 (
"com.sun.star.xml.sax.FastParser" ),
1414 mxContext ), uno::UNO_QUERY_THROW);
1416 <xsl:for-each select=
"//namespace-alias">
1418 mxFastParser-
>registerNamespace(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
"</xsl:text>
1419 <xsl:value-of select="@name
"/>
1420 <xsl:text>")),
</xsl:text>
1421 <xsl:call-template name=
"namespaceid"/>
1422 <xsl:text>);
</xsl:text>
1427 return mxFastParser;
1432 <xsl:template name=
"searchdefinenamespace">
1433 <xsl:param name=
"name"/>
1434 <xsl:variable name=
"tmp">
1435 <xsl:for-each select=
"ancestor::namespace">
1436 <xsl:call-template name=
"searchdefinenamespacerec">
1437 <xsl:with-param name=
"name" select=
"$name"/>
1438 </xsl:call-template>
1442 <xsl:when test=
"string-length($tmp) > 0">
1443 <xsl:value-of select=
"$tmp"/>
1446 <xsl:for-each select=
"key('defines-with-name', $name)[1]">
1447 <xsl:value-of select=
"ancestor::namespace/@name"/>
1448 <xsl:text>:
</xsl:text>
1449 <xsl:value-of select=
"@name"/>
1455 <xsl:template name=
"searchdefinenamespacerec">
1456 <xsl:param name=
"name"/>
1457 <xsl:variable name=
"nsname" select=
"@name"/>
1458 <xsl:variable name=
"nsid" select=
"generate-id(.)"/>
1459 <xsl:variable name=
"tmp">
1460 <xsl:for-each select=
"key('defines-with-name', $name)">
1461 <xsl:if test=
"generate-id(ancestor::namespace)=$nsid">
1462 <xsl:value-of select=
"$nsname"/>
1463 <xsl:text>:
</xsl:text>
1464 <xsl:value-of select=
"$name"/>
1469 <xsl:when test=
"string-length($tmp) > 0">
1470 <xsl:value-of select=
"$tmp"/>
1473 <xsl:for-each select=
"./rng:include">
1474 <xsl:for-each select=
"/model/namespace[@file=@href]">
1475 <xsl:call-template name=
"searchdefinenamespacerec">
1476 <xsl:with-param name=
"name" select=
"$name"/>
1477 </xsl:call-template>
1484 <xsl:template name=
"fastattributescheckattr">
1485 <xsl:text>if (Attribs-
>hasAttribute(
</xsl:text>
1486 <xsl:call-template name=
"fastlocalname"/>
1487 <xsl:text>))
</xsl:text>
1490 <xsl:template name=
"fastattributescheckattrwithns">
1491 <xsl:text>if (Attribs-
>hasAttribute(
</xsl:text>
1492 <xsl:call-template name=
"fasttoken"/>
1493 <xsl:text>))
</xsl:text>
1496 <xsl:template name=
"fastcontextnameforattribute">
1498 <xsl:when test=
"./rng:ref">
1499 <xsl:for-each select=
"./rng:ref">
1500 <xsl:call-template name=
"valuenameforref"/>
1503 <xsl:when test=
"./rng:data/@type = 'boolean'">
1504 <xsl:text>OOXMLBooleanValue
</xsl:text>
1506 <xsl:when test=
"./rng:data/@type = 'unsignedInt'">
1507 <xsl:text>OOXMLIntegerValue
</xsl:text>
1509 <xsl:when test=
"./rng:text or ./rng:data/@type = 'string' or ./rng:data/@type = 'token'">
1510 <xsl:text>OOXMLStringValue
</xsl:text>
1515 <xsl:template name=
"fastattributesproperties">
1516 <xsl:variable name=
"definename" select=
"@name"/>
1517 <xsl:for-each select=
".//rng:attribute">
1518 <xsl:variable name=
"attrname" select=
"@name"/>
1519 <xsl:variable name=
"contextname">
1520 <xsl:call-template name=
"fastcontextnameforattribute"/>
1522 <xsl:variable name=
"attrid">
1523 <xsl:call-template name=
"idforattr"/>
1525 <xsl:if test=
"string-length($contextname) > 0 and string-length($attrid) > 0">
1528 <xsl:call-template name=
"fastattributescheckattrwithns"/>
1531 ::rtl::OUString aValue(Attribs-
>getValue(
</xsl:text>
1532 <xsl:call-template name=
"fasttoken"/>
1534 OOXMLFastHelper
< </xsl:text>
1535 <xsl:value-of select=
"$contextname"/>
1536 <xsl:text> >::newProperty(this,
</xsl:text>
1537 <xsl:value-of select=
"$attrid"/>
1538 <xsl:text>, aValue);
</xsl:text>
1539 <xsl:for-each select=
"ancestor::namespace/resource[@name=$definename]">
1540 <xsl:for-each select=
"./attribute[@name=$attrname]">
1542 <xsl:when test=
"@action='checkId'">
1544 checkId(aValue);
</xsl:text>
1546 <xsl:when test=
"@action='checkXNoteType'">
1548 <xsl:when test=
"@action='setXNoteId'">
1550 setXNoteId(aValue);
</xsl:text>
1561 <xsl:template name=
"fastcharactersstringvalue">
1564 msValue = sText;
</xsl:text>
1567 <xsl:template name=
"fastattributesstringvalue">
1568 <xsl:for-each select=
".//rng:attribute">
1571 <xsl:call-template name=
"fastattributescheckattrwithns"/>
1573 msValue = Attribs-
>getValue(
</xsl:text>
1574 <xsl:call-template name=
"fasttoken"/>
1575 <xsl:text>);
</xsl:text>
1579 <xsl:template name=
"fastcharactersintvalue">
1582 mnValue = sText.toInt32();
</xsl:text>
1585 <xsl:template name=
"fastattributesintvalue">
1586 <xsl:for-each select=
".//rng:attribute">
1589 <xsl:call-template name=
"fastattributescheckattrwithns"/>
1591 mnValue = Attribs-
>getValue(
</xsl:text>
1592 <xsl:call-template name=
"fasttoken"/>
1593 <xsl:text>).toInt32();
</xsl:text>
1597 <xsl:template name=
"fastcharactershexvalue">
1600 mnValue = sText.toInt32(
16);
</xsl:text>
1603 <xsl:template name=
"fastattributeshexvalue">
1604 <xsl:for-each select=
".//rng:attribute">
1607 <xsl:call-template name=
"fastattributescheckattrwithns"/>
1609 mnValue = Attribs-
>getValue(
</xsl:text>
1610 <xsl:call-template name=
"fasttoken"/>
1611 <xsl:text>).toInt32(
16);
</xsl:text>
1615 <xsl:template name=
"fastcharactersboolvalue">
1618 setValue( sText );
</xsl:text>
1621 <xsl:template name=
"fastattributesboolvalue">
1622 <xsl:for-each select=
".//rng:attribute">
1625 <xsl:call-template name=
"fastattributescheckattrwithns"/>
1627 setValue(Attribs-
>getValue(
</xsl:text>
1628 <xsl:call-template name=
"fasttoken"/>
1629 <xsl:text>));
</xsl:text>
1633 <xsl:template name=
"fastcharacterslistvalue">
1634 <xsl:variable name=
"bodywithns">
1635 <xsl:for-each select=
"rng:ref">
1636 <xsl:variable name=
"refname" select=
"@name"/>
1637 <xsl:variable name=
"refns">
1638 <xsl:call-template name=
"searchdefinenamespace">
1639 <xsl:with-param name=
"name" select=
"@name"/>
1640 </xsl:call-template>
1642 <xsl:variable name=
"valname">
1643 <xsl:for-each select=
"/model/namespace[@name=substring-before($refns, ':')]">
1644 <xsl:for-each select=
"./rng:grammar/rng:define[@name=substring-after($refns, ':')]">
1645 <xsl:call-template name=
"valuenamefordefine"/>
1650 mpValue = OOXMLValue::Pointer_t (new
</xsl:text>
1651 <xsl:value-of select=
"$valname"/>
1652 <xsl:text>( sText ) );
</xsl:text>
1655 <xsl:if test=
"string-length($bodywithns) > 0">
1658 <xsl:value-of select=
"$bodywithns"/>
1662 <xsl:template name=
"fastattributeslistvalue">
1663 <xsl:for-each select=
".//rng:attribute">
1664 <xsl:variable name=
"myfasttoken">
1665 <xsl:call-template name=
"fastlocalname"/>
1667 <xsl:variable name=
"myfasttokenwithns">
1668 <xsl:call-template name=
"fasttoken"/>
1670 <xsl:variable name=
"bodywithns">
1671 <xsl:for-each select=
"rng:ref">
1672 <xsl:variable name=
"refname" select=
"@name"/>
1673 <xsl:variable name=
"refns">
1674 <xsl:call-template name=
"searchdefinenamespace">
1675 <xsl:with-param name=
"name" select=
"@name"/>
1676 </xsl:call-template>
1678 <xsl:variable name=
"valname">
1679 <xsl:for-each select=
"/model/namespace[@name=substring-before($refns, ':')]">
1680 <xsl:for-each select=
"./rng:grammar/rng:define[@name=substring-after($refns, ':')]">
1681 <xsl:call-template name=
"valuenamefordefine"/>
1686 mpValue = OOXMLValue::Pointer_t (new
</xsl:text>
1687 <xsl:value-of select=
"$valname"/>
1688 <xsl:text>(Attribs-
>getValue(
</xsl:text>
1689 <xsl:value-of select=
"$myfasttokenwithns"/>
1690 <xsl:text>)));
</xsl:text>
1693 <xsl:if test=
"string-length($bodywithns) > 0">
1696 <xsl:call-template name=
"fastattributescheckattrwithns"/>
1697 <xsl:value-of select=
"$bodywithns"/>
1702 <xsl:template name=
"fastattributebody">
1703 <xsl:variable name=
"resource">
1704 <xsl:call-template name=
"contextresource"/>
1707 <xsl:when test=
"$resource = 'Properties' or $resource = 'Stream' or $resource='XNote' or $resource='Shape'" >
1708 <xsl:call-template name=
"fastattributesproperties"/>
1710 <xsl:when test=
"$resource = 'StringValue'">
1711 <xsl:call-template name=
"fastattributesstringvalue"/>
1713 <xsl:when test=
"$resource = 'IntegerValue'">
1714 <xsl:call-template name=
"fastattributesintvalue"/>
1716 <xsl:when test=
"$resource = 'HexValue'">
1717 <xsl:call-template name=
"fastattributeshexvalue"/>
1719 <xsl:when test=
"$resource = 'BooleanValue'">
1720 <xsl:call-template name=
"fastattributesboolvalue"/>
1722 <xsl:when test=
"$resource = 'ListValue'">
1723 <xsl:call-template name=
"fastattributeslistvalue"/>
1728 <xsl:template name=
"valuenameforref">
1729 <xsl:variable name=
"definename">
1730 <xsl:call-template name=
"searchdefinenamespace">
1731 <xsl:with-param name=
"name" select=
"@name"/>
1732 </xsl:call-template>
1734 <xsl:for-each select=
"/model/namespace[@name=substring-before($definename, ':')]">
1735 <xsl:for-each select=
"./rng:grammar/rng:define[@name=substring-after($definename, ':')]">
1736 <xsl:call-template name=
"valuenamefordefine"/>
1741 <xsl:template name=
"fastcontextnameforref">
1742 <xsl:variable name=
"definename">
1743 <xsl:call-template name=
"searchdefinenamespace">
1744 <xsl:with-param name=
"name" select=
"@name"/>
1745 </xsl:call-template>
1748 <xsl:text>/* </xsl:text>
1749 <xsl:value-of select="@name"/>
1750 <xsl:text>, </xsl:text>
1751 <xsl:value-of select="$definename"/>
1752 <xsl:text> */</xsl:text>
1754 <xsl:for-each select=
"/model/namespace[@name=substring-before($definename, ':')]">
1755 <xsl:for-each select=
"./rng:grammar/rng:define[@name=substring-after($definename, ':')]">
1756 <xsl:call-template name=
"fastcontextname"/>
1761 <xsl:template name=
"fastattributebodyrefs">
1762 <xsl:for-each select=
".//rng:ref[not(ancestor::rng:element or ancestor::rng:attribute)]">
1763 <xsl:variable name=
"contextname">
1764 <xsl:call-template name=
"fastcontextnameforref"/>
1766 <xsl:if test=
"string-length($contextname) > 0">
1768 OOXMLFastHelper
<</xsl:text>
1769 <xsl:value-of select=
"$contextname"/>
1770 <xsl:text>>::attributes(this, Attribs);
</xsl:text>
1776 Generates definition of method attributes for current <define>
1778 <xsl:template name=
"fastattribute">
1779 <xsl:variable name=
"resource">
1780 <xsl:call-template name=
"contextresource"/>
1782 <!--<xsl:if test="not($resource='Shape')"> -->
1783 <xsl:variable name=
"body">
1784 <xsl:call-template name=
"fastattributebody"/>
1786 <xsl:variable name=
"bodyrefs">
1787 <xsl:call-template name=
"fastattributebodyrefs"/>
1789 <xsl:if test=
"string-length($body) > 0 or string-length($bodyrefs) > 0">
1792 <xsl:call-template name=
"fastcontextname"/>
1793 <xsl:text>::attributes
1794 (const uno::Reference
< xml::sax::XFastAttributeList
> & Attribs)
1795 throw (uno::RuntimeException, xml::sax::SAXException)
1797 #ifdef DEBUG_DUMP_ATTRIBUTES
1798 dumpAttribs(Attribs);
1801 <xsl:value-of select=
"$body"/>
1802 <xsl:value-of select=
"$bodyrefs"/>
1810 <xsl:template name=
"fastelementcreatestatement">
1811 <xsl:for-each select=
".//rng:ref">
1813 <xsl:when test=
"@name='BUILT_IN_ANY_TYPE'">
1814 <xsl:text>createFromStart(Element, Attribs)
</xsl:text>
1817 <xsl:variable name=
"classname">
1818 <xsl:call-template name=
"fastcontextname"/>
1820 <xsl:if test=
"string-length($classname) > 0">
1821 <xsl:text>OOXMLFastHelper
<</xsl:text>
1822 <xsl:value-of select=
"$classname"/>
1823 <xsl:text>>::createAndSetParent(this, Element,
</xsl:text>
1824 <xsl:for-each select=
"ancestor::rng:element">
1825 <xsl:variable name=
"id">
1826 <xsl:call-template name=
"idforelement"/>
1829 <xsl:when test=
"string-length($id) > 0">
1830 <xsl:value-of select=
"$id"/>
1833 <xsl:text>0</xsl:text>
1837 <xsl:text>)
</xsl:text>
1845 Generates name for parent class of fast context.
1847 <xsl:template name=
"fastresourceclass">
1848 <xsl:text>OOXMLFastContextHandler
</xsl:text>
1849 <xsl:call-template name=
"contextresource"/>
1853 Generates the declaration of the fast context for the current <define>
1855 <xsl:template name=
"fastcontextdecl">
1856 <xsl:variable name=
"classname">
1857 <xsl:call-template name=
"fastcontextname"/>
1860 class WRITERFILTER_DLLPRIVATE
</xsl:text>
1861 <xsl:value-of select=
"$classname"/>
1862 <xsl:text>: public
</xsl:text>
1863 <xsl:call-template name=
"fastresourceclass"/>
1867 explicit
</xsl:text>
1868 <xsl:value-of select=
"$classname"/>
1870 (OOXMLFastContextHandler * context);
1871 virtual ~
</xsl:text>
1872 <xsl:value-of select=
"$classname"/>
1875 <xsl:variable name=
"createchildcontextbody">
1876 <xsl:call-template name=
"createfastchildcontext"/>
1878 <xsl:if test=
"string-length($createchildcontextbody) > 0">
1879 virtual uno::Reference
< xml::sax::XFastContextHandler
>
1880 lcl_createFastChildContext
1881 (::sal_Int32 Element,
1882 const uno::Reference
< xml::sax::XFastAttributeList
> & Attribs)
1883 throw (uno::RuntimeException, xml::sax::SAXException);
1885 <xsl:variable name=
"fastattributebody">
1886 <xsl:call-template name=
"fastattribute"/>
1888 <xsl:if test=
"string-length($fastattributebody) > 0">
1889 virtual void attributes
1890 (const uno::Reference
< xml::sax::XFastAttributeList
> & Attribs)
1891 throw (uno::RuntimeException, xml::sax::SAXException);
1893 <xsl:variable name=
"faststartactionbody">
1894 <xsl:call-template name=
"faststartaction"/>
1896 <xsl:if test=
"string-length($faststartactionbody)">
1897 virtual void lcl_startAction(Token_t nElement);
1899 <xsl:variable name=
"fastendactionbody">
1900 <xsl:call-template name=
"fastendaction"/>
1902 <xsl:if test=
"string-length($fastendactionbody)">
1903 virtual void lcl_endAction(Token_t nElement);
1905 <xsl:variable name=
"fastcharactersbody">
1906 <xsl:call-template name=
"fastcharacters"/>
1908 <xsl:if test=
"string-length($fastcharactersbody)">
1909 virtual void lcl_characters(const ::rtl::OUString
& aChars)
1910 throw (uno::RuntimeException, xml::sax::SAXException);
1913 virtual string getType() const { return
"</xsl:text>
1914 <xsl:value-of select="$classname
"/>
1915 <xsl:text>"; }
</xsl:text>
1916 <xsl:variable name=
"propagatespropsbody">
1917 <xsl:call-template name=
"propagatesproperties"/>
1919 <xsl:if test=
"string-length($propagatespropsbody)">
1921 virtual bool propagatesProperties() const;
</xsl:text>
1928 <xsl:template name=
"fastcontextdecls">
1929 <xsl:param name=
"namespace"/>
1930 <xsl:for-each select=
"/model/namespace[@name=$namespace]">
1931 <xsl:for-each select=
"./rng:grammar/rng:define">
1932 <xsl:variable name=
"do">
1933 <xsl:call-template name=
"classfordefine"/>
1938 <xsl:value-of select=
"ancestor::namespace/@name"/>
1939 <xsl:text>:
</xsl:text>
1940 <xsl:value-of select=
"@name"/>
1943 <xsl:if test=
"$do = '1'">
1944 <xsl:call-template name=
"fastcontextdecl"/>
1950 <xsl:template name=
"fastcontextconstructor">
1951 <xsl:variable name=
"classname">
1952 <xsl:call-template name=
"fastcontextname"/>
1954 <xsl:value-of select=
"$classname"/>
1955 <xsl:text>::
</xsl:text>
1956 <xsl:value-of select=
"$classname"/>
1958 (OOXMLFastContextHandler * pContext)
1960 <xsl:call-template name=
"fastresourceclass"/>
1961 <xsl:text>(pContext)
1966 <xsl:template name=
"fastcontextdestructor">
1967 <xsl:variable name=
"classname">
1968 <xsl:call-template name=
"fastcontextname"/>
1970 <xsl:value-of select=
"$classname"/>
1971 <xsl:text>::~
</xsl:text>
1972 <xsl:value-of select=
"$classname"/>
1979 <xsl:template name=
"faststartactionbodysetid">
1980 <xsl:if test=
"@resource = 'Table' or @resource='PropertyTable'">
1983 <xsl:call-template name=
"idtoqname">
1984 <xsl:with-param name=
"id" select=
"@tokenid"/>
1985 </xsl:call-template>
1986 <xsl:text>);
</xsl:text>
1990 <xsl:template name=
"faststartactionbodychooseaction">
1991 <xsl:for-each select=
"./action[@name='start']">
1992 <xsl:call-template name=
"chooseaction"/>
1996 <xsl:template name=
"faststartactionbody">
1997 <xsl:variable name=
"name" select=
"@name"/>
1998 <xsl:for-each select=
"ancestor::namespace/resource[@name = $name]">
1999 <xsl:call-template name=
"faststartactionbodysetid"/>
2000 <xsl:call-template name=
"faststartactionbodychooseaction"/>
2004 <xsl:template name=
"faststartaction">
2005 <xsl:variable name=
"body">
2006 <xsl:call-template name=
"faststartactionbody"/>
2008 <xsl:variable name=
"name" select=
"@name"/>
2009 <xsl:if test=
"string-length($body) > 0">
2010 <xsl:variable name=
"classname">
2011 <xsl:call-template name=
"fastcontextname"/>
2015 <xsl:value-of select=
"$classname"/>
2016 <xsl:text>::lcl_startAction(Token_t
</xsl:text>
2017 <xsl:for-each select=
"ancestor::namespace/resource[@name=$name]">
2018 <xsl:if test=
"./element/action[@name='start']">
2019 <xsl_text> nElement
</xsl_text>
2024 <xsl:value-of select=
"$body"/>
2031 <xsl:template name=
"fastendactionbody">
2032 <xsl:variable name=
"name" select=
"@name"/>
2033 <xsl:for-each select=
"ancestor::namespace/resource[@name = $name]">
2034 <xsl:for-each select=
"./action[@name='end']">
2035 <xsl:call-template name=
"chooseaction"/>
2040 <xsl:template name=
"fastendaction">
2041 <xsl:variable name=
"body">
2042 <xsl:call-template name=
"fastendactionbody"/>
2044 <xsl:variable name=
"name" select=
"@name"/>
2045 <xsl:if test=
"string-length($body) > 0">
2046 <xsl:variable name=
"classname">
2047 <xsl:call-template name=
"fastcontextname"/>
2051 <xsl:value-of select=
"$classname"/>
2052 <xsl:text>::lcl_endAction(Token_t
</xsl:text>
2053 <xsl:for-each select=
"ancestor::namespace/resource[@name=$name]">
2054 <xsl:if test=
"./element/action[@name='end']">
2055 <xsl_text> nElement
</xsl_text>
2060 <xsl:value-of select=
"$body"/>
2067 <xsl:template name=
"fastcharactersbody">
2068 <xsl:variable name=
"name" select=
"@name"/>
2069 <!-- ST values as text -->
2070 <xsl:variable name=
"resource">
2071 <xsl:call-template name=
"contextresource"/>
2074 <xsl:when test=
"$resource = 'StringValue'">
2075 <xsl:call-template name=
"fastcharactersstringvalue"/>
2077 <xsl:when test=
"$resource = 'IntegerValue'">
2078 <xsl:call-template name=
"fastcharactersintvalue"/>
2080 <xsl:when test=
"$resource = 'HexValue'">
2081 <xsl:call-template name=
"fastcharactershexvalue"/>
2083 <xsl:when test=
"$resource = 'BooleanValue'">
2084 <xsl:call-template name=
"fastcharactersboolvalue"/>
2086 <xsl:when test=
"$resource = 'ListValue'">
2087 <xsl:call-template name=
"fastcharacterslistvalue"/>
2091 <!-- characters action -->
2092 <xsl:for-each select=
"ancestor::namespace/resource[@name = $name]//action[@name='characters']">
2093 <xsl:call-template name=
"chooseaction"/>
2097 <xsl:template name=
"fastcharacters">
2098 <xsl:variable name=
"body">
2099 <xsl:call-template name=
"fastcharactersbody"/>
2101 <xsl:if test=
"string-length($body) > 0">
2102 <xsl:variable name=
"classname">
2103 <xsl:call-template name=
"fastcontextname"/>
2107 <xsl:value-of select=
"$classname"/>
2108 <xsl:text>::lcl_characters(const ::rtl::OUString
& sText)
2109 throw (uno::RuntimeException, xml::sax::SAXException)
2111 <xsl:value-of select=
"$body"/>
2118 <xsl:template name=
"propagatespropertiesbody">
2119 <xsl:variable name=
"name" select=
"@name"/>
2120 <xsl:for-each select=
"ancestor::namespace/resource[@name=$name]">
2121 <xsl:for-each select=
".//action">
2123 <xsl:when test=
"@name='propagateCharacterProperties'">
2125 return true;
</xsl:text>
2127 <xsl:when test=
"@name='propagateTableProperties'">
2129 return true;
</xsl:text>
2136 <xsl:template name=
"propagatesproperties">
2137 <xsl:variable name=
"body">
2138 <xsl:call-template name=
"propagatespropertiesbody"/>
2140 <xsl:if test=
"string-length($body) > 0">
2141 <xsl:variable name=
"classname">
2142 <xsl:call-template name=
"fastcontextname"/>
2146 <xsl:value-of select=
"$classname"/>
2147 <xsl:text>::propagatesProperties() const
2149 <xsl:value-of select=
"$body"/>
2156 <xsl:template name=
"fastcontextcreatefromstart">
2158 uno::Reference
< xml::sax::XFastContextHandler
>
2159 OOXMLFastContextHandler::createFromStart
2160 (::sal_Int32 Element,
2161 const uno::Reference
< xml::sax::XFastAttributeList
> & Attribs)
2164 debug_logger-
>startElement(
"createfromstart");
2165 debug_logger-
>attribute(
"element", fastTokenToId(Element));
2167 uno::Reference
< xml::sax::XFastContextHandler
> xResult;
</xsl:text>
2169 <xsl:for-each select=
"//namespace/start">
2170 <xsl:variable name=
"name" select=
"@name"/>
2171 <xsl:for-each select=
"ancestor::namespace/rng:grammar/rng:define[@name=$name]">
2173 if (! xResult.is() || dynamic_cast
<OOXMLFastContextHandler *
>(xResult.get())-
>isFallback())
2175 xResult = OOXMLFastHelper
< </xsl:text>
2176 <xsl:call-template name=
"fastcontextname"/>
2177 <xsl:text> >::createAndSetParentRef(this, Element, Attribs);
2184 debug_logger-
>endElement(
"createfromstart");
2192 <xsl:key name=
"attribs-qnames" match=
"rng:attribute" use=
"@qname"/>
2194 <xsl:template name=
"dumpattribs">
2196 void dumpAttrib(const char * sToken, sal_uInt32 nToken,
2197 const uno::Reference
< xml::sax::XFastAttributeList
2202 if (Attribs-
>hasAttribute(nToken))
2204 debug_logger-
>startElement(
"attrib");
2205 debug_logger-
>attribute(
"id", sToken);
2206 debug_logger-
>chars(Attribs-
>getValue(nToken));
2207 debug_logger-
>endElement(
"attrib");
2212 debug_logger-
>startElement(
"error");
2213 debug_logger-
>chars(sToken);
2214 debug_logger-
>endElement(
"error");
2219 (const uno::Reference
< xml::sax::XFastAttributeList
> & Attribs)
2220 throw (uno::RuntimeException, xml::sax::SAXException)
2222 debug_logger-
>startElement(
"attribs");
2224 <xsl:for-each select=
"//rng:attribute[@name]">
2225 <xsl:if test=
"generate-id(.) = generate-id(key('attribs-qnames', @qname)[1]
2228 dumpAttrib(
"</xsl:text>
2229 <xsl:call-template name="fastlocalname
"/>
2230 <xsl:text>",
</xsl:text>
2231 <xsl:call-template name=
"fastlocalname"/>
2232 <xsl:text>, Attribs);
</xsl:text>
2234 dumpAttrib(
"</xsl:text>
2235 <xsl:call-template name="fasttoken
"/>
2236 <xsl:text>",
</xsl:text>
2237 <xsl:call-template name=
"fasttoken"/>
2238 <xsl:text>, Attribs);
</xsl:text>
2242 debug_logger-
>endElement(
"attribs");
2246 <xsl:template name=
"createfastchildcontextname">
2247 <xsl:text>createFastContextHandler_
</xsl:text>
2248 <xsl:value-of select=
"@name"/>
2251 <xsl:template name=
"caselabeldefine">
2252 <xsl:text>case CLASS_
</xsl:text>
2253 <xsl:value-of select=
"translate(ancestor::namespace/@name, '-', '_')"/>
2254 <xsl:text>_
</xsl:text>
2255 <xsl:value-of select=
"@name"/>
2256 <xsl:text>:
</xsl:text>
2259 <xsl:template name=
"createfastchildcontextswitchbodyref">
2260 <xsl:variable name=
"definename">
2261 <xsl:call-template name=
"searchdefinenamespace">
2262 <xsl:with-param name=
"name" select=
"@name"/>
2263 </xsl:call-template>
2265 <xsl:for-each select=
"/model/namespace[@name=substring-before($definename, ':')]">
2266 <xsl:for-each select=
"./rng:grammar/rng:define[@name=substring-after($definename, ':')]">
2267 <xsl:call-template name=
"createfastchildcontextswitchbody"/>
2272 <xsl:template name=
"createfastchildcontextswitchbody">
2273 <xsl:for-each select=
".//rng:element">
2276 <xsl:call-template name=
"caselabelfasttoken"/>
2278 xResult.set(
</xsl:text>
2279 <xsl:call-template name=
"fastelementcreatestatement"/>
2284 select=
".//rng:ref[not(ancestor::rng:element or ancestor::rng:attribute)]">
2285 <xsl:call-template name=
"createfastchildcontextswitchbodyref"/>
2289 <xsl:template name=
"createfastchildcontextswitch">
2290 <xsl:variable name=
"body">
2291 <xsl:call-template name=
"createfastchildcontextswitchbody"/>
2293 <xsl:if test=
"string-length($body) > 0">
2297 <xsl:value-of select=
"$body"/>
2305 <xsl:template name=
"createfastchildcontextlookup">
2307 uno::Reference
<XFastContextHandler
> </xsl:text>
2308 <xsl:call-template name=
"createfastchildcontextname"/>
2309 <xsl:text>(Id parent, Token_t Element)
2311 uno::Reference
<XFastContextHandler
> xResult;
2314 <xsl:for-each select=
"./rng:grammar/rng:define">
2315 <xsl:variable name=
"do">
2316 <xsl:call-template name=
"classfordefine"/>
2318 <xsl:if test=
"$do='1'">
2319 <xsl:variable name=
"casebody">
2320 <xsl:call-template name=
"createfastchildcontextswitch"/>
2322 <xsl:if test=
"string-length($casebody) > 0">
2325 <xsl:call-template name=
"caselabeldefine"/>
2326 <xsl:value-of select=
"$casebody"/>