1<!--*********************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 ***********************************************************--> 21<xsl:stylesheet 22 version="1.0" 23 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 24 xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 25 xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 26 xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 27 xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 28 xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 29 xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 30 xmlns:xlink="http://www.w3.org/1999/xlink" 31 xmlns:dc="http://purl.org/dc/elements/1.1/" 32 xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" 33 xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 34 xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 35 xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 36 xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 37 xmlns:math="http://www.w3.org/1998/Math/MathML" 38 xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 39 xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 40 xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 41 xmlns:ooo="http://openoffice.org/2004/office" 42 xmlns:ooow="http://openoffice.org/2004/writer" 43 xmlns:oooc="http://openoffice.org/2004/calc" 44 xmlns:dom="http://www.w3.org/2001/xml-events" 45 xmlns:xforms="http://www.w3.org/2002/xforms" 46 xmlns:xsd="http://www.w3.org/2001/XMLSchema" 47 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 48 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 49 xmlns:rng="http://relaxng.org/ns/structure/1.0" 50 xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" 51 xmlns:UML = 'org.omg.xmi.namespace.UML' xml:space="default"> 52 <xsl:output method="text" /> 53 <xsl:param name="prefix"/> 54 55 <xsl:include href="factorytools.xsl"/> 56 57<xsl:template name="factorymutex"> 58 <xsl:call-template name="factoryclassname"/> 59 <xsl:text>_Mutex</xsl:text> 60</xsl:template> 61 62<xsl:template name="factorymutexdecl"> 63 <xsl:variable name="classname"> 64 <xsl:call-template name="factoryclassname"/> 65 </xsl:variable> 66 <xsl:text> 67typedef rtl::Static < osl::Mutex, </xsl:text> 68 <xsl:value-of select="$classname"/> 69 <xsl:text> > </xsl:text> 70 <xsl:value-of select="$classname"/> 71 <xsl:text>_Mutex; 72</xsl:text> 73</xsl:template> 74 75<xsl:template name="factoryconstructor"> 76 <xsl:variable name="classname"> 77 <xsl:call-template name="factoryclassname"/> 78 </xsl:variable> 79 <xsl:text> 80</xsl:text> 81 <xsl:value-of select="$classname"/> 82 <xsl:text>::</xsl:text> 83 <xsl:value-of select="$classname"/> 84 <xsl:text>() 85{ 86 // multi-thread-safe mutex for all platforms 87 88 osl::MutexGuard aGuard(</xsl:text> 89 <xsl:call-template name="factorymutex"/> 90 <xsl:text>::get()); 91} 92</xsl:text> 93</xsl:template> 94 95<xsl:template name="factorydestructor"> 96 <xsl:variable name="classname"> 97 <xsl:call-template name="factoryclassname"/> 98 </xsl:variable> 99 <xsl:text> 100</xsl:text> 101 <xsl:value-of select="$classname"/> 102 <xsl:text>::~</xsl:text> 103 <xsl:value-of select="$classname"/> 104 <xsl:text>() 105{ 106} 107</xsl:text> 108</xsl:template> 109 110<xsl:template name="factorygetinstance"> 111 <xsl:variable name="classname"> 112 <xsl:call-template name="factoryclassname"/> 113 </xsl:variable> 114 <xsl:text> 115OOXMLFactory_ns::Pointer_t </xsl:text> 116 <xsl:value-of select="$classname"/> 117 <xsl:text>::m_pInstance; 118 119OOXMLFactory_ns::Pointer_t </xsl:text> 120 <xsl:value-of select="$classname"/> 121 <xsl:text>::getInstance() 122{ 123 if (m_pInstance.get() == NULL) 124 m_pInstance.reset(new </xsl:text> 125 <xsl:value-of select="$classname"/> 126 <xsl:text>()); 127 128 return m_pInstance; 129} 130</xsl:text> 131</xsl:template> 132 133<!-- 134 Returns resource for attribute. 135--> 136 137<xsl:template name="resourceforattribute"> 138 <xsl:variable name="mynsid" select="generate-id(ancestor::namespace)"/> 139 <xsl:for-each select="rng:ref"> 140 <xsl:variable name="name" select="@name"/> 141 <xsl:variable name="resource1"> 142 <xsl:for-each select="key('context-resource', @name)[generate-id(ancestor::namespace) = $mynsid]"> 143 <xsl:value-of select="@resource"/> 144 </xsl:for-each> 145 </xsl:variable> 146 <xsl:choose> 147 <xsl:when test="string-length($resource1) > 0"> 148 <xsl:value-of select="$resource1"/> 149 </xsl:when> 150 <xsl:otherwise> 151 <xsl:for-each select="ancestor::namespace/rng:grammar/rng:define[@name=$name]"> 152 <xsl:call-template name="resourceforattribute"/> 153 </xsl:for-each> 154 </xsl:otherwise> 155 </xsl:choose> 156 </xsl:for-each> 157 <xsl:for-each select=".//rng:text"> 158 <xsl:text>String</xsl:text> 159 </xsl:for-each> 160 <xsl:for-each select=".//rng:data[@type='base64Binary']"> 161 <xsl:text>String</xsl:text> 162 </xsl:for-each> 163 <xsl:for-each select=".//rng:data[@type='boolean']"> 164 <xsl:text>Boolean</xsl:text> 165 </xsl:for-each> 166 <xsl:for-each select=".//rng:data[@type='unsignedInt']"> 167 <xsl:text>Integer</xsl:text> 168 </xsl:for-each> 169 <xsl:for-each select=".//rng:data[@type='int']"> 170 <xsl:text>Integer</xsl:text> 171 </xsl:for-each> 172</xsl:template> 173 174<!-- 175 176creates code block in OOXMLFactory_<namespace>::createAttributeToResourceMap 177for a rng:define 178 179 --> 180<xsl:template name="factoryattributetoresourcemapinner"> 181 <xsl:variable name="defname" select="@name"/> 182 <xsl:for-each select=".//rng:ref[not(ancestor::rng:element or ancestor::rng:attribute)]"> 183 <xsl:variable name="name" select="@name"/> 184 <xsl:for-each select="ancestor::namespace/rng:grammar/rng:define[@name=$name]"> 185 <xsl:call-template name="factoryattributetoresourcemapinner"/> 186 </xsl:for-each> 187 </xsl:for-each> 188 189 <xsl:for-each select=".//rng:attribute"> 190 <xsl:if test="position()=1"> 191 <xsl:text> 192 // </xsl:text> 193 <xsl:value-of select="$defname"/> 194 </xsl:if> 195 <xsl:variable name="resource"> 196 <xsl:call-template name="resourceforattribute"/> 197 </xsl:variable> 198 199 <xsl:choose> 200 <xsl:when test="string-length($resource) > 0"> 201 <xsl:variable name="refdefine1"> 202 <xsl:for-each select="rng:ref"> 203 <xsl:variable name="refname" select="@name"/> 204 <xsl:for-each select="ancestor::rng:grammar/rng:define[@name=$refname]"> 205 <xsl:call-template name="idfordefine"/> 206 </xsl:for-each> 207 </xsl:for-each> 208 </xsl:variable> 209 <xsl:variable name="refdefine"> 210 <xsl:choose> 211 <xsl:when test="string-length($refdefine1) > 0"> 212 <xsl:value-of select="$refdefine1"/> 213 </xsl:when> 214 <xsl:otherwise> 215 <xsl:text>0</xsl:text> 216 </xsl:otherwise> 217 </xsl:choose> 218 </xsl:variable> 219 <xsl:text> 220 (*pMap)[</xsl:text> 221 <xsl:call-template name="fasttoken"/> 222 <xsl:text>] = AttributeInfo(RT_</xsl:text> 223 <xsl:value-of select="$resource"/> 224 <xsl:text>, </xsl:text> 225 <xsl:value-of select="$refdefine"/> 226 <xsl:text>);</xsl:text> 227 </xsl:when> 228 <xsl:otherwise> 229 <xsl:text> 230 // empty resource: </xsl:text> 231 <xsl:call-template name="fasttoken"/> 232 </xsl:otherwise> 233 </xsl:choose> 234 235 </xsl:for-each> 236</xsl:template> 237 238<!-- factoryattributetoresourcemap --> 239<xsl:template name="factoryattributetoresourcemap"> 240 <xsl:text> 241AttributeToResourceMapPointer </xsl:text> 242 <xsl:call-template name="factoryclassname"/> 243 <xsl:text>::createAttributeToResourceMap(Id nId) 244{ 245 AttributeToResourceMapPointer pMap(new AttributeToResourceMap()); 246 247 switch (nId) 248 {</xsl:text> 249 <xsl:for-each select="rng:grammar/rng:define"> 250 <xsl:variable name="inner"> 251 <xsl:call-template name="factoryattributetoresourcemapinner"/> 252 </xsl:variable> 253 <xsl:if test="string-length($inner) > 0"> 254 <xsl:text> 255 </xsl:text> 256 <xsl:call-template name="caselabeldefine"/> 257 <xsl:value-of select="$inner"/> 258 <xsl:text> 259 break;</xsl:text> 260 </xsl:if> 261 </xsl:for-each> 262 default: 263 break; 264 } 265 266 return pMap; 267} 268</xsl:template> 269 270<!-- factorylistvaluemap --> 271<xsl:template name="factorylistvaluemap"> 272 <xsl:text> 273ListValueMapPointer </xsl:text> 274 <xsl:call-template name="factoryclassname"/> 275 <xsl:text>::createListValueMap(Id nId) 276{ 277 ListValueMapPointer pMap(new ListValueMap()); 278 279 switch (nId) 280 {</xsl:text> 281 <xsl:for-each select="resource[@resource='List']"> 282 <xsl:text> 283 </xsl:text> 284 <xsl:call-template name="caselabeldefine"/> 285 <xsl:for-each select="value"> 286 <xsl:text> 287 (*pMap)[</xsl:text> 288 <xsl:call-template name="valuestringname"> 289 <xsl:with-param name="string" select="text()"/> 290 </xsl:call-template> 291 <xsl:text>] = </xsl:text> 292 <xsl:call-template name="idtoqname"> 293 <xsl:with-param name="id" select="@tokenid"/> 294 </xsl:call-template> 295 <xsl:text>;</xsl:text> 296 </xsl:for-each> 297 <xsl:text> 298 break;</xsl:text> 299 </xsl:for-each> 300 <xsl:text> 301 default: 302 break; 303 } 304 305 return pMap; 306}</xsl:text> 307</xsl:template> 308 309<!-- factoryelementtoresorucemapinner --> 310<xsl:template name="factorycreateelementmapinner"> 311 <xsl:for-each select=".//rng:ref[not(ancestor::rng:element or ancestor::rng:attribute)]"> 312 <xsl:variable name="name" select="@name"/> 313 <xsl:variable name="block"> 314 <xsl:for-each select="ancestor::namespace/rng:grammar/rng:define[@name=$name]"> 315 <xsl:call-template name="factorycreateelementmapinner"/> 316 </xsl:for-each> 317 </xsl:variable> 318 <xsl:variable name="block1"> 319 <xsl:choose> 320 <xsl:when test="string-length($block) = 0"> 321 <xsl:for-each select="ancestor::model/namespace/rng:grammar/rng:define[@name=$name]"> 322 <xsl:call-template name="factorycreateelementmapinner"/> 323 </xsl:for-each> 324 </xsl:when> 325 <xsl:otherwise> 326 <xsl:value-of select="$block"/> 327 </xsl:otherwise> 328 </xsl:choose> 329 </xsl:variable> 330 <xsl:if test="string-length($block1) > 0"> 331 <xsl:text> 332 /* ref: </xsl:text> 333 <xsl:value-of select="$name"/> 334 <xsl:text>*/</xsl:text> 335 <xsl:value-of select="$block1"/> 336 </xsl:if> 337 </xsl:for-each> 338 <xsl:for-each select=".//rng:element"> 339 <xsl:variable name="resource"> 340 <xsl:for-each select="rng:ref"> 341 <xsl:call-template name="contextresource"/> 342 </xsl:for-each> 343 </xsl:variable> 344 <xsl:if test="string-length($resource) > 0"> 345 <xsl:text> 346 (*pMap)[</xsl:text> 347 <xsl:call-template name="fasttoken"/> 348 <xsl:text>] = CreateElement(RT_</xsl:text> 349 <xsl:value-of select="$resource"/> 350 <xsl:text>, </xsl:text> 351 <xsl:for-each select="rng:ref"> 352 <xsl:call-template name="idforref"/> 353 </xsl:for-each> 354 <xsl:text>);</xsl:text> 355 </xsl:if> 356 </xsl:for-each> 357</xsl:template> 358 359<xsl:template name="factorycreateelementmapfromstart"> 360 <xsl:for-each select="start"> 361 <xsl:variable name="name" select="@name"/> 362 <xsl:variable name="block"> 363 <xsl:for-each select="ancestor::namespace/rng:grammar/rng:define[@name=$name]"> 364 <xsl:call-template name="factorycreateelementmapinner"> 365 </xsl:call-template> 366 </xsl:for-each> 367 </xsl:variable> 368 <xsl:text> 369 /* start: </xsl:text> 370 <xsl:value-of select="$name"/> 371 <xsl:text>*/</xsl:text> 372 <xsl:if test="string-length($block) > 0"> 373 <xsl:value-of select="$block"/> 374 </xsl:if> 375 </xsl:for-each> 376</xsl:template> 377 378<!-- factoryelementtoresourcemap --> 379<xsl:template name="factorycreateelementmap"> 380 <xsl:text> 381CreateElementMapPointer </xsl:text> 382 <xsl:call-template name="factoryclassname"/> 383 <xsl:text>::createCreateElementMap(Id nId) 384{ 385 CreateElementMapPointer pMap(new CreateElementMap()); 386 387 switch (nId) 388 {</xsl:text> 389 <xsl:for-each select="rng:grammar/rng:define"> 390 <xsl:variable name="inner"> 391 <xsl:call-template name="factorycreateelementmapinner"/> 392 </xsl:variable> 393 <xsl:if test="string-length($inner) > 0"> 394 <xsl:text> 395 </xsl:text> 396 <xsl:call-template name="caselabeldefine"/> 397 <xsl:value-of select="$inner"/> 398 <xsl:text> 399 break;</xsl:text> 400 </xsl:if> 401 </xsl:for-each> 402 <xsl:text> 403 default:</xsl:text> 404 <xsl:call-template name="factorycreateelementmapfromstart"/> 405 <xsl:text> 406 break; 407 } 408 409 return pMap; 410}</xsl:text> 411</xsl:template> 412 413 <!-- 414 Chooses the action for the current <action> element. 415 --> 416 <xsl:template name="factorychooseaction"> 417 <xsl:if test="@tokenid"> 418 <xsl:text> 419 if (sal::static_int_cast<Id>(pHandler->getId()) == </xsl:text> 420 <xsl:call-template name="idtoqname"> 421 <xsl:with-param name="id" select="@tokenid"/> 422 </xsl:call-template> 423 <xsl:text>) 424 {</xsl:text> 425 </xsl:if> 426 <xsl:for-each select="./cond"> 427 <xsl:text> 428 { 429 OOXMLPropertySetEntryToInteger aHandler(</xsl:text> 430 <xsl:call-template name="idtoqname"> 431 <xsl:with-param name="id" select="@tokenid"/> 432 </xsl:call-template> 433 <xsl:text>); 434 dynamic_cast<OOXMLFastContextHandlerStream*>(pHandler)->getPropertySetAttrs()->resolve(aHandler); 435 436 if (sal::static_int_cast<Id>(aHandler.getValue()) == </xsl:text> 437 <xsl:call-template name="idtoqname"> 438 <xsl:with-param name="id" select="@value"/> 439 </xsl:call-template> 440 <xsl:text>) 441 {</xsl:text> 442 </xsl:for-each> 443 <xsl:choose> 444 <xsl:when test="@action='handleXNotes' or 445 @action='handleHdrFtr' or 446 @action='handleComment' or 447 @action='handlePicture' or 448 @action='handleBreak' or 449 @action='handleOLE'"> 450 <xsl:text> 451 dynamic_cast<OOXMLFastContextHandlerProperties*>(pHandler)-></xsl:text> 452 <xsl:value-of select="@action"/> 453 <xsl:text>();</xsl:text> 454 </xsl:when> 455 <xsl:when test="@action='propagateCharacterPropertiesAsSet'"> 456 <xsl:text> 457 pHandler->propagateCharacterPropertiesAsSet(</xsl:text> 458 <xsl:call-template name="idtoqname"> 459 <xsl:with-param name="id" select="@sendtokenid"/> 460 </xsl:call-template> 461 <xsl:text>);</xsl:text> 462 </xsl:when> 463 <xsl:when test="@action='startCell' or @action='endCell'"> 464 <xsl:text> 465 dynamic_cast<OOXMLFastContextHandlerTextTableCell*>(pHandler)-></xsl:text> 466 <xsl:value-of select="@action"/> 467 <xsl:text>();</xsl:text> 468 </xsl:when> 469 <xsl:when test="@action='startRow' or @action='endRow'"> 470 <xsl:text> 471 dynamic_cast<OOXMLFastContextHandlerTextTableRow*>(pHandler)-></xsl:text> 472 <xsl:value-of select="@action"/> 473 <xsl:text>();</xsl:text> 474 </xsl:when> 475 <xsl:when test="@action='sendProperty' or @action='handleHyperlink'"> 476 <xsl:text> 477 dynamic_cast<OOXMLFastContextHandlerStream*>(pHandler)-></xsl:text> 478 <xsl:value-of select="@action"/> 479 <xsl:text>();</xsl:text> 480 </xsl:when> 481 <xsl:when test="@action='fieldstart'"> 482 <xsl:text> 483 pHandler->startField();</xsl:text> 484 </xsl:when> 485 <xsl:when test="@action='fieldsep'"> 486 <xsl:text> 487 pHandler->fieldSeparator();</xsl:text> 488 </xsl:when> 489 <xsl:when test="@action='fieldend'"> 490 <xsl:text> 491 pHandler->endField();</xsl:text> 492 </xsl:when> 493 <xsl:when test="@action='printproperty'"> 494 <xsl:text> 495 dynamic_cast<OOXMLFastContextHandlerStream*>(pHandler)->sendProperty(</xsl:text> 496 <xsl:call-template name="idtoqname"> 497 <xsl:with-param name="id" select="@sendtokenid"/> 498 </xsl:call-template> 499 <xsl:text>);</xsl:text> 500 </xsl:when> 501 <xsl:when test="@action='sendPropertiesWithId'"> 502 <xsl:text> 503 pHandler->sendPropertiesWithId(</xsl:text> 504 <xsl:call-template name="idtoqname"> 505 <xsl:with-param name="id" select="@sendtokenid"/> 506 </xsl:call-template> 507 <xsl:text>);</xsl:text> 508 </xsl:when> 509 <xsl:when test="@action='text'"> 510 pHandler->text(sText); 511 </xsl:when> 512 <xsl:when test="@action='newProperty'"> 513 <xsl:text> 514 OOXMLFastHelper<OOXMLIntegerValue>::newProperty(pHandler, </xsl:text> 515 <xsl:call-template name="idtoqname"> 516 <xsl:with-param name="id" select="@tokenid"/> 517 </xsl:call-template> 518 <xsl:text>, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("</xsl:text> 519 <xsl:value-of select="@value"/> 520 <xsl:text>")));</xsl:text> 521 </xsl:when> 522 <xsl:when test="@action='mark'"> 523 <xsl:text> 524 OOXMLFastHelper<OOXMLIntegerValue>::mark(pHandler, </xsl:text> 525 <xsl:call-template name="idtoqname"> 526 <xsl:with-param name="id" select="@sendtokenid"/> 527 </xsl:call-template> 528 <xsl:text>, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("</xsl:text> 529 <xsl:value-of select="@value"/> 530 <xsl:text>")));</xsl:text> 531 </xsl:when> 532 <xsl:when test="@action='tokenproperty'"> 533 <xsl:text> 534 OOXMLFastHelper<OOXMLIntegerValue>::newProperty(pHandler, </xsl:text> 535 <xsl:call-template name="idtoqname"> 536 <xsl:with-param name="id">ooxml:token</xsl:with-param> 537 </xsl:call-template> 538 <xsl:text>, pHandler->getToken());</xsl:text> 539 </xsl:when> 540 <xsl:otherwise> 541 <xsl:text> 542 pHandler-></xsl:text> 543 <xsl:value-of select="@action"/> 544 <xsl:text>();</xsl:text> 545 </xsl:otherwise> 546 </xsl:choose> 547 <xsl:for-each select="./cond"> 548 <xsl:text> 549 } 550 }</xsl:text> 551 </xsl:for-each> 552 <xsl:if test="@tokenid"> 553 <xsl:text> 554 }</xsl:text> 555 </xsl:if> 556 </xsl:template> 557 558<!-- factoryaction --> 559<xsl:template name="factoryaction"> 560 <xsl:param name="action"/> 561 <xsl:variable name="switchblock1"> 562 <xsl:for-each select="resource[action/@name=$action]"> 563 <xsl:text> 564 </xsl:text> 565 <xsl:call-template name="caselabeldefine"/> 566 <xsl:for-each select="action[@name=$action]"> 567 <xsl:call-template name="factorychooseaction"/> 568 </xsl:for-each> 569 <xsl:text> break;
</xsl:text> 570 </xsl:for-each> 571 </xsl:variable> 572 <xsl:variable name="switchblock2"> 573 <xsl:if test="$action='characters'"> 574 <xsl:for-each select="resource[@resource='Value']"> 575 <xsl:if test="count(attribute) = 0"> 576 <xsl:variable name="name" select="@name"/> 577 <xsl:text> </xsl:text> 578 <xsl:call-template name="caselabeldefine"/> 579 <xsl:text>
</xsl:text> 580 <xsl:for-each select="ancestor::namespace/rng:grammar/rng:define[@name=$name]"> 581 <xsl:for-each select="rng:ref"> 582 <xsl:call-template name="charactersactionforvalues"/> 583 </xsl:for-each> 584 </xsl:for-each> 585 <xsl:text> break;
</xsl:text> 586 </xsl:if> 587 </xsl:for-each> 588 </xsl:if> 589 </xsl:variable> 590 <xsl:text>

</xsl:text> 591 <xsl:text>void </xsl:text> 592 <xsl:call-template name="factoryclassname"/> 593 <xsl:text>::</xsl:text> 594 <xsl:value-of select="$action"/> 595 <xsl:text>Action(OOXMLFastContextHandler*</xsl:text> 596 <xsl:if test="string-length($switchblock1) > 0 or string-length($switchblock2) > 0"> 597 <xsl:text> pHandler</xsl:text> 598 </xsl:if> 599 <xsl:if test="$action='characters'"> 600 <xsl:text>, const ::rtl::OUString &</xsl:text> 601 <xsl:if test="contains($switchblock1, 'sText') or contains($switchblock2, 'sText')"> 602 <xsl:text> sText</xsl:text> 603 </xsl:if> 604 </xsl:if> 605 <xsl:text>)
</xsl:text> 606 <xsl:text>{
</xsl:text> 607 <xsl:if test="string-length($switchblock1) > 0 or string-length($switchblock2) > 0"> 608 <xsl:text> sal_uInt32 nDefine = pHandler->getDefine();
</xsl:text> 609 </xsl:if> 610 <xsl:if test="string-length($switchblock1) > 0"> 611 <xsl:text> switch (nDefine)
</xsl:text> 612 <xsl:text> {
</xsl:text> 613 <xsl:value-of select="$switchblock1"/> 614 <xsl:text> default:
</xsl:text> 615 <xsl:text> break;
</xsl:text> 616 <xsl:text> }
</xsl:text> 617 </xsl:if> 618 <xsl:if test="string-length($switchblock2) > 0"> 619 <xsl:text> OOXMLFastContextHandlerValue * pValueHandler = dynamic_cast<OOXMLFastContextHandlerValue *>(pHandler);
</xsl:text> 620 <xsl:text> switch (nDefine)
</xsl:text> 621 <xsl:text> {
</xsl:text> 622 <xsl:value-of select="$switchblock2"/> 623 <xsl:text> default:
</xsl:text> 624 <xsl:text> break;
</xsl:text> 625 <xsl:text> }
</xsl:text> 626 </xsl:if> 627 <xsl:text>}
</xsl:text> 628</xsl:template> 629 630<xsl:template name="charactersactionforvalues"> 631 <xsl:variable name="name" select="@name"/> 632 <xsl:for-each select="ancestor::namespace/rng:grammar/rng:define[@name=$name]"> 633 <xsl:text> {
</xsl:text> 634 <xsl:text> // </xsl:text> 635 <xsl:value-of select="@name"/> 636 <xsl:text>
</xsl:text> 637 <xsl:for-each select="rng:data[@type='int']"> 638 <xsl:text> OOXMLValue::Pointer_t pValue(new OOXMLIntegerValue(sText));
</xsl:text> 639 <xsl:text> pValueHandler->setValue(pValue);
</xsl:text> 640 </xsl:for-each> 641 <xsl:for-each select="rng:list"> 642 <xsl:text> ListValueMapPointer pListValueMap = getListValueMap(nDefine);
</xsl:text> 643 <xsl:text> if (pListValueMap.get() != NULL)
</xsl:text> 644 <xsl:text> {
</xsl:text> 645 <xsl:text> OOXMLValue::Pointer_t pValue(new OOXMLIntegerValue((*pListValueMap)[sText]));
</xsl:text> 646 <xsl:text> pValueHandler->setValue(pValue);</xsl:text> 647 <xsl:text> }
</xsl:text> 648 </xsl:for-each> 649 <xsl:text> }
</xsl:text> 650 </xsl:for-each> 651</xsl:template> 652 653<!-- factoryactions --> 654<xsl:template name="factoryactions"> 655 <xsl:variable name="ns" select="@name"/> 656 <xsl:for-each select="resource/action[not(@name='characters')]"> 657 <xsl:sort select="@name"/> 658 <xsl:if test="generate-id(key('actions', @name)[ancestor::namespace/@name=$ns][1]) = generate-id(.)"> 659 <xsl:variable name="name" select="@name"/> 660 <xsl:for-each select="ancestor::namespace"> 661 <xsl:call-template name="factoryaction"> 662 <xsl:with-param name="action" select="$name"/> 663 </xsl:call-template> 664 </xsl:for-each> 665 </xsl:if> 666 </xsl:for-each> 667 <xsl:call-template name="factoryaction"> 668 <xsl:with-param name="action">characters</xsl:with-param> 669 </xsl:call-template> 670</xsl:template> 671 672<xsl:template name="factorygetdefinename"> 673 <xsl:text> 674string </xsl:text> 675 <xsl:call-template name="factoryclassname"/> 676 <xsl:text>::getDefineName(Id nId) const 677{ 678 static IdToStringMapPointer pMap; 679 680 if (pMap.get() == NULL) 681 { 682 pMap = IdToStringMapPointer(new IdToStringMap()); 683 684</xsl:text> 685 <xsl:for-each select="rng:grammar/rng:define"> 686 <xsl:text> 687 (*pMap)[</xsl:text> 688 <xsl:call-template name="idfordefine"/> 689 <xsl:text>] = "</xsl:text> 690 <xsl:value-of select="@name"/> 691 <xsl:text>";</xsl:text> 692 </xsl:for-each> 693 } 694 695 return (*pMap)[nId]; 696} 697 698</xsl:template> 699 700<xsl:template name="factorytokentoidmapinner"> 701 <xsl:variable name="name" select="@name"/> 702 <xsl:for-each select=".//rng:ref[not(ancestor::rng:element or ancestor::rng:attribute)]"> 703 <xsl:variable name="refname" select="@name"/> 704 <xsl:variable name="refblock1"> 705 <xsl:for-each 706 select="ancestor::rng:grammar/rng:define[@name=$refname]"> 707 <xsl:call-template name="factorytokentoidmapinner"/> 708 </xsl:for-each> 709 </xsl:variable> 710 <xsl:choose> 711 <xsl:when test="string-length($refblock1) = 0"> 712 <xsl:for-each select="ancestor::model/namespace/rng:grammar/rng:define[@name=$refname]"> 713 <xsl:call-template name="factorytokentoidmapinner"/> 714 </xsl:for-each> 715 </xsl:when> 716 <xsl:otherwise> 717 <xsl:value-of select="$refblock1"/> 718 </xsl:otherwise> 719 </xsl:choose> 720 </xsl:for-each> 721 <xsl:variable name="body"> 722 <xsl:for-each select="ancestor::namespace/resource[@name=$name]"> 723 <xsl:for-each select="element[@tokenid]|attribute[@tokenid]"> 724 <xsl:text> 725 (*pMap)[</xsl:text> 726 <xsl:call-template name="fasttoken"/> 727 <xsl:text>] = </xsl:text> 728 <xsl:call-template name="idtoqname"> 729 <xsl:with-param name="id" select="@tokenid"/> 730 </xsl:call-template> 731 <xsl:text>;</xsl:text> 732 </xsl:for-each> 733 </xsl:for-each> 734 </xsl:variable> 735 <xsl:if test="string-length($body) > 0"> 736 <xsl:text> 737 // </xsl:text> 738 <xsl:value-of select="$name"/> 739 <xsl:value-of select="$body"/> 740 </xsl:if> 741</xsl:template> 742 743<xsl:template name="factorytokentoidmap"> 744 <xsl:text> 745TokenToIdMapPointer </xsl:text> 746 <xsl:call-template name="factoryclassname"/> 747 <xsl:text>::createTokenToIdMap(Id nId) 748{ 749 TokenToIdMapPointer pMap(new TokenToIdMap()); 750 751 switch (nId) 752 {</xsl:text> 753 <xsl:for-each select="rng:grammar/rng:define"> 754 <xsl:variable name="inner"> 755 <xsl:call-template name="factorytokentoidmapinner"/> 756 </xsl:variable> 757 <xsl:if test="string-length($inner) > 0"> 758 <xsl:text> 759 </xsl:text> 760 <xsl:call-template name="caselabeldefine"/> 761 <xsl:value-of select="$inner"/> 762 <xsl:text> 763 break;</xsl:text> 764 </xsl:if> 765 </xsl:for-each> 766 <xsl:text> 767 default:</xsl:text> 768 <xsl:for-each select="start"> 769 <xsl:variable name="name" select="@name"/> 770 <xsl:text> 771 // </xsl:text> 772 <xsl:value-of select="$name"/> 773 <xsl:for-each select="ancestor::namespace/rng:grammar/rng:define[@name=$name]"> 774 <xsl:call-template name="factorytokentoidmapinner"/> 775 </xsl:for-each> 776 </xsl:for-each> 777 <xsl:text> 778 break; 779 } 780 781 return pMap; 782} 783</xsl:text> 784</xsl:template> 785 786<xsl:template name="factoryattributeactiondefineinner"> 787 <xsl:variable name="name" select="@name"/> 788 <xsl:variable name="block"> 789 <xsl:for-each select="ancestor::namespace/resource[@name=$name]"> 790 <xsl:for-each select="attribute[@action]"> 791 <xsl:text> 792 case </xsl:text> 793 <xsl:call-template name="fasttoken"/> 794 <xsl:text>: 795 pHandler-></xsl:text> 796 <xsl:value-of select="@action"/> 797 <xsl:text>(pValue); 798 break;</xsl:text> 799 </xsl:for-each> 800 </xsl:for-each> 801 </xsl:variable> 802 <xsl:if test="string-length($block) > 0"> 803 <xsl:variable name="handlertype"> 804 <xsl:text>OOXMLFastContextHandler</xsl:text> 805 <xsl:for-each select="ancestor::namespace/resource[@name=$name]"> 806 <xsl:value-of select="@resource"/> 807 </xsl:for-each> 808 </xsl:variable> 809 <xsl:text> 810 { 811 </xsl:text> 812 <xsl:value-of select="$handlertype"/> 813 <xsl:text> * pHandler = dynamic_cast<</xsl:text> 814 <xsl:value-of select="$handlertype"/> 815 <xsl:text> * >(_pHandler); 816 817 switch(nToken) 818 {</xsl:text> 819 <xsl:value-of select="$block"/> 820 <xsl:text> 821 default: 822 break; 823 } 824 }</xsl:text> 825 </xsl:if> 826</xsl:template> 827 828<xsl:template name="factoryattributeactioninner"> 829 <xsl:for-each select="rng:grammar/rng:define"> 830 <xsl:variable name="inner"> 831 <xsl:call-template name="factoryattributeactiondefineinner"/> 832 </xsl:variable> 833 <xsl:if test="string-length($inner) > 0"> 834 <xsl:text> 835 </xsl:text> 836 <xsl:call-template name="caselabeldefine"/> 837 <xsl:value-of select="$inner"/> 838 <xsl:text> 839 break;</xsl:text> 840 </xsl:if> 841 </xsl:for-each> 842</xsl:template> 843 844<xsl:template name="factoryattributeaction"> 845 <xsl:variable name="inner"> 846 <xsl:call-template name="factoryattributeactioninner"/> 847 </xsl:variable> 848 <xsl:choose> 849 <xsl:when test="string-length($inner) > 0"> 850 <xsl:text> 851void </xsl:text> 852<xsl:call-template name="factoryclassname"/> 853<xsl:text>::attributeAction(OOXMLFastContextHandler * _pHandler, Token_t nToken, OOXMLValue::Pointer_t pValue) 854{ 855 switch(_pHandler->getDefine()) 856 {</xsl:text> 857 <xsl:value-of select="$inner"/> 858 <xsl:text> 859 default: 860 break; 861 } 862} 863</xsl:text> 864 </xsl:when> 865 <xsl:otherwise> 866 <xsl:text> 867void </xsl:text> 868<xsl:call-template name="factoryclassname"/> 869<xsl:text>::attributeAction(OOXMLFastContextHandler *, Token_t, OOXMLValue::Pointer_t) 870{ 871} 872</xsl:text> 873 </xsl:otherwise> 874 </xsl:choose> 875</xsl:template> 876 877<xsl:template name="factorygetname"> 878 <xsl:param name="ns"/> 879 <xsl:text> 880#ifdef DEBUG_FACTORY 881string </xsl:text> 882<xsl:call-template name="factoryclassname"/> 883<xsl:text>::getName() const 884{ 885 return "</xsl:text> 886 <xsl:value-of select="$ns"/> 887 <xsl:text>"; 888} 889#endif 890</xsl:text> 891</xsl:template> 892 893 <xsl:template match="/"> 894 <xsl:variable name="ns" select="substring-before(substring-after($file, 'OOXMLFactory_'), '.cxx')"/> 895 <xsl:text> 896#include "doctok/sprmids.hxx" 897#include "doctok/resourceids.hxx" 898#include "ooxml/resourceids.hxx" 899#include "OOXMLFactory_values.hxx" 900#include "OOXMLFactory_</xsl:text> 901 <xsl:value-of select="$ns"/> 902 <xsl:text>.hxx" 903#include "OOXMLFastHelper.hxx" 904 905namespace writerfilter { 906namespace ooxml { 907 908/// @cond GENERATED 909 </xsl:text> 910 <xsl:for-each select="/model/namespace[@name=$ns]"> 911 <xsl:call-template name="factorymutexdecl"/> 912 <xsl:call-template name="factoryconstructor"/> 913 <xsl:call-template name="factorydestructor"/> 914 <xsl:call-template name="factorygetinstance"/> 915 <xsl:call-template name="factoryattributetoresourcemap"/> 916 <xsl:call-template name="factorylistvaluemap"/> 917 <xsl:call-template name="factorycreateelementmap"/> 918 <xsl:call-template name="factoryactions"/> 919 <xsl:call-template name="factorygetdefinename"/> 920 <xsl:call-template name="factorytokentoidmap"/> 921 <xsl:call-template name="factoryattributeaction"/> 922 <xsl:call-template name="factorygetname"> 923 <xsl:with-param name="ns" select="$ns"/> 924 </xsl:call-template> 925 </xsl:for-each> 926 <xsl:text> 927/// @endcond 928}} 929</xsl:text> 930</xsl:template> 931 932</xsl:stylesheet> 933