update dev300-m58
[ooovba.git] / writerfilter / source / ooxml / resourcestools.xsl
blob9b17e4d3126f8d0a7add289ae77663175096b785
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 <xsl:template name="licenseheader">
97 <xsl:text>
98 /*
100 THIS FILE IS GENERATED AUTOMATICALLY! DO NOT EDIT!
103 &#xa;</xsl:text>
104 </xsl:template>
106 <xsl:template name="hasrefs">
107 <xsl:choose>
108 <xsl:when test=".//rng:ref[not(ancestor::rng:element or ancestor::rng:attribute)]">
109 <xsl:text>1</xsl:text>
110 </xsl:when>
111 <xsl:otherwise>
112 <xsl:text>0</xsl:text>
113 </xsl:otherwise>
114 </xsl:choose>
115 </xsl:template>
117 <!--
118 Returns <define> for the current <ref>.
120 The current node must be a <ref>!
122 <xsl:template name="defineforref">
123 <xsl:variable name="mygrammarid" select="generate-id(ancestor::rng:grammar)"/>
124 <xsl:value-of select="key('defines-with-name', @name)[generate-id(ancestor::rng:grammar) = $mygrammarid]"/>
125 </xsl:template>
127 <!--
128 Create name with prefix.
130 The result is <prefix>:<name>.
132 Exception: If <name> contains a ':' the prefix is ignored.
134 @param prefix the prefix
135 @param name the name
137 <xsl:template name="prefixname">
138 <xsl:param name="prefix"/>
139 <xsl:param name="name"/>
140 <xsl:choose>
141 <xsl:when test="contains($name, ':')">
142 <xsl:value-of select="$name"/>
143 </xsl:when>
144 <xsl:otherwise>
145 <xsl:value-of select="$prefix"/>
146 <xsl:text>:</xsl:text>
147 <xsl:value-of select="$name"/>
148 </xsl:otherwise>
149 </xsl:choose>
150 </xsl:template>
152 <xsl:template name="fastnamespace">
153 <xsl:if test="string-length(@prefix) > 0">
154 <xsl:text>NS_</xsl:text>
155 <xsl:value-of select="@prefix"/>
156 </xsl:if>
157 </xsl:template>
159 <xsl:template name="fastlocalname">
160 <xsl:text>OOXML_</xsl:text>
161 <xsl:value-of select="@localname"/>
162 </xsl:template>
164 <!--
165 Create entries in enum definition for fast tokens.
167 For each occurrence of rng:element an entry
169 OOXML_<name>
171 is generated, but only if the element is the first named <name>.
173 <xsl:template name="enumfasttokens">
174 <xsl:param name="prefix"/>
175 <xsl:for-each select=".//rng:element|.//rng:attribute">
176 <xsl:if test="generate-id(.) = generate-id(key('same-token-name', @localname)[1])">
177 <xsl:call-template name="fastlocalname"/>
178 <xsl:text>, &#xa; </xsl:text>
179 </xsl:if>
180 </xsl:for-each>
181 </xsl:template>
183 <xsl:template name="fasttokens">
184 <xsl:text>
185 typedef sal_Int32 Token_t;
186 </xsl:text>
187 <xsl:for-each select="/model/fasttoken">
188 <xsl:text>
189 const Token_t OOXML_</xsl:text>
190 <xsl:value-of select="translate(., '-', '_')"/>
191 <xsl:text> = </xsl:text>
192 <xsl:value-of select="position() - 1"/>
193 <xsl:text>;</xsl:text>
194 </xsl:for-each>
195 <xsl:text>
196 const Token_t OOXML_FAST_TOKENS_END =</xsl:text>
197 <xsl:value-of select="count(/model/fasttoken)"/>
198 <xsl:text>;&#xa;</xsl:text>
199 </xsl:template>
201 <!--
202 Returns prefix for the rng:grammar of the current node.
204 <xsl:template name="prefixforgrammar">
205 <xsl:variable name="ns" select="ancestor::rng:grammar/@ns"/>
206 <xsl:variable name="nsalias"><xsl:value-of select="key('namespace-aliases', $ns)/@alias"/></xsl:variable>
207 <!--<xsl:variable name="nsalias">test</xsl:variable>-->
208 <xsl:choose>
209 <xsl:when test="string-length($nsalias) > 0">
210 <xsl:value-of select="$nsalias"/>
211 </xsl:when>
212 <xsl:otherwise>
213 <xsl:value-of select="translate(substring-after($ns, 'http://'), '/.', '__')"/>
214 </xsl:otherwise>
215 </xsl:choose>
216 </xsl:template>
218 <!--
219 Returns prefix for the rng:grammar of the matching nodes.
221 <xsl:template match="*" mode="grammar-prefix">
222 <xsl:call-template name="prefixforgrammar"/>
223 </xsl:template>
225 <!--
226 Generates name for fast context class for this <define>
228 <xsl:template name="fastcontextname">
229 <xsl:variable name="do">
230 <xsl:call-template name="classfordefine"/>
231 </xsl:variable>
232 <xsl:if test="$do = '1'">
233 <xsl:variable name="definename">
234 <xsl:call-template name="searchdefinenamespace">
235 <xsl:with-param name="name" select="@name"/>
236 </xsl:call-template>
237 </xsl:variable>
238 <xsl:for-each select="/model/namespace[@name=substring-before($definename, ':')]">
239 <xsl:text>OOXMLFastContextHandler_</xsl:text>
240 <xsl:value-of select="@namespacealias"/>
241 <xsl:text>_</xsl:text>
242 <xsl:value-of select="substring-after($definename, ':')"/>
243 </xsl:for-each>
244 </xsl:if>
245 </xsl:template>
247 <!--
248 Returns the value of the @resource attribute of the <resource>
249 node according to the current <define>.
251 <xsl:template name="contextresource">
252 <xsl:variable name="mynsid" select="generate-id(ancestor::namespace)"/>
253 <xsl:choose>
254 <xsl:when test="count(key('context-resource', @name)) = 1">
255 <xsl:value-of select="key('context-resource', @name)/@resource"/>
256 </xsl:when>
257 <xsl:otherwise>
258 <xsl:value-of select="key('context-resource', @name)[generate-id(ancestor::namespace)=$mynsid]/@resource"/>
259 </xsl:otherwise>
260 </xsl:choose>
261 </xsl:template>
263 <!--
264 Returns a value name.
266 The resulting value name is
268 OOXMLValue_$prefix_$name
270 @prefix the prefix
271 @name the name
273 <xsl:template name="valuename">
274 <xsl:param name="prefix"/>
275 <xsl:param name="name"/>
276 <xsl:text>OOXMLValue_</xsl:text>
277 <xsl:value-of select="$prefix"/>
278 <xsl:text>_</xsl:text>
279 <xsl:value-of select="$name"/>
280 </xsl:template>
282 <!--
283 Returns the value name for the current <define>.
285 <xsl:template name="valuenamefordefine">
286 <xsl:call-template name="valuename">
287 <xsl:with-param name="prefix" select="key('namespace-aliases', ancestor::namespace/rng:grammar/@ns)/@alias"/>
288 <xsl:with-param name="name" select="translate(@name, '-', '_')"/>
289 </xsl:call-template>
290 </xsl:template>
292 <!--
293 Returns the name of the parent class of the class for the
294 current <define>.
296 Precondition: The class for the current <define> is derived
297 indirectly from OOXMLValue.
300 <xsl:template name="valueparent">
301 <xsl:variable name="resource">
302 <xsl:call-template name="contextresource"/>
303 </xsl:variable>
304 <xsl:text>OOXML</xsl:text>
305 <xsl:value-of select="$resource"/>
306 <xsl:text>Value</xsl:text>
307 </xsl:template>
309 <!--
310 Generates declaration for a value class.
312 Precondition: <resource> for current <define> indicates that the
313 class is derived directly or indirectly from OOXMLValue.
315 <xsl:template name="valuedecl">
316 <xsl:variable name="classname">
317 <xsl:call-template name="valuenamefordefine"/>
318 </xsl:variable>
319 <xsl:variable name="resource">
320 <xsl:call-template name="contextresource"/>
321 </xsl:variable>
322 <xsl:text>
323 class </xsl:text>
324 <xsl:value-of select="$classname"/>
325 <xsl:text> : public </xsl:text>
326 <xsl:call-template name="valueparent"/>
327 <xsl:text>
329 public:
330 </xsl:text>
331 <xsl:choose>
332 <xsl:when test="$resource='List'">
333 <xsl:value-of select="$classname"/>
334 <xsl:text>(</xsl:text>
335 <xsl:text>const rtl::OUString &amp; rValue</xsl:text>
336 <xsl:text>);</xsl:text>
337 </xsl:when>
338 <xsl:otherwise>
339 <xsl:value-of select="$classname"/>
340 <xsl:text>(const rtl::OUString &amp; rValue) : </xsl:text>
341 <xsl:call-template name="valueparent"/>
342 <xsl:text>(rValue) {}</xsl:text>
343 </xsl:otherwise>
344 </xsl:choose>
345 <xsl:text>
346 virtual ~</xsl:text>
347 <xsl:value-of select="$classname"/>
348 <xsl:text>() {}
350 </xsl:text>
351 </xsl:template>
353 <!--
354 Checks if a class derived from OOXMLContex shall be defined for
355 the current <define>.
357 @retval 1 the class shall be defined.
358 @retval 0 otherwise
360 <xsl:template name="classfordefine">
361 <!--
362 <xsl:variable name="name" select="@name"/>
363 <xsl:choose>
364 <xsl:when test="(starts-with(@name, 'CT_') or starts-with(@name, 'EG_') or starts-with(@name, 'AG_'))">1</xsl:when>
365 <xsl:when test="ancestor::namespace//start[@name=$name]">1</xsl:when>
366 <xsl:otherwise>0</xsl:otherwise>
367 </xsl:choose>
369 <xsl:value-of select="@classfordefine"/>
370 </xsl:template>
372 <!--
373 Checks if a class derived from OOXMLValue shall be defined for
374 the current <define>.
376 @retval 1 the class shall be defined
377 @retval 0 otherwise
379 <xsl:template name="valuefordefine">
380 <xsl:choose>
381 <xsl:when test="starts-with(@name, 'ST_')">1</xsl:when>
382 <xsl:otherwise>0</xsl:otherwise>
383 </xsl:choose>
384 </xsl:template>
386 <xsl:template name="valuedecls">
387 <xsl:for-each select=".//rng:grammar/rng:define">
388 <xsl:variable name="dovalue">
389 <xsl:call-template name="valuefordefine"/>
390 </xsl:variable>
391 <xsl:if test="$dovalue = '1'">
392 <xsl:call-template name="valuedecl"/>
393 </xsl:if>
394 </xsl:for-each>
395 </xsl:template>
397 <!--
398 Generate switch body for createFastChildContext
400 <xsl:template name="switchbodycreatechildcontext">
401 <xsl:for-each select=".//rng:element[@name]">
402 <xsl:call-template name="caselabelfasttoken"/>
403 <xsl:variable name="createstatement">
404 <xsl:call-template name="fastelementcreatestatement"/>
405 </xsl:variable>
406 <xsl:if test="string-length($createstatement) > 0">
407 <xsl:text>
408 xContextHandler.set(</xsl:text>
409 <xsl:value-of select="$createstatement"/>
410 <xsl:text>);
411 </xsl:text>
412 </xsl:if>
413 <xsl:text>
414 break;
415 </xsl:text>
416 </xsl:for-each>
417 </xsl:template>
419 <xsl:template name="fastelementcreatefromrefstatement">
420 <xsl:variable name="definename">
421 <xsl:call-template name="searchdefinenamespace">
422 <xsl:with-param name="name" select="@name"/>
423 </xsl:call-template>
424 </xsl:variable>
425 <xsl:for-each select="/model/namespace[@name=substring-before($definename, ':')]">
426 <xsl:for-each select="./rng:grammar/rng:define[@name=substring-after($definename, ':')]">
427 <xsl:variable name="do">
428 <xsl:call-template name="classfordefine"/>
429 </xsl:variable>
430 <xsl:if test="$do = '1'">
431 <xsl:text>OOXMLFastHelper &lt;</xsl:text>
432 <xsl:call-template name="fastcontextname"/>
433 <xsl:text>&gt;::createAndSetParentRef(this, Element, Attribs)</xsl:text>
434 </xsl:if>
435 </xsl:for-each>
436 </xsl:for-each>
437 </xsl:template>
439 <xsl:template name="switchbodycreatechildcontextrefs">
440 <xsl:for-each select=".//rng:ref[not (ancestor::rng:element or ancestor::rng:attribute)]">
441 <xsl:variable name="createstatement">
442 <xsl:call-template name="fastelementcreatefromrefstatement"/>
443 </xsl:variable>
444 <xsl:if test="string-length($createstatement) > 0">
445 <xsl:text>
446 if (! xContextHandler.is() || dynamic_cast&lt;OOXMLFastContextHandler *&gt;(xContextHandler.get())->isFallback())
448 xContextHandler.set(</xsl:text>
449 <xsl:value-of select="$createstatement"/>
450 <xsl:text>);
452 </xsl:text>
453 </xsl:if>
454 </xsl:for-each>
455 <xsl:for-each select=".//rng:element[rng:anyName]">
456 <xsl:variable name="createstatement">
457 <xsl:call-template name="fastelementcreatestatement"/>
458 </xsl:variable>
459 <xsl:if test="string-length($createstatement) > 0">
460 <xsl:text>
461 if (! xContextHandler.is() || dynamic_cast&lt;OOXMLFastContextHandler *&gt;(xContextHandler.get())->isFallback())
463 xContextHandler.set(</xsl:text>
464 <xsl:value-of select="$createstatement"/>
465 <xsl:text>);
467 </xsl:text>
468 </xsl:if>
469 </xsl:for-each>
470 </xsl:template>
472 <!--
473 Generates definition of method createFastChildContext for current <define>
475 <xsl:template name="createfastchildcontext">
476 <xsl:variable name="resource">
477 <xsl:call-template name="contextresource"/>
478 </xsl:variable>
479 <xsl:if test="not($resource='Shape')">
480 <xsl:variable name="switchbody">
481 <xsl:call-template name="switchbodycreatechildcontext"/>
482 </xsl:variable>
483 <xsl:variable name="switchbodyrefs">
484 <xsl:call-template name="switchbodycreatechildcontextrefs"/>
485 </xsl:variable>
486 <xsl:if test="string-length($switchbody) > 0 or string-length($switchbodyrefs) > 0">
487 <xsl:text>
488 uno::Reference &lt; xml::sax::XFastContextHandler &gt;
489 </xsl:text>
490 <xsl:call-template name="fastcontextname"/>
491 <xsl:text>::lcl_createFastChildContext
492 (::sal_Int32 Element,
493 const uno::Reference &lt; xml::sax::XFastAttributeList &gt; &amp;</xsl:text>
494 <xsl:if test="contains($switchbody, 'Attribs') or contains($switchbodyrefs, 'Attribs')">
495 <xsl:text> Attribs</xsl:text>
496 </xsl:if>
497 <xsl:text>)
498 throw (uno::RuntimeException, xml::sax::SAXException)
500 uno::Reference &lt; xml::sax::XFastContextHandler &gt; xContextHandler;
501 </xsl:text>
502 <xsl:if test="string-length($switchbody) > 0">
503 <xsl:text>
504 switch (Element)
506 </xsl:text>
507 <xsl:value-of select="$switchbody"/>
508 <xsl:text>
509 default:
510 break;
512 </xsl:text>
513 </xsl:if>
514 <xsl:if test="string-length($switchbodyrefs) > 0">
515 <xsl:value-of select="$switchbodyrefs"/>
516 </xsl:if>
517 <xsl:text>
519 return xContextHandler;
521 </xsl:text>
522 </xsl:if>
523 </xsl:if>
524 </xsl:template>
526 <xsl:template name="idforattr">
527 <xsl:variable name="name" select="@name"/>
528 <xsl:for-each select="ancestor::rng:define">
529 <xsl:variable name="definename" select="@name"/>
530 <xsl:for-each select="ancestor::namespace/resource[@name=$definename]">
531 <xsl:for-each select="./attribute[@name=$name]">
532 <xsl:call-template name="idtoqname">
533 <xsl:with-param name="id" select="@tokenid"/>
534 </xsl:call-template>
535 </xsl:for-each>
536 </xsl:for-each>
537 </xsl:for-each>
538 </xsl:template>
540 <xsl:template name="idforelement">
541 <xsl:variable name="name" select="@name"/>
542 <xsl:for-each select="ancestor::rng:define">
543 <xsl:variable name="definename" select="@name"/>
544 <xsl:for-each select="ancestor::namespace/resource[@name=$definename]">
545 <xsl:for-each select="./element[@name=$name]">
546 <xsl:call-template name="idtoqname">
547 <xsl:with-param name="id" select="@tokenid"/>
548 </xsl:call-template>
549 </xsl:for-each>
550 </xsl:for-each>
551 </xsl:for-each>
552 </xsl:template>
554 <!--
555 Processes token id given in <resource> elements.
557 The result is the identifier for the tokenid.
559 <xsl:template name="processtokenid">
560 <xsl:choose>
561 <xsl:when test="contains(@tokenid, ':')">
562 <xsl:call-template name="idtoqname">
563 <xsl:with-param name="id" select="@tokenid"/>
564 </xsl:call-template>
565 </xsl:when>
566 <xsl:otherwise>
567 <xsl:value-of select="@tokenid"/>
568 </xsl:otherwise>
569 </xsl:choose>
570 </xsl:template>
572 <xsl:template name="getidcaseimpl">
573 <xsl:for-each select="attribute|element">
574 <xsl:text>
575 </xsl:text>
576 <xsl:call-template name="caselabelfasttoken"/>
577 <xsl:text>
578 nResult = </xsl:text>
579 <xsl:call-template name="processtokenid"/>
580 <xsl:text>;
581 break;</xsl:text>
582 </xsl:for-each>
583 </xsl:template>
585 <xsl:template name="attributeproptype">
586 <xsl:variable name="mynsid" select="generate-id(ancestor::namespace)"/>
587 <xsl:variable name="name" select="@name"/>
588 <xsl:variable name="resource" select="key('context-resource', @name)[generate-id(ancestor::namespace)=$mynsid]"/>
589 <xsl:choose>
590 <xsl:when test="$resource/element[@name=$name]">
591 <xsl:text>OOXMLPropertyImpl::SPRM</xsl:text>
592 </xsl:when>
593 <xsl:otherwise>
594 <xsl:text>OOXMLPropertyImpl::ATTRIBUTE</xsl:text>
595 </xsl:otherwise>
596 </xsl:choose>
597 </xsl:template>
599 <!--
600 Check if a default is defined for a define.
602 Returns if the <resource> for the current <define> has a
603 <default> child.
605 @retval 0 there is no default
606 @retval 1 there is a default
608 <xsl:template name="contexthasdefault">
609 <xsl:variable name="name" select="@name"/>
610 <xsl:choose>
611 <xsl:when test="ancestor::namespace/resource[@name=$name]//default">1</xsl:when>
612 <xsl:otherwise>0</xsl:otherwise>
613 </xsl:choose>
614 </xsl:template>
616 <!--
617 Chooses the action for the current <action> element.
619 <xsl:template name="chooseaction">
620 <xsl:if test="@tokenid">
621 <xsl:text>
622 if (sal::static_int_cast&lt;Id&gt;(getId()) == </xsl:text>
623 <xsl:call-template name="idtoqname">
624 <xsl:with-param name="id" select="@tokenid"/>
625 </xsl:call-template>
626 <xsl:text>)
627 {</xsl:text>
628 </xsl:if>
629 <xsl:for-each select="./cond">
630 <xsl:text>
632 OOXMLPropertySetEntryToInteger aHandler(</xsl:text>
633 <xsl:call-template name="idtoqname">
634 <xsl:with-param name="id" select="@tokenid"/>
635 </xsl:call-template>
636 <xsl:text>);
637 getPropertySetAttrs()->resolve(aHandler);
639 if (sal::static_int_cast&lt;Id&gt;(aHandler.getValue()) == </xsl:text>
640 <xsl:call-template name="idtoqname">
641 <xsl:with-param name="id" select="@value"/>
642 </xsl:call-template>
643 <xsl:text>)
644 {</xsl:text>
645 </xsl:for-each>
646 <xsl:choose>
647 <xsl:when test="@action='sendTableDepth'">
648 <xsl:text>
649 sendTableDepth();</xsl:text>
650 </xsl:when>
651 <xsl:when test="@action='startCell'">
652 <xsl:text>
653 startCell();</xsl:text>
654 </xsl:when>
655 <xsl:when test="@action='startParagraphGroup'">
656 <xsl:text>
657 startParagraphGroup();</xsl:text>
658 </xsl:when>
659 <xsl:when test="@action='startCharacterGroup'">
660 <xsl:text>
661 startCharacterGroup();</xsl:text>
662 </xsl:when>
663 <xsl:when test="@action='startSectionGroup'">
664 <xsl:text>
665 startSectionGroup();</xsl:text>
666 </xsl:when>
667 <xsl:when test="@action='fieldstart'">
668 <xsl:text>
669 startField();</xsl:text>
670 </xsl:when>
671 <xsl:when test="@action='fieldsep'">
672 <xsl:text>
673 fieldSeparator();</xsl:text>
674 </xsl:when>
675 <xsl:when test="@action='fieldend'">
676 <xsl:text>
677 endField();</xsl:text>
678 </xsl:when>
679 <xsl:when test="@action='ftnednref'">
680 <xsl:text>
681 ftnednref();</xsl:text>
682 </xsl:when>
683 <xsl:when test="@action='ftnednsep'">
684 <xsl:text>
685 ftnednsep();</xsl:text>
686 </xsl:when>
687 <xsl:when test="@action='ftnedncont'">
688 <xsl:text>
689 ftnedncont();</xsl:text>
690 </xsl:when>
691 <xsl:when test="@action='pgNum'">
692 <xsl:text>
693 pgNum();</xsl:text>
694 </xsl:when>
695 <xsl:when test="@action='tab'">
696 <xsl:text>
697 tab();</xsl:text>
698 </xsl:when>
699 <xsl:when test="@action='cr'">
700 <xsl:text>
701 cr();</xsl:text>
702 </xsl:when>
703 <xsl:when test="@action='noBreakHyphen'">
704 <xsl:text>
705 noBreakHyphen();</xsl:text>
706 </xsl:when>
707 <xsl:when test="@action='softHyphen'">
708 <xsl:text>
709 softHyphen();</xsl:text>
710 </xsl:when>
711 <xsl:when test="@action='endOfParagraph'">
712 <xsl:text>
713 endOfParagraph();</xsl:text>
714 </xsl:when>
715 <xsl:when test="@action='handleLastParagraphInSection'">
716 <xsl:text>
717 handleLastParagraphInSection();</xsl:text>
718 </xsl:when>
719 <xsl:when test="@action='setLastParagraphInSection'">
720 <xsl:text>
721 setLastParagraphInSection();</xsl:text>
722 </xsl:when>
723 <xsl:when test="@action='endCell'">
724 <xsl:text>
725 endCell();</xsl:text>
726 </xsl:when>
727 <xsl:when test="@action='endParagraphGroup'">
728 <xsl:text>
729 endParagraphGroup();</xsl:text>
730 </xsl:when>
731 <xsl:when test="@action='endCharacterGroup'">
732 <xsl:text>
733 endCharacterGroup();</xsl:text>
734 </xsl:when>
735 <xsl:when test="@action='endSectionGroup'">
736 <xsl:text>
737 endSectionGroup();</xsl:text>
738 </xsl:when>
739 <xsl:when test="@action='handleXNotes'">
740 handleXNotes();</xsl:when>
741 <xsl:when test="@action='handleHdrFtr'">
742 handleHdrFtr();</xsl:when>
743 <xsl:when test="@action='handleComment'">
744 handleComment();</xsl:when>
745 <xsl:when test="@action='handlePicture'">
746 handlePicture();</xsl:when>
747 <xsl:when test="@action='handleHyperlink'">
748 handleHyperlink();</xsl:when>
749 <xsl:when test="@action='handleBreak'">
750 handleBreak();</xsl:when>
751 <xsl:when test="@action='handleOLE'">
752 handleOLE();</xsl:when>
753 <xsl:when test="@action='printproperty'">
754 <xsl:text>
755 sendProperty(</xsl:text>
756 <xsl:call-template name="idtoqname">
757 <xsl:with-param name="id" select="@sendtokenid"/>
758 </xsl:call-template>
759 <xsl:text>);</xsl:text>
760 </xsl:when>
761 <xsl:when test="@action='propagateCharacterProperties'">
762 propagateCharacterProperties();
763 </xsl:when>
764 <xsl:when test="@action='propagateCharacterPropertiesAsSet'">
765 <xsl:text>
766 propagateCharacterPropertiesAsSet(</xsl:text>
767 <xsl:call-template name="idtoqname">
768 <xsl:with-param name="id" select="@sendtokenid"/>
769 </xsl:call-template>
770 <xsl:text>);</xsl:text>
771 </xsl:when>
772 <xsl:when test="@action='propagateTableProperties'">
773 propagateTableProperties();
774 </xsl:when>
775 <xsl:when test="@action='sendPropertiesWithId'">
776 <xsl:text>
777 sendPropertiesWithId(</xsl:text>
778 <xsl:call-template name="idtoqname">
779 <xsl:with-param name="id" select="@sendtokenid"/>
780 </xsl:call-template>
781 <xsl:text>);</xsl:text>
782 </xsl:when>
783 <xsl:when test="@action='clearProps'">
784 clearProps();
785 </xsl:when>
786 <xsl:when test="@action='text'">
787 text(sText);
788 </xsl:when>
789 <xsl:when test="@action='setHandle'">
790 setHandle();
791 </xsl:when>
793 <xsl:when test="@action='footnoteSeparator'">
794 footnoteSeparator();
795 </xsl:when>
796 <xsl:when test="@action='footnoteCont'">
797 footnoteCont();
798 </xsl:when>
799 <xsl:when test="@action='endnoteSeparator'">
800 endnoteSeparator();
801 </xsl:when>
802 <xsl:when test="@action='endnoteCont'">
803 endnoteCont();
804 </xsl:when>
805 <xsl:when test="@action='newProperty'">
806 <xsl:text>
807 OOXMLFastHelper&lt;OOXMLIntegerValue&gt;::newProperty(this, </xsl:text>
808 <xsl:call-template name="idtoqname">
809 <xsl:with-param name="id" select="@tokenid"/>
810 </xsl:call-template>
811 <xsl:text>, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("</xsl:text>
812 <xsl:value-of select="@value"/>
813 <xsl:text>")));</xsl:text>
814 </xsl:when>
815 <xsl:when test="@action='mark'">
816 <xsl:text>
817 OOXMLFastHelper&lt;OOXMLIntegerValue&gt;::mark(this, </xsl:text>
818 <xsl:call-template name="idtoqname">
819 <xsl:with-param name="id" select="@sendtokenid"/>
820 </xsl:call-template>
821 <xsl:text>, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("</xsl:text>
822 <xsl:value-of select="@value"/>
823 <xsl:text>")));</xsl:text>
824 </xsl:when>
825 <xsl:when test="@action='tokenproperty'">
826 <xsl:text>
827 OOXMLFastHelper&lt;OOXMLIntegerValue&gt;::newProperty(this, </xsl:text>
828 <xsl:call-template name="idtoqname">
829 <xsl:with-param name="id">ooxml:token</xsl:with-param>
830 </xsl:call-template>
831 <xsl:text>, getToken());</xsl:text>
832 </xsl:when>
833 </xsl:choose>
834 <xsl:for-each select="./cond">
835 <xsl:text>
837 }</xsl:text>
838 </xsl:for-each>
839 <xsl:if test="@tokenid">
840 <xsl:text>
841 }</xsl:text>
842 </xsl:if>
843 </xsl:template>
845 <!--
846 Generates the definitions of the methods of the fast context class
847 for the current <define>.
849 <xsl:template name="fastcontextimpls">
850 <xsl:param name="ns"/>
851 <xsl:for-each select=".//namespace[@name=$ns]">
852 <xsl:text>
853 </xsl:text>
854 <xsl:for-each select="./rng:grammar/rng:define">
855 <xsl:variable name="do">
856 <xsl:call-template name="classfordefine"/>
857 </xsl:variable>
858 <xsl:if test="$do = '1'">
859 <xsl:variable name="classname">
860 <xsl:call-template name="fastcontextname"/>
861 </xsl:variable>
862 <xsl:text>
864 class: </xsl:text>
865 <xsl:value-of select="$classname"/>
866 <xsl:text>
868 </xsl:text>
869 <xsl:call-template name="fastcontextconstructor"/>
870 <xsl:call-template name="fastcontextdestructor"/>
871 <xsl:call-template name="faststartaction"/>
872 <xsl:call-template name="fastendaction"/>
873 <xsl:call-template name="createfastchildcontext"/>
874 <xsl:call-template name="fastattribute"/>
875 <xsl:call-template name="fastcharacters"/>
876 <xsl:call-template name="propagatesproperties"/>
877 </xsl:if>
878 </xsl:for-each>
879 </xsl:for-each>
880 </xsl:template>
882 <xsl:key name="value-with-content" match="//rng:value"
883 use="text()"/>
885 <!--
886 Generates name for a value string.
888 Value strings are possible values for attributes in OOXML.
890 @param string the string as present in the according <rng:value>
892 <xsl:template name="valuestringname">
893 <xsl:param name="string"/>
894 <xsl:text>OOXMLValueString_</xsl:text>
895 <xsl:value-of select="translate($string, '-+ ,', 'mp__')"/>
896 </xsl:template>
898 <!--
899 Generates constant definitions for attribute values.
901 <xsl:template name="valueconstants">
902 <xsl:text>
903 rtl::OUString </xsl:text>
904 <xsl:call-template name="valuestringname">
905 <xsl:with-param name="string"></xsl:with-param>
906 </xsl:call-template>
907 <xsl:text>(RTL_CONSTASCII_USTRINGPARAM(""));</xsl:text>
908 <xsl:for-each select="//rng:value[generate-id(key('value-with-content', text())[1]) = generate-id(.)]">
909 <xsl:text>
910 rtl::OUString </xsl:text>
911 <xsl:call-template name="valuestringname">
912 <xsl:with-param name="string" select="."/>
913 </xsl:call-template>
914 <xsl:text>(RTL_CONSTASCII_USTRINGPARAM("</xsl:text>
915 <xsl:value-of select="."/>
916 <xsl:text>"));</xsl:text>
917 </xsl:for-each>
918 </xsl:template>
920 <!--
921 Generates constant declarations for attribute values.
923 <xsl:template name="valueconstantdecls">
924 <xsl:text>
925 extern rtl::OUString
926 </xsl:text>
927 <xsl:call-template name="valuestringname">
928 <xsl:with-param name="string"></xsl:with-param>
929 </xsl:call-template>
930 <xsl:text>;</xsl:text>
931 <xsl:for-each select="//rng:value[generate-id(key('value-with-content', text())[1]) = generate-id(.)]">
932 <xsl:text>
933 extern rtl::OUString </xsl:text>
934 <xsl:call-template name="valuestringname">
935 <xsl:with-param name="string" select="."/>
936 </xsl:call-template>
937 <xsl:text>;</xsl:text>
938 </xsl:for-each>
939 </xsl:template>
941 <!--
942 Generates definition of constructor for attribute value class
943 for current <define>.
945 <xsl:template name="valueconstructorimpl">
946 <xsl:variable name="name" select="@name"/>
947 <xsl:variable name="resource">
948 <xsl:call-template name="contextresource"/>
949 </xsl:variable>
950 <xsl:choose>
951 <xsl:when test="$resource = 'List'">
952 <xsl:variable name="classname">
953 <xsl:call-template name="valuenamefordefine"/>
954 </xsl:variable>
955 <xsl:text>&#xa;</xsl:text>
956 <xsl:value-of select="$classname"/>
957 <xsl:text>::</xsl:text>
958 <xsl:value-of select="$classname"/>
959 <xsl:text>(const rtl::OUString &amp; </xsl:text>
960 <xsl:choose>
961 <xsl:when test="count(ancestor::namespace/resource[@name=$name]/value) > 0">
962 <xsl:text>rValue</xsl:text>
963 </xsl:when>
964 <xsl:otherwise>
965 <xsl:text>/* rValue */</xsl:text>
966 </xsl:otherwise>
967 </xsl:choose>
968 <xsl:text>)
969 : OOXMLListValue()
970 {</xsl:text>
971 <xsl:for-each select="ancestor::namespace/resource[@name=$name]">
972 <xsl:for-each select="./default">
973 <xsl:text>
974 mnValue = </xsl:text>
975 <xsl:choose>
976 <xsl:when test="@tokenid">
977 <xsl:call-template name="idtoqname">
978 <xsl:with-param name="id" select="@tokenid"/>
979 </xsl:call-template>
980 </xsl:when>
981 <xsl:otherwise>
982 <xsl:value-of select="."/>
983 </xsl:otherwise>
984 </xsl:choose>
985 <xsl:text>;</xsl:text>
986 </xsl:for-each>
987 <xsl:for-each select="./value">
988 <xsl:text>
989 if (rValue.compareTo(</xsl:text>
990 <xsl:call-template name="valuestringname">
991 <xsl:with-param name="string" select="text()"/>
992 </xsl:call-template>
993 <xsl:text>) == 0)
995 mnValue = </xsl:text>
996 <xsl:call-template name="idtoqname">
997 <xsl:with-param name="id" select="@tokenid"/>
998 </xsl:call-template>
999 <xsl:text>;
1000 return;
1001 }</xsl:text>
1002 </xsl:for-each>
1003 </xsl:for-each>
1004 <xsl:text>
1006 </xsl:text>
1007 </xsl:when>
1008 </xsl:choose>
1009 </xsl:template>
1011 <!--
1012 Generates definition of destructor of attribute value class for
1013 current <define>.
1015 <xsl:template name="valuedestructorimpl">
1016 <xsl:variable name="classname">
1017 <xsl:call-template name="valuenamefordefine"/>
1018 </xsl:variable>
1019 <xsl:text>&#xa;</xsl:text>
1020 <xsl:value-of select="$classname"/>
1021 <xsl:text>::~</xsl:text>
1022 <xsl:value-of select="$classname"/>
1023 <xsl:text>()
1026 </xsl:text>
1027 </xsl:template>
1029 <!--
1030 Generates definitions for attribute value class for current
1031 <define>.
1033 <xsl:template name="valueimpls">
1034 <xsl:for-each select=".//rng:grammar/rng:define">
1035 <xsl:variable name="do">
1036 <xsl:call-template name="valuefordefine"/>
1037 </xsl:variable>
1038 <xsl:if test="$do = 1">
1039 <xsl:variable name="classname">
1040 <xsl:call-template name="valuenamefordefine"/>
1041 </xsl:variable>
1042 <xsl:text>
1044 class: </xsl:text>
1045 <xsl:value-of select="$classname"/>
1046 <xsl:text>
1048 </xsl:text>
1049 <xsl:call-template name="valueconstructorimpl"/>
1050 </xsl:if>
1051 </xsl:for-each>
1052 </xsl:template>
1054 <xsl:key name="tokenids" match="@tokenid|@sendtokenid" use="."/>
1056 <!--
1057 Generates contant definitions for tokenids.
1059 <xsl:template name="defineooxmlids">
1060 <xsl:text>
1061 namespace NS_ooxml
1062 {</xsl:text>
1063 <xsl:for-each select="//@tokenid|//@sendtokenid">
1064 <xsl:if test="contains(., 'ooxml:') and generate-id(.) = generate-id(key('tokenids', .)[1])">
1065 <xsl:text>
1066 const Id LN_</xsl:text>
1067 <xsl:value-of select="substring-after(., 'ooxml:')"/>
1068 <xsl:text> = </xsl:text>
1069 <xsl:value-of select="90000 + position()"/>
1070 <xsl:text>;</xsl:text>
1071 </xsl:if>
1072 </xsl:for-each>
1074 </xsl:template>
1076 <xsl:template name="ooxmlidstoxml">
1077 <xsl:text>
1078 void ooxmlsprmidsToXML(::std::ostream &amp; out)
1079 {</xsl:text>
1080 <xsl:for-each select="//@tokenid">
1081 <xsl:if test="contains(., 'ooxml:') and generate-id(.) = generate-id(key('tokenids', .)[1]) and ancestor::element">
1082 <xsl:text>
1083 out &lt;&lt; "&lt;theid name=\"</xsl:text>
1084 <xsl:value-of select="."/>
1085 <xsl:text>\"&gt;</xsl:text>
1086 <xsl:value-of select="90000 + position()"/>
1087 <xsl:text>&lt;/theid&gt;" &lt;&lt; endl; </xsl:text>
1088 </xsl:if>
1089 </xsl:for-each>
1090 <xsl:text>
1091 }</xsl:text>
1092 <xsl:text>
1093 void ooxmlidsToXML(::std::ostream &amp; out)
1094 {</xsl:text>
1095 <xsl:for-each select="//@tokenid">
1096 <xsl:if test="contains(., 'ooxml:') and generate-id(.) = generate-id(key('tokenids', .)[1]) and ancestor::attribute">
1097 <xsl:text>
1098 out &lt;&lt; "&lt;theid name=\"</xsl:text>
1099 <xsl:value-of select="."/>
1100 <xsl:text>\"&gt;</xsl:text>
1101 <xsl:value-of select="90000 + position()"/>
1102 <xsl:text>&lt;/theid&gt;" &lt;&lt; endl; </xsl:text>
1103 </xsl:if>
1104 </xsl:for-each>
1105 <xsl:text>
1106 }</xsl:text>
1107 </xsl:template>
1109 <!--
1110 Generates mapping from tokenids to strings. (DEBUG)
1112 <xsl:template name="qnametostr">
1113 <xsl:text>
1114 void QNameToString::init_ooxml()
1116 /* ooxml */
1117 </xsl:text>
1118 <xsl:for-each select="//@tokenid">
1119 <xsl:if test="generate-id(.) = generate-id(key('tokenids', .)[1]) and contains(., 'ooxml:')">
1120 <xsl:text>
1121 mMap[</xsl:text>
1122 <xsl:call-template name="idtoqname">
1123 <xsl:with-param name="id" select="."/>
1124 </xsl:call-template>
1125 <xsl:text>] = "</xsl:text>
1126 <xsl:value-of select="."/>
1127 <xsl:text>";</xsl:text>
1128 </xsl:if>
1129 </xsl:for-each>
1130 <xsl:text>
1132 </xsl:text>
1133 </xsl:template>
1135 <xsl:template name="qnametostrfunc">
1136 <xsl:text>
1137 string qnameToString(sal_uInt32 nToken)
1139 string sResult;
1141 switch (nToken)
1142 {</xsl:text>
1143 <xsl:for-each select="//resource">
1144 <xsl:variable name="name" select="@name"/>
1145 <xsl:for-each select="attribute|element">
1146 <xsl:if test="contains(@tokenid, 'ooxml:')">
1147 <xsl:text>
1148 case </xsl:text>
1149 <xsl:call-template name="idtoqname">
1150 <xsl:with-param name="id" select="@tokenid"/>
1151 </xsl:call-template>
1152 <xsl:text>:
1153 sResult = "</xsl:text>
1154 <xsl:value-of select="@token"/>
1155 <xsl:text>";
1156 break;</xsl:text>
1157 </xsl:if>
1158 </xsl:for-each>
1159 </xsl:for-each>
1160 <xsl:text>
1161 default:
1165 return sResult;
1166 }</xsl:text>
1167 </xsl:template>
1169 <xsl:key name="resources-with-kind" match="resource[.//kind]"
1170 use=".//kind/@name"/>
1172 <xsl:key name="sprms-with-code" match="element" use="@tokenid"/>
1174 <!--
1175 Generates case labels for mapping from token ids to a single kind
1176 of sprm.
1178 @param kind the sprm kind for which to generate the case labels
1180 <xsl:template name="sprmkindcase">
1181 <xsl:param name="kind"/>
1182 <xsl:for-each select="key('resources-with-kind', $kind)/element">
1183 <xsl:if test="generate-id(.) = generate-id(key('sprms-with-code', @tokenid))">
1184 <xsl:text>
1185 case </xsl:text>
1186 <xsl:call-template name="idtoqname">
1187 <xsl:with-param name="id" select="@tokenid"/>
1188 </xsl:call-template>
1189 <xsl:text>: //</xsl:text>
1190 <xsl:value-of select="ancestor::resource/@name"/>
1191 <xsl:text>, </xsl:text>
1192 <xsl:value-of select="@name"/>
1193 </xsl:if>
1194 </xsl:for-each>
1195 </xsl:template>
1197 <!--
1198 Generates SprmKind.
1200 <xsl:template name="sprmkind">
1201 <xsl:text>
1202 Sprm::Kind SprmKind(sal_uInt32 nSprmCode)
1204 Sprm::Kind nResult = Sprm::UNKNOWN;
1206 switch (nSprmCode)
1207 {</xsl:text>
1208 <xsl:call-template name="sprmkindcase">
1209 <xsl:with-param name="kind">paragraph</xsl:with-param>
1210 </xsl:call-template>
1211 <xsl:text>
1212 nResult = Sprm::PARAGRAPH;
1213 break;</xsl:text>
1214 <xsl:call-template name="sprmkindcase">
1215 <xsl:with-param name="kind">character</xsl:with-param>
1216 </xsl:call-template>
1217 <xsl:text>
1218 nResult = Sprm::CHARACTER;
1219 break;</xsl:text>
1220 <xsl:call-template name="sprmkindcase">
1221 <xsl:with-param name="kind">table</xsl:with-param>
1222 </xsl:call-template>
1223 <xsl:text>
1224 nResult = Sprm::TABLE;
1225 break;</xsl:text>
1226 <xsl:text>
1227 default:
1228 break;
1231 return nResult;
1232 }</xsl:text>
1233 </xsl:template>
1235 <!--
1236 Generates qname for id.
1238 @param id the id to generate qname for
1240 If id is of format <prefix>:<localname> the result is
1242 NS_<prefix>::LN_<localname>
1244 If id does not contain ":" the result is just id.
1246 <xsl:template name='idtoqname'>
1247 <xsl:param name='id'/>
1248 <xsl:choose>
1249 <xsl:when test="contains($id, ':')">
1250 <xsl:text>NS_</xsl:text>
1251 <xsl:value-of select='substring-before($id, ":")'/>
1252 <xsl:text>::LN_</xsl:text>
1253 <xsl:value-of select='substring-after($id, ":")'/>
1254 </xsl:when>
1255 <xsl:otherwise>
1256 <xsl:value-of select="$id"/>
1257 </xsl:otherwise>
1258 </xsl:choose>
1259 </xsl:template>
1261 <xsl:key name="same-token-name" match="rng:element|rng:attribute" use="@localname"/>
1263 <!--
1264 Generates input for gperf to genreate hash map for OOXMLFastTokenHandler
1266 <xsl:template name="gperfinputfasttokenhandler">
1267 <xsl:text>
1269 #include "OOXMLFastTokens.hxx"
1271 namespace writerfilter { namespace ooxml { namespace tokenmap {
1273 struct token { const char * name; Token_t nToken; };
1274 %%</xsl:text>
1275 <xsl:for-each select=".//rng:element|.//rng:attribute">
1276 <xsl:if test="generate-id(.) = generate-id(key('same-token-name', @localname)[1])">
1277 <xsl:text>&#xa;</xsl:text>
1278 <xsl:value-of select="@localname"/>
1279 <xsl:text>, </xsl:text>
1280 <xsl:call-template name="fastlocalname"/>
1281 </xsl:if>
1282 </xsl:for-each>
1283 <xsl:text>
1284 %%&#xa;</xsl:text>
1285 }}}&#xa;</xsl:template>
1287 <xsl:template name="namespaceid">
1288 <xsl:text>NS_</xsl:text>
1289 <xsl:value-of select="@alias"/>
1290 </xsl:template>
1292 <xsl:template name="namespaceids">
1293 <xsl:for-each select="//namespace-alias">
1294 <xsl:text>
1295 const sal_uInt32 </xsl:text>
1296 <xsl:call-template name="namespaceid"/>
1297 <xsl:text> = </xsl:text>
1298 <xsl:value-of select="@id"/>
1299 <xsl:text> &lt;&lt; 16;</xsl:text>
1300 </xsl:for-each>
1301 </xsl:template>
1303 <xsl:template name="fasttoken">
1304 <xsl:variable name="ns">
1305 <xsl:call-template name="fastnamespace"/>
1306 </xsl:variable>
1307 <xsl:if test="string-length($ns) > 0">
1308 <xsl:value-of select="$ns"/>
1309 <xsl:text>|</xsl:text>
1310 </xsl:if>
1311 <xsl:call-template name="fastlocalname"/>
1312 </xsl:template>
1314 <xsl:template name="fasttokenwithattr">
1315 <xsl:if test="local-name(.)='attribute'">
1316 <xsl:text>F_Attribute|</xsl:text>
1317 </xsl:if>
1318 <xsl:call-template name="fasttoken"/>
1319 </xsl:template>
1321 <xsl:template name="caselabelfasttoken">
1322 <xsl:text>case </xsl:text>
1323 <xsl:call-template name="fasttokenwithattr"/>
1324 <xsl:text>:</xsl:text>
1325 </xsl:template>
1327 <xsl:key name="elementsattrsbynamespace"
1328 match="rng:element[@name]|rng:attribute[@name]" use="ancestor::rng:grammar/@ns"/>
1330 <xsl:template name="fasttokentoid">
1331 <xsl:text>
1332 namespace tokenmap {
1333 struct token { const char * name; Token_t nToken; };
1334 class Perfect_Hash
1336 private:
1337 static inline unsigned int hash (const char *str, unsigned int len);
1338 public:
1339 static struct token *in_word_set (const char *str, unsigned int len);
1343 string fastTokenToId(sal_uInt32 nToken)
1345 </xsl:text>
1346 <xsl:text>
1347 string sResult;
1349 switch (nToken &amp; 0xffff0000)
1350 {</xsl:text>
1351 <xsl:for-each select="//namespace-alias">
1352 <xsl:text>
1353 case NS_</xsl:text>
1354 <xsl:value-of select="@alias"/>
1355 <xsl:text>:
1356 sResult += "</xsl:text>
1357 <xsl:value-of select="@alias"/>
1358 <xsl:text>:";
1359 break;</xsl:text>
1360 </xsl:for-each>
1361 <xsl:text>
1364 switch (nToken &amp; 0xffff)
1365 {</xsl:text>
1366 <xsl:for-each select=".//rng:element[@localname]|.//rng:attribute[@localname]">
1367 <xsl:variable name="localname" select="@localname"/>
1368 <xsl:if test="generate-id(.) = generate-id(key('same-token-name', $localname)[1])">
1369 <xsl:text>
1370 case </xsl:text>
1371 <xsl:call-template name="fastlocalname"/>
1372 <xsl:text>:
1373 sResult += "</xsl:text>
1374 <xsl:value-of select="$localname"/>
1375 <xsl:text>";
1376 break;</xsl:text>
1377 </xsl:if>
1378 </xsl:for-each>
1379 <xsl:text>
1382 return sResult;
1384 </xsl:text>
1385 </xsl:template>
1387 <xsl:template name="getfastparser">
1388 <xsl:text>
1389 uno::Reference &lt; xml::sax::XFastParser &gt; OOXMLStreamImpl::getFastParser()
1391 if (! mxFastParser.is())
1393 uno::Reference &lt; lang::XMultiComponentFactory &gt; xFactory =
1394 uno::Reference &lt; lang::XMultiComponentFactory &gt;
1395 (mxContext->getServiceManager());
1397 mxFastParser.set(xFactory->createInstanceWithContext
1398 ( ::rtl::OUString::createFromAscii
1399 ( "com.sun.star.xml.sax.FastParser" ),
1400 mxContext ), uno::UNO_QUERY_THROW);
1401 </xsl:text>
1402 <xsl:for-each select="//namespace-alias">
1403 <xsl:text>
1404 mxFastParser->registerNamespace(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("</xsl:text>
1405 <xsl:value-of select="@name"/>
1406 <xsl:text>")), </xsl:text>
1407 <xsl:call-template name="namespaceid"/>
1408 <xsl:text>);</xsl:text>
1409 </xsl:for-each>
1410 <xsl:text>
1413 return mxFastParser;
1415 </xsl:text>
1416 </xsl:template>
1418 <xsl:template name="searchdefinenamespace">
1419 <xsl:param name="name"/>
1420 <xsl:variable name="tmp">
1421 <xsl:for-each select="ancestor::namespace">
1422 <xsl:call-template name="searchdefinenamespacerec">
1423 <xsl:with-param name="name" select="$name"/>
1424 </xsl:call-template>
1425 </xsl:for-each>
1426 </xsl:variable>
1427 <xsl:choose>
1428 <xsl:when test="string-length($tmp) > 0">
1429 <xsl:value-of select="$tmp"/>
1430 </xsl:when>
1431 <xsl:otherwise>
1432 <xsl:for-each select="key('defines-with-name', $name)[1]">
1433 <xsl:value-of select="ancestor::namespace/@name"/>
1434 <xsl:text>:</xsl:text>
1435 <xsl:value-of select="@name"/>
1436 </xsl:for-each>
1437 </xsl:otherwise>
1438 </xsl:choose>
1439 </xsl:template>
1441 <xsl:template name="searchdefinenamespacerec">
1442 <xsl:param name="name"/>
1443 <xsl:variable name="nsname" select="@name"/>
1444 <xsl:variable name="nsid" select="generate-id(.)"/>
1445 <xsl:variable name="tmp">
1446 <xsl:for-each select="key('defines-with-name', $name)">
1447 <xsl:if test="generate-id(ancestor::namespace)=$nsid">
1448 <xsl:value-of select="$nsname"/>
1449 <xsl:text>:</xsl:text>
1450 <xsl:value-of select="$name"/>
1451 </xsl:if>
1452 </xsl:for-each>
1453 </xsl:variable>
1454 <xsl:choose>
1455 <xsl:when test="string-length($tmp) > 0">
1456 <xsl:value-of select="$tmp"/>
1457 </xsl:when>
1458 <xsl:otherwise>
1459 <xsl:for-each select="./rng:include">
1460 <xsl:for-each select="/model/namespace[@file=@href]">
1461 <xsl:call-template name="searchdefinenamespacerec">
1462 <xsl:with-param name="name" select="$name"/>
1463 </xsl:call-template>
1464 </xsl:for-each>
1465 </xsl:for-each>
1466 </xsl:otherwise>
1467 </xsl:choose>
1468 </xsl:template>
1470 <xsl:template name="fastattributescheckattr">
1471 <xsl:text>if (Attribs->hasAttribute(</xsl:text>
1472 <xsl:call-template name="fastlocalname"/>
1473 <xsl:text>))</xsl:text>
1474 </xsl:template>
1476 <xsl:template name="fastattributescheckattrwithns">
1477 <xsl:text>if (Attribs->hasAttribute(</xsl:text>
1478 <xsl:call-template name="fasttoken"/>
1479 <xsl:text>))</xsl:text>
1480 </xsl:template>
1482 <xsl:template name="fastcontextnameforattribute">
1483 <xsl:choose>
1484 <xsl:when test="./rng:ref">
1485 <xsl:for-each select="./rng:ref">
1486 <xsl:call-template name="valuenameforref"/>
1487 </xsl:for-each>
1488 </xsl:when>
1489 <xsl:when test="./rng:data/@type = 'boolean'">
1490 <xsl:text>OOXMLBooleanValue</xsl:text>
1491 </xsl:when>
1492 <xsl:when test="./rng:data/@type = 'unsignedInt'">
1493 <xsl:text>OOXMLIntegerValue</xsl:text>
1494 </xsl:when>
1495 <xsl:when test="./rng:text or ./rng:data/@type = 'string' or ./rng:data/@type = 'token'">
1496 <xsl:text>OOXMLStringValue</xsl:text>
1497 </xsl:when>
1498 </xsl:choose>
1499 </xsl:template>
1501 <xsl:template name="fastattributesproperties">
1502 <xsl:variable name="definename" select="@name"/>
1503 <xsl:for-each select=".//rng:attribute">
1504 <xsl:variable name="attrname" select="@name"/>
1505 <xsl:variable name="contextname">
1506 <xsl:call-template name="fastcontextnameforattribute"/>
1507 </xsl:variable>
1508 <xsl:variable name="attrid">
1509 <xsl:call-template name="idforattr"/>
1510 </xsl:variable>
1511 <xsl:if test="string-length($contextname) > 0 and string-length($attrid) > 0">
1512 <xsl:text>
1513 </xsl:text>
1514 <xsl:call-template name="fastattributescheckattrwithns"/>
1515 <xsl:text>
1517 ::rtl::OUString aValue(Attribs->getValue(</xsl:text>
1518 <xsl:call-template name="fasttoken"/>
1519 <xsl:text>));
1520 OOXMLFastHelper &lt; </xsl:text>
1521 <xsl:value-of select="$contextname"/>
1522 <xsl:text> &gt;::newProperty(this, </xsl:text>
1523 <xsl:value-of select="$attrid"/>
1524 <xsl:text>, aValue);</xsl:text>
1525 <xsl:for-each select="ancestor::namespace/resource[@name=$definename]">
1526 <xsl:for-each select="./attribute[@name=$attrname]">
1527 <xsl:choose>
1528 <xsl:when test="@action='checkId'">
1529 <xsl:text>
1530 checkId(aValue);</xsl:text>
1531 </xsl:when>
1532 <xsl:when test="@action='checkXNoteType'">
1533 </xsl:when>
1534 <xsl:when test="@action='setXNoteId'">
1535 <xsl:text>
1536 setXNoteId(aValue);</xsl:text>
1537 </xsl:when>
1538 </xsl:choose>
1539 </xsl:for-each>
1540 </xsl:for-each>
1541 <xsl:text>
1542 }</xsl:text>
1543 </xsl:if>
1544 </xsl:for-each>
1545 </xsl:template>
1547 <xsl:template name="fastattributesstringvalue">
1548 <xsl:for-each select=".//rng:attribute">
1549 <xsl:text>
1550 </xsl:text>
1551 <xsl:call-template name="fastattributescheckattrwithns"/>
1552 <xsl:text>
1553 msValue = Attribs->getValue(</xsl:text>
1554 <xsl:call-template name="fasttoken"/>
1555 <xsl:text>);</xsl:text>
1556 </xsl:for-each>
1557 </xsl:template>
1559 <xsl:template name="fastattributesintvalue">
1560 <xsl:for-each select=".//rng:attribute">
1561 <xsl:text>
1562 </xsl:text>
1563 <xsl:call-template name="fastattributescheckattrwithns"/>
1564 <xsl:text>
1565 mnValue = Attribs->getValue(</xsl:text>
1566 <xsl:call-template name="fasttoken"/>
1567 <xsl:text>).toInt32();</xsl:text>
1568 </xsl:for-each>
1569 </xsl:template>
1571 <xsl:template name="fastattributeshexvalue">
1572 <xsl:for-each select=".//rng:attribute">
1573 <xsl:text>
1574 </xsl:text>
1575 <xsl:call-template name="fastattributescheckattrwithns"/>
1576 <xsl:text>
1577 mnValue = Attribs->getValue(</xsl:text>
1578 <xsl:call-template name="fasttoken"/>
1579 <xsl:text>).toInt32(16);</xsl:text>
1580 </xsl:for-each>
1581 </xsl:template>
1583 <xsl:template name="fastattributesboolvalue">
1584 <xsl:for-each select=".//rng:attribute">
1585 <xsl:text>
1586 </xsl:text>
1587 <xsl:call-template name="fastattributescheckattrwithns"/>
1588 <xsl:text>
1589 setValue(Attribs->getValue(</xsl:text>
1590 <xsl:call-template name="fasttoken"/>
1591 <xsl:text>));</xsl:text>
1592 </xsl:for-each>
1593 </xsl:template>
1595 <xsl:template name="fastattributeslistvalue">
1596 <xsl:for-each select=".//rng:attribute">
1597 <xsl:variable name="myfasttoken">
1598 <xsl:call-template name="fastlocalname"/>
1599 </xsl:variable>
1600 <xsl:variable name="myfasttokenwithns">
1601 <xsl:call-template name="fasttoken"/>
1602 </xsl:variable>
1603 <xsl:variable name="bodywithns">
1604 <xsl:for-each select="rng:ref">
1605 <xsl:variable name="refname" select="@name"/>
1606 <xsl:variable name="refns">
1607 <xsl:call-template name="searchdefinenamespace">
1608 <xsl:with-param name="name" select="@name"/>
1609 </xsl:call-template>
1610 </xsl:variable>
1611 <xsl:variable name="valname">
1612 <xsl:for-each select="/model/namespace[@name=substring-before($refns, ':')]">
1613 <xsl:for-each select="./rng:grammar/rng:define[@name=substring-after($refns, ':')]">
1614 <xsl:call-template name="valuenamefordefine"/>
1615 </xsl:for-each>
1616 </xsl:for-each>
1617 </xsl:variable>
1618 <xsl:text>
1619 mpValue = OOXMLValue::Pointer_t (new </xsl:text>
1620 <xsl:value-of select="$valname"/>
1621 <xsl:text>(Attribs->getValue(</xsl:text>
1622 <xsl:value-of select="$myfasttokenwithns"/>
1623 <xsl:text>)));</xsl:text>
1624 </xsl:for-each>
1625 </xsl:variable>
1626 <xsl:if test="string-length($bodywithns) > 0">
1627 <xsl:text>
1628 </xsl:text>
1629 <xsl:call-template name="fastattributescheckattrwithns"/>
1630 <xsl:value-of select="$bodywithns"/>
1631 </xsl:if>
1632 </xsl:for-each>
1633 </xsl:template>
1635 <xsl:template name="fastattributebody">
1636 <xsl:variable name="resource">
1637 <xsl:call-template name="contextresource"/>
1638 </xsl:variable>
1639 <xsl:choose>
1640 <xsl:when test="$resource = 'Properties' or $resource = 'Stream' or $resource='XNote' or $resource='Shape'" >
1641 <xsl:call-template name="fastattributesproperties"/>
1642 </xsl:when>
1643 <xsl:when test="$resource = 'StringValue'">
1644 <xsl:call-template name="fastattributesstringvalue"/>
1645 </xsl:when>
1646 <xsl:when test="$resource = 'IntegerValue'">
1647 <xsl:call-template name="fastattributesintvalue"/>
1648 </xsl:when>
1649 <xsl:when test="$resource = 'HexValue'">
1650 <xsl:call-template name="fastattributeshexvalue"/>
1651 </xsl:when>
1652 <xsl:when test="$resource = 'BooleanValue'">
1653 <xsl:call-template name="fastattributesboolvalue"/>
1654 </xsl:when>
1655 <xsl:when test="$resource = 'ListValue'">
1656 <xsl:call-template name="fastattributeslistvalue"/>
1657 </xsl:when>
1658 </xsl:choose>
1659 </xsl:template>
1661 <xsl:template name="valuenameforref">
1662 <xsl:variable name="definename">
1663 <xsl:call-template name="searchdefinenamespace">
1664 <xsl:with-param name="name" select="@name"/>
1665 </xsl:call-template>
1666 </xsl:variable>
1667 <xsl:for-each select="/model/namespace[@name=substring-before($definename, ':')]">
1668 <xsl:for-each select="./rng:grammar/rng:define[@name=substring-after($definename, ':')]">
1669 <xsl:call-template name="valuenamefordefine"/>
1670 </xsl:for-each>
1671 </xsl:for-each>
1672 </xsl:template>
1674 <xsl:template name="fastcontextnameforref">
1675 <xsl:variable name="definename">
1676 <xsl:call-template name="searchdefinenamespace">
1677 <xsl:with-param name="name" select="@name"/>
1678 </xsl:call-template>
1679 </xsl:variable>
1680 <!--
1681 <xsl:text>/* </xsl:text>
1682 <xsl:value-of select="@name"/>
1683 <xsl:text>, </xsl:text>
1684 <xsl:value-of select="$definename"/>
1685 <xsl:text> */</xsl:text>
1687 <xsl:for-each select="/model/namespace[@name=substring-before($definename, ':')]">
1688 <xsl:for-each select="./rng:grammar/rng:define[@name=substring-after($definename, ':')]">
1689 <xsl:call-template name="fastcontextname"/>
1690 </xsl:for-each>
1691 </xsl:for-each>
1692 </xsl:template>
1694 <xsl:template name="fastattributebodyrefs">
1695 <xsl:for-each select=".//rng:ref[not(ancestor::rng:element or ancestor::rng:attribute)]">
1696 <xsl:variable name="contextname">
1697 <xsl:call-template name="fastcontextnameforref"/>
1698 </xsl:variable>
1699 <xsl:if test="string-length($contextname) > 0">
1700 <xsl:text>
1701 OOXMLFastHelper &lt;</xsl:text>
1702 <xsl:value-of select="$contextname"/>
1703 <xsl:text>&gt;::attributes(this, Attribs);</xsl:text>
1704 </xsl:if>
1705 </xsl:for-each>
1706 </xsl:template>
1708 <!--
1709 Generates definition of method attributes for current <define>
1711 <xsl:template name="fastattribute">
1712 <xsl:variable name="resource">
1713 <xsl:call-template name="contextresource"/>
1714 </xsl:variable>
1715 <!--<xsl:if test="not($resource='Shape')"> -->
1716 <xsl:variable name="body">
1717 <xsl:call-template name="fastattributebody"/>
1718 </xsl:variable>
1719 <xsl:variable name="bodyrefs">
1720 <xsl:call-template name="fastattributebodyrefs"/>
1721 </xsl:variable>
1722 <xsl:if test="string-length($body) > 0 or string-length($bodyrefs) > 0">
1723 <xsl:text>
1724 void </xsl:text>
1725 <xsl:call-template name="fastcontextname"/>
1726 <xsl:text>::attributes
1727 (const uno::Reference &lt; xml::sax::XFastAttributeList &gt; &amp; Attribs)
1728 throw (uno::RuntimeException, xml::sax::SAXException)
1730 #ifdef DEBUG_DUMP_ATTRIBUTES
1731 dumpAttribs(Attribs);
1732 #endif
1733 </xsl:text>
1734 <xsl:value-of select="$body"/>
1735 <xsl:value-of select="$bodyrefs"/>
1736 <xsl:text>
1738 </xsl:text>
1739 </xsl:if>
1740 <!-- </xsl:if> -->
1741 </xsl:template>
1743 <xsl:template name="fastelementcreatestatement">
1744 <xsl:for-each select=".//rng:ref">
1745 <xsl:choose>
1746 <xsl:when test="@name='BUILT_IN_ANY_TYPE'">
1747 <xsl:text>createFromStart(Element, Attribs)</xsl:text>
1748 </xsl:when>
1749 <xsl:otherwise>
1750 <xsl:variable name="classname">
1751 <xsl:call-template name="fastcontextname"/>
1752 </xsl:variable>
1753 <xsl:if test="string-length($classname) > 0">
1754 <xsl:text>OOXMLFastHelper &lt;</xsl:text>
1755 <xsl:value-of select="$classname"/>
1756 <xsl:text>&gt;::createAndSetParent(this, Element, </xsl:text>
1757 <xsl:for-each select="ancestor::rng:element">
1758 <xsl:variable name="id">
1759 <xsl:call-template name="idforelement"/>
1760 </xsl:variable>
1761 <xsl:choose>
1762 <xsl:when test="string-length($id) > 0">
1763 <xsl:value-of select="$id"/>
1764 </xsl:when>
1765 <xsl:otherwise>
1766 <xsl:text>0</xsl:text>
1767 </xsl:otherwise>
1768 </xsl:choose>
1769 </xsl:for-each>
1770 <xsl:text>)</xsl:text>
1771 </xsl:if>
1772 </xsl:otherwise>
1773 </xsl:choose>
1774 </xsl:for-each>
1775 </xsl:template>
1777 <!--
1778 Generates name for parent class of fast context.
1780 <xsl:template name="fastresourceclass">
1781 <xsl:text>OOXMLFastContextHandler</xsl:text>
1782 <xsl:call-template name="contextresource"/>
1783 </xsl:template>
1785 <!--
1786 Generates the declaration of the fast context for the current <define>
1788 <xsl:template name="fastcontextdecl">
1789 <xsl:variable name="classname">
1790 <xsl:call-template name="fastcontextname"/>
1791 </xsl:variable>
1792 <xsl:text>
1793 class WRITERFILTER_DLLPRIVATE </xsl:text>
1794 <xsl:value-of select="$classname"/>
1795 <xsl:text>: public </xsl:text>
1796 <xsl:call-template name="fastresourceclass"/>
1797 <xsl:text>
1799 public:
1800 explicit </xsl:text>
1801 <xsl:value-of select="$classname"/>
1802 <xsl:text>
1803 (OOXMLFastContextHandler * context);
1804 virtual ~</xsl:text>
1805 <xsl:value-of select="$classname"/>
1806 <xsl:text>();
1807 </xsl:text>
1808 <xsl:variable name="createchildcontextbody">
1809 <xsl:call-template name="createfastchildcontext"/>
1810 </xsl:variable>
1811 <xsl:if test="string-length($createchildcontextbody) > 0">
1812 virtual uno::Reference &lt; xml::sax::XFastContextHandler &gt;
1813 lcl_createFastChildContext
1814 (::sal_Int32 Element,
1815 const uno::Reference &lt; xml::sax::XFastAttributeList &gt; &amp; Attribs)
1816 throw (uno::RuntimeException, xml::sax::SAXException);
1817 </xsl:if>
1818 <xsl:variable name="fastattributebody">
1819 <xsl:call-template name="fastattribute"/>
1820 </xsl:variable>
1821 <xsl:if test="string-length($fastattributebody) > 0">
1822 virtual void attributes
1823 (const uno::Reference &lt; xml::sax::XFastAttributeList &gt; &amp; Attribs)
1824 throw (uno::RuntimeException, xml::sax::SAXException);
1825 </xsl:if>
1826 <xsl:variable name="faststartactionbody">
1827 <xsl:call-template name="faststartaction"/>
1828 </xsl:variable>
1829 <xsl:if test="string-length($faststartactionbody)">
1830 virtual void lcl_startAction(Token_t nElement);
1831 </xsl:if>
1832 <xsl:variable name="fastendactionbody">
1833 <xsl:call-template name="fastendaction"/>
1834 </xsl:variable>
1835 <xsl:if test="string-length($fastendactionbody)">
1836 virtual void lcl_endAction(Token_t nElement);
1837 </xsl:if>
1838 <xsl:variable name="fastcharactersbody">
1839 <xsl:call-template name="fastcharacters"/>
1840 </xsl:variable>
1841 <xsl:if test="string-length($fastcharactersbody)">
1842 virtual void lcl_characters(const ::rtl::OUString &amp; aChars)
1843 throw (uno::RuntimeException, xml::sax::SAXException);
1844 </xsl:if>
1845 <xsl:text>
1846 virtual string getType() const { return "</xsl:text>
1847 <xsl:value-of select="$classname"/>
1848 <xsl:text>"; }</xsl:text>
1849 <xsl:variable name="propagatespropsbody">
1850 <xsl:call-template name="propagatesproperties"/>
1851 </xsl:variable>
1852 <xsl:if test="string-length($propagatespropsbody)">
1853 <xsl:text>
1854 virtual bool propagatesProperties() const;</xsl:text>
1855 </xsl:if>
1856 <xsl:text>
1858 </xsl:text>
1859 </xsl:template>
1861 <xsl:template name="fastcontextdecls">
1862 <xsl:param name="namespace"/>
1863 <xsl:for-each select="/model/namespace[@name=$namespace]">
1864 <xsl:for-each select="./rng:grammar/rng:define">
1865 <xsl:variable name="do">
1866 <xsl:call-template name="classfordefine"/>
1867 </xsl:variable>
1868 <xsl:text>
1870 </xsl:text>
1871 <xsl:value-of select="ancestor::namespace/@name"/>
1872 <xsl:text>:</xsl:text>
1873 <xsl:value-of select="@name"/>
1874 <xsl:text>
1875 */</xsl:text>
1876 <xsl:if test="$do = '1'">
1877 <xsl:call-template name="fastcontextdecl"/>
1878 </xsl:if>
1879 </xsl:for-each>
1880 </xsl:for-each>
1881 </xsl:template>
1883 <xsl:template name="fastcontextconstructor">
1884 <xsl:variable name="classname">
1885 <xsl:call-template name="fastcontextname"/>
1886 </xsl:variable>
1887 <xsl:value-of select="$classname"/>
1888 <xsl:text>::</xsl:text>
1889 <xsl:value-of select="$classname"/>
1890 <xsl:text>
1891 (OOXMLFastContextHandler * pContext)
1892 : </xsl:text>
1893 <xsl:call-template name="fastresourceclass"/>
1894 <xsl:text>(pContext)
1896 </xsl:text>
1897 </xsl:template>
1899 <xsl:template name="fastcontextdestructor">
1900 <xsl:variable name="classname">
1901 <xsl:call-template name="fastcontextname"/>
1902 </xsl:variable>
1903 <xsl:value-of select="$classname"/>
1904 <xsl:text>::~</xsl:text>
1905 <xsl:value-of select="$classname"/>
1906 <xsl:text>
1909 </xsl:text>
1910 </xsl:template>
1912 <xsl:template name="faststartactionbodysetid">
1913 <xsl:if test="@resource = 'Table' or @resource='PropertyTable'">
1914 <xsl:text>
1915 setId(</xsl:text>
1916 <xsl:call-template name="idtoqname">
1917 <xsl:with-param name="id" select="@tokenid"/>
1918 </xsl:call-template>
1919 <xsl:text>);</xsl:text>
1920 </xsl:if>
1921 </xsl:template>
1923 <xsl:template name="faststartactionbodychooseaction">
1924 <xsl:for-each select="./action[@name='start']">
1925 <xsl:call-template name="chooseaction"/>
1926 </xsl:for-each>
1927 </xsl:template>
1929 <xsl:template name="faststartactionbody">
1930 <xsl:variable name="name" select="@name"/>
1931 <xsl:for-each select="ancestor::namespace/resource[@name = $name]">
1932 <xsl:call-template name="faststartactionbodysetid"/>
1933 <xsl:call-template name="faststartactionbodychooseaction"/>
1934 </xsl:for-each>
1935 </xsl:template>
1937 <xsl:template name="faststartaction">
1938 <xsl:variable name="body">
1939 <xsl:call-template name="faststartactionbody"/>
1940 </xsl:variable>
1941 <xsl:variable name="name" select="@name"/>
1942 <xsl:if test="string-length($body) > 0">
1943 <xsl:variable name="classname">
1944 <xsl:call-template name="fastcontextname"/>
1945 </xsl:variable>
1946 <xsl:text>
1947 void </xsl:text>
1948 <xsl:value-of select="$classname"/>
1949 <xsl:text>::lcl_startAction(Token_t</xsl:text>
1950 <xsl:for-each select="ancestor::namespace/resource[@name=$name]">
1951 <xsl:if test="./element/action[@name='start']">
1952 <xsl_text> nElement</xsl_text>
1953 </xsl:if>
1954 </xsl:for-each>
1955 <xsl:text>)
1956 {</xsl:text>
1957 <xsl:value-of select="$body"/>
1958 <xsl:text>
1960 </xsl:text>
1961 </xsl:if>
1962 </xsl:template>
1964 <xsl:template name="fastendactionbody">
1965 <xsl:variable name="name" select="@name"/>
1966 <xsl:for-each select="ancestor::namespace/resource[@name = $name]">
1967 <xsl:for-each select="./action[@name='end']">
1968 <xsl:call-template name="chooseaction"/>
1969 </xsl:for-each>
1970 </xsl:for-each>
1971 </xsl:template>
1973 <xsl:template name="fastendaction">
1974 <xsl:variable name="body">
1975 <xsl:call-template name="fastendactionbody"/>
1976 </xsl:variable>
1977 <xsl:variable name="name" select="@name"/>
1978 <xsl:if test="string-length($body) > 0">
1979 <xsl:variable name="classname">
1980 <xsl:call-template name="fastcontextname"/>
1981 </xsl:variable>
1982 <xsl:text>
1983 void </xsl:text>
1984 <xsl:value-of select="$classname"/>
1985 <xsl:text>::lcl_endAction(Token_t</xsl:text>
1986 <xsl:for-each select="ancestor::namespace/resource[@name=$name]">
1987 <xsl:if test="./element/action[@name='end']">
1988 <xsl_text> nElement</xsl_text>
1989 </xsl:if>
1990 </xsl:for-each>
1991 <xsl:text>)
1992 {</xsl:text>
1993 <xsl:value-of select="$body"/>
1994 <xsl:text>
1996 </xsl:text>
1997 </xsl:if>
1998 </xsl:template>
2000 <xsl:template name="fastcharactersbody">
2001 <xsl:variable name="name" select="@name"/>
2002 <xsl:for-each select="ancestor::namespace/resource[@name = $name]//action[@name='characters']">
2003 <xsl:call-template name="chooseaction"/>
2004 </xsl:for-each>
2005 </xsl:template>
2007 <xsl:template name="fastcharacters">
2008 <xsl:variable name="body">
2009 <xsl:call-template name="fastcharactersbody"/>
2010 </xsl:variable>
2011 <xsl:if test="string-length($body) > 0">
2012 <xsl:variable name="classname">
2013 <xsl:call-template name="fastcontextname"/>
2014 </xsl:variable>
2015 <xsl:text>
2016 void </xsl:text>
2017 <xsl:value-of select="$classname"/>
2018 <xsl:text>::lcl_characters(const ::rtl::OUString &amp; sText)
2019 throw (uno::RuntimeException, xml::sax::SAXException)
2020 {</xsl:text>
2021 <xsl:value-of select="$body"/>
2022 <xsl:text>
2024 </xsl:text>
2025 </xsl:if>
2026 </xsl:template>
2028 <xsl:template name="propagatespropertiesbody">
2029 <xsl:variable name="name" select="@name"/>
2030 <xsl:for-each select="ancestor::namespace/resource[@name=$name]">
2031 <xsl:for-each select=".//action">
2032 <xsl:choose>
2033 <xsl:when test="@name='propagateCharacterProperties'">
2034 <xsl:text>
2035 return true;</xsl:text>
2036 </xsl:when>
2037 <xsl:when test="@name='propagateTableProperties'">
2038 <xsl:text>
2039 return true;</xsl:text>
2040 </xsl:when>
2041 </xsl:choose>
2042 </xsl:for-each>
2043 </xsl:for-each>
2044 </xsl:template>
2046 <xsl:template name="propagatesproperties">
2047 <xsl:variable name="body">
2048 <xsl:call-template name="propagatespropertiesbody"/>
2049 </xsl:variable>
2050 <xsl:if test="string-length($body) > 0">
2051 <xsl:variable name="classname">
2052 <xsl:call-template name="fastcontextname"/>
2053 </xsl:variable>
2054 <xsl:text>
2055 bool </xsl:text>
2056 <xsl:value-of select="$classname"/>
2057 <xsl:text>::propagatesProperties() const
2058 {</xsl:text>
2059 <xsl:value-of select="$body"/>
2060 <xsl:text>
2062 </xsl:text>
2063 </xsl:if>
2064 </xsl:template>
2066 <xsl:template name="fastcontextcreatefromstart">
2067 <xsl:text>
2068 uno::Reference &lt; xml::sax::XFastContextHandler &gt;
2069 OOXMLFastContextHandler::createFromStart
2070 (::sal_Int32 Element,
2071 const uno::Reference &lt; xml::sax::XFastAttributeList &gt; &amp; Attribs)
2073 #ifdef DEBUG_CREATE
2074 debug_logger-&gt;startElement("createfromstart");
2075 debug_logger-&gt;attribute("element", fastTokenToId(Element));
2076 #endif
2077 uno::Reference &lt; xml::sax::XFastContextHandler &gt; xResult;</xsl:text>
2079 <xsl:for-each select="//namespace/start">
2080 <xsl:variable name="name" select="@name"/>
2081 <xsl:for-each select="ancestor::namespace/rng:grammar/rng:define[@name=$name]">
2082 <xsl:text>
2083 if (! xResult.is() || dynamic_cast&lt;OOXMLFastContextHandler *&gt;(xResult.get())->isFallback())
2085 xResult = OOXMLFastHelper &lt; </xsl:text>
2086 <xsl:call-template name="fastcontextname"/>
2087 <xsl:text> &gt;::createAndSetParentRef(this, Element, Attribs);
2088 }</xsl:text>
2089 </xsl:for-each>
2090 </xsl:for-each>
2091 <xsl:text>
2093 #ifdef DEBUG_CREATE
2094 debug_logger-&gt;endElement("createfromstart");
2095 #endif
2097 return xResult;
2099 </xsl:text>
2100 </xsl:template>
2102 <xsl:key name="attribs-qnames" match="rng:attribute" use="@qname"/>
2104 <xsl:template name="dumpattribs">
2105 <xsl:text>
2106 void dumpAttrib(const char * sToken, sal_uInt32 nToken,
2107 const uno::Reference &lt; xml::sax::XFastAttributeList
2108 &gt; &amp; Attribs)
2112 if (Attribs->hasAttribute(nToken))
2114 debug_logger-&gt;startElement("attrib");
2115 debug_logger-&gt;attribute("id", sToken);
2116 debug_logger-&gt;chars(Attribs->getValue(nToken));
2117 debug_logger-&gt;endElement("attrib");
2120 catch (...)
2122 debug_logger-&gt;startElement("error");
2123 debug_logger-&gt;chars(sToken);
2124 debug_logger-&gt;endElement("error");
2128 void dumpAttribs
2129 (const uno::Reference &lt; xml::sax::XFastAttributeList &gt; &amp; Attribs)
2130 throw (uno::RuntimeException, xml::sax::SAXException)
2132 debug_logger-&gt;startElement("attribs");
2133 </xsl:text>
2134 <xsl:for-each select="//rng:attribute[@name]">
2135 <xsl:if test="generate-id(.) = generate-id(key('attribs-qnames', @qname)[1]
2137 <xsl:text>
2138 dumpAttrib("</xsl:text>
2139 <xsl:call-template name="fastlocalname"/>
2140 <xsl:text>", </xsl:text>
2141 <xsl:call-template name="fastlocalname"/>
2142 <xsl:text>, Attribs);</xsl:text>
2143 <xsl:text>
2144 dumpAttrib("</xsl:text>
2145 <xsl:call-template name="fasttoken"/>
2146 <xsl:text>", </xsl:text>
2147 <xsl:call-template name="fasttoken"/>
2148 <xsl:text>, Attribs);</xsl:text>
2149 </xsl:if>
2150 </xsl:for-each>
2151 <xsl:text>
2152 debug_logger-&gt;endElement("attribs");
2153 }</xsl:text>
2154 </xsl:template>
2156 <xsl:template name="createfastchildcontextname">
2157 <xsl:text>createFastContextHandler_</xsl:text>
2158 <xsl:value-of select="@name"/>
2159 </xsl:template>
2161 <xsl:template name="caselabeldefine">
2162 <xsl:text>case CLASS_</xsl:text>
2163 <xsl:value-of select="translate(ancestor::namespace/@name, '-', '_')"/>
2164 <xsl:text>_</xsl:text>
2165 <xsl:value-of select="@name"/>
2166 <xsl:text>:</xsl:text>
2167 </xsl:template>
2169 <xsl:template name="createfastchildcontextswitchbodyref">
2170 <xsl:variable name="definename">
2171 <xsl:call-template name="searchdefinenamespace">
2172 <xsl:with-param name="name" select="@name"/>
2173 </xsl:call-template>
2174 </xsl:variable>
2175 <xsl:for-each select="/model/namespace[@name=substring-before($definename, ':')]">
2176 <xsl:for-each select="./rng:grammar/rng:define[@name=substring-after($definename, ':')]">
2177 <xsl:call-template name="createfastchildcontextswitchbody"/>
2178 </xsl:for-each>
2179 </xsl:for-each>
2180 </xsl:template>
2182 <xsl:template name="createfastchildcontextswitchbody">
2183 <xsl:for-each select=".//rng:element">
2184 <xsl:text>
2185 </xsl:text>
2186 <xsl:call-template name="caselabelfasttoken"/>
2187 <xsl:text>
2188 xResult.set(</xsl:text>
2189 <xsl:call-template name="fastelementcreatestatement"/>
2190 <xsl:text>);
2191 break;</xsl:text>
2192 </xsl:for-each>
2193 <xsl:for-each
2194 select=".//rng:ref[not(ancestor::rng:element or ancestor::rng:attribute)]">
2195 <xsl:call-template name="createfastchildcontextswitchbodyref"/>
2196 </xsl:for-each>
2197 </xsl:template>
2199 <xsl:template name="createfastchildcontextswitch">
2200 <xsl:variable name="body">
2201 <xsl:call-template name="createfastchildcontextswitchbody"/>
2202 </xsl:variable>
2203 <xsl:if test="string-length($body) > 0">
2204 <xsl:text>
2205 switch(Element)
2206 {</xsl:text>
2207 <xsl:value-of select="$body"/>
2208 <xsl:text>
2209 default:
2211 }</xsl:text>
2212 </xsl:if>
2213 </xsl:template>
2215 <xsl:template name="createfastchildcontextlookup">
2216 <xsl:text>
2217 uno::Reference&lt;XFastContextHandler&gt; </xsl:text>
2218 <xsl:call-template name="createfastchildcontextname"/>
2219 <xsl:text>(Id parent, Token_t Element)
2221 uno::Reference&lt;XFastContextHandler&gt; xResult;
2222 switch (parent)
2223 {</xsl:text>
2224 <xsl:for-each select="./rng:grammar/rng:define">
2225 <xsl:variable name="do">
2226 <xsl:call-template name="classfordefine"/>
2227 </xsl:variable>
2228 <xsl:if test="$do='1'">
2229 <xsl:variable name="casebody">
2230 <xsl:call-template name="createfastchildcontextswitch"/>
2231 </xsl:variable>
2232 <xsl:if test="string-length($casebody) > 0">
2233 <xsl:text>
2234 </xsl:text>
2235 <xsl:call-template name="caselabeldefine"/>
2236 <xsl:value-of select="$casebody"/>
2237 <xsl:text>
2238 break;</xsl:text>
2239 </xsl:if>
2240 </xsl:if>
2241 </xsl:for-each>
2242 <xsl:text>
2243 default:
2247 return xResult;
2249 </xsl:text>
2250 </xsl:template>
2252 </xsl:stylesheet>