1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_xmloff.hxx" 30 #include <com/sun/star/xml/sax/SAXParseException.hpp> 31 #include <com/sun/star/xml/sax/SAXException.hpp> 32 #include <com/sun/star/xml/sax/XDocumentHandler.hpp> 33 #include <com/sun/star/xml/sax/XAttributeList.hpp> 34 #include <xmloff/nmspmap.hxx> 35 #include <xmloff/xmltoken.hxx> 36 #include "xmloff/xmlnmspe.hxx" 37 #include "PropType.hxx" 38 #include "DeepTContext.hxx" 39 #include "RenameElemTContext.hxx" 40 #include "ProcAttrTContext.hxx" 41 #include "ActionMapTypesOOo.hxx" 42 #include "MutableAttrList.hxx" 43 #include "TransformerActions.hxx" 44 #include "PropertyActionsOOo.hxx" 45 #ifndef _XMLOFF_TRANSFORMERBASE_HXX 46 #include "TransformerBase.hxx" 47 #endif 48 49 #ifndef _XMLOFF_STYLEOASISTCONTEXT_HXX 50 #include "StyleOOoTContext.hxx" 51 #endif 52 #include <xmloff/xmluconv.hxx> 53 #include <rtl/ustrbuf.hxx> 54 #include <rtl/math.hxx> 55 56 using ::rtl::OUString; 57 using namespace ::xmloff::token; 58 using namespace ::com::sun::star::uno; 59 using namespace ::com::sun::star::xml::sax; 60 61 const sal_uInt16 MAX_PROP_TYPES = 4; 62 #define ENTRY4(a,b,c,d) \ 63 { XML_PROP_TYPE_##a, XML_PROP_TYPE_##b, \ 64 XML_PROP_TYPE_##c, XML_PROP_TYPE_##d } 65 #define ENTRY3(a,b,c) \ 66 { XML_PROP_TYPE_##a, XML_PROP_TYPE_##b, \ 67 XML_PROP_TYPE_##c, XML_PROP_TYPE_END } 68 #define ENTRY2(a,b) \ 69 { XML_PROP_TYPE_##a, XML_PROP_TYPE_##b, \ 70 XML_PROP_TYPE_END, XML_PROP_TYPE_END } 71 #define ENTRY1(a) \ 72 { XML_PROP_TYPE_##a, XML_PROP_TYPE_##END, \ 73 XML_PROP_TYPE_END, XML_PROP_TYPE_END } 74 75 static XMLPropType aPropTypes[XML_FAMILY_TYPE_END][MAX_PROP_TYPES] = 76 { 77 ENTRY3( GRAPHIC, PARAGRAPH, TEXT ), // XML_FAMILY_TYPE_GRAPHIC, 78 ENTRY3( GRAPHIC, PARAGRAPH, TEXT ), // XML_FAMILY_TYPE_PRESENTATION, 79 ENTRY1( DRAWING_PAGE ), // XML_FAMILY_TYPE_DRAWING_PAGE, 80 ENTRY1( END ), // XML_FAMILY_TYPE_MASTER_PAGE 81 ENTRY1( PAGE_LAYOUT ), // XML_FAMILY_TYPE_PAGE_LAYOUT, 82 ENTRY1( HEADER_FOOTER ), // XML_FAMILY_TYPE_HEADER_FOOTER 83 ENTRY1( TEXT ), // XML_FAMILY_TYPE_TEXT, 84 ENTRY2( PARAGRAPH, TEXT ), // XML_FAMILY_TYPE_PARAGRAPH, 85 ENTRY1( RUBY ), //XML_FAMILY_TYPE_RUBY, 86 ENTRY1( SECTION ), // XML_FAMILY_TYPE_SECTION, 87 ENTRY1( TABLE ), // XML_FAMILY_TYPE_TABLE, 88 ENTRY1( TABLE_COLUMN ), // XML_FAMILY_TYPE_TABLE_COLUMN, 89 ENTRY1( TABLE_ROW ), // XML_FAMILY_TYPE_TABLE_ROW, 90 ENTRY3( TABLE_CELL, PARAGRAPH, TEXT ), // XML_FAMILY_TYPE_TABLE_CELL, 91 ENTRY1( LIST_LEVEL ), // XML_FAMILY_TYPE_LIST, 92 ENTRY4( CHART, GRAPHIC, PARAGRAPH, TEXT ), // XML_FAMILY_TYPE_CHART, 93 ENTRY1( TEXT ), // XML_FAMILY_TYPE_DATA, 94 ENTRY1( END ), // XML_FAMILY_TYPE_GRADIENT, 95 ENTRY1( END ), // XML_FAMILY_TYPE_HATCH, 96 ENTRY1( END ), // XML_FAMILY_TYPE_FILL_IMAGE, 97 ENTRY1( END ), // XML_FAMILY_TYPE_STROKE_DASH, 98 ENTRY1( END ), // XML_FAMILY_TYPE_MARKER, 99 ENTRY1( END ) // XML_FAMILY_TYPE_PRESENTATION_PAGE_LAYOUT, 100 }; 101 102 static XMLTokenEnum aPropTokens[XML_PROP_TYPE_END] = 103 { 104 XML_GRAPHIC_PROPERTIES, 105 XML_DRAWING_PAGE_PROPERTIES, 106 XML_PAGE_LAYOUT_PROPERTIES, 107 XML_HEADER_FOOTER_PROPERTIES, 108 XML_TEXT_PROPERTIES, 109 XML_PARAGRAPH_PROPERTIES, 110 XML_RUBY_PROPERTIES, 111 XML_SECTION_PROPERTIES, 112 XML_TABLE_PROPERTIES, 113 XML_TABLE_COLUMN_PROPERTIES, 114 XML_TABLE_ROW_PROPERTIES, 115 XML_TABLE_CELL_PROPERTIES, 116 XML_LIST_LEVEL_PROPERTIES, 117 XML_CHART_PROPERTIES 118 }; 119 120 static sal_uInt16 aAttrActionMaps[XML_PROP_TYPE_END] = 121 { 122 PROP_OOO_GRAPHIC_ATTR_ACTIONS, 123 PROP_OOO_DRAWING_PAGE_ATTR_ACTIONS, // DRAWING_PAGE 124 PROP_OOO_PAGE_LAYOUT_ATTR_ACTIONS, 125 PROP_OOO_HEADER_FOOTER_ATTR_ACTIONS, 126 PROP_OOO_TEXT_ATTR_ACTIONS, 127 PROP_OOO_PARAGRAPH_ATTR_ACTIONS, 128 MAX_OOO_PROP_ACTIONS, // RUBY 129 PROP_OOO_SECTION_ATTR_ACTIONS, 130 PROP_OOO_TABLE_ATTR_ACTIONS, 131 PROP_OOO_TABLE_COLUMN_ATTR_ACTIONS, 132 PROP_OOO_TABLE_ROW_ATTR_ACTIONS, 133 PROP_OOO_TABLE_CELL_ATTR_ACTIONS, 134 PROP_OOO_LIST_LEVEL_ATTR_ACTIONS, 135 PROP_OOO_CHART_ATTR_ACTIONS 136 }; 137 138 static sal_uInt16 aElemActionMaps[XML_PROP_TYPE_END] = 139 { 140 PROP_OOO_GRAPHIC_ELEM_ACTIONS, 141 MAX_OOO_PROP_ACTIONS, 142 MAX_OOO_PROP_ACTIONS, 143 MAX_OOO_PROP_ACTIONS, 144 PROP_OOO_TEXT_ELEM_ACTIONS, 145 PROP_OOO_PARAGRAPH_ELEM_ACTIONS, 146 MAX_OOO_PROP_ACTIONS, 147 MAX_OOO_PROP_ACTIONS, 148 MAX_OOO_PROP_ACTIONS, 149 MAX_OOO_PROP_ACTIONS, 150 MAX_OOO_PROP_ACTIONS, 151 PROP_OOO_TABLE_CELL_ELEM_ACTIONS, 152 MAX_OOO_PROP_ACTIONS, 153 PROP_OOO_CHART_ELEM_ACTIONS 154 }; 155 156 157 //------------------------------------------------------------------------------ 158 159 class XMLTypedPropertiesOOoTContext_Impl : public XMLPersElemContentTContext 160 { 161 ::com::sun::star::uno::Reference< 162 ::com::sun::star::xml::sax::XAttributeList > m_xAttrList; 163 164 public: 165 166 TYPEINFO(); 167 168 XMLTypedPropertiesOOoTContext_Impl( XMLTransformerBase& rTransformer, 169 const ::rtl::OUString& rQName ); 170 171 virtual ~XMLTypedPropertiesOOoTContext_Impl(); 172 173 using XMLPersAttrListTContext::AddAttribute; 174 void AddAttribute( const ::rtl::OUString &sName , 175 const ::rtl::OUString &sValue ); 176 void AddAttribute( sal_uInt16 nPrefix, XMLTokenEnum eToken, 177 const ::rtl::OUString &sValue ); 178 179 virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& rAttrList ); 180 181 virtual void Export(); 182 }; 183 184 TYPEINIT1( XMLTypedPropertiesOOoTContext_Impl, XMLPersElemContentTContext ); 185 186 XMLTypedPropertiesOOoTContext_Impl::XMLTypedPropertiesOOoTContext_Impl( 187 XMLTransformerBase& rImp, 188 const OUString& rQName ) : 189 XMLPersElemContentTContext( rImp, rQName ), 190 m_xAttrList( new XMLMutableAttributeList() ) 191 { 192 } 193 194 XMLTypedPropertiesOOoTContext_Impl::~XMLTypedPropertiesOOoTContext_Impl() 195 { 196 } 197 198 void XMLTypedPropertiesOOoTContext_Impl::AddAttribute( 199 const ::rtl::OUString &sName , 200 const ::rtl::OUString &sValue ) 201 { 202 static_cast< XMLMutableAttributeList * >( m_xAttrList.get() ) 203 ->AddAttribute( sName, sValue ); 204 } 205 206 void XMLTypedPropertiesOOoTContext_Impl::AddAttribute( 207 sal_uInt16 nPrefix, XMLTokenEnum eToken, 208 const ::rtl::OUString &sValue ) 209 { 210 OUString sName( 211 GetTransformer().GetNamespaceMap().GetQNameByKey( 212 nPrefix, ::xmloff::token::GetXMLToken( eToken ) ) ); 213 static_cast< XMLMutableAttributeList * >( m_xAttrList.get() ) 214 ->AddAttribute( sName, sValue ); 215 } 216 217 void XMLTypedPropertiesOOoTContext_Impl::StartElement( 218 const Reference< XAttributeList >& ) 219 { 220 // empty, ignore even the attribute list 221 } 222 223 void XMLTypedPropertiesOOoTContext_Impl::Export() 224 { 225 if( m_xAttrList->getLength() || HasElementContent() ) 226 { 227 GetTransformer().GetDocHandler()->startElement( GetQName(), m_xAttrList ); 228 ExportContent(); 229 GetTransformer().GetDocHandler()->endElement( GetQName() ); 230 } 231 } 232 233 //------------------------------------------------------------------------------ 234 235 class XMLPropertiesOOoTContext_Impl : public XMLTransformerContext 236 { 237 ::rtl::Reference < XMLTypedPropertiesOOoTContext_Impl > 238 m_aPropContexts[MAX_PROP_TYPES]; 239 240 typedef XMLPropType XMLPropTypes[MAX_PROP_TYPES]; 241 242 XMLPropTypes m_aPropTypes; 243 244 sal_Bool m_bPersistent; 245 246 XMLTypedPropertiesOOoTContext_Impl *GetPropContextAndAction( 247 TransformerAction_Impl& rAction, 248 sal_uInt16 nPrefix, const OUString& rLocalName, 249 sal_Bool bElem ); 250 251 XMLTypedPropertiesOOoTContext_Impl *GetPropContext( 252 XMLPropType eType ); 253 254 255 public: 256 257 TYPEINFO(); 258 259 XMLPropertiesOOoTContext_Impl( XMLTransformerBase& rTransformer, 260 const ::rtl::OUString& rQName, 261 XMLPropTypes& rTypes, 262 sal_Bool bPersistent ); 263 264 virtual ~XMLPropertiesOOoTContext_Impl(); 265 266 XMLTransformerContext *CreateChildContext( 267 sal_uInt16 nPrefix, 268 const OUString& rLocalName, 269 const OUString& rQName, 270 const Reference< XAttributeList >& rAttrList ); 271 272 virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& rAttrList ); 273 274 virtual void EndElement(); 275 276 virtual void Characters( const ::rtl::OUString& rChars ); 277 278 virtual void Export(); 279 280 virtual sal_Bool IsPersistent() const; 281 }; 282 283 TYPEINIT1( XMLPropertiesOOoTContext_Impl, XMLTransformerContext ); 284 285 XMLTypedPropertiesOOoTContext_Impl 286 *XMLPropertiesOOoTContext_Impl::GetPropContext( 287 XMLPropType eType ) 288 { 289 sal_uInt16 nIndex = MAX_PROP_TYPES; 290 for( sal_uInt16 i=0; i< MAX_PROP_TYPES; i++ ) 291 { 292 if( m_aPropTypes[i] == eType ) 293 { 294 nIndex = i; 295 break; 296 } 297 } 298 if( MAX_PROP_TYPES == nIndex ) 299 return 0; 300 301 if( !m_aPropContexts[nIndex].is() ) 302 { 303 m_aPropContexts[nIndex] = 304 new XMLTypedPropertiesOOoTContext_Impl( 305 GetTransformer(), 306 GetTransformer().GetNamespaceMap().GetQNameByKey( 307 XML_NAMESPACE_STYLE, 308 ::xmloff::token::GetXMLToken( 309 aPropTokens[m_aPropTypes[nIndex]] ) )); 310 } 311 312 return m_aPropContexts[nIndex].get(); 313 } 314 315 316 XMLTypedPropertiesOOoTContext_Impl 317 *XMLPropertiesOOoTContext_Impl::GetPropContextAndAction( 318 TransformerAction_Impl& rAction, 319 sal_uInt16 nPrefix, const OUString& rLocalName, 320 sal_Bool bElem ) 321 { 322 rAction.m_nActionType = XML_ATACTION_COPY; 323 sal_uInt16 nIndex = 0; 324 325 XMLTransformerActions::key_type aKey( nPrefix, rLocalName ); 326 sal_uInt16 i=0; 327 while( i < MAX_PROP_TYPES && XML_PROP_TYPE_END!=m_aPropTypes[i]) 328 { 329 sal_uInt16 nActionMap = 330 (bElem ? aElemActionMaps : aAttrActionMaps)[m_aPropTypes[i]]; 331 if( nActionMap < MAX_OOO_PROP_ACTIONS ) 332 { 333 XMLTransformerActions *pActions = 334 GetTransformer().GetUserDefinedActions( nActionMap ); 335 OSL_ENSURE( pActions, "go no actions" ); 336 if( pActions ) 337 { 338 XMLTransformerActions::const_iterator aIter = 339 pActions->find( aKey ); 340 341 if( !(aIter == pActions->end()) ) 342 { 343 rAction = (*aIter).second; 344 nIndex = i; 345 break; 346 } 347 } 348 } 349 ++i; 350 } 351 352 #ifdef DBG_UTIL 353 if( !( XML_NAMESPACE_NONE == nPrefix || 354 (XML_NAMESPACE_UNKNOWN_FLAG & nPrefix) || 355 XML_PROP_TYPE_END==m_aPropTypes[1] || 356 (i<MAX_PROP_TYPES && XML_PROP_TYPE_END!=m_aPropTypes[i]) ) ) 357 { 358 ::rtl::OString aTmp("Didnt't find property: "); 359 const ::rtl::OUString& rPrefix = 360 GetTransformer().GetNamespaceMap().GetPrefixByKey( nPrefix ); 361 aTmp += ::rtl::OString( rPrefix.getStr(), rPrefix.getLength(), 362 RTL_TEXTENCODING_ASCII_US ); 363 aTmp += ::rtl::OString::valueOf( ':' ); 364 aTmp += ::rtl::OString( rLocalName.getStr(), rLocalName.getLength(), 365 RTL_TEXTENCODING_ASCII_US ); 366 aTmp += ::rtl::OString(", assuming <style:"); 367 const ::rtl::OUString& rName = 368 ::xmloff::token::GetXMLToken( aPropTokens[m_aPropTypes[0]] ); 369 aTmp += ::rtl::OString( rName.getStr(), rName.getLength(), 370 RTL_TEXTENCODING_ASCII_US ); 371 aTmp += ::rtl::OString::valueOf( '>' ); 372 373 OSL_ENSURE( !this, aTmp ); 374 } 375 #endif 376 377 if( !m_aPropContexts[nIndex].is() ) 378 { 379 m_aPropContexts[nIndex] = 380 new XMLTypedPropertiesOOoTContext_Impl( 381 GetTransformer(), 382 GetTransformer().GetNamespaceMap().GetQNameByKey( 383 XML_NAMESPACE_STYLE, 384 ::xmloff::token::GetXMLToken( 385 aPropTokens[m_aPropTypes[nIndex]] ) )); 386 } 387 388 return m_aPropContexts[nIndex].get(); 389 } 390 391 XMLPropertiesOOoTContext_Impl::XMLPropertiesOOoTContext_Impl( 392 XMLTransformerBase& rImp, 393 const OUString& rQName, 394 XMLPropTypes& rTypes, 395 sal_Bool bPersistent ) : 396 XMLTransformerContext( rImp, rQName ), 397 m_bPersistent( bPersistent ) 398 { 399 for( sal_uInt16 i=0; i < MAX_PROP_TYPES; ++i ) 400 { 401 // remember the types that belong to the attribute and element lists 402 m_aPropTypes[i] = rTypes[i]; 403 } 404 } 405 406 XMLPropertiesOOoTContext_Impl::~XMLPropertiesOOoTContext_Impl() 407 { 408 } 409 410 XMLTransformerContext *XMLPropertiesOOoTContext_Impl::CreateChildContext( 411 sal_uInt16 nPrefix, 412 const OUString& rLocalName, 413 const OUString& rQName, 414 const Reference< XAttributeList >& rAttrList ) 415 { 416 TransformerAction_Impl aAction; 417 return GetPropContextAndAction( aAction, nPrefix, rLocalName, sal_True ) 418 ->CreateChildContext( nPrefix, rLocalName, rQName, rAttrList ); 419 } 420 421 422 void XMLPropertiesOOoTContext_Impl::StartElement( 423 const Reference< XAttributeList >& rAttrList ) 424 { 425 Reference< XAttributeList > xAttrList( rAttrList ); 426 427 XMLTypedPropertiesOOoTContext_Impl * pIntervalMinorDivisorContext = 0; 428 double fIntervalMajor = 0.0; 429 double fIntervalMinor = 0.0; 430 sal_Bool bMoveProtect = sal_False; 431 sal_Bool bSizeProtect = sal_False; 432 OUString aProtectAttrValue; 433 XMLTypedPropertiesOOoTContext_Impl * pProtectContext = 0; 434 435 // --> OD 2005-05-13 #i49139# - attribute <style:mirror> has to be priority 436 // over attribute <style:draw>. The filter from OpenDocument file format 437 // to OpenOffice.org file format produces styles with both attributes. 438 sal_Bool bExistStyleMirror( sal_False ); 439 OUString aStyleMirrorAttrValue; 440 sal_Bool bExistDrawMirror( sal_False ); 441 OUString aDrawMirrorAttrValue; 442 XMLTypedPropertiesOOoTContext_Impl* pMirrorContext( 0L ); 443 // <-- 444 445 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 446 for( sal_Int16 i=0; i < nAttrCount; i++ ) 447 { 448 const OUString sAttrName = xAttrList->getNameByIndex( i ); 449 const OUString sAttrValue = xAttrList->getValueByIndex( i ); 450 OUString aLocalName; 451 sal_uInt16 nPrefix = 452 GetTransformer().GetNamespaceMap().GetKeyByAttrName( sAttrName, 453 &aLocalName ); 454 TransformerAction_Impl aAction; 455 XMLTypedPropertiesOOoTContext_Impl *pContext = 456 GetPropContextAndAction( aAction, nPrefix, aLocalName, sal_False ); 457 switch( aAction.m_nActionType ) 458 { 459 case XML_ATACTION_REMOVE: 460 break; 461 case XML_ATACTION_COPY: 462 pContext->AddAttribute( sAttrName, sAttrValue ); 463 break; 464 case XML_ATACTION_COPY_DUPLICATE: 465 { 466 pContext->AddAttribute( sAttrName, sAttrValue ); 467 XMLTypedPropertiesOOoTContext_Impl *pContext2 = 468 GetPropContext( (XMLPropType)aAction.m_nParam1 ); 469 if( pContext2 ) 470 pContext2->AddAttribute( sAttrName, sAttrValue ); 471 } 472 break; 473 case XML_ATACTION_RENAME: 474 { 475 pContext->AddAttribute( aAction.GetQNamePrefixFromParam1(), 476 aAction.GetQNameTokenFromParam1(), 477 sAttrValue ); 478 } 479 break; 480 case XML_ATACTION_ENCODE_STYLE_NAME_REF: 481 { 482 OUString aAttrValue( sAttrValue ); 483 GetTransformer().EncodeStyleName(aAttrValue); 484 pContext->AddAttribute( sAttrName, aAttrValue ); 485 } 486 break; 487 case XML_ATACTION_RENAME_ENCODE_STYLE_NAME_REF: 488 { 489 OUString aAttrValue( sAttrValue ); 490 GetTransformer().EncodeStyleName(aAttrValue); 491 pContext->AddAttribute( aAction.GetQNamePrefixFromParam1(), 492 aAction.GetQNameTokenFromParam1(), 493 aAttrValue ); 494 } 495 break; 496 case XML_ATACTION_NEG_PERCENT: 497 { 498 OUString aAttrValue( sAttrValue ); 499 GetTransformer().NegPercent(aAttrValue); 500 pContext->AddAttribute( sAttrName, aAttrValue ); 501 } 502 break; 503 case XML_ATACTION_RENAME_NEG_PERCENT: 504 { 505 OUString aAttrValue( sAttrValue ); 506 GetTransformer().NegPercent(aAttrValue); 507 pContext->AddAttribute( aAction.GetQNamePrefixFromParam1(), 508 aAction.GetQNameTokenFromParam1(), 509 aAttrValue ); 510 } 511 break; 512 case XML_ATACTION_INCH2IN: 513 { 514 OUString aAttrValue( sAttrValue ); 515 XMLTransformerBase::ReplaceSingleInchWithIn( aAttrValue ); 516 pContext->AddAttribute( sAttrName, aAttrValue ); 517 } 518 break; 519 case XML_ATACTION_INCH2IN_DUPLICATE: 520 { 521 OUString aAttrValue( sAttrValue ); 522 XMLTransformerBase::ReplaceSingleInchWithIn( aAttrValue ); 523 pContext->AddAttribute( sAttrName, aAttrValue ); 524 XMLTypedPropertiesOOoTContext_Impl *pContext2 = 525 GetPropContext( (XMLPropType)aAction.m_nParam1 ); 526 if( pContext2 ) 527 pContext2->AddAttribute( sAttrName, aAttrValue ); 528 } 529 break; 530 case XML_ATACTION_INCHS2INS: 531 { 532 OUString aAttrValue( sAttrValue ); 533 XMLTransformerBase::ReplaceInchWithIn( aAttrValue ); 534 pContext->AddAttribute( sAttrName, aAttrValue ); 535 } 536 break; 537 case XML_PTACTION_LINE_MODE: 538 { 539 OUString aAttrValue( GetXMLToken( 540 IsXMLToken( sAttrValue, XML_TRUE ) 541 ? XML_CONTINUOUS 542 : XML_SKIP_WHITE_SPACE) ); 543 OUString aAttrQName( 544 GetTransformer().GetNamespaceMap().GetQNameByKey( 545 XML_NAMESPACE_STYLE, 546 GetXMLToken( XML_TEXT_UNDERLINE_MODE ) ) ); 547 pContext->AddAttribute( aAttrQName, aAttrValue ); 548 549 aAttrQName = 550 GetTransformer().GetNamespaceMap().GetQNameByKey( 551 XML_NAMESPACE_STYLE, 552 GetXMLToken( XML_TEXT_LINE_THROUGH_MODE ) ); 553 pContext->AddAttribute( aAttrQName, aAttrValue ); 554 } 555 break; 556 case XML_PTACTION_KEEP_WITH_NEXT: 557 { 558 OUString aAttrValue( GetXMLToken( 559 IsXMLToken( sAttrValue, XML_TRUE ) 560 ? XML_ALWAYS 561 : XML_AUTO) ); 562 pContext->AddAttribute( sAttrName, aAttrValue ); 563 } 564 break; 565 case XML_PTACTION_UNDERLINE: 566 { 567 XMLTokenEnum eToken = GetTransformer().GetToken( sAttrValue ); 568 sal_Bool bBold = sal_False, bDouble = sal_False; 569 switch( eToken ) 570 { 571 case XML_SINGLE: 572 eToken = XML_SOLID; 573 break; 574 case XML_DOUBLE: 575 eToken = XML_SOLID; 576 bDouble = sal_True; 577 break; 578 case XML_BOLD: 579 eToken = XML_SOLID; 580 bBold = sal_True; 581 break; 582 case XML_BOLD_DOTTED: 583 eToken = XML_DOTTED; 584 bBold = sal_True; 585 break; 586 case XML_BOLD_DASH: 587 eToken = XML_DASH; 588 bBold = sal_True; 589 break; 590 case XML_BOLD_LONG_DASH: 591 eToken = XML_LONG_DASH; 592 bBold = sal_True; 593 break; 594 case XML_BOLD_DOT_DASH: 595 eToken = XML_DOT_DASH; 596 bBold = sal_True; 597 break; 598 case XML_BOLD_DOT_DOT_DASH: 599 eToken = XML_DOT_DOT_DASH; 600 bBold = sal_True; 601 break; 602 case XML_BOLD_WAVE: 603 eToken = XML_WAVE; 604 bBold = sal_True; 605 break; 606 case XML_DOUBLE_WAVE: 607 eToken = XML_WAVE; 608 bDouble = sal_True; 609 break; 610 case XML_NONE: 611 eToken = XML_NONE; 612 bDouble = sal_False; 613 break; 614 default: 615 OSL_ENSURE( false, "xmloff::XMLPropertiesOOoTContext_Impl::StartElement(), unknown underline token!" ); 616 break; 617 } 618 pContext->AddAttribute( 619 GetTransformer().GetNamespaceMap().GetQNameByKey( 620 XML_NAMESPACE_STYLE, 621 GetXMLToken( XML_TEXT_UNDERLINE_STYLE ) ), 622 eToken != XML_TOKEN_END ? GetXMLToken( eToken ) 623 : sAttrValue ); 624 if( bDouble ) 625 pContext->AddAttribute( 626 GetTransformer().GetNamespaceMap().GetQNameByKey( 627 XML_NAMESPACE_STYLE, 628 GetXMLToken( XML_TEXT_UNDERLINE_TYPE ) ), 629 GetXMLToken( XML_DOUBLE ) ); 630 if( bBold ) 631 pContext->AddAttribute( 632 GetTransformer().GetNamespaceMap().GetQNameByKey( 633 XML_NAMESPACE_STYLE, 634 GetXMLToken( XML_TEXT_UNDERLINE_WIDTH ) ), 635 GetXMLToken( XML_BOLD ) ); 636 } 637 break; 638 case XML_PTACTION_LINETHROUGH: 639 { 640 XMLTokenEnum eToken = GetTransformer().GetToken( sAttrValue ); 641 sal_Bool bBold = sal_False, bDouble = sal_False; 642 sal_Unicode c = 0; 643 switch( eToken ) 644 { 645 case XML_SINGLE_LINE: 646 eToken = XML_SOLID; 647 break; 648 case XML_DOUBLE_LINE: 649 eToken = XML_SOLID; 650 bDouble = sal_True; 651 break; 652 case XML_THICK_LINE: 653 eToken = XML_SOLID; 654 bBold = sal_True; 655 break; 656 case XML_SLASH: 657 eToken = XML_SOLID; 658 c = '/'; 659 break; 660 case XML_uX: 661 eToken = XML_SOLID; 662 c = 'X'; 663 break; 664 default: 665 break; 666 } 667 pContext->AddAttribute( 668 GetTransformer().GetNamespaceMap().GetQNameByKey( 669 XML_NAMESPACE_STYLE, 670 GetXMLToken( XML_TEXT_LINE_THROUGH_STYLE ) ), 671 eToken != XML_TOKEN_END ? GetXMLToken( eToken ) 672 : sAttrValue ); 673 if( bDouble ) 674 pContext->AddAttribute( 675 GetTransformer().GetNamespaceMap().GetQNameByKey( 676 XML_NAMESPACE_STYLE, 677 GetXMLToken( XML_TEXT_LINE_THROUGH_TYPE ) ), 678 GetXMLToken( XML_DOUBLE ) ); 679 if( bBold ) 680 pContext->AddAttribute( 681 GetTransformer().GetNamespaceMap().GetQNameByKey( 682 XML_NAMESPACE_STYLE, 683 GetXMLToken( XML_TEXT_LINE_THROUGH_WIDTH ) ), 684 GetXMLToken( XML_BOLD ) ); 685 if( c ) 686 pContext->AddAttribute( 687 GetTransformer().GetNamespaceMap().GetQNameByKey( 688 XML_NAMESPACE_STYLE, 689 GetXMLToken( XML_TEXT_LINE_THROUGH_TEXT ) ), 690 OUString::valueOf( c ) ); 691 } 692 break; 693 case XML_PTACTION_SPLINES: 694 { 695 sal_Int32 nSplineType = sAttrValue.toInt32(); 696 OUString aNewAttrName = GetTransformer().GetNamespaceMap().GetQNameByKey( 697 XML_NAMESPACE_CHART, GetXMLToken( XML_INTERPOLATION ) ); 698 699 switch( nSplineType ) 700 { 701 // straight lines 702 case 0: 703 pContext->AddAttribute( 704 aNewAttrName, GetXMLToken( XML_NONE )); 705 break; 706 // cubic spline 707 case 1: 708 pContext->AddAttribute( 709 aNewAttrName, GetXMLToken( XML_CUBIC_SPLINE )); 710 break; 711 // B-spline 712 case 2: 713 pContext->AddAttribute( 714 aNewAttrName, GetXMLToken( XML_B_SPLINE )); 715 break; 716 717 default: 718 OSL_ENSURE( false, "invalid spline type" ); 719 pContext->AddAttribute( 720 aNewAttrName, GetXMLToken( XML_NONE )); 721 break; 722 } 723 } 724 break; 725 case XML_PTACTION_INTERVAL_MAJOR: 726 pContext->AddAttribute( sAttrName, sAttrValue ); 727 SvXMLUnitConverter::convertDouble( fIntervalMajor, sAttrValue ); 728 break; 729 case XML_PTACTION_INTERVAL_MINOR: 730 SvXMLUnitConverter::convertDouble( fIntervalMinor, sAttrValue ); 731 pIntervalMinorDivisorContext = pContext; 732 break; 733 case XML_PTACTION_SYMBOL: 734 { 735 sal_Int32 nSymbolType = sAttrValue.toInt32(); 736 OUString aNewAttrName = GetTransformer().GetNamespaceMap().GetQNameByKey( 737 XML_NAMESPACE_CHART, GetXMLToken( XML_SYMBOL_TYPE ) ); 738 739 if( nSymbolType >= 0 ) 740 { 741 pContext->AddAttribute( aNewAttrName, GetXMLToken( XML_NAMED_SYMBOL )); 742 enum XMLTokenEnum eToken = XML_TOKEN_INVALID; 743 switch( nSymbolType ) 744 { 745 // SYMBOL0 746 case 0: 747 // "square" has an awkward token name 748 eToken = XML_GRADIENTSTYLE_SQUARE; 749 break; 750 // SYMBOL1 751 case 1: 752 eToken = XML_DIAMOND; 753 break; 754 // SYMBOL2 755 case 2: 756 eToken = XML_ARROW_DOWN; 757 break; 758 // SYMBOL3 759 case 3: 760 eToken = XML_ARROW_UP; 761 break; 762 // SYMBOL4 763 case 4: 764 eToken = XML_ARROW_RIGHT; 765 break; 766 // SYMBOL5 767 case 5: 768 eToken = XML_ARROW_LEFT; 769 break; 770 // SYMBOL6 771 case 6: 772 eToken = XML_BOW_TIE; 773 break; 774 // SYMBOL7 775 case 7: 776 eToken = XML_HOURGLASS; 777 break; 778 default: 779 OSL_ENSURE( false, "invalid named symbol" ); 780 break; 781 } 782 783 if( eToken != XML_TOKEN_INVALID ) 784 { 785 pContext->AddAttribute( GetTransformer().GetNamespaceMap().GetQNameByKey( 786 XML_NAMESPACE_CHART, GetXMLToken( XML_SYMBOL_NAME )), 787 GetXMLToken( eToken )); 788 } 789 } 790 else 791 { 792 switch( nSymbolType ) 793 { 794 // NONE 795 case -3: 796 pContext->AddAttribute( 797 aNewAttrName, GetXMLToken( XML_NONE )); 798 break; 799 // AUTO 800 case -2: 801 pContext->AddAttribute( 802 aNewAttrName, GetXMLToken( XML_AUTOMATIC )); 803 break; 804 // BITMAPURL 805 case -1: 806 pContext->AddAttribute( 807 aNewAttrName, GetXMLToken( XML_IMAGE )); 808 break; 809 default: 810 OSL_ENSURE( false, "invalid symbol type" ); 811 pContext->AddAttribute( 812 aNewAttrName, GetXMLToken( XML_NONE )); 813 break; 814 } 815 } 816 } 817 break; 818 case XML_PTACTION_SYMBOL_IMAGE_NAME: 819 { 820 // create an xlink:href element for URI attribute 821 XMLPersAttrListTContext *pSymbolImageContext = new XMLPersAttrListTContext( 822 GetTransformer(), GetTransformer().GetNamespaceMap().GetQNameByKey( 823 XML_NAMESPACE_CHART, GetXMLToken( XML_SYMBOL_IMAGE ))); 824 825 OUString aAttrValue( sAttrValue ); 826 if( GetTransformer().ConvertURIToOASIS( aAttrValue, sal_True )) 827 { 828 pSymbolImageContext->AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, aAttrValue ); 829 pContext->AddContent( pSymbolImageContext ); 830 } 831 } 832 break; 833 834 // #i25616# 835 case XML_PTACTION_TRANSPARENCY : 836 { 837 OUString aAttrValue( sAttrValue ); 838 GetTransformer().NegPercent(aAttrValue); 839 pContext->AddAttribute( XML_NAMESPACE_DRAW, 840 XML_OPACITY, 841 aAttrValue ); 842 pContext->AddAttribute( XML_NAMESPACE_DRAW, 843 XML_IMAGE_OPACITY, 844 aAttrValue ); 845 } 846 break; 847 848 case XML_PTACTION_BREAK_INSIDE: 849 { 850 pContext->AddAttribute( 851 XML_NAMESPACE_FO, XML_KEEP_TOGETHER, 852 GetXMLToken( 853 IsXMLToken( sAttrValue, XML_COLUMNSPLIT_AVOID ) 854 ? XML_ALWAYS 855 : XML_AUTO ) ); 856 } 857 break; 858 case XML_ATACTION_CAPTION_ESCAPE_OOO: 859 { 860 OUString aAttrValue( sAttrValue ); 861 if( aAttrValue.indexOf( sal_Unicode('%') ) != -1 ) 862 { 863 sal_Int32 nValue = 0; 864 SvXMLUnitConverter::convertPercent( nValue, sAttrValue ); 865 if( nValue ) 866 { 867 nValue /= 100; 868 rtl::OUStringBuffer aOut; 869 SvXMLUnitConverter::convertPercent( aOut, nValue ); 870 aAttrValue = aOut.makeStringAndClear(); 871 } 872 } 873 else 874 { 875 XMLTransformerBase::ReplaceSingleInchWithIn( aAttrValue ); 876 } 877 878 pContext->AddAttribute( sAttrName, aAttrValue ); 879 } 880 break; 881 case XML_ATACTION_MOVE_PROTECT: 882 bMoveProtect = IsXMLToken( sAttrValue, XML_TRUE ); 883 pProtectContext = pContext; 884 break; 885 case XML_ATACTION_SIZE_PROTECT: 886 bSizeProtect = IsXMLToken( sAttrValue, XML_TRUE ); 887 pProtectContext = pContext; 888 break; 889 case XML_ATACTION_PROTECT: 890 aProtectAttrValue = sAttrValue; 891 pProtectContext = pContext; 892 break; 893 case XML_ATACTION_DRAW_MIRROR_OOO: // renames draw:mirror to style:mirror and adapts values 894 { 895 // --> OD 2005-05-13 #i49139# 896 aDrawMirrorAttrValue = 897 GetXMLToken( IsXMLToken( sAttrValue, XML_TRUE ) 898 ? XML_HORIZONTAL : XML_NONE ); 899 bExistDrawMirror = sal_True; 900 pMirrorContext = pContext; 901 // <-- 902 } 903 break; 904 // --> OD 2005-05-12 #i49139# 905 case XML_ATACTION_STYLE_MIRROR_OOO: // adapts style:mirror values 906 { 907 SvXMLTokenEnumerator aTokenEnum( sAttrValue ); 908 OUString aToken; 909 while( aTokenEnum.getNextToken( aToken ) ) 910 { 911 if ( aStyleMirrorAttrValue.getLength() > 0 ) 912 { 913 aStyleMirrorAttrValue += rtl::OUString::createFromAscii( " " ); 914 } 915 916 if ( IsXMLToken( aToken, XML_HORIZONTAL_ON_LEFT_PAGES ) ) 917 { 918 aStyleMirrorAttrValue += GetXMLToken( XML_HORIZONTAL_ON_EVEN ); 919 } 920 else if ( IsXMLToken( aToken, XML_HORIZONTAL_ON_RIGHT_PAGES ) ) 921 { 922 aStyleMirrorAttrValue += GetXMLToken( XML_HORIZONTAL_ON_ODD ); 923 } 924 else 925 { 926 aStyleMirrorAttrValue += aToken; 927 } 928 } 929 bExistStyleMirror = sal_True; 930 pMirrorContext = pContext; 931 } 932 break; 933 // <-- 934 case XML_ATACTION_GAMMA_OOO: // converts double value to percentage 935 { 936 double fValue = sAttrValue.toDouble(); 937 sal_Int32 nValue = (sal_Int32)((fValue * 100.0) + ( fValue > 0 ? 0.5 : - 0.5 ) ); 938 939 rtl::OUStringBuffer aOut; 940 SvXMLUnitConverter::convertPercent( aOut, nValue ); 941 OUString aAttrValue( aOut.makeStringAndClear() ); 942 pContext->AddAttribute( sAttrName, aAttrValue ); 943 } 944 break; 945 case XML_ATACTION_OPACITY_FIX: 946 { 947 sal_Int32 nValue; 948 if( sAttrValue.indexOf( sal_Unicode('%') ) != -1 ) 949 { 950 SvXMLUnitConverter::convertPercent( nValue, sAttrValue ); 951 } 952 else 953 { 954 nValue = sal_Int32( sAttrValue.toDouble() * 100.0 ); 955 } 956 nValue = 100 - nValue; 957 958 rtl::OUStringBuffer aOut; 959 SvXMLUnitConverter::convertPercent( aOut, nValue ); 960 pContext->AddAttribute( sAttrName, aOut.makeStringAndClear() ); 961 } 962 break; 963 default: 964 OSL_ENSURE( !this, "unknown action" ); 965 break; 966 } 967 } 968 969 // --> OD 2005-05-13 #i49139# 970 if ( bExistStyleMirror ) 971 { 972 pMirrorContext->AddAttribute( 973 GetTransformer().GetNamespaceMap().GetQNameByKey( 974 XML_NAMESPACE_STYLE, GetXMLToken( XML_MIRROR ) ), 975 aStyleMirrorAttrValue); 976 } 977 else if ( bExistDrawMirror ) 978 { 979 pMirrorContext->AddAttribute( 980 GetTransformer().GetNamespaceMap().GetQNameByKey( 981 XML_NAMESPACE_STYLE, GetXMLToken( XML_MIRROR ) ), 982 aDrawMirrorAttrValue); 983 } 984 // <-- 985 986 if( bMoveProtect || bSizeProtect || aProtectAttrValue.getLength() ) 987 { 988 if( (bMoveProtect ||bSizeProtect) && IsXMLToken( aProtectAttrValue, XML_NONE ) ) 989 aProtectAttrValue = OUString(); 990 991 const OUString& rPosition = GetXMLToken( XML_POSITION ); 992 if( bMoveProtect && -1 == aProtectAttrValue.indexOf( rPosition ) ) 993 { 994 if( aProtectAttrValue.getLength() ) 995 aProtectAttrValue += OUString::valueOf( sal_Unicode( ' ' ) ); 996 aProtectAttrValue += rPosition; 997 } 998 999 const OUString& rSize = GetXMLToken( XML_SIZE ); 1000 if( bSizeProtect && -1 == aProtectAttrValue.indexOf( rSize ) ) 1001 { 1002 if( aProtectAttrValue.getLength() ) 1003 aProtectAttrValue += OUString::valueOf( sal_Unicode( ' ' ) ); 1004 aProtectAttrValue += rSize; 1005 } 1006 1007 pProtectContext->AddAttribute( GetTransformer().GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_STYLE, GetXMLToken( XML_PROTECT ) ), aProtectAttrValue ); 1008 } 1009 1010 if( pIntervalMinorDivisorContext ) 1011 { 1012 if( fIntervalMinor != 0.0 ) 1013 { 1014 sal_Int32 nIntervalMinorDivisor = static_cast< sal_Int32 >( 1015 ::rtl::math::round( fIntervalMajor / fIntervalMinor )); 1016 1017 ::rtl::OUStringBuffer aBuf; 1018 SvXMLUnitConverter::convertNumber( aBuf, nIntervalMinorDivisor ); 1019 pIntervalMinorDivisorContext->AddAttribute( 1020 GetTransformer().GetNamespaceMap().GetQNameByKey( 1021 XML_NAMESPACE_CHART, 1022 GetXMLToken( XML_INTERVAL_MINOR_DIVISOR )), 1023 aBuf.makeStringAndClear()); 1024 } 1025 } 1026 } 1027 1028 void XMLPropertiesOOoTContext_Impl::EndElement() 1029 { 1030 if( !m_bPersistent ) 1031 Export(); 1032 } 1033 1034 void XMLPropertiesOOoTContext_Impl::Characters( const OUString& ) 1035 { 1036 // ignore them 1037 } 1038 1039 void XMLPropertiesOOoTContext_Impl::Export() 1040 { 1041 1042 for( sal_uInt16 i=0; i < MAX_PROP_TYPES; i++ ) 1043 { 1044 if( m_aPropContexts[i].is() ) 1045 m_aPropContexts[i]->Export(); 1046 } 1047 } 1048 1049 sal_Bool XMLPropertiesOOoTContext_Impl::IsPersistent() const 1050 { 1051 return m_bPersistent; 1052 } 1053 1054 1055 //------------------------------------------------------------------------------ 1056 1057 TYPEINIT1( XMLStyleOOoTContext, XMLPersElemContentTContext ); 1058 1059 XMLStyleOOoTContext::XMLStyleOOoTContext( XMLTransformerBase& rImp, 1060 const OUString& rQName, 1061 XMLFamilyType eT, 1062 sal_Bool bPersistent ) : 1063 XMLPersElemContentTContext( rImp, rQName ), 1064 m_eFamily( eT ), 1065 m_bPersistent( bPersistent ) 1066 { 1067 } 1068 1069 XMLStyleOOoTContext::XMLStyleOOoTContext( 1070 XMLTransformerBase& rImp, 1071 const OUString& rQName, 1072 XMLFamilyType eT, 1073 sal_uInt16 nPrefix, 1074 ::xmloff::token::XMLTokenEnum eToken, 1075 sal_Bool bPersistent ) : 1076 XMLPersElemContentTContext( rImp, rQName, nPrefix, eToken ), 1077 m_eFamily( eT ), 1078 m_bPersistent( bPersistent ) 1079 { 1080 } 1081 1082 XMLStyleOOoTContext::~XMLStyleOOoTContext() 1083 { 1084 } 1085 1086 XMLTransformerContext *XMLStyleOOoTContext::CreateChildContext( 1087 sal_uInt16 nPrefix, 1088 const OUString& rLocalName, 1089 const OUString& rQName, 1090 const Reference< XAttributeList >& rAttrList ) 1091 { 1092 XMLTransformerContext *pContext = 0; 1093 1094 if( XML_NAMESPACE_STYLE == nPrefix && 1095 IsXMLToken( rLocalName, XML_PROPERTIES ) ) 1096 { 1097 if( aPropTypes[m_eFamily][0] == XML_PROP_TYPE_END ) 1098 { 1099 OSL_ENSURE( !this, "unexpected properties element" ); 1100 pContext = m_bPersistent 1101 ? XMLPersElemContentTContext::CreateChildContext( 1102 nPrefix, rLocalName, rQName, rAttrList ) 1103 : XMLTransformerContext::CreateChildContext( 1104 nPrefix, rLocalName, rQName, rAttrList ); 1105 } 1106 else if( aPropTypes[m_eFamily][1] == XML_PROP_TYPE_END ) 1107 { 1108 sal_uInt16 nActionMap = 1109 aAttrActionMaps[aPropTypes[m_eFamily][0]]; 1110 if( nActionMap < MAX_OOO_PROP_ACTIONS ) 1111 { 1112 pContext = new XMLPropertiesOOoTContext_Impl( 1113 GetTransformer(), rQName, 1114 aPropTypes[m_eFamily], m_bPersistent ); 1115 } 1116 else 1117 { 1118 if( m_bPersistent ) 1119 pContext = new XMLPersElemContentTContext( 1120 GetTransformer(), rQName, 1121 XML_NAMESPACE_STYLE, 1122 aPropTokens[aPropTypes[m_eFamily][0]] ); 1123 else 1124 pContext = new XMLRenameElemTransformerContext( 1125 GetTransformer(), rQName, 1126 XML_NAMESPACE_STYLE, 1127 aPropTokens[aPropTypes[m_eFamily][0]] ); 1128 } 1129 } 1130 else 1131 { 1132 pContext = new XMLPropertiesOOoTContext_Impl( 1133 GetTransformer(), rQName, 1134 aPropTypes[m_eFamily], m_bPersistent); 1135 } 1136 1137 if( m_bPersistent ) 1138 AddContent( pContext ); 1139 } 1140 else 1141 { 1142 pContext = m_bPersistent 1143 ? XMLPersElemContentTContext::CreateChildContext( 1144 nPrefix, rLocalName, rQName, rAttrList ) 1145 : XMLTransformerContext::CreateChildContext( 1146 nPrefix, rLocalName, rQName, rAttrList ); 1147 } 1148 1149 return pContext; 1150 } 1151 1152 void XMLStyleOOoTContext::StartElement( 1153 const Reference< XAttributeList >& rAttrList ) 1154 { 1155 XMLTransformerActions *pActions = 1156 GetTransformer().GetUserDefinedActions( OOO_STYLE_ACTIONS ); 1157 OSL_ENSURE( pActions, "go no actions" ); 1158 1159 Reference< XAttributeList > xAttrList( rAttrList ); 1160 XMLMutableAttributeList *pMutableAttrList = 0; 1161 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 1162 for( sal_Int16 i=0; i < nAttrCount; i++ ) 1163 { 1164 const OUString sAttrName = xAttrList->getNameByIndex( i ); 1165 OUString aLocalName; 1166 sal_uInt16 nPrefix = 1167 GetTransformer().GetNamespaceMap().GetKeyByAttrName( sAttrName, 1168 &aLocalName ); 1169 XMLTransformerActions::key_type aKey( nPrefix, aLocalName ); 1170 XMLTransformerActions::const_iterator aIter = 1171 pActions->find( aKey ); 1172 if( !(aIter == pActions->end() ) ) 1173 { 1174 if( !pMutableAttrList ) 1175 { 1176 pMutableAttrList = 1177 new XMLMutableAttributeList( xAttrList ); 1178 xAttrList = pMutableAttrList; 1179 } 1180 const OUString sAttrValue = xAttrList->getValueByIndex( i ); 1181 switch( (*aIter).second.m_nActionType ) 1182 { 1183 case XML_ATACTION_STYLE_FAMILY: 1184 { 1185 sal_Bool bControl = sal_False; 1186 if( XML_FAMILY_TYPE_END == m_eFamily ) 1187 { 1188 if( IsXMLToken( sAttrValue, XML_GRAPHICS ) ) 1189 m_eFamily = XML_FAMILY_TYPE_GRAPHIC; 1190 else if( IsXMLToken( sAttrValue, XML_PRESENTATION ) ) 1191 m_eFamily = XML_FAMILY_TYPE_PRESENTATION; 1192 else if( IsXMLToken( sAttrValue, XML_DRAWING_PAGE ) ) 1193 m_eFamily = XML_FAMILY_TYPE_DRAWING_PAGE; 1194 else if( IsXMLToken( sAttrValue, XML_TEXT) ) 1195 m_eFamily = XML_FAMILY_TYPE_TEXT; 1196 else if( IsXMLToken( sAttrValue, XML_PARAGRAPH) ) 1197 m_eFamily = XML_FAMILY_TYPE_PARAGRAPH; 1198 else if( IsXMLToken( sAttrValue, XML_RUBY) ) 1199 m_eFamily = XML_FAMILY_TYPE_RUBY; 1200 else if( IsXMLToken( sAttrValue, XML_SECTION) ) 1201 m_eFamily = XML_FAMILY_TYPE_SECTION; 1202 else if( IsXMLToken( sAttrValue, XML_TABLE) ) 1203 m_eFamily = XML_FAMILY_TYPE_TABLE; 1204 else if( IsXMLToken( sAttrValue, XML_TABLE_COLUMN) ) 1205 m_eFamily = XML_FAMILY_TYPE_TABLE_COLUMN; 1206 else if( IsXMLToken( sAttrValue, XML_TABLE_ROW) ) 1207 m_eFamily = XML_FAMILY_TYPE_TABLE_ROW; 1208 else if( IsXMLToken( sAttrValue, XML_TABLE_CELL) ) 1209 m_eFamily = XML_FAMILY_TYPE_TABLE_CELL; 1210 else if( IsXMLToken( sAttrValue, XML_CHART) ) 1211 m_eFamily = XML_FAMILY_TYPE_CHART; 1212 else if( IsXMLToken( sAttrValue, XML_CONTROL) ) 1213 { 1214 m_eFamily = XML_FAMILY_TYPE_PARAGRAPH; 1215 bControl = sal_True; 1216 } 1217 } 1218 if( XML_FAMILY_TYPE_GRAPHIC == m_eFamily ) 1219 { 1220 pMutableAttrList->SetValueByIndex( i, 1221 GetXMLToken( XML_GRAPHIC ) ); 1222 } 1223 else if( bControl ) 1224 { 1225 pMutableAttrList->SetValueByIndex( i, 1226 GetXMLToken( XML_PARAGRAPH ) ); 1227 } 1228 } 1229 break; 1230 case XML_ATACTION_INCH2IN: 1231 { 1232 OUString aAttrValue( sAttrValue ); 1233 if( XMLTransformerBase::ReplaceSingleInchWithIn( 1234 aAttrValue ) ) 1235 pMutableAttrList->SetValueByIndex( i, aAttrValue ); 1236 } 1237 break; 1238 case XML_ATACTION_ENCODE_STYLE_NAME: 1239 { 1240 OUString aAttrValue( sAttrValue ); 1241 if( GetTransformer().EncodeStyleName(aAttrValue) ) 1242 { 1243 pMutableAttrList->SetValueByIndex( i, aAttrValue ); 1244 OUString aNewAttrQName( 1245 GetTransformer().GetNamespaceMap(). 1246 GetQNameByKey( 1247 nPrefix, ::xmloff::token::GetXMLToken( 1248 XML_DISPLAY_NAME ) ) ); 1249 pMutableAttrList->AddAttribute( aNewAttrQName, 1250 sAttrValue ); 1251 } 1252 } 1253 break; 1254 case XML_ATACTION_ENCODE_STYLE_NAME_REF: 1255 { 1256 OUString aAttrValue( sAttrValue ); 1257 if( GetTransformer().EncodeStyleName(aAttrValue) ) 1258 pMutableAttrList->SetValueByIndex( i, aAttrValue ); 1259 } 1260 break; 1261 case XML_ATACTION_NEG_PERCENT: 1262 { 1263 OUString aAttrValue( sAttrValue ); 1264 if( GetTransformer().NegPercent(aAttrValue) ) 1265 pMutableAttrList->SetValueByIndex( i, aAttrValue ); 1266 } 1267 break; 1268 case XML_ATACTION_URI_OOO: 1269 { 1270 OUString aAttrValue( sAttrValue ); 1271 if( GetTransformer().ConvertURIToOASIS( aAttrValue, 1272 static_cast< sal_Bool >((*aIter).second.m_nParam1))) 1273 pMutableAttrList->SetValueByIndex( i, aAttrValue ); 1274 } 1275 break; 1276 default: 1277 OSL_ENSURE( !this, "unknown action" ); 1278 break; 1279 } 1280 } 1281 } 1282 if( XML_FAMILY_TYPE_END == m_eFamily ) 1283 m_eFamily = XML_FAMILY_TYPE_TEXT; 1284 if( m_bPersistent ) 1285 XMLPersElemContentTContext::StartElement( xAttrList ); 1286 else 1287 GetTransformer().GetDocHandler()->startElement( GetExportQName(), 1288 xAttrList ); 1289 } 1290 1291 void XMLStyleOOoTContext::EndElement() 1292 { 1293 if( m_bPersistent ) 1294 XMLPersElemContentTContext::EndElement(); 1295 else 1296 GetTransformer().GetDocHandler()->endElement( GetExportQName() ); 1297 } 1298 1299 void XMLStyleOOoTContext::Characters( const OUString& ) 1300 { 1301 // element content only: 1302 } 1303 1304 sal_Bool XMLStyleOOoTContext::IsPersistent() const 1305 { 1306 return m_bPersistent; 1307 } 1308 1309 XMLTransformerActions *XMLStyleOOoTContext::CreateTransformerActions( 1310 sal_uInt16 nType ) 1311 { 1312 XMLTransformerActionInit *pInit = 0; 1313 1314 switch( nType ) 1315 { 1316 case PROP_OOO_GRAPHIC_ATTR_ACTIONS: 1317 pInit = aGraphicPropertyOOoAttrActionTable; 1318 break; 1319 case PROP_OOO_GRAPHIC_ELEM_ACTIONS: 1320 pInit = aGraphicPropertyOOoElemActionTable; 1321 break; 1322 case PROP_OOO_DRAWING_PAGE_ATTR_ACTIONS: 1323 pInit = aDrawingPagePropertyOOoAttrActionTable; 1324 break; 1325 case PROP_OOO_PAGE_LAYOUT_ATTR_ACTIONS: 1326 pInit = aPageLayoutPropertyOOoAttrActionTable; 1327 break; 1328 case PROP_OOO_HEADER_FOOTER_ATTR_ACTIONS: 1329 pInit = aHeaderFooterPropertyOOoAttrActionTable; 1330 break; 1331 case PROP_OOO_TEXT_ATTR_ACTIONS: 1332 pInit = aTextPropertyOOoAttrActionTable; 1333 break; 1334 case PROP_OOO_TEXT_ELEM_ACTIONS: 1335 pInit = aTextPropertyOOoElemActionTable; 1336 break; 1337 case PROP_OOO_PARAGRAPH_ATTR_ACTIONS: 1338 pInit = aParagraphPropertyOOoAttrActionTable; 1339 break; 1340 case PROP_OOO_PARAGRAPH_ELEM_ACTIONS: 1341 pInit = aParagraphPropertyOOoElemActionTable; 1342 break; 1343 case PROP_OOO_SECTION_ATTR_ACTIONS: 1344 pInit = aSectionPropertyOOoAttrActionTable; 1345 break; 1346 case PROP_OOO_TABLE_ATTR_ACTIONS: 1347 pInit = aTablePropertyOOoAttrActionTable; 1348 break; 1349 case PROP_OOO_TABLE_COLUMN_ATTR_ACTIONS: 1350 pInit = aTableColumnPropertyOOoAttrActionTable; 1351 break; 1352 case PROP_OOO_TABLE_ROW_ATTR_ACTIONS: 1353 pInit = aTableRowPropertyOOoAttrActionTable; 1354 break; 1355 case PROP_OOO_TABLE_CELL_ATTR_ACTIONS: 1356 pInit = aTableCellPropertyOOoAttrActionTable; 1357 break; 1358 case PROP_OOO_TABLE_CELL_ELEM_ACTIONS: 1359 pInit = aTableCellPropertyOOoElemActionTable; 1360 break; 1361 case PROP_OOO_LIST_LEVEL_ATTR_ACTIONS: 1362 pInit = aListLevelPropertyOOoAttrActionTable; 1363 break; 1364 case PROP_OOO_CHART_ATTR_ACTIONS: 1365 pInit = aChartPropertyOOoAttrActionTable; 1366 break; 1367 case PROP_OOO_CHART_ELEM_ACTIONS: 1368 pInit = aChartPropertyOOoElemActionTable; 1369 break; 1370 } 1371 1372 XMLTransformerActions *pActions = 0; 1373 if( pInit ) 1374 pActions = new XMLTransformerActions( pInit ); 1375 1376 return pActions; 1377 } 1378