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 22 23<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 24 xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:UML = 'org.omg.xmi.namespace.UML' xml:space="default"> 25<xsl:output method="text" /> 26 27 <xsl:include href="resourcetools.xsl"/> 28 29<xsl:template match="/"> 30 <xsl:call-template name="licenseheader"/> 31 <xsl:text> 32#include <resources.hxx> 33 34#ifndef WW8_OUTPUT_WITH_DEPTH 35#include <WW8OutputWithDepth.hxx> 36#endif 37 38#ifndef INCLUDED_SPRMIDS_HXX 39#include <sprmids.hxx> 40#endif 41 42namespace writerfilter { 43namespace doctok { 44 45extern WW8OutputWithDepth output; 46 47using namespace ::std; 48</xsl:text> 49 <xsl:apply-templates select='/XMI/XMI.content/UML:Model' mode="sprmkind"/> 50 <xsl:apply-templates select='.//UML:Class' mode='class'/> 51 <xsl:apply-templates select='//UML:Model' mode='createsprmprops'/> 52 <xsl:apply-templates select='/XMI/XMI.content/UML:Model' 53 mode='createsprmbinary'/> 54 <xsl:apply-templates select='/XMI/XMI.content/UML:Model' 55 mode='createdffrecord'/> 56 <xsl:apply-templates select='/XMI/XMI.content/UML:Model' mode='ww8foptename'/> 57 <xsl:apply-templates select='/XMI/XMI.content/UML:Model' 58 mode='isbooleandffopt'/> 59 <xsl:text> 60}} 61</xsl:text> 62</xsl:template> 63 64 <xsl:template match="UML:Class" mode="class"> 65 <xsl:choose> 66 <xsl:when test='.//UML:Stereotype[@xmi.idref = "ww8resource"]'> 67 <xsl:apply-templates select="." mode="ww8resource"> 68 <xsl:with-param name="classprefix">WW8</xsl:with-param> 69 <xsl:with-param name="needsinit">true</xsl:with-param> 70 </xsl:apply-templates> 71 </xsl:when> 72 <xsl:when test='.//UML:Stereotype[@xmi.idref = "dffrecord"]'> 73 <xsl:apply-templates select="." mode="ww8resource"> 74 <xsl:with-param name="classprefix">Dff</xsl:with-param> 75 </xsl:apply-templates> 76 </xsl:when> 77 </xsl:choose> 78 </xsl:template> 79 80 <xsl:template match="UML:Class" mode="ww8resource"> 81 <xsl:param name="classprefix"/> 82 <xsl:param name="needsinit"/> 83 <xsl:variable name="parentresource"> 84 <xsl:call-template name='parenttype'> 85 <xsl:with-param name='type'><xsl:value-of select='@xmi.id'/></xsl:with-param> 86 </xsl:call-template> 87 </xsl:variable> 88 <xsl:variable name='size_'><xsl:value-of select='./*/UML:TaggedValue[./*/UML:TagDefinition/@xmi.idref="size"]/UML:TaggedValue.dataValue'/></xsl:variable> 89 <xsl:variable name='size'> 90 <xsl:choose> 91 <xsl:when test='$size_ != ""'><xsl:value-of select='$size_'/></xsl:when> 92 <xsl:otherwise>0</xsl:otherwise> 93 </xsl:choose> 94 </xsl:variable> 95 <xsl:variable name="classname"><xsl:value-of select="$classprefix"/><xsl:value-of select="@name"/></xsl:variable> 96 <xsl:variable name="superclass"> 97 <xsl:choose> 98 <xsl:when test='.//UML:Stereotype[@xmi.idref = "ww8sprm"]'>WW8PropertyImpl</xsl:when> 99 <xsl:otherwise>WW8StructBase</xsl:otherwise> 100 </xsl:choose> 101 </xsl:variable> 102 <xsl:variable name="surroundclass"> 103 <xsl:choose> 104 <xsl:when test='.//UML:Stereotype[@xmi.idref = "ww8sprm"]'>WW8PropertyImpl</xsl:when> 105 <xsl:otherwise>WW8StructBase</xsl:otherwise> 106 </xsl:choose> 107 </xsl:variable> 108 <xsl:text> 109/* 110 Automatically generated class: </xsl:text><xsl:value-of select="@name"/><xsl:text> 111 </xsl:text> 112 <xsl:for-each select='./UML:ModelElement.stereotype/UML:Stereotype'> 113 <xsl:text> 114 Stereotype </xsl:text> 115 <xsl:value-of select='@xmi.idref'/> 116 <xsl:text>
</xsl:text> 117 </xsl:for-each> 118 <xsl:text> 119 Parent Resource: </xsl:text> 120 <xsl:value-of select="$parentresource"/> 121 <xsl:text> 122 Size: </xsl:text><xsl:value-of select='$size'/> 123 <xsl:text> 124*/ 125 </xsl:text> 126 127 <xsl:value-of select="$classname"/> 128 <xsl:text>::~</xsl:text> 129 <xsl:value-of select="$classname"/> 130 <xsl:text>() 131 { 132 } 133 </xsl:text> 134 <xsl:if test="$needsinit='true'"> 135 <xsl:text> 136 void </xsl:text> 137 <xsl:value-of select="$classname"/> 138 <xsl:text>::init() 139 { 140 </xsl:text> 141 <xsl:if test='.//UML:Stereotype[@xmi.idref ="withmembers"]'> 142 <xsl:for-each select='.//UML:Attribute[@name!="reserved"]'> 143 <xsl:apply-templates select='.' mode='initmembers'/> 144 </xsl:for-each> 145 </xsl:if> 146 <xsl:if test='.//UML:Stereotype[@xmi.idref ="initimpl"]'> 147 <xsl:text> initImpl();
</xsl:text> 148 </xsl:if> 149 <xsl:text> 150 }
</xsl:text> 151 </xsl:if> 152 153 <xsl:choose> 154 <xsl:when test='$parentresource="Properties"'> 155 <xsl:apply-templates select="." mode="resolveProperties"> 156 <xsl:with-param name="classname" select="$classname"/> 157 </xsl:apply-templates> 158 </xsl:when> 159 <xsl:when test='$parentresource="Table"'> 160 <xsl:apply-templates select="." mode="resolveTable"> 161 <xsl:with-param name="classname" select="$classname"/> 162 </xsl:apply-templates> 163 </xsl:when> 164 </xsl:choose> 165 166 </xsl:template> 167 168 <xsl:template match="UML:Class" mode="resolveProperties"> 169 <xsl:param name="classname"/> 170 <xsl:variable name="rHandler"> 171 <xsl:choose> 172 <xsl:when test='.//UML:Attribute[@name!="reserved"]'> 173 <xsl:if test='.//UML:Stereotype[@xmi.idref != "noresolve"]'> 174 <xsl:text>rHandler</xsl:text> 175 </xsl:if> 176 </xsl:when> 177 <xsl:when test='.//UML:Operation[@name!="reserved"]'> 178 <xsl:if test='.//UML:Stereotype[@xmi.idref != "noresolve"]'> 179 <xsl:text>rHandler</xsl:text> 180 </xsl:if> 181 </xsl:when> 182 <xsl:when test='.//UML:Stereotype[@xmi.idref = "resolvenoauto"]'> 183 <xsl:text>rHandler</xsl:text> 184 </xsl:when> 185 </xsl:choose> 186 </xsl:variable> 187 <xsl:text> 188 void </xsl:text> 189 <xsl:value-of select="$classname"/> 190 <xsl:choose> 191 <xsl:when test=".//UML:Stereotype[@xmi.idref='ww8resource']"> 192 <xsl:text>::resolve(Properties & </xsl:text> 193 <xsl:value-of select="$rHandler"/> 194 <xsl:text>)</xsl:text> 195 </xsl:when> 196 <xsl:when test=".//UML:Stereotype[@xmi.idref='dffrecord']"> 197 <xsl:text>::resolveLocal(Properties & </xsl:text> 198 <xsl:value-of select="$rHandler"/> 199 <xsl:text>)</xsl:text> 200 </xsl:when> 201 </xsl:choose> 202 <xsl:text> 203 {</xsl:text> 204 <xsl:if test='.//UML:Stereotype[@xmi.idref="debug"]'> 205 <xsl:text> 206 dump(output);</xsl:text> 207 </xsl:if> 208 <xsl:text> 209 try 210 {</xsl:text> 211 <xsl:for-each select='.//UML:Attribute[@name!="reserved"]'> 212 <xsl:choose> 213 <xsl:when test='.//UML:Stereotype[@xmi.idref="noresolve"]'> 214 </xsl:when> 215 <xsl:otherwise> 216 <xsl:apply-templates select='.' mode='resolveAttribute'/> 217 </xsl:otherwise> 218 </xsl:choose> 219 </xsl:for-each> 220 <xsl:for-each select='.//UML:Operation[@name!="reserved"]'> 221 <xsl:choose> 222 <xsl:when test='.//UML:Stereotype[@xmi.idref="noresolve"]'> 223 </xsl:when> 224 <xsl:otherwise> 225 <xsl:apply-templates select='.' mode='resolveOperation'/> 226 </xsl:otherwise> 227 </xsl:choose> 228 </xsl:for-each> 229 230 <xsl:if test='.//UML:Stereotype[@xmi.idref = "resolvenoauto"]'> 231 resolveNoAuto(rHandler); 232 </xsl:if> 233 <xsl:text> 234 } catch (Exception & e) { 235 clog << e.getText() << endl; 236 } 237 } 238 239 void 240 </xsl:text> 241 <xsl:value-of select="$classname"/> 242 <xsl:text>::dump(OutputWithDepth < string > & o) const 243 { 244 o.addItem("<dump type='</xsl:text> 245 <xsl:value-of select='@name'/> 246 <xsl:text>'>"); 247 248 WW8StructBase::dump(o);</xsl:text> 249 <xsl:for-each select='.//UML:Attribute[@name!="reserved"]'> 250 <xsl:apply-templates select='.' mode='dumpAttribute'/> 251 </xsl:for-each> 252 253 <xsl:text> 254 o.addItem("</dump>"); 255 }
</xsl:text> 256 </xsl:template> 257 258 <xsl:template match='UML:Attribute' mode='resolveAttribute'> 259 <xsl:variable name="attrid"> 260 <xsl:for-each select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="attrid"]'> 261 <xsl:value-of select='UML:TaggedValue.dataValue'/> 262 </xsl:for-each> 263 </xsl:variable> 264 <xsl:variable name="qname"> 265 <xsl:call-template name='idtoqname'> 266 <xsl:with-param name='id'> 267 <xsl:value-of select='$attrid'/> 268 </xsl:with-param> 269 </xsl:call-template> 270 </xsl:variable> 271 <xsl:choose> 272 <xsl:when test='.//UML:Stereotype/@xmi.idref = "attribute"'> 273 <xsl:text> 274 { 275 WW8Value::Pointer_t pVal = createValue(get_</xsl:text> 276 <xsl:value-of select="@name"/> 277 <xsl:text>()); 278 rHandler.attribute(</xsl:text> 279 <xsl:value-of select="$qname"/> 280 <xsl:text>, *pVal); 281 }</xsl:text> 282 </xsl:when> 283 <xsl:when test='.//UML:Stereotype/@xmi.idref = "array"'> 284 <xsl:variable name="elementtype"> 285 <xsl:value-of select='.//UML:DataType/@xmi.idref'/> 286 </xsl:variable> 287 <xsl:variable name="parentclass"> 288 <xsl:call-template name='parenttype'> 289 <xsl:with-param name='type'> 290 <xsl:value-of select='$elementtype'/> 291 </xsl:with-param> 292 </xsl:call-template> 293 </xsl:variable> 294 <xsl:text> 295 { 296 sal_uInt32 nCount = get_</xsl:text> 297 <xsl:value-of select="@name"/> 298 <xsl:text>_count(); 299 for (sal_uInt32 n = 0; n < nCount; ++n) 300 { 301 WW8Value::Pointer_t pVal = createValue(get_</xsl:text> 302 <xsl:value-of select="@name"/> 303 <xsl:text>(n)); 304 rHandler.attribute(</xsl:text> 305 <xsl:value-of select="$qname"/> 306 <xsl:text>, *pVal); 307 } 308 }</xsl:text> 309 </xsl:when> 310 <xsl:when test='.//UML:Stereotype/@xmi.idref = "string"'> 311 <xsl:text> 312 { 313 WW8StringValue aVal(get_</xsl:text> 314 <xsl:value-of select='@name'/> 315 <xsl:text>()); 316 rHandler.attribute(</xsl:text> 317 <xsl:value-of select="$qname"/> 318 <xsl:text>, aVal); 319 }</xsl:text> 320 </xsl:when> 321 </xsl:choose> 322 </xsl:template> 323 324 <xsl:template match='UML:Attribute' mode='dumpAttribute'> 325 <xsl:variable name="type"> 326 <xsl:value-of select='.//UML:DataType/@xmi.idref'/> 327 </xsl:variable><xsl:variable name="saltype"> 328 <xsl:call-template name='saltype'> 329 <xsl:with-param name='type'> 330 <xsl:value-of select='$type'/> 331 </xsl:with-param> 332 <xsl:with-param name='parenttype'> 333 <xsl:apply-templates select="." mode="parentclass"/> 334 </xsl:with-param> 335 </xsl:call-template> 336 </xsl:variable> 337 <xsl:variable name="name" select="@name"/> 338 <xsl:for-each select=".//UML:Stereotype"> 339 <xsl:choose> 340 <xsl:when test='@xmi.idref = "attributeremainder"'/> 341 <xsl:when test='@xmi.idref = "array"'> 342 <xsl:text> 343 { 344 sal_uInt32 nCount = get_</xsl:text> 345 <xsl:value-of select='$name'/> 346 <xsl:text>_count(); 347 348 for (sal_uInt32 n = 0; n < nCount; ++n) 349 { 350 writerfilter::dump(o, "</xsl:text> 351 <xsl:value-of select='$name'/> 352 <xsl:text>", get_</xsl:text> 353 <xsl:value-of select="$name"/> 354 <xsl:text>(n)); 355 } 356 }</xsl:text> 357 </xsl:when> 358 <xsl:when test='@xmi.idref = "string"'> 359 <xsl:text> 360 { 361 WW8StringValue aVal(get_</xsl:text> 362 <xsl:value-of select='$name'/> 363 <xsl:text>()); 364 365 o.addItem("</xsl:text> 366 <xsl:value-of select='$name'/> 367 <xsl:text>" << "=\"" + aVal.toString() + "\""); 368 }</xsl:text> 369 </xsl:when> 370 <xsl:otherwise> 371 <xsl:text> 372 writerfilter::dump(o, "</xsl:text> 373 <xsl:value-of select='$name'/> 374 <xsl:text>", get_</xsl:text> 375 <xsl:value-of select="$name"/> 376 <xsl:text>());</xsl:text> 377 </xsl:otherwise> 378 </xsl:choose> 379 </xsl:for-each> 380 </xsl:template> 381 382 <xsl:template name="resolveOperationAttribute"> 383 <xsl:variable name="opid"> 384 <xsl:for-each select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="opid"]'> 385 <xsl:value-of select='./UML:TaggedValue.dataValue'/> 386 </xsl:for-each> 387 </xsl:variable> 388 <xsl:text> 389 { 390 WW8Value::Pointer_t pVal = createValue(get_</xsl:text> 391 <xsl:value-of select="@name"/> 392 <xsl:text>()); 393 rHandler.attribute(</xsl:text> 394 <xsl:call-template name='idtoqname'> 395 <xsl:with-param name='id'><xsl:value-of select='$opid'/></xsl:with-param> 396 </xsl:call-template> 397 <xsl:text>, *pVal); 398 }
</xsl:text> 399 </xsl:template> 400 401 <xsl:template name="resolveOperationArray"> 402 <xsl:variable name="elementtype"> 403 <xsl:value-of select='.//UML:Parameter.type/@xmi.idref'/> 404 </xsl:variable> 405 <xsl:variable name="opid"> 406 <xsl:for-each select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="opid"]'> 407 <xsl:value-of select='./UML:TaggedValue.dataValue'/> 408 </xsl:for-each> 409 </xsl:variable> 410 <xsl:variable name="parentclass"> 411 <xsl:for-each select='/XMI/XMI.content/UML:Model/UML:Namespace.ownedElement/UML:Generalization[UML:Generalization.child/UML:Class/@xmi.idref=$elementtype]'> 412 <xsl:value-of select='./UML:Generalization.parent/UML:Class/@xmi.idref'/> 413 </xsl:for-each> 414 </xsl:variable> 415 <xsl:text> 416 { 417 sal_uInt32 nCount = get_</xsl:text> 418 <xsl:value-of select="@name"/> 419 <xsl:text>_count(); 420 421 for (sal_uInt32 n = 0; n < nCount; ++n) 422 { 423 WW8Value::Pointer_t pVal = createValue(get_</xsl:text> 424 <xsl:value-of select="@name"/> 425 <xsl:text>(n)); 426 rHandler.attribute(</xsl:text> 427 <xsl:call-template name='idtoqname'> 428 <xsl:with-param name='id'><xsl:value-of select='$opid'/></xsl:with-param> 429 </xsl:call-template> 430 <xsl:text>, *pVal); 431 } 432 }
</xsl:text> 433 </xsl:template> 434 435 <xsl:template name="resolveOperationBinary"> 436 <xsl:text> 437 { 438 WW8BinaryObjReference::Pointer_t pRef(get_</xsl:text> 439 <xsl:value-of select="@name"/> 440 <xsl:text>()); 441 WW8Sprm aSprm(pRef); 442 443 rHandler.sprm(aSprm); 444 }
</xsl:text> 445 </xsl:template> 446 447 <xsl:template match='UML:Operation' mode='resolveOperation'> 448 <xsl:choose> 449 <xsl:when test='.//UML:Stereotype/@xmi.idref = "attribute"'> 450 <xsl:call-template name="resolveOperationAttribute"/> 451 </xsl:when> 452 <xsl:when test='.//UML:Stereotype/@xmi.idref = "array"'> 453 <xsl:call-template name="resolveOperationArray"/> 454 </xsl:when> 455 <xsl:when test='.//UML:Stereotype/@xmi.idref = "binary"'> 456 <xsl:call-template name="resolveOperationBinary"/> 457 </xsl:when> 458 </xsl:choose> 459 </xsl:template> 460 461 <xsl:template match="UML:Class" mode="resolveTable"> 462 <xsl:param name="classname"/> 463 <xsl:text>void </xsl:text> 464 <xsl:value-of select="$classname"/> 465 <xsl:text>::resolve(Table & rHandler) 466 { 467 sal_uInt32 nCount = getEntryCount(); 468 writerfilter::Reference< Properties >::Pointer_t pEntry; 469 for (sal_uInt32 n = 0; n < nCount; ++n) 470 { 471 pEntry = getEntry(n); 472 473 if (pEntry.get() != 0x0) 474 { 475 try 476 { 477 rHandler.entry(n, pEntry); 478 } 479 catch (ExceptionOutOfBounds e) 480 { 481 } 482 } 483 } 484 } 485 </xsl:text> 486 </xsl:template> 487 488<xsl:template match='UML:Model' mode='createsprmprops'> 489writerfilter::Reference < Properties > ::Pointer_t createSprmProps 490(WW8PropertyImpl & rProp) 491{ 492 writerfilter::Reference < Properties > ::Pointer_t pResult; 493 494 switch (rProp.getId()) 495 { 496<xsl:for-each select='.//UML:Class[.//UML:Stereotype/@xmi.idref="ww8sprm" and .//UML:Stereotype/@xmi.idref="ww8resource"]'> 497 case <xsl:value-of select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="sprmcode"]//UML:TaggedValue.dataValue'/>: 498 pResult = writerfilter::Reference < Properties > ::Pointer_t(new WW8<xsl:value-of select='@name'/>(rProp, 0, rProp.getCount())); 499 500 break; 501</xsl:for-each> 502 default: 503 break; 504 } 505 506 return pResult; 507} 508</xsl:template> 509 510<xsl:template match='UML:Model' mode='createsprmbinary'> 511<xsl:text> 512writerfilter::Reference < BinaryObj > ::Pointer_t createSprmBinary 513(WW8PropertyImpl & rProp) 514{ 515 writerfilter::Reference < BinaryObj > ::Pointer_t pResult; 516 517 switch (rProp.getId()) 518 {
 519 // warnings.... 520 case 0: 521 break; 522</xsl:text> 523<xsl:for-each select='.//UML:Class[.//UML:Stereotype/@xmi.idref="ww8sprmbinary" and .//UML:Stereotype/@xmi.idref="ww8resource"]'> 524 case <xsl:value-of select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="sprmcode"]//UML:TaggedValue.dataValue'/>: 525 { 526 WW8<xsl:value-of select='@name'/>::Pointer_t p(new WW8<xsl:value-of select='@name'/>(rProp, 0, rProp.getCount())); 527 528 pResult = p->getBinary(); 529 } 530 531 break; 532</xsl:for-each> 533<xsl:text> 534 default: 535 break; 536 } 537 538 return pResult; 539} 540</xsl:text> 541</xsl:template> 542 543<!-- returns optname of UML:Class --> 544<xsl:template name="optname"> 545 <xsl:for-each select="./UML:ModelElement.taggedValue/UML:TaggedValue"> 546 <xsl:if test=".//UML:TagDefinition/@xmi.idref='optname'"> 547 <xsl:value-of select="./UML:TaggedValue.dataValue"/> 548 </xsl:if> 549 </xsl:for-each> 550</xsl:template> 551 552<xsl:template name="ww8foptenamecase"> 553 <xsl:text> 554 case </xsl:text> 555 <xsl:variable name="optname"> 556 <xsl:call-template name="optname"/> 557 </xsl:variable> 558 <xsl:call-template name="idtoqname"> 559 <xsl:with-param name="id" select="$optname"/> 560 </xsl:call-template> 561 <xsl:text>: 562 result = rtl::OUString::createFromAscii("</xsl:text> 563 <xsl:value-of select="$optname"/> 564 <xsl:text>"); 565 break;</xsl:text> 566</xsl:template> 567 568<xsl:template name="getdffoptname"> 569 <xsl:text> 570rtl::OUString getDffOptName(sal_uInt32 nPid) 571{ 572 rtl::OUString result; 573 574 switch (nPid) 575 {
</xsl:text> 576 <xsl:for-each select="./UML:Class[./UML:ModelElement.stereotype/UML:Stereotype/@xmi.idref='dffopt']"> 577 <xsl:call-template name="ww8foptenamecase"/> 578 </xsl:for-each> 579 <xsl:text> 580 default: 581 break; 582 } 583 584 return result; 585}</xsl:text> 586</xsl:template> 587 588<xsl:template name="ww8foptegetvalue"> 589 <xsl:text> 590WW8Value::Pointer_t WW8FOPTE::get_value() 591{ 592 WW8Value::Pointer_t pResult; 593 594 switch (get_pid()) 595 {</xsl:text> 596 <xsl:for-each select=".//UML:Class[./UML:ModelElement.stereotype/UML:Stereotype/@xmi.idref='dffopt']"> 597 <xsl:variable name="type"> 598 <xsl:for-each select="./UML:ModelElement.taggedValue/UML:TaggedValue[./UML:TaggedValue.type/UML:TagDefinition/@xmi.idref='type']"> 599 <xsl:value-of select="UML:TaggedValue.dataValue"/> 600 </xsl:for-each> 601 </xsl:variable> 602 <xsl:if test="$type != 'unknown'"> 603 <xsl:variable name="typetype"> 604 <xsl:call-template name="typetype"> 605 <xsl:with-param name="type" select="$type"/> 606 </xsl:call-template> 607 </xsl:variable> 608 <xsl:variable name="valuetype"> 609 <xsl:call-template name="valuetype"> 610 <xsl:with-param name="type" select="$type"/> 611 </xsl:call-template> 612 </xsl:variable> 613 <xsl:text> 614 case </xsl:text> 615 <xsl:for-each select="./UML:ModelElement.taggedValue/UML:TaggedValue[./UML:TaggedValue.type/UML:TagDefinition/@xmi.idref='dffid']"> 616 <xsl:value-of select="UML:TaggedValue.dataValue"/> 617 </xsl:for-each> 618 <xsl:variable name="optname"> 619 <xsl:for-each select="./UML:ModelElement.taggedValue/UML:TaggedValue[./UML:TaggedValue.type/UML:TagDefinition/@xmi.idref='optname']"> 620 <xsl:value-of select="UML:TaggedValue.dataValue"/> 621 </xsl:for-each> 622 </xsl:variable> 623 <xsl:call-template name="idtoqname"> 624 <xsl:with-param name="id" select="$optname"/> 625 </xsl:call-template> 626 <xsl:text>:</xsl:text> 627 <xsl:choose> 628 <xsl:when test="./UML:ModelElement.taggedValue/UML:TaggedValue[./UML:TaggedValue.type/UML:TagDefinition/@xmi.idref='isbool']"> 629 <xsl:text> 630 pResult = createValue(getU32(0x2) & 1);</xsl:text> 631 </xsl:when> 632 <xsl:when test="$typetype='complex'"> 633 <xsl:text> 634 pResult = createValue(new </xsl:text> 635 <xsl:value-of select="$valuetype"/> 636 <xsl:text>(getU32(0x2)));</xsl:text> 637 </xsl:when> 638 <xsl:when test="$typetype='string'"> 639 <xsl:text> 640 pResult = get_stringValue();
</xsl:text> 641 </xsl:when> 642 <xsl:otherwise> 643 <xsl:text> 644 pResult = createValue(getU32(0x2));</xsl:text> 645 </xsl:otherwise> 646 </xsl:choose> 647 <xsl:text> 648 break;</xsl:text> 649 </xsl:if> 650 </xsl:for-each> 651 <xsl:text> 652 default: 653 pResult = createValue(getU32(0x2)); 654 655 break; 656 } 657 658 return pResult; 659}</xsl:text> 660</xsl:template> 661 662<xsl:template match='UML:Model/UML:Namespace.ownedElement' mode='ww8foptename'> 663 <xsl:text> 664rtl::OUString WW8FOPTE::get_name() 665{ 666 return getDffOptName(get_pid()); 667}</xsl:text> 668<xsl:call-template name="getdffoptname"/> 669<xsl:text> 670 671WW8Value::Pointer_t WW8FOPTE::get_stringValue() 672{ 673 WW8Value::Pointer_t pResult; 674 DffOPT * pOpt = dynamic_cast < DffOPT * >(mpParent); 675 sal_uInt32 nExtraOffset = pOpt->get_extraoffset(mnIndex); 676 sal_uInt32 nExtraLength = pOpt->get_extraoffset(mnIndex + 1) - nExtraOffset; 677 pResult = createValue(mpParent->getString(nExtraOffset, nExtraLength / 2)); 678 679 return pResult; 680} 681</xsl:text> 682<xsl:call-template name="ww8foptegetvalue"/> 683</xsl:template> 684 685<xsl:template match="UML:Model" mode="createdffrecord"> 686<xsl:text> 687DffRecord * createDffRecord 688(WW8StructBase * pParent, sal_uInt32 nOffset, sal_uInt32 * pCount) 689{ 690 DffRecord * pResult = NULL; 691 DffRecord aTmpRec(pParent, nOffset, 8); 692 sal_uInt32 nSize = aTmpRec.calcSize(); 693 694 if (pCount != NULL) 695 *pCount = nSize; 696 697 switch (aTmpRec.getRecordType()) 698 {
</xsl:text> 699 <xsl:for-each select='.//UML:Class[.//UML:Stereotype/@xmi.idref="dffrecord"]'> 700 <xsl:text> case </xsl:text> 701 <xsl:value-of select=".//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref='dffid']//UML:TaggedValue.dataValue"/> 702 <xsl:text>: 703 pResult = new Dff</xsl:text> 704 <xsl:value-of select="@name"/> 705 <xsl:text>(pParent, nOffset, nSize); 706 707 break;
</xsl:text> 708 </xsl:for-each> 709 <xsl:text> 710 default: 711 pResult = new DffRecord(pParent, nOffset, nSize); 712 713 break; 714 } 715 716 return pResult; 717} 718 719DffRecord * createDffRecord 720(WW8Stream & rStream, sal_uInt32 nOffset, sal_uInt32 * pCount) 721{ 722 DffRecord * pResult = NULL; 723 DffRecord aTmpRec(rStream, nOffset, 8); 724 sal_uInt32 nSize = aTmpRec.calcSize(); 725 726 if (pCount != NULL) 727 *pCount = nSize; 728 729 switch (aTmpRec.getRecordType()) 730 {
</xsl:text> 731 <xsl:for-each select='.//UML:Class[.//UML:Stereotype/@xmi.idref="dffrecord"]'> 732 <xsl:text> case </xsl:text> 733 <xsl:value-of select=".//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref='dffid']//UML:TaggedValue.dataValue"/> 734 <xsl:text>: 735 pResult = new Dff</xsl:text> 736 <xsl:value-of select="@name"/> 737 <xsl:text>(rStream, nOffset, nSize); 738 739 break;
</xsl:text> 740 </xsl:for-each> 741 <xsl:text> 742 default: 743 pResult = new DffRecord(rStream, nOffset, nSize); 744 745 break; 746 } 747 748 return pResult; 749} 750 </xsl:text> 751</xsl:template> 752 753<xsl:template match="UML:Attribute" mode="initmembers"> 754 <xsl:variable name="stereotype"><xsl:value-of select=".//UML:Stereotype/@xmi.idref"/></xsl:variable> 755 <xsl:variable name="offset_"><xsl:value-of select='translate(.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="offset"]/UML:TaggedValue.dataValue, "ABCDEFX", "abcdefx")'/></xsl:variable> 756 <xsl:variable name="offset"> 757 <xsl:if test='$offset_ != "" and not(starts-with($offset_, "0x"))'>0x</xsl:if> 758 <xsl:value-of select='$offset_'/> 759 </xsl:variable> 760 <xsl:variable name="shift"><xsl:value-of select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="shift"]/UML:TaggedValue.dataValue'/></xsl:variable> 761 <xsl:variable name="mask_"><xsl:value-of select='translate(.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="mask"]/UML:TaggedValue.dataValue, "ABCDEFX", "abcdefx")'/></xsl:variable> 762 <xsl:variable name="mask"> 763 <xsl:if test='$mask_ != "" and not(starts-with($mask_, "0x"))'>0x</xsl:if> 764 <xsl:value-of select='$mask_'/> 765 </xsl:variable> 766 <xsl:variable name="type"><xsl:value-of select='.//UML:DataType/@xmi.idref'/></xsl:variable><xsl:variable name="saltype"> 767 <xsl:call-template name='saltype'> 768 <xsl:with-param name='type'> 769 <xsl:value-of select='$type'/> 770 </xsl:with-param> 771 </xsl:call-template> 772</xsl:variable> 773 774/* 775<xsl:value-of select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref="comment"]/UML:TaggedValue.dataValue'/> 776 777Name: <xsl:value-of select='@name'/>(<xsl:value-of select='$stereotype'/>) 778Offset: <xsl:value-of select='$offset'/> 779Mask: <xsl:value-of select='$mask'/> 780Shift: <xsl:value-of select='$shift'/> 781*/ 782 783<xsl:choose> 784 <xsl:when test='$stereotype = "attribute"'> 785 m<xsl:value-of select='@name'/> = (get<xsl:value-of select="$type"/>(<xsl:value-of select="$offset"/>)<xsl:if test="string-length($mask)>0"> & <xsl:value-of select="$mask"/></xsl:if>)<xsl:if test="$shift>0"> >> <xsl:value-of select="$shift"/></xsl:if>; 786 </xsl:when> 787 <xsl:when test='$stereotype = "array"'> 788 <xsl:text> 789 { 790 sal_uInt32 nCount = </xsl:text> 791 <xsl:value-of select='.//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref = "arraycount"]/UML:TaggedValue.dataValue'/> 792 <xsl:text>; 793 m</xsl:text> 794 <xsl:value-of select='@name'/> 795 <xsl:text> = new </xsl:text><xsl:value-of select='$saltype'/><xsl:text>[nCount]; 796 797 for (sal_uInt32 n = 0; n < nCount; ++n) 798 m</xsl:text><xsl:value-of select='@name'/><xsl:text>[n] = get</xsl:text> 799 <xsl:value-of select='$type'/> 800 <xsl:text>(</xsl:text> 801 <xsl:value-of select='$offset'/> 802 <xsl:text> + nIndex * sizeof(</xsl:text> 803 <xsl:value-of select='$saltype'/> 804 <xsl:text>)); 805 } 806 </xsl:text> 807 </xsl:when> 808 <xsl:when test='$stereotype = "string"'> 809 m<xsl:value-of select='@name'/> = getString(<xsl:value-of select='$offset'/>) 810 </xsl:when> 811</xsl:choose> 812</xsl:template> 813 814<xsl:template match="UML:Model" mode="isbooleandffopt"> 815<xsl:text> 816bool isBooleanDffOpt(sal_uInt32 nId) 817{ 818 bool bResult = false; 819 820 switch (nId) 821 {
</xsl:text> 822 <xsl:for-each select='.//UML:Class[.//UML:Stereotype/@xmi.idref="dffopt"]'> 823 <xsl:if test=".//UML:TagDefinition[@xmi.idref='isbool']"> 824 <xsl:text> case </xsl:text> 825 <xsl:variable name="optname"> 826 <xsl:value-of select=".//UML:TaggedValue[.//UML:TagDefinition/@xmi.idref='optname']//UML:TaggedValue.dataValue"/> 827 </xsl:variable> 828 <xsl:call-template name="idtoqname"> 829 <xsl:with-param name="id" select="$optname"/> 830 </xsl:call-template> 831 <xsl:text>:
</xsl:text> 832 </xsl:if> 833 </xsl:for-each> 834 <xsl:text> 835 bResult = true; 836 break; 837 838 default: 839 break; 840 } 841 842 return bResult; 843} 844</xsl:text> 845</xsl:template> 846 847</xsl:stylesheet> 848 849