merge the formfield patch from ooo-build
[ooovba.git] / writerfilter / source / ooxml / resourcestools.xsl
blob7296cbd34154af0656fc7d06bef646a62c78965a
1 <!--
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * Copyright 2008 by Sun Microsystems, Inc.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * $RCSfile: resourcestools.xsl,v $
12 * $Revision: 1.49 $
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 ************************************************************************/
33 -->
34 <xsl:stylesheet
35 version="1.0"
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"
67 xml:space="default">
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>
102 </xsl:for-each>
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>
108 </xsl:template>
110 <xsl:template name="licenseheader">
111 <xsl:text>
114 THIS FILE IS GENERATED AUTOMATICALLY! DO NOT EDIT!
117 &#xa;</xsl:text>
118 </xsl:template>
120 <xsl:template name="hasrefs">
121 <xsl:choose>
122 <xsl:when test=".//rng:ref[not(ancestor::rng:element or ancestor::rng:attribute)]">
123 <xsl:text>1</xsl:text>
124 </xsl:when>
125 <xsl:otherwise>
126 <xsl:text>0</xsl:text>
127 </xsl:otherwise>
128 </xsl:choose>
129 </xsl:template>
131 <!--
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]"/>
139 </xsl:template>
141 <!--
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
149 @param name the name
151 <xsl:template name="prefixname">
152 <xsl:param name="prefix"/>
153 <xsl:param name="name"/>
154 <xsl:choose>
155 <xsl:when test="contains($name, ':')">
156 <xsl:value-of select="$name"/>
157 </xsl:when>
158 <xsl:otherwise>
159 <xsl:value-of select="$prefix"/>
160 <xsl:text>:</xsl:text>
161 <xsl:value-of select="$name"/>
162 </xsl:otherwise>
163 </xsl:choose>
164 </xsl:template>
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"/>
170 </xsl:if>
171 </xsl:template>
173 <xsl:template name="fastlocalname">
174 <xsl:text>OOXML_</xsl:text>
175 <xsl:value-of select="@localname"/>
176 </xsl:template>
178 <!--
179 Create entries in enum definition for fast tokens.
181 For each occurrence of rng:element an entry
183 OOXML_<name>
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>, &#xa; </xsl:text>
193 </xsl:if>
194 </xsl:for-each>
195 </xsl:template>
197 <xsl:template name="fasttokens">
198 <xsl:text>
199 typedef sal_Int32 Token_t;
200 </xsl:text>
201 <xsl:for-each select="/model/fasttoken">
202 <xsl:text>
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>
208 </xsl:for-each>
209 <xsl:text>
210 const Token_t OOXML_FAST_TOKENS_END =</xsl:text>
211 <xsl:value-of select="count(/model/fasttoken)"/>
212 <xsl:text>;&#xa;</xsl:text>
213 </xsl:template>
215 <!--
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>-->
222 <xsl:choose>
223 <xsl:when test="string-length($nsalias) > 0">
224 <xsl:value-of select="$nsalias"/>
225 </xsl:when>
226 <xsl:otherwise>
227 <xsl:value-of select="translate(substring-after($ns, 'http://'), '/.', '__')"/>
228 </xsl:otherwise>
229 </xsl:choose>
230 </xsl:template>
232 <!--
233 Returns prefix for the rng:grammar of the matching nodes.
235 <xsl:template match="*" mode="grammar-prefix">
236 <xsl:call-template name="prefixforgrammar"/>
237 </xsl:template>
239 <!--
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"/>
245 </xsl:variable>
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"/>
250 </xsl:call-template>
251 </xsl:variable>
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, ':')"/>
257 </xsl:for-each>
258 </xsl:if>
259 </xsl:template>
261 <!--
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)"/>
267 <xsl:choose>
268 <xsl:when test="count(key('context-resource', @name)) = 1">
269 <xsl:value-of select="key('context-resource', @name)/@resource"/>
270 </xsl:when>
271 <xsl:otherwise>
272 <xsl:value-of select="key('context-resource', @name)[generate-id(ancestor::namespace)=$mynsid]/@resource"/>
273 </xsl:otherwise>
274 </xsl:choose>
275 </xsl:template>
277 <!--
278 Returns a value name.
280 The resulting value name is
282 OOXMLValue_$prefix_$name
284 @prefix the prefix
285 @name the 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"/>
294 </xsl:template>
296 <!--
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, '-', '_')"/>
303 </xsl:call-template>
304 </xsl:template>
306 <!--
307 Returns the name of the parent class of the class for the
308 current <define>.
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"/>
317 </xsl:variable>
318 <xsl:text>OOXML</xsl:text>
319 <xsl:value-of select="$resource"/>
320 <xsl:text>Value</xsl:text>
321 </xsl:template>
323 <!--
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"/>
332 </xsl:variable>
333 <xsl:variable name="resource">
334 <xsl:call-template name="contextresource"/>
335 </xsl:variable>
336 <xsl:text>
337 class </xsl:text>
338 <xsl:value-of select="$classname"/>
339 <xsl:text> : public </xsl:text>
340 <xsl:call-template name="valueparent"/>
341 <xsl:text>
343 public:
344 </xsl:text>
345 <xsl:choose>
346 <xsl:when test="$resource='List'">
347 <xsl:value-of select="$classname"/>
348 <xsl:text>(</xsl:text>
349 <xsl:text>const rtl::OUString &amp; rValue</xsl:text>
350 <xsl:text>);</xsl:text>
351 </xsl:when>
352 <xsl:otherwise>
353 <xsl:value-of select="$classname"/>
354 <xsl:text>(const rtl::OUString &amp; rValue) : </xsl:text>
355 <xsl:call-template name="valueparent"/>
356 <xsl:text>(rValue) {}</xsl:text>
357 </xsl:otherwise>
358 </xsl:choose>
359 <xsl:text>
360 virtual ~</xsl:text>
361 <xsl:value-of select="$classname"/>
362 <xsl:text>() {}
364 </xsl:text>
365 </xsl:template>
367 <!--
368 Checks if a class derived from OOXMLContex shall be defined for
369 the current <define>.
371 @retval 1 the class shall be defined.
372 @retval 0 otherwise
374 <xsl:template name="classfordefine">
375 <!--
376 <xsl:variable name="name" select="@name"/>
377 <xsl:choose>
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>
381 </xsl:choose>
383 <xsl:value-of select="@classfordefine"/>
384 </xsl:template>
386 <!--
387 Checks if a class derived from OOXMLValue shall be defined for
388 the current <define>.
390 @retval 1 the class shall be defined
391 @retval 0 otherwise
393 <xsl:template name="valuefordefine">
394 <xsl:choose>
395 <xsl:when test="starts-with(@name, 'ST_')">1</xsl:when>
396 <xsl:otherwise>0</xsl:otherwise>
397 </xsl:choose>
398 </xsl:template>
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"/>
404 </xsl:variable>
405 <xsl:if test="$dovalue = '1'">
406 <xsl:call-template name="valuedecl"/>
407 </xsl:if>
408 </xsl:for-each>
409 </xsl:template>
411 <!--
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"/>
419 </xsl:variable>
420 <xsl:if test="string-length($createstatement) > 0">
421 <xsl:text>
422 xContextHandler.set(</xsl:text>
423 <xsl:value-of select="$createstatement"/>
424 <xsl:text>);
425 </xsl:text>
426 </xsl:if>
427 <xsl:text>
428 break;
429 </xsl:text>
430 </xsl:for-each>
431 </xsl:template>
433 <xsl:template name="fastelementcreatefromrefstatement">
434 <xsl:variable name="definename">
435 <xsl:call-template name="searchdefinenamespace">
436 <xsl:with-param name="name" select="@name"/>
437 </xsl:call-template>
438 </xsl:variable>
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"/>
443 </xsl:variable>
444 <xsl:if test="$do = '1'">
445 <xsl:text>OOXMLFastHelper &lt;</xsl:text>
446 <xsl:call-template name="fastcontextname"/>
447 <xsl:text>&gt;::createAndSetParentRef(this, Element, Attribs)</xsl:text>
448 </xsl:if>
449 </xsl:for-each>
450 </xsl:for-each>
451 </xsl:template>
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"/>
457 </xsl:variable>
458 <xsl:if test="string-length($createstatement) > 0">
459 <xsl:text>
460 if (! xContextHandler.is() || dynamic_cast&lt;OOXMLFastContextHandler *&gt;(xContextHandler.get())->isFallback())
462 xContextHandler.set(</xsl:text>
463 <xsl:value-of select="$createstatement"/>
464 <xsl:text>);
466 </xsl:text>
467 </xsl:if>
468 </xsl:for-each>
469 <xsl:for-each select=".//rng:element[rng:anyName]">
470 <xsl:variable name="createstatement">
471 <xsl:call-template name="fastelementcreatestatement"/>
472 </xsl:variable>
473 <xsl:if test="string-length($createstatement) > 0">
474 <xsl:text>
475 if (! xContextHandler.is() || dynamic_cast&lt;OOXMLFastContextHandler *&gt;(xContextHandler.get())->isFallback())
477 xContextHandler.set(</xsl:text>
478 <xsl:value-of select="$createstatement"/>
479 <xsl:text>);
481 </xsl:text>
482 </xsl:if>
483 </xsl:for-each>
484 </xsl:template>
486 <!--
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"/>
492 </xsl:variable>
493 <xsl:if test="not($resource='Shape')">
494 <xsl:variable name="switchbody">
495 <xsl:call-template name="switchbodycreatechildcontext"/>
496 </xsl:variable>
497 <xsl:variable name="switchbodyrefs">
498 <xsl:call-template name="switchbodycreatechildcontextrefs"/>
499 </xsl:variable>
500 <xsl:if test="string-length($switchbody) > 0 or string-length($switchbodyrefs) > 0">
501 <xsl:text>
502 uno::Reference &lt; xml::sax::XFastContextHandler &gt;
503 </xsl:text>
504 <xsl:call-template name="fastcontextname"/>
505 <xsl:text>::lcl_createFastChildContext
506 (::sal_Int32 Element,
507 const uno::Reference &lt; xml::sax::XFastAttributeList &gt; &amp;</xsl:text>
508 <xsl:if test="contains($switchbody, 'Attribs') or contains($switchbodyrefs, 'Attribs')">
509 <xsl:text> Attribs</xsl:text>
510 </xsl:if>
511 <xsl:text>)
512 throw (uno::RuntimeException, xml::sax::SAXException)
514 uno::Reference &lt; xml::sax::XFastContextHandler &gt; xContextHandler;
515 </xsl:text>
516 <xsl:if test="string-length($switchbody) > 0">
517 <xsl:text>
518 switch (Element)
520 </xsl:text>
521 <xsl:value-of select="$switchbody"/>
522 <xsl:text>
523 default:
524 break;
526 </xsl:text>
527 </xsl:if>
528 <xsl:if test="string-length($switchbodyrefs) > 0">
529 <xsl:value-of select="$switchbodyrefs"/>
530 </xsl:if>
531 <xsl:text>
533 return xContextHandler;
535 </xsl:text>
536 </xsl:if>
537 </xsl:if>
538 </xsl:template>
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"/>
548 </xsl:call-template>
549 </xsl:for-each>
550 </xsl:for-each>
551 </xsl:for-each>
552 </xsl:template>
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"/>
562 </xsl:call-template>
563 </xsl:for-each>
564 </xsl:for-each>
565 </xsl:for-each>
566 </xsl:template>
568 <!--
569 Processes token id given in <resource> elements.
571 The result is the identifier for the tokenid.
573 <xsl:template name="processtokenid">
574 <xsl:choose>
575 <xsl:when test="contains(@tokenid, ':')">
576 <xsl:call-template name="idtoqname">
577 <xsl:with-param name="id" select="@tokenid"/>
578 </xsl:call-template>
579 </xsl:when>
580 <xsl:otherwise>
581 <xsl:value-of select="@tokenid"/>
582 </xsl:otherwise>
583 </xsl:choose>
584 </xsl:template>
586 <xsl:template name="getidcaseimpl">
587 <xsl:for-each select="attribute|element">
588 <xsl:text>
589 </xsl:text>
590 <xsl:call-template name="caselabelfasttoken"/>
591 <xsl:text>
592 nResult = </xsl:text>
593 <xsl:call-template name="processtokenid"/>
594 <xsl:text>;
595 break;</xsl:text>
596 </xsl:for-each>
597 </xsl:template>
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]"/>
603 <xsl:choose>
604 <xsl:when test="$resource/element[@name=$name]">
605 <xsl:text>OOXMLPropertyImpl::SPRM</xsl:text>
606 </xsl:when>
607 <xsl:otherwise>
608 <xsl:text>OOXMLPropertyImpl::ATTRIBUTE</xsl:text>
609 </xsl:otherwise>
610 </xsl:choose>
611 </xsl:template>
613 <!--
614 Check if a default is defined for a define.
616 Returns if the <resource> for the current <define> has a
617 <default> child.
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"/>
624 <xsl:choose>
625 <xsl:when test="ancestor::namespace/resource[@name=$name]//default">1</xsl:when>
626 <xsl:otherwise>0</xsl:otherwise>
627 </xsl:choose>
628 </xsl:template>
630 <!--
631 Chooses the action for the current <action> element.
633 <xsl:template name="chooseaction">
634 <xsl:if test="@tokenid">
635 <xsl:text>
636 if (sal::static_int_cast&lt;Id&gt;(getId()) == </xsl:text>
637 <xsl:call-template name="idtoqname">
638 <xsl:with-param name="id" select="@tokenid"/>
639 </xsl:call-template>
640 <xsl:text>)
641 {</xsl:text>
642 </xsl:if>
643 <xsl:for-each select="./cond">
644 <xsl:text>
646 OOXMLPropertySetEntryToInteger aHandler(</xsl:text>
647 <xsl:call-template name="idtoqname">
648 <xsl:with-param name="id" select="@tokenid"/>
649 </xsl:call-template>
650 <xsl:text>);
651 getPropertySetAttrs()->resolve(aHandler);
653 if (sal::static_int_cast&lt;Id&gt;(aHandler.getValue()) == </xsl:text>
654 <xsl:call-template name="idtoqname">
655 <xsl:with-param name="id" select="@value"/>
656 </xsl:call-template>
657 <xsl:text>)
658 {</xsl:text>
659 </xsl:for-each>
660 <xsl:choose>
661 <xsl:when test="@action='sendTableDepth'">
662 <xsl:text>
663 sendTableDepth();</xsl:text>
664 </xsl:when>
665 <xsl:when test="@action='startCell'">
666 <xsl:text>
667 startCell();</xsl:text>
668 </xsl:when>
669 <xsl:when test="@action='startParagraphGroup'">
670 <xsl:text>
671 startParagraphGroup();</xsl:text>
672 </xsl:when>
673 <xsl:when test="@action='startCharacterGroup'">
674 <xsl:text>
675 startCharacterGroup();</xsl:text>
676 </xsl:when>
677 <xsl:when test="@action='startSectionGroup'">
678 <xsl:text>
679 startSectionGroup();</xsl:text>
680 </xsl:when>
681 <xsl:when test="@action='fieldstart'">
682 <xsl:text>
683 startField();</xsl:text>
684 </xsl:when>
685 <xsl:when test="@action='fieldsep'">
686 <xsl:text>
687 fieldSeparator();</xsl:text>
688 </xsl:when>
689 <xsl:when test="@action='fieldend'">
690 <xsl:text>
691 endField();</xsl:text>
692 </xsl:when>
693 <xsl:when test="@action='ftnednref'">
694 <xsl:text>
695 ftnednref();</xsl:text>
696 </xsl:when>
697 <xsl:when test="@action='ftnednsep'">
698 <xsl:text>
699 ftnednsep();</xsl:text>
700 </xsl:when>
701 <xsl:when test="@action='ftnedncont'">
702 <xsl:text>
703 ftnedncont();</xsl:text>
704 </xsl:when>
705 <xsl:when test="@action='pgNum'">
706 <xsl:text>
707 pgNum();</xsl:text>
708 </xsl:when>
709 <xsl:when test="@action='tab'">
710 <xsl:text>
711 tab();</xsl:text>
712 </xsl:when>
713 <xsl:when test="@action='cr'">
714 <xsl:text>
715 cr();</xsl:text>
716 </xsl:when>
717 <xsl:when test="@action='noBreakHyphen'">
718 <xsl:text>
719 noBreakHyphen();</xsl:text>
720 </xsl:when>
721 <xsl:when test="@action='softHyphen'">
722 <xsl:text>
723 softHyphen();</xsl:text>
724 </xsl:when>
725 <xsl:when test="@action='endOfParagraph'">
726 <xsl:text>
727 endOfParagraph();</xsl:text>
728 </xsl:when>
729 <xsl:when test="@action='handleLastParagraphInSection'">
730 <xsl:text>
731 handleLastParagraphInSection();</xsl:text>
732 </xsl:when>
733 <xsl:when test="@action='setLastParagraphInSection'">
734 <xsl:text>
735 setLastParagraphInSection();</xsl:text>
736 </xsl:when>
737 <xsl:when test="@action='endCell'">
738 <xsl:text>
739 endCell();</xsl:text>
740 </xsl:when>
741 <xsl:when test="@action='endParagraphGroup'">
742 <xsl:text>
743 endParagraphGroup();</xsl:text>
744 </xsl:when>
745 <xsl:when test="@action='endCharacterGroup'">
746 <xsl:text>
747 endCharacterGroup();</xsl:text>
748 </xsl:when>
749 <xsl:when test="@action='endSectionGroup'">
750 <xsl:text>
751 endSectionGroup();</xsl:text>
752 </xsl:when>
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'">
768 <xsl:text>
769 sendProperty(</xsl:text>
770 <xsl:call-template name="idtoqname">
771 <xsl:with-param name="id" select="@sendtokenid"/>
772 </xsl:call-template>
773 <xsl:text>);</xsl:text>
774 </xsl:when>
775 <xsl:when test="@action='propagateCharacterProperties'">
776 propagateCharacterProperties();
777 </xsl:when>
778 <xsl:when test="@action='propagateCharacterPropertiesAsSet'">
779 <xsl:text>
780 propagateCharacterPropertiesAsSet(</xsl:text>
781 <xsl:call-template name="idtoqname">
782 <xsl:with-param name="id" select="@sendtokenid"/>
783 </xsl:call-template>
784 <xsl:text>);</xsl:text>
785 </xsl:when>
786 <xsl:when test="@action='propagateTableProperties'">
787 propagateTableProperties();
788 </xsl:when>
789 <xsl:when test="@action='sendPropertiesWithId'">
790 <xsl:text>
791 sendPropertiesWithId(</xsl:text>
792 <xsl:call-template name="idtoqname">
793 <xsl:with-param name="id" select="@sendtokenid"/>
794 </xsl:call-template>
795 <xsl:text>);</xsl:text>
796 </xsl:when>
797 <xsl:when test="@action='clearProps'">
798 clearProps();
799 </xsl:when>
800 <xsl:when test="@action='text'">
801 text(sText);
802 </xsl:when>
803 <xsl:when test="@action='setHandle'">
804 setHandle();
805 </xsl:when>
807 <xsl:when test="@action='footnoteSeparator'">
808 footnoteSeparator();
809 </xsl:when>
810 <xsl:when test="@action='footnoteCont'">
811 footnoteCont();
812 </xsl:when>
813 <xsl:when test="@action='endnoteSeparator'">
814 endnoteSeparator();
815 </xsl:when>
816 <xsl:when test="@action='endnoteCont'">
817 endnoteCont();
818 </xsl:when>
819 <xsl:when test="@action='newProperty'">
820 <xsl:text>
821 OOXMLFastHelper&lt;OOXMLIntegerValue&gt;::newProperty(this, </xsl:text>
822 <xsl:call-template name="idtoqname">
823 <xsl:with-param name="id" select="@tokenid"/>
824 </xsl:call-template>
825 <xsl:text>, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("</xsl:text>
826 <xsl:value-of select="@value"/>
827 <xsl:text>")));</xsl:text>
828 </xsl:when>
829 <xsl:when test="@action='mark'">
830 <xsl:text>
831 OOXMLFastHelper&lt;OOXMLIntegerValue&gt;::mark(this, </xsl:text>
832 <xsl:call-template name="idtoqname">
833 <xsl:with-param name="id" select="@sendtokenid"/>
834 </xsl:call-template>
835 <xsl:text>, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("</xsl:text>
836 <xsl:value-of select="@value"/>
837 <xsl:text>")));</xsl:text>
838 </xsl:when>
839 <xsl:when test="@action='tokenproperty'">
840 <xsl:text>
841 OOXMLFastHelper&lt;OOXMLIntegerValue&gt;::newProperty(this, </xsl:text>
842 <xsl:call-template name="idtoqname">
843 <xsl:with-param name="id">ooxml:token</xsl:with-param>
844 </xsl:call-template>
845 <xsl:text>, getToken());</xsl:text>
846 </xsl:when>
847 </xsl:choose>
848 <xsl:for-each select="./cond">
849 <xsl:text>
851 }</xsl:text>
852 </xsl:for-each>
853 <xsl:if test="@tokenid">
854 <xsl:text>
855 }</xsl:text>
856 </xsl:if>
857 </xsl:template>
859 <!--
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]">
866 <xsl:text>
867 </xsl:text>
868 <xsl:for-each select="./rng:grammar/rng:define">
869 <xsl:variable name="do">
870 <xsl:call-template name="classfordefine"/>
871 </xsl:variable>
872 <xsl:if test="$do = '1'">
873 <xsl:variable name="classname">
874 <xsl:call-template name="fastcontextname"/>
875 </xsl:variable>
876 <xsl:text>
878 class: </xsl:text>
879 <xsl:value-of select="$classname"/>
880 <xsl:text>
882 </xsl:text>
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"/>
891 </xsl:if>
892 </xsl:for-each>
893 </xsl:for-each>
894 </xsl:template>
896 <xsl:key name="value-with-content" match="//rng:value"
897 use="text()"/>
899 <!--
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__')"/>
910 </xsl:template>
912 <!--
913 Generates constant definitions for attribute values.
915 <xsl:template name="valueconstants">
916 <xsl:text>
917 rtl::OUString </xsl:text>
918 <xsl:call-template name="valuestringname">
919 <xsl:with-param name="string"></xsl:with-param>
920 </xsl:call-template>
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(.)]">
923 <xsl:text>
924 rtl::OUString </xsl:text>
925 <xsl:call-template name="valuestringname">
926 <xsl:with-param name="string" select="."/>
927 </xsl:call-template>
928 <xsl:text>(RTL_CONSTASCII_USTRINGPARAM("</xsl:text>
929 <xsl:value-of select="."/>
930 <xsl:text>"));</xsl:text>
931 </xsl:for-each>
932 </xsl:template>
934 <!--
935 Generates constant declarations for attribute values.
937 <xsl:template name="valueconstantdecls">
938 <xsl:text>
939 extern rtl::OUString
940 </xsl:text>
941 <xsl:call-template name="valuestringname">
942 <xsl:with-param name="string"></xsl:with-param>
943 </xsl:call-template>
944 <xsl:text>;</xsl:text>
945 <xsl:for-each select="//rng:value[generate-id(key('value-with-content', text())[1]) = generate-id(.)]">
946 <xsl:text>
947 extern rtl::OUString </xsl:text>
948 <xsl:call-template name="valuestringname">
949 <xsl:with-param name="string" select="."/>
950 </xsl:call-template>
951 <xsl:text>;</xsl:text>
952 </xsl:for-each>
953 </xsl:template>
955 <!--
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"/>
963 </xsl:variable>
964 <xsl:choose>
965 <xsl:when test="$resource = 'List'">
966 <xsl:variable name="classname">
967 <xsl:call-template name="valuenamefordefine"/>
968 </xsl:variable>
969 <xsl:text>&#xa;</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 &amp; </xsl:text>
974 <xsl:choose>
975 <xsl:when test="count(ancestor::namespace/resource[@name=$name]/value) > 0">
976 <xsl:text>rValue</xsl:text>
977 </xsl:when>
978 <xsl:otherwise>
979 <xsl:text>/* rValue */</xsl:text>
980 </xsl:otherwise>
981 </xsl:choose>
982 <xsl:text>)
983 : OOXMLListValue()
984 {</xsl:text>
985 <xsl:for-each select="ancestor::namespace/resource[@name=$name]">
986 <xsl:for-each select="./default">
987 <xsl:text>
988 mnValue = </xsl:text>
989 <xsl:choose>
990 <xsl:when test="@tokenid">
991 <xsl:call-template name="idtoqname">
992 <xsl:with-param name="id" select="@tokenid"/>
993 </xsl:call-template>
994 </xsl:when>
995 <xsl:otherwise>
996 <xsl:value-of select="."/>
997 </xsl:otherwise>
998 </xsl:choose>
999 <xsl:text>;</xsl:text>
1000 </xsl:for-each>
1001 <xsl:for-each select="./value">
1002 <xsl:text>
1003 if (rValue.compareTo(</xsl:text>
1004 <xsl:call-template name="valuestringname">
1005 <xsl:with-param name="string" select="text()"/>
1006 </xsl:call-template>
1007 <xsl:text>) == 0)
1009 mnValue = </xsl:text>
1010 <xsl:call-template name="idtoqname">
1011 <xsl:with-param name="id" select="@tokenid"/>
1012 </xsl:call-template>
1013 <xsl:text>;
1014 return;
1015 }</xsl:text>
1016 </xsl:for-each>
1017 </xsl:for-each>
1018 <xsl:text>
1020 </xsl:text>
1021 </xsl:when>
1022 </xsl:choose>
1023 </xsl:template>
1025 <!--
1026 Generates definition of destructor of attribute value class for
1027 current <define>.
1029 <xsl:template name="valuedestructorimpl">
1030 <xsl:variable name="classname">
1031 <xsl:call-template name="valuenamefordefine"/>
1032 </xsl:variable>
1033 <xsl:text>&#xa;</xsl:text>
1034 <xsl:value-of select="$classname"/>
1035 <xsl:text>::~</xsl:text>
1036 <xsl:value-of select="$classname"/>
1037 <xsl:text>()
1040 </xsl:text>
1041 </xsl:template>
1043 <!--
1044 Generates definitions for attribute value class for current
1045 <define>.
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"/>
1051 </xsl:variable>
1052 <xsl:if test="$do = 1">
1053 <xsl:variable name="classname">
1054 <xsl:call-template name="valuenamefordefine"/>
1055 </xsl:variable>
1056 <xsl:text>
1058 class: </xsl:text>
1059 <xsl:value-of select="$classname"/>
1060 <xsl:text>
1062 </xsl:text>
1063 <xsl:call-template name="valueconstructorimpl"/>
1064 </xsl:if>
1065 </xsl:for-each>
1066 </xsl:template>
1068 <xsl:key name="tokenids" match="@tokenid|@sendtokenid" use="."/>
1070 <!--
1071 Generates contant definitions for tokenids.
1073 <xsl:template name="defineooxmlids">
1074 <xsl:text>
1075 namespace NS_ooxml
1076 {</xsl:text>
1077 <xsl:for-each select="//@tokenid|//@sendtokenid">
1078 <xsl:if test="contains(., 'ooxml:') and generate-id(.) = generate-id(key('tokenids', .)[1])">
1079 <xsl:text>
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>
1085 </xsl:if>
1086 </xsl:for-each>
1088 </xsl:template>
1090 <xsl:template name="ooxmlidstoxml">
1091 <xsl:text>
1092 void ooxmlsprmidsToXML(::std::ostream &amp; out)
1093 {</xsl:text>
1094 <xsl:for-each select="//@tokenid">
1095 <xsl:if test="contains(., 'ooxml:') and generate-id(.) = generate-id(key('tokenids', .)[1]) and ancestor::element">
1096 <xsl:text>
1097 out &lt;&lt; "&lt;theid name=\"</xsl:text>
1098 <xsl:value-of select="."/>
1099 <xsl:text>\"&gt;</xsl:text>
1100 <xsl:value-of select="90000 + position()"/>
1101 <xsl:text>&lt;/theid&gt;" &lt;&lt; endl; </xsl:text>
1102 </xsl:if>
1103 </xsl:for-each>
1104 <xsl:text>
1105 }</xsl:text>
1106 <xsl:text>
1107 void ooxmlidsToXML(::std::ostream &amp; out)
1108 {</xsl:text>
1109 <xsl:for-each select="//@tokenid">
1110 <xsl:if test="contains(., 'ooxml:') and generate-id(.) = generate-id(key('tokenids', .)[1]) and ancestor::attribute">
1111 <xsl:text>
1112 out &lt;&lt; "&lt;theid name=\"</xsl:text>
1113 <xsl:value-of select="."/>
1114 <xsl:text>\"&gt;</xsl:text>
1115 <xsl:value-of select="90000 + position()"/>
1116 <xsl:text>&lt;/theid&gt;" &lt;&lt; endl; </xsl:text>
1117 </xsl:if>
1118 </xsl:for-each>
1119 <xsl:text>
1120 }</xsl:text>
1121 </xsl:template>
1123 <!--
1124 Generates mapping from tokenids to strings. (DEBUG)
1126 <xsl:template name="qnametostr">
1127 <xsl:text>
1128 void QNameToString::init_ooxml()
1130 /* ooxml */
1131 </xsl:text>
1132 <xsl:for-each select="//@tokenid">
1133 <xsl:if test="generate-id(.) = generate-id(key('tokenids', .)[1]) and contains(., 'ooxml:')">
1134 <xsl:text>
1135 mMap[</xsl:text>
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>
1142 </xsl:if>
1143 </xsl:for-each>
1144 <xsl:text>
1146 </xsl:text>
1147 </xsl:template>
1149 <xsl:template name="qnametostrfunc">
1150 <xsl:text>
1151 string qnameToString(sal_uInt32 nToken)
1153 string sResult;
1155 switch (nToken)
1156 {</xsl:text>
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:')">
1161 <xsl:text>
1162 case </xsl:text>
1163 <xsl:call-template name="idtoqname">
1164 <xsl:with-param name="id" select="@tokenid"/>
1165 </xsl:call-template>
1166 <xsl:text>:
1167 sResult = "</xsl:text>
1168 <xsl:value-of select="@token"/>
1169 <xsl:text>";
1170 break;</xsl:text>
1171 </xsl:if>
1172 </xsl:for-each>
1173 </xsl:for-each>
1174 <xsl:text>
1175 default:
1179 return sResult;
1180 }</xsl:text>
1181 </xsl:template>
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"/>
1188 <!--
1189 Generates case labels for mapping from token ids to a single kind
1190 of sprm.
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))">
1198 <xsl:text>
1199 case </xsl:text>
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"/>
1207 </xsl:if>
1208 </xsl:for-each>
1209 </xsl:template>
1211 <!--
1212 Generates SprmKind.
1214 <xsl:template name="sprmkind">
1215 <xsl:text>
1216 Sprm::Kind SprmKind(sal_uInt32 nSprmCode)
1218 Sprm::Kind nResult = Sprm::UNKNOWN;
1220 switch (nSprmCode)
1221 {</xsl:text>
1222 <xsl:call-template name="sprmkindcase">
1223 <xsl:with-param name="kind">paragraph</xsl:with-param>
1224 </xsl:call-template>
1225 <xsl:text>
1226 nResult = Sprm::PARAGRAPH;
1227 break;</xsl:text>
1228 <xsl:call-template name="sprmkindcase">
1229 <xsl:with-param name="kind">character</xsl:with-param>
1230 </xsl:call-template>
1231 <xsl:text>
1232 nResult = Sprm::CHARACTER;
1233 break;</xsl:text>
1234 <xsl:call-template name="sprmkindcase">
1235 <xsl:with-param name="kind">table</xsl:with-param>
1236 </xsl:call-template>
1237 <xsl:text>
1238 nResult = Sprm::TABLE;
1239 break;</xsl:text>
1240 <xsl:text>
1241 default:
1242 break;
1245 return nResult;
1246 }</xsl:text>
1247 </xsl:template>
1249 <!--
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'/>
1262 <xsl:choose>
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, ":")'/>
1268 </xsl:when>
1269 <xsl:otherwise>
1270 <xsl:value-of select="$id"/>
1271 </xsl:otherwise>
1272 </xsl:choose>
1273 </xsl:template>
1275 <xsl:key name="same-token-name" match="rng:element|rng:attribute" use="@localname"/>
1277 <!--
1278 Generates input for gperf to genreate hash map for OOXMLFastTokenHandler
1280 <xsl:template name="gperfinputfasttokenhandler">
1281 <xsl:text>
1283 #include "OOXMLFastTokens.hxx"
1285 namespace writerfilter { namespace ooxml { namespace tokenmap {
1287 struct token { const char * name; Token_t nToken; };
1288 %%</xsl:text>
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>&#xa;</xsl:text>
1292 <xsl:value-of select="@localname"/>
1293 <xsl:text>, </xsl:text>
1294 <xsl:call-template name="fastlocalname"/>
1295 </xsl:if>
1296 </xsl:for-each>
1297 <xsl:text>
1298 %%&#xa;</xsl:text>
1299 }}}&#xa;</xsl:template>
1301 <xsl:template name="namespaceid">
1302 <xsl:text>NS_</xsl:text>
1303 <xsl:value-of select="@alias"/>
1304 </xsl:template>
1306 <xsl:template name="namespaceids">
1307 <xsl:for-each select="//namespace-alias">
1308 <xsl:text>
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> &lt;&lt; 16;</xsl:text>
1314 </xsl:for-each>
1315 </xsl:template>
1317 <xsl:template name="fasttoken">
1318 <xsl:variable name="ns">
1319 <xsl:call-template name="fastnamespace"/>
1320 </xsl:variable>
1321 <xsl:if test="string-length($ns) > 0">
1322 <xsl:value-of select="$ns"/>
1323 <xsl:text>|</xsl:text>
1324 </xsl:if>
1325 <xsl:call-template name="fastlocalname"/>
1326 </xsl:template>
1328 <xsl:template name="fasttokenwithattr">
1329 <xsl:if test="local-name(.)='attribute'">
1330 <xsl:text>F_Attribute|</xsl:text>
1331 </xsl:if>
1332 <xsl:call-template name="fasttoken"/>
1333 </xsl:template>
1335 <xsl:template name="caselabelfasttoken">
1336 <xsl:text>case </xsl:text>
1337 <xsl:call-template name="fasttokenwithattr"/>
1338 <xsl:text>:</xsl:text>
1339 </xsl:template>
1341 <xsl:key name="elementsattrsbynamespace"
1342 match="rng:element[@name]|rng:attribute[@name]" use="ancestor::rng:grammar/@ns"/>
1344 <xsl:template name="fasttokentoid">
1345 <xsl:text>
1346 namespace tokenmap {
1347 struct token { const char * name; Token_t nToken; };
1348 class Perfect_Hash
1350 private:
1351 static inline unsigned int hash (const char *str, unsigned int len);
1352 public:
1353 static struct token *in_word_set (const char *str, unsigned int len);
1357 string fastTokenToId(sal_uInt32 nToken)
1359 </xsl:text>
1360 <xsl:text>
1361 string sResult;
1363 switch (nToken &amp; 0xffff0000)
1364 {</xsl:text>
1365 <xsl:for-each select="//namespace-alias">
1366 <xsl:text>
1367 case NS_</xsl:text>
1368 <xsl:value-of select="@alias"/>
1369 <xsl:text>:
1370 sResult += "</xsl:text>
1371 <xsl:value-of select="@alias"/>
1372 <xsl:text>:";
1373 break;</xsl:text>
1374 </xsl:for-each>
1375 <xsl:text>
1378 switch (nToken &amp; 0xffff)
1379 {</xsl:text>
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])">
1383 <xsl:text>
1384 case </xsl:text>
1385 <xsl:call-template name="fastlocalname"/>
1386 <xsl:text>:
1387 sResult += "</xsl:text>
1388 <xsl:value-of select="$localname"/>
1389 <xsl:text>";
1390 break;</xsl:text>
1391 </xsl:if>
1392 </xsl:for-each>
1393 <xsl:text>
1396 return sResult;
1398 </xsl:text>
1399 </xsl:template>
1401 <xsl:template name="getfastparser">
1402 <xsl:text>
1403 uno::Reference &lt; xml::sax::XFastParser &gt; OOXMLStreamImpl::getFastParser()
1405 if (! mxFastParser.is())
1407 uno::Reference &lt; lang::XMultiComponentFactory &gt; xFactory =
1408 uno::Reference &lt; lang::XMultiComponentFactory &gt;
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);
1415 </xsl:text>
1416 <xsl:for-each select="//namespace-alias">
1417 <xsl:text>
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>
1423 </xsl:for-each>
1424 <xsl:text>
1427 return mxFastParser;
1429 </xsl:text>
1430 </xsl:template>
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>
1439 </xsl:for-each>
1440 </xsl:variable>
1441 <xsl:choose>
1442 <xsl:when test="string-length($tmp) > 0">
1443 <xsl:value-of select="$tmp"/>
1444 </xsl:when>
1445 <xsl:otherwise>
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"/>
1450 </xsl:for-each>
1451 </xsl:otherwise>
1452 </xsl:choose>
1453 </xsl:template>
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"/>
1465 </xsl:if>
1466 </xsl:for-each>
1467 </xsl:variable>
1468 <xsl:choose>
1469 <xsl:when test="string-length($tmp) > 0">
1470 <xsl:value-of select="$tmp"/>
1471 </xsl:when>
1472 <xsl:otherwise>
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>
1478 </xsl:for-each>
1479 </xsl:for-each>
1480 </xsl:otherwise>
1481 </xsl:choose>
1482 </xsl: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>
1488 </xsl:template>
1490 <xsl:template name="fastattributescheckattrwithns">
1491 <xsl:text>if (Attribs->hasAttribute(</xsl:text>
1492 <xsl:call-template name="fasttoken"/>
1493 <xsl:text>))</xsl:text>
1494 </xsl:template>
1496 <xsl:template name="fastcontextnameforattribute">
1497 <xsl:choose>
1498 <xsl:when test="./rng:ref">
1499 <xsl:for-each select="./rng:ref">
1500 <xsl:call-template name="valuenameforref"/>
1501 </xsl:for-each>
1502 </xsl:when>
1503 <xsl:when test="./rng:data/@type = 'boolean'">
1504 <xsl:text>OOXMLBooleanValue</xsl:text>
1505 </xsl:when>
1506 <xsl:when test="./rng:data/@type = 'unsignedInt'">
1507 <xsl:text>OOXMLIntegerValue</xsl:text>
1508 </xsl:when>
1509 <xsl:when test="./rng:text or ./rng:data/@type = 'string' or ./rng:data/@type = 'token'">
1510 <xsl:text>OOXMLStringValue</xsl:text>
1511 </xsl:when>
1512 </xsl:choose>
1513 </xsl:template>
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"/>
1521 </xsl:variable>
1522 <xsl:variable name="attrid">
1523 <xsl:call-template name="idforattr"/>
1524 </xsl:variable>
1525 <xsl:if test="string-length($contextname) > 0 and string-length($attrid) > 0">
1526 <xsl:text>
1527 </xsl:text>
1528 <xsl:call-template name="fastattributescheckattrwithns"/>
1529 <xsl:text>
1531 ::rtl::OUString aValue(Attribs->getValue(</xsl:text>
1532 <xsl:call-template name="fasttoken"/>
1533 <xsl:text>));
1534 OOXMLFastHelper &lt; </xsl:text>
1535 <xsl:value-of select="$contextname"/>
1536 <xsl:text> &gt;::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]">
1541 <xsl:choose>
1542 <xsl:when test="@action='checkId'">
1543 <xsl:text>
1544 checkId(aValue);</xsl:text>
1545 </xsl:when>
1546 <xsl:when test="@action='checkXNoteType'">
1547 </xsl:when>
1548 <xsl:when test="@action='setXNoteId'">
1549 <xsl:text>
1550 setXNoteId(aValue);</xsl:text>
1551 </xsl:when>
1552 </xsl:choose>
1553 </xsl:for-each>
1554 </xsl:for-each>
1555 <xsl:text>
1556 }</xsl:text>
1557 </xsl:if>
1558 </xsl:for-each>
1559 </xsl:template>
1561 <xsl:template name="fastcharactersstringvalue">
1562 <xsl:text>
1564 msValue = sText;</xsl:text>
1565 </xsl:template>
1567 <xsl:template name="fastattributesstringvalue">
1568 <xsl:for-each select=".//rng:attribute">
1569 <xsl:text>
1570 </xsl:text>
1571 <xsl:call-template name="fastattributescheckattrwithns"/>
1572 <xsl:text>
1573 msValue = Attribs->getValue(</xsl:text>
1574 <xsl:call-template name="fasttoken"/>
1575 <xsl:text>);</xsl:text>
1576 </xsl:for-each>
1577 </xsl:template>
1579 <xsl:template name="fastcharactersintvalue">
1580 <xsl:text>
1582 mnValue = sText.toInt32();</xsl:text>
1583 </xsl:template>
1585 <xsl:template name="fastattributesintvalue">
1586 <xsl:for-each select=".//rng:attribute">
1587 <xsl:text>
1588 </xsl:text>
1589 <xsl:call-template name="fastattributescheckattrwithns"/>
1590 <xsl:text>
1591 mnValue = Attribs->getValue(</xsl:text>
1592 <xsl:call-template name="fasttoken"/>
1593 <xsl:text>).toInt32();</xsl:text>
1594 </xsl:for-each>
1595 </xsl:template>
1597 <xsl:template name="fastcharactershexvalue">
1598 <xsl:text>
1600 mnValue = sText.toInt32(16);</xsl:text>
1601 </xsl:template>
1603 <xsl:template name="fastattributeshexvalue">
1604 <xsl:for-each select=".//rng:attribute">
1605 <xsl:text>
1606 </xsl:text>
1607 <xsl:call-template name="fastattributescheckattrwithns"/>
1608 <xsl:text>
1609 mnValue = Attribs->getValue(</xsl:text>
1610 <xsl:call-template name="fasttoken"/>
1611 <xsl:text>).toInt32(16);</xsl:text>
1612 </xsl:for-each>
1613 </xsl:template>
1615 <xsl:template name="fastcharactersboolvalue">
1616 <xsl:text>
1618 setValue( sText );</xsl:text>
1619 </xsl:template>
1621 <xsl:template name="fastattributesboolvalue">
1622 <xsl:for-each select=".//rng:attribute">
1623 <xsl:text>
1624 </xsl:text>
1625 <xsl:call-template name="fastattributescheckattrwithns"/>
1626 <xsl:text>
1627 setValue(Attribs->getValue(</xsl:text>
1628 <xsl:call-template name="fasttoken"/>
1629 <xsl:text>));</xsl:text>
1630 </xsl:for-each>
1631 </xsl:template>
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>
1641 </xsl:variable>
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"/>
1646 </xsl:for-each>
1647 </xsl:for-each>
1648 </xsl:variable>
1649 <xsl:text>
1650 mpValue = OOXMLValue::Pointer_t (new </xsl:text>
1651 <xsl:value-of select="$valname"/>
1652 <xsl:text>( sText ) );</xsl:text>
1653 </xsl:for-each>
1654 </xsl:variable>
1655 <xsl:if test="string-length($bodywithns) > 0">
1656 <xsl:text>
1657 </xsl:text>
1658 <xsl:value-of select="$bodywithns"/>
1659 </xsl:if>
1660 </xsl:template>
1662 <xsl:template name="fastattributeslistvalue">
1663 <xsl:for-each select=".//rng:attribute">
1664 <xsl:variable name="myfasttoken">
1665 <xsl:call-template name="fastlocalname"/>
1666 </xsl:variable>
1667 <xsl:variable name="myfasttokenwithns">
1668 <xsl:call-template name="fasttoken"/>
1669 </xsl:variable>
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>
1677 </xsl:variable>
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"/>
1682 </xsl:for-each>
1683 </xsl:for-each>
1684 </xsl:variable>
1685 <xsl:text>
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>
1691 </xsl:for-each>
1692 </xsl:variable>
1693 <xsl:if test="string-length($bodywithns) > 0">
1694 <xsl:text>
1695 </xsl:text>
1696 <xsl:call-template name="fastattributescheckattrwithns"/>
1697 <xsl:value-of select="$bodywithns"/>
1698 </xsl:if>
1699 </xsl:for-each>
1700 </xsl:template>
1702 <xsl:template name="fastattributebody">
1703 <xsl:variable name="resource">
1704 <xsl:call-template name="contextresource"/>
1705 </xsl:variable>
1706 <xsl:choose>
1707 <xsl:when test="$resource = 'Properties' or $resource = 'Stream' or $resource='XNote' or $resource='Shape'" >
1708 <xsl:call-template name="fastattributesproperties"/>
1709 </xsl:when>
1710 <xsl:when test="$resource = 'StringValue'">
1711 <xsl:call-template name="fastattributesstringvalue"/>
1712 </xsl:when>
1713 <xsl:when test="$resource = 'IntegerValue'">
1714 <xsl:call-template name="fastattributesintvalue"/>
1715 </xsl:when>
1716 <xsl:when test="$resource = 'HexValue'">
1717 <xsl:call-template name="fastattributeshexvalue"/>
1718 </xsl:when>
1719 <xsl:when test="$resource = 'BooleanValue'">
1720 <xsl:call-template name="fastattributesboolvalue"/>
1721 </xsl:when>
1722 <xsl:when test="$resource = 'ListValue'">
1723 <xsl:call-template name="fastattributeslistvalue"/>
1724 </xsl:when>
1725 </xsl:choose>
1726 </xsl:template>
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>
1733 </xsl:variable>
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"/>
1737 </xsl:for-each>
1738 </xsl:for-each>
1739 </xsl:template>
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>
1746 </xsl:variable>
1747 <!--
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"/>
1757 </xsl:for-each>
1758 </xsl:for-each>
1759 </xsl:template>
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"/>
1765 </xsl:variable>
1766 <xsl:if test="string-length($contextname) > 0">
1767 <xsl:text>
1768 OOXMLFastHelper &lt;</xsl:text>
1769 <xsl:value-of select="$contextname"/>
1770 <xsl:text>&gt;::attributes(this, Attribs);</xsl:text>
1771 </xsl:if>
1772 </xsl:for-each>
1773 </xsl:template>
1775 <!--
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"/>
1781 </xsl:variable>
1782 <!--<xsl:if test="not($resource='Shape')"> -->
1783 <xsl:variable name="body">
1784 <xsl:call-template name="fastattributebody"/>
1785 </xsl:variable>
1786 <xsl:variable name="bodyrefs">
1787 <xsl:call-template name="fastattributebodyrefs"/>
1788 </xsl:variable>
1789 <xsl:if test="string-length($body) > 0 or string-length($bodyrefs) > 0">
1790 <xsl:text>
1791 void </xsl:text>
1792 <xsl:call-template name="fastcontextname"/>
1793 <xsl:text>::attributes
1794 (const uno::Reference &lt; xml::sax::XFastAttributeList &gt; &amp; Attribs)
1795 throw (uno::RuntimeException, xml::sax::SAXException)
1797 #ifdef DEBUG_DUMP_ATTRIBUTES
1798 dumpAttribs(Attribs);
1799 #endif
1800 </xsl:text>
1801 <xsl:value-of select="$body"/>
1802 <xsl:value-of select="$bodyrefs"/>
1803 <xsl:text>
1805 </xsl:text>
1806 </xsl:if>
1807 <!-- </xsl:if> -->
1808 </xsl:template>
1810 <xsl:template name="fastelementcreatestatement">
1811 <xsl:for-each select=".//rng:ref">
1812 <xsl:choose>
1813 <xsl:when test="@name='BUILT_IN_ANY_TYPE'">
1814 <xsl:text>createFromStart(Element, Attribs)</xsl:text>
1815 </xsl:when>
1816 <xsl:otherwise>
1817 <xsl:variable name="classname">
1818 <xsl:call-template name="fastcontextname"/>
1819 </xsl:variable>
1820 <xsl:if test="string-length($classname) > 0">
1821 <xsl:text>OOXMLFastHelper &lt;</xsl:text>
1822 <xsl:value-of select="$classname"/>
1823 <xsl:text>&gt;::createAndSetParent(this, Element, </xsl:text>
1824 <xsl:for-each select="ancestor::rng:element">
1825 <xsl:variable name="id">
1826 <xsl:call-template name="idforelement"/>
1827 </xsl:variable>
1828 <xsl:choose>
1829 <xsl:when test="string-length($id) > 0">
1830 <xsl:value-of select="$id"/>
1831 </xsl:when>
1832 <xsl:otherwise>
1833 <xsl:text>0</xsl:text>
1834 </xsl:otherwise>
1835 </xsl:choose>
1836 </xsl:for-each>
1837 <xsl:text>)</xsl:text>
1838 </xsl:if>
1839 </xsl:otherwise>
1840 </xsl:choose>
1841 </xsl:for-each>
1842 </xsl:template>
1844 <!--
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"/>
1850 </xsl:template>
1852 <!--
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"/>
1858 </xsl:variable>
1859 <xsl:text>
1860 class WRITERFILTER_DLLPRIVATE </xsl:text>
1861 <xsl:value-of select="$classname"/>
1862 <xsl:text>: public </xsl:text>
1863 <xsl:call-template name="fastresourceclass"/>
1864 <xsl:text>
1866 public:
1867 explicit </xsl:text>
1868 <xsl:value-of select="$classname"/>
1869 <xsl:text>
1870 (OOXMLFastContextHandler * context);
1871 virtual ~</xsl:text>
1872 <xsl:value-of select="$classname"/>
1873 <xsl:text>();
1874 </xsl:text>
1875 <xsl:variable name="createchildcontextbody">
1876 <xsl:call-template name="createfastchildcontext"/>
1877 </xsl:variable>
1878 <xsl:if test="string-length($createchildcontextbody) > 0">
1879 virtual uno::Reference &lt; xml::sax::XFastContextHandler &gt;
1880 lcl_createFastChildContext
1881 (::sal_Int32 Element,
1882 const uno::Reference &lt; xml::sax::XFastAttributeList &gt; &amp; Attribs)
1883 throw (uno::RuntimeException, xml::sax::SAXException);
1884 </xsl:if>
1885 <xsl:variable name="fastattributebody">
1886 <xsl:call-template name="fastattribute"/>
1887 </xsl:variable>
1888 <xsl:if test="string-length($fastattributebody) > 0">
1889 virtual void attributes
1890 (const uno::Reference &lt; xml::sax::XFastAttributeList &gt; &amp; Attribs)
1891 throw (uno::RuntimeException, xml::sax::SAXException);
1892 </xsl:if>
1893 <xsl:variable name="faststartactionbody">
1894 <xsl:call-template name="faststartaction"/>
1895 </xsl:variable>
1896 <xsl:if test="string-length($faststartactionbody)">
1897 virtual void lcl_startAction(Token_t nElement);
1898 </xsl:if>
1899 <xsl:variable name="fastendactionbody">
1900 <xsl:call-template name="fastendaction"/>
1901 </xsl:variable>
1902 <xsl:if test="string-length($fastendactionbody)">
1903 virtual void lcl_endAction(Token_t nElement);
1904 </xsl:if>
1905 <xsl:variable name="fastcharactersbody">
1906 <xsl:call-template name="fastcharacters"/>
1907 </xsl:variable>
1908 <xsl:if test="string-length($fastcharactersbody)">
1909 virtual void lcl_characters(const ::rtl::OUString &amp; aChars)
1910 throw (uno::RuntimeException, xml::sax::SAXException);
1911 </xsl:if>
1912 <xsl:text>
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"/>
1918 </xsl:variable>
1919 <xsl:if test="string-length($propagatespropsbody)">
1920 <xsl:text>
1921 virtual bool propagatesProperties() const;</xsl:text>
1922 </xsl:if>
1923 <xsl:text>
1925 </xsl:text>
1926 </xsl:template>
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"/>
1934 </xsl:variable>
1935 <xsl:text>
1937 </xsl:text>
1938 <xsl:value-of select="ancestor::namespace/@name"/>
1939 <xsl:text>:</xsl:text>
1940 <xsl:value-of select="@name"/>
1941 <xsl:text>
1942 */</xsl:text>
1943 <xsl:if test="$do = '1'">
1944 <xsl:call-template name="fastcontextdecl"/>
1945 </xsl:if>
1946 </xsl:for-each>
1947 </xsl:for-each>
1948 </xsl:template>
1950 <xsl:template name="fastcontextconstructor">
1951 <xsl:variable name="classname">
1952 <xsl:call-template name="fastcontextname"/>
1953 </xsl:variable>
1954 <xsl:value-of select="$classname"/>
1955 <xsl:text>::</xsl:text>
1956 <xsl:value-of select="$classname"/>
1957 <xsl:text>
1958 (OOXMLFastContextHandler * pContext)
1959 : </xsl:text>
1960 <xsl:call-template name="fastresourceclass"/>
1961 <xsl:text>(pContext)
1963 </xsl:text>
1964 </xsl:template>
1966 <xsl:template name="fastcontextdestructor">
1967 <xsl:variable name="classname">
1968 <xsl:call-template name="fastcontextname"/>
1969 </xsl:variable>
1970 <xsl:value-of select="$classname"/>
1971 <xsl:text>::~</xsl:text>
1972 <xsl:value-of select="$classname"/>
1973 <xsl:text>
1976 </xsl:text>
1977 </xsl:template>
1979 <xsl:template name="faststartactionbodysetid">
1980 <xsl:if test="@resource = 'Table' or @resource='PropertyTable'">
1981 <xsl:text>
1982 setId(</xsl:text>
1983 <xsl:call-template name="idtoqname">
1984 <xsl:with-param name="id" select="@tokenid"/>
1985 </xsl:call-template>
1986 <xsl:text>);</xsl:text>
1987 </xsl:if>
1988 </xsl:template>
1990 <xsl:template name="faststartactionbodychooseaction">
1991 <xsl:for-each select="./action[@name='start']">
1992 <xsl:call-template name="chooseaction"/>
1993 </xsl:for-each>
1994 </xsl:template>
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"/>
2001 </xsl:for-each>
2002 </xsl:template>
2004 <xsl:template name="faststartaction">
2005 <xsl:variable name="body">
2006 <xsl:call-template name="faststartactionbody"/>
2007 </xsl:variable>
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"/>
2012 </xsl:variable>
2013 <xsl:text>
2014 void </xsl:text>
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>
2020 </xsl:if>
2021 </xsl:for-each>
2022 <xsl:text>)
2023 {</xsl:text>
2024 <xsl:value-of select="$body"/>
2025 <xsl:text>
2027 </xsl:text>
2028 </xsl:if>
2029 </xsl:template>
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"/>
2036 </xsl:for-each>
2037 </xsl:for-each>
2038 </xsl:template>
2040 <xsl:template name="fastendaction">
2041 <xsl:variable name="body">
2042 <xsl:call-template name="fastendactionbody"/>
2043 </xsl:variable>
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"/>
2048 </xsl:variable>
2049 <xsl:text>
2050 void </xsl:text>
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>
2056 </xsl:if>
2057 </xsl:for-each>
2058 <xsl:text>)
2059 {</xsl:text>
2060 <xsl:value-of select="$body"/>
2061 <xsl:text>
2063 </xsl:text>
2064 </xsl:if>
2065 </xsl:template>
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"/>
2072 </xsl:variable>
2073 <xsl:choose>
2074 <xsl:when test="$resource = 'StringValue'">
2075 <xsl:call-template name="fastcharactersstringvalue"/>
2076 </xsl:when>
2077 <xsl:when test="$resource = 'IntegerValue'">
2078 <xsl:call-template name="fastcharactersintvalue"/>
2079 </xsl:when>
2080 <xsl:when test="$resource = 'HexValue'">
2081 <xsl:call-template name="fastcharactershexvalue"/>
2082 </xsl:when>
2083 <xsl:when test="$resource = 'BooleanValue'">
2084 <xsl:call-template name="fastcharactersboolvalue"/>
2085 </xsl:when>
2086 <xsl:when test="$resource = 'ListValue'">
2087 <xsl:call-template name="fastcharacterslistvalue"/>
2088 </xsl:when>
2089 </xsl:choose>
2091 <!-- characters action -->
2092 <xsl:for-each select="ancestor::namespace/resource[@name = $name]//action[@name='characters']">
2093 <xsl:call-template name="chooseaction"/>
2094 </xsl:for-each>
2095 </xsl:template>
2097 <xsl:template name="fastcharacters">
2098 <xsl:variable name="body">
2099 <xsl:call-template name="fastcharactersbody"/>
2100 </xsl:variable>
2101 <xsl:if test="string-length($body) > 0">
2102 <xsl:variable name="classname">
2103 <xsl:call-template name="fastcontextname"/>
2104 </xsl:variable>
2105 <xsl:text>
2106 void </xsl:text>
2107 <xsl:value-of select="$classname"/>
2108 <xsl:text>::lcl_characters(const ::rtl::OUString &amp; sText)
2109 throw (uno::RuntimeException, xml::sax::SAXException)
2110 {</xsl:text>
2111 <xsl:value-of select="$body"/>
2112 <xsl:text>
2114 </xsl:text>
2115 </xsl:if>
2116 </xsl:template>
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">
2122 <xsl:choose>
2123 <xsl:when test="@name='propagateCharacterProperties'">
2124 <xsl:text>
2125 return true;</xsl:text>
2126 </xsl:when>
2127 <xsl:when test="@name='propagateTableProperties'">
2128 <xsl:text>
2129 return true;</xsl:text>
2130 </xsl:when>
2131 </xsl:choose>
2132 </xsl:for-each>
2133 </xsl:for-each>
2134 </xsl:template>
2136 <xsl:template name="propagatesproperties">
2137 <xsl:variable name="body">
2138 <xsl:call-template name="propagatespropertiesbody"/>
2139 </xsl:variable>
2140 <xsl:if test="string-length($body) > 0">
2141 <xsl:variable name="classname">
2142 <xsl:call-template name="fastcontextname"/>
2143 </xsl:variable>
2144 <xsl:text>
2145 bool </xsl:text>
2146 <xsl:value-of select="$classname"/>
2147 <xsl:text>::propagatesProperties() const
2148 {</xsl:text>
2149 <xsl:value-of select="$body"/>
2150 <xsl:text>
2152 </xsl:text>
2153 </xsl:if>
2154 </xsl:template>
2156 <xsl:template name="fastcontextcreatefromstart">
2157 <xsl:text>
2158 uno::Reference &lt; xml::sax::XFastContextHandler &gt;
2159 OOXMLFastContextHandler::createFromStart
2160 (::sal_Int32 Element,
2161 const uno::Reference &lt; xml::sax::XFastAttributeList &gt; &amp; Attribs)
2163 #ifdef DEBUG_CREATE
2164 debug_logger-&gt;startElement("createfromstart");
2165 debug_logger-&gt;attribute("element", fastTokenToId(Element));
2166 #endif
2167 uno::Reference &lt; xml::sax::XFastContextHandler &gt; 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]">
2172 <xsl:text>
2173 if (! xResult.is() || dynamic_cast&lt;OOXMLFastContextHandler *&gt;(xResult.get())->isFallback())
2175 xResult = OOXMLFastHelper &lt; </xsl:text>
2176 <xsl:call-template name="fastcontextname"/>
2177 <xsl:text> &gt;::createAndSetParentRef(this, Element, Attribs);
2178 }</xsl:text>
2179 </xsl:for-each>
2180 </xsl:for-each>
2181 <xsl:text>
2183 #ifdef DEBUG_CREATE
2184 debug_logger-&gt;endElement("createfromstart");
2185 #endif
2187 return xResult;
2189 </xsl:text>
2190 </xsl:template>
2192 <xsl:key name="attribs-qnames" match="rng:attribute" use="@qname"/>
2194 <xsl:template name="dumpattribs">
2195 <xsl:text>
2196 void dumpAttrib(const char * sToken, sal_uInt32 nToken,
2197 const uno::Reference &lt; xml::sax::XFastAttributeList
2198 &gt; &amp; Attribs)
2202 if (Attribs->hasAttribute(nToken))
2204 debug_logger-&gt;startElement("attrib");
2205 debug_logger-&gt;attribute("id", sToken);
2206 debug_logger-&gt;chars(Attribs->getValue(nToken));
2207 debug_logger-&gt;endElement("attrib");
2210 catch (...)
2212 debug_logger-&gt;startElement("error");
2213 debug_logger-&gt;chars(sToken);
2214 debug_logger-&gt;endElement("error");
2218 void dumpAttribs
2219 (const uno::Reference &lt; xml::sax::XFastAttributeList &gt; &amp; Attribs)
2220 throw (uno::RuntimeException, xml::sax::SAXException)
2222 debug_logger-&gt;startElement("attribs");
2223 </xsl:text>
2224 <xsl:for-each select="//rng:attribute[@name]">
2225 <xsl:if test="generate-id(.) = generate-id(key('attribs-qnames', @qname)[1]
2227 <xsl:text>
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>
2233 <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>
2239 </xsl:if>
2240 </xsl:for-each>
2241 <xsl:text>
2242 debug_logger-&gt;endElement("attribs");
2243 }</xsl:text>
2244 </xsl:template>
2246 <xsl:template name="createfastchildcontextname">
2247 <xsl:text>createFastContextHandler_</xsl:text>
2248 <xsl:value-of select="@name"/>
2249 </xsl:template>
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>
2257 </xsl:template>
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>
2264 </xsl:variable>
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"/>
2268 </xsl:for-each>
2269 </xsl:for-each>
2270 </xsl:template>
2272 <xsl:template name="createfastchildcontextswitchbody">
2273 <xsl:for-each select=".//rng:element">
2274 <xsl:text>
2275 </xsl:text>
2276 <xsl:call-template name="caselabelfasttoken"/>
2277 <xsl:text>
2278 xResult.set(</xsl:text>
2279 <xsl:call-template name="fastelementcreatestatement"/>
2280 <xsl:text>);
2281 break;</xsl:text>
2282 </xsl:for-each>
2283 <xsl:for-each
2284 select=".//rng:ref[not(ancestor::rng:element or ancestor::rng:attribute)]">
2285 <xsl:call-template name="createfastchildcontextswitchbodyref"/>
2286 </xsl:for-each>
2287 </xsl:template>
2289 <xsl:template name="createfastchildcontextswitch">
2290 <xsl:variable name="body">
2291 <xsl:call-template name="createfastchildcontextswitchbody"/>
2292 </xsl:variable>
2293 <xsl:if test="string-length($body) > 0">
2294 <xsl:text>
2295 switch(Element)
2296 {</xsl:text>
2297 <xsl:value-of select="$body"/>
2298 <xsl:text>
2299 default:
2301 }</xsl:text>
2302 </xsl:if>
2303 </xsl:template>
2305 <xsl:template name="createfastchildcontextlookup">
2306 <xsl:text>
2307 uno::Reference&lt;XFastContextHandler&gt; </xsl:text>
2308 <xsl:call-template name="createfastchildcontextname"/>
2309 <xsl:text>(Id parent, Token_t Element)
2311 uno::Reference&lt;XFastContextHandler&gt; xResult;
2312 switch (parent)
2313 {</xsl:text>
2314 <xsl:for-each select="./rng:grammar/rng:define">
2315 <xsl:variable name="do">
2316 <xsl:call-template name="classfordefine"/>
2317 </xsl:variable>
2318 <xsl:if test="$do='1'">
2319 <xsl:variable name="casebody">
2320 <xsl:call-template name="createfastchildcontextswitch"/>
2321 </xsl:variable>
2322 <xsl:if test="string-length($casebody) > 0">
2323 <xsl:text>
2324 </xsl:text>
2325 <xsl:call-template name="caselabeldefine"/>
2326 <xsl:value-of select="$casebody"/>
2327 <xsl:text>
2328 break;</xsl:text>
2329 </xsl:if>
2330 </xsl:if>
2331 </xsl:for-each>
2332 <xsl:text>
2333 default:
2337 return xResult;
2339 </xsl:text>
2340 </xsl:template>
2342 </xsl:stylesheet>