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 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_xmloff.hxx" 26 #include "unointerfacetouniqueidentifiermapper.hxx" 27 #include <rtl/ustring.hxx> 28 #include <rtl/ustrbuf.hxx> 29 #include <tools/debug.hxx> 30 31 #include <tools/string.hxx> 32 #include <svl/svarray.hxx> 33 #include <com/sun/star/text/XTextFrame.hpp> 34 #include <com/sun/star/text/XTextCursor.hpp> 35 #include <com/sun/star/beans/XPropertySet.hpp> 36 #include <com/sun/star/beans/XPropertySetInfo.hpp> 37 #include <com/sun/star/text/ControlCharacter.hpp> 38 #include <com/sun/star/container/XIndexReplace.hpp> 39 #include <com/sun/star/drawing/XShapes.hpp> 40 #include <com/sun/star/container/XEnumerationAccess.hpp> 41 #include <com/sun/star/rdf/XMetadatable.hpp> 42 43 44 #include <xmloff/xmlictxt.hxx> 45 #include <xmloff/xmlimp.hxx> 46 #include <xmloff/xmltoken.hxx> 47 #include <xmloff/nmspmap.hxx> 48 #include "xmloff/xmlnmspe.hxx" 49 #include <xmloff/txtimp.hxx> 50 #include "txtparai.hxx" 51 #include "txtfldi.hxx" 52 #include <xmloff/xmluconv.hxx> 53 #include "XMLFootnoteImportContext.hxx" 54 #include "XMLTextMarkImportContext.hxx" 55 #include "XMLTextFrameContext.hxx" 56 #include <xmloff/XMLCharContext.hxx> 57 #include "XMLTextFrameHyperlinkContext.hxx" 58 #include <xmloff/XMLEventsImportContext.hxx> 59 #include "XMLChangeImportContext.hxx" 60 #include "txtlists.hxx" 61 62 63 // OD 2004-04-21 #i26791# 64 #include <txtparaimphint.hxx> 65 typedef XMLHint_Impl *XMLHint_ImplPtr; 66 SV_DECL_PTRARR_DEL( XMLHints_Impl, XMLHint_ImplPtr, 5, 5 ) 67 SV_IMPL_PTRARR( XMLHints_Impl, XMLHint_ImplPtr ) 68 // OD 2004-04-21 #i26791# 69 #include <com/sun/star/beans/XPropertySet.hpp> 70 71 using ::rtl::OUString; 72 using ::rtl::OUStringBuffer; 73 74 using namespace ::com::sun::star; 75 using namespace ::com::sun::star::uno; 76 using namespace ::com::sun::star::text; 77 using namespace ::com::sun::star::drawing; 78 using namespace ::com::sun::star::beans; 79 using namespace ::xmloff::token; 80 using ::com::sun::star::container::XEnumerationAccess; 81 using ::com::sun::star::container::XEnumeration; 82 83 84 TYPEINIT1( XMLCharContext, SvXMLImportContext ); 85 86 XMLCharContext::XMLCharContext( 87 SvXMLImport& rImport, 88 sal_uInt16 nPrfx, 89 const OUString& rLName, 90 const Reference< xml::sax::XAttributeList > & xAttrList, 91 sal_Unicode c, 92 sal_Bool bCount ) : 93 SvXMLImportContext( rImport, nPrfx, rLName ) 94 ,m_nControl(0) 95 ,m_nCount(1) 96 ,m_c(c) 97 { 98 if( bCount ) 99 { 100 const SvXMLNamespaceMap& rMap = GetImport().GetNamespaceMap(); 101 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 102 for( sal_Int16 i=0; i < nAttrCount; i++ ) 103 { 104 const OUString& rAttrName = xAttrList->getNameByIndex( i ); 105 106 OUString aLocalName; 107 sal_uInt16 nPrefix =rMap.GetKeyByAttrName( rAttrName,&aLocalName ); 108 if( XML_NAMESPACE_TEXT == nPrefix && 109 IsXMLToken( aLocalName, XML_C ) ) 110 { 111 sal_Int32 nTmp = xAttrList->getValueByIndex(i).toInt32(); 112 if( nTmp > 0L ) 113 { 114 if( nTmp > USHRT_MAX ) 115 m_nCount = USHRT_MAX; 116 else 117 m_nCount = (sal_uInt16)nTmp; 118 } 119 } 120 } 121 } 122 } 123 124 XMLCharContext::XMLCharContext( 125 SvXMLImport& rImp, 126 sal_uInt16 nPrfx, 127 const OUString& rLName, 128 const Reference< xml::sax::XAttributeList > &, 129 sal_Int16 nControl ) : 130 SvXMLImportContext( rImp, nPrfx, rLName ) 131 ,m_nControl(nControl) 132 ,m_nCount(0) 133 ,m_c(0) 134 { 135 } 136 137 XMLCharContext::~XMLCharContext() 138 { 139 } 140 // ----------------------------------------------------------------------------- 141 void XMLCharContext::EndElement() 142 { 143 if ( !m_nCount ) 144 InsertControlCharacter( m_nControl ); 145 else 146 { 147 if( 1U == m_nCount ) 148 { 149 OUString sBuff( &m_c, 1 ); 150 InsertString(sBuff); 151 } 152 else 153 { 154 OUStringBuffer sBuff( m_nCount ); 155 while( m_nCount-- ) 156 sBuff.append( &m_c, 1 ); 157 158 InsertString(sBuff.makeStringAndClear() ); 159 } 160 } 161 } 162 // ----------------------------------------------------------------------------- 163 void XMLCharContext::InsertControlCharacter(sal_Int16 _nControl) 164 { 165 GetImport().GetTextImport()->InsertControlCharacter( _nControl ); 166 } 167 void XMLCharContext::InsertString(const ::rtl::OUString& _sString) 168 { 169 GetImport().GetTextImport()->InsertString( _sString ); 170 } 171 172 // --------------------------------------------------------------------- 173 174 /** import start of reference (<text:reference-start>) */ 175 class XMLStartReferenceContext_Impl : public SvXMLImportContext 176 { 177 public: 178 TYPEINFO(); 179 180 // Do everything in constructor. Well ... 181 XMLStartReferenceContext_Impl ( 182 SvXMLImport& rImport, 183 sal_uInt16 nPrefix, 184 const OUString& rLocalName, 185 XMLHints_Impl& rHnts, 186 const Reference<xml::sax::XAttributeList> & xAttrList); 187 188 static sal_Bool FindName( 189 SvXMLImport& rImport, 190 const Reference<xml::sax::XAttributeList> & xAttrList, 191 OUString& rName); 192 }; 193 194 TYPEINIT1( XMLStartReferenceContext_Impl, SvXMLImportContext ); 195 196 XMLStartReferenceContext_Impl::XMLStartReferenceContext_Impl( 197 SvXMLImport& rImport, 198 sal_uInt16 nPrefix, 199 const OUString& rLocalName, 200 XMLHints_Impl& rHints, 201 const Reference<xml::sax::XAttributeList> & xAttrList) : 202 SvXMLImportContext(rImport, nPrefix, rLocalName) 203 { 204 OUString sName; 205 206 if (FindName(GetImport(), xAttrList, sName)) 207 { 208 XMLHint_Impl* pHint = new XMLReferenceHint_Impl( 209 sName, rImport.GetTextImport()->GetCursor()->getStart() ); 210 211 // degenerates to point reference, if no end is found! 212 pHint->SetEnd(rImport.GetTextImport()->GetCursor()->getStart() ); 213 214 rHints.Insert(pHint, rHints.Count()); 215 } 216 } 217 218 sal_Bool XMLStartReferenceContext_Impl::FindName( 219 SvXMLImport& rImport, 220 const Reference<xml::sax::XAttributeList> & xAttrList, 221 OUString& rName) 222 { 223 sal_Bool bNameOK( sal_False ); 224 225 // find name attribute first 226 const sal_Int16 nLength( xAttrList->getLength() ); 227 for (sal_Int16 nAttr = 0; nAttr < nLength; nAttr++) 228 { 229 OUString sLocalName; 230 const sal_uInt16 nPrefix = rImport.GetNamespaceMap(). 231 GetKeyByAttrName( xAttrList->getNameByIndex(nAttr), 232 &sLocalName ); 233 234 if ( (XML_NAMESPACE_TEXT == nPrefix) && 235 IsXMLToken(sLocalName, XML_NAME) ) 236 { 237 rName = xAttrList->getValueByIndex(nAttr); 238 bNameOK = sal_True; 239 } 240 } 241 242 return bNameOK; 243 } 244 245 // --------------------------------------------------------------------- 246 247 /** import end of reference (<text:reference-end>) */ 248 class XMLEndReferenceContext_Impl : public SvXMLImportContext 249 { 250 public: 251 TYPEINFO(); 252 253 // Do everything in constructor. Well ... 254 XMLEndReferenceContext_Impl( 255 SvXMLImport& rImport, 256 sal_uInt16 nPrefix, 257 const OUString& rLocalName, 258 XMLHints_Impl& rHnts, 259 const Reference<xml::sax::XAttributeList> & xAttrList); 260 }; 261 262 TYPEINIT1( XMLEndReferenceContext_Impl, SvXMLImportContext ); 263 264 XMLEndReferenceContext_Impl::XMLEndReferenceContext_Impl( 265 SvXMLImport& rImport, 266 sal_uInt16 nPrefix, 267 const OUString& rLocalName, 268 XMLHints_Impl& rHints, 269 const Reference<xml::sax::XAttributeList> & xAttrList) : 270 SvXMLImportContext(rImport, nPrefix, rLocalName) 271 { 272 OUString sName; 273 274 // borrow from XMLStartReferenceContext_Impl 275 if (XMLStartReferenceContext_Impl::FindName(GetImport(), xAttrList, sName)) 276 { 277 // search for reference start 278 sal_uInt16 nCount = rHints.Count(); 279 for(sal_uInt16 nPos = 0; nPos < nCount; nPos++) 280 { 281 XMLHint_Impl *pHint = rHints[nPos]; 282 if ( pHint->IsReference() && 283 sName.equals( ((XMLReferenceHint_Impl *)pHint)->GetRefName()) ) 284 { 285 // set end and stop searching 286 pHint->SetEnd(GetImport().GetTextImport()-> 287 GetCursor()->getStart() ); 288 break; 289 } 290 } 291 // else: no start (in this paragraph) -> ignore 292 } 293 } 294 295 // --------------------------------------------------------------------- 296 297 class XMLImpSpanContext_Impl : public SvXMLImportContext 298 { 299 const OUString sTextFrame; 300 301 XMLHints_Impl& rHints; 302 XMLStyleHint_Impl *pHint; 303 304 sal_Bool& rIgnoreLeadingSpace; 305 306 sal_uInt8 nStarFontsConvFlags; 307 308 public: 309 310 TYPEINFO(); 311 312 XMLImpSpanContext_Impl( 313 SvXMLImport& rImport, 314 sal_uInt16 nPrfx, 315 const OUString& rLName, 316 const Reference< xml::sax::XAttributeList > & xAttrList, 317 XMLHints_Impl& rHnts, 318 sal_Bool& rIgnLeadSpace 319 ,sal_uInt8 nSFConvFlags 320 ); 321 322 virtual ~XMLImpSpanContext_Impl(); 323 324 static SvXMLImportContext *CreateChildContext( 325 SvXMLImport& rImport, 326 sal_uInt16 nPrefix, const OUString& rLocalName, 327 const Reference< xml::sax::XAttributeList > & xAttrList, 328 sal_uInt16 nToken, XMLHints_Impl& rHnts, 329 sal_Bool& rIgnLeadSpace 330 ,sal_uInt8 nStarFontsConvFlags = 0 331 ); 332 virtual SvXMLImportContext *CreateChildContext( 333 sal_uInt16 nPrefix, const OUString& rLocalName, 334 const Reference< xml::sax::XAttributeList > & xAttrList ); 335 336 virtual void Characters( const OUString& rChars ); 337 }; 338 // --------------------------------------------------------------------- 339 340 class XMLImpHyperlinkContext_Impl : public SvXMLImportContext 341 { 342 XMLHints_Impl& mrHints; 343 XMLHyperlinkHint_Impl *mpHint; 344 345 sal_Bool& mrbIgnoreLeadingSpace; 346 347 public: 348 349 TYPEINFO(); 350 351 XMLImpHyperlinkContext_Impl( 352 SvXMLImport& rImport, 353 sal_uInt16 nPrfx, 354 const OUString& rLName, 355 const Reference< xml::sax::XAttributeList > & xAttrList, 356 XMLHints_Impl& rHnts, 357 sal_Bool& rIgnLeadSpace ); 358 359 virtual ~XMLImpHyperlinkContext_Impl(); 360 361 virtual SvXMLImportContext *CreateChildContext( 362 sal_uInt16 nPrefix, const OUString& rLocalName, 363 const Reference< xml::sax::XAttributeList > & xAttrList ); 364 365 virtual void Characters( const OUString& rChars ); 366 }; 367 368 TYPEINIT1( XMLImpHyperlinkContext_Impl, SvXMLImportContext ); 369 370 XMLImpHyperlinkContext_Impl::XMLImpHyperlinkContext_Impl( 371 SvXMLImport& rImport, 372 sal_uInt16 nPrfx, 373 const OUString& rLName, 374 const Reference< xml::sax::XAttributeList > & xAttrList, 375 XMLHints_Impl& rHnts, 376 sal_Bool& rIgnLeadSpace ) 377 : SvXMLImportContext( rImport, nPrfx, rLName ) 378 , mrHints( rHnts ) 379 , mpHint( new XMLHyperlinkHint_Impl( GetImport().GetTextImport()->GetCursorAsRange()->getStart() ) ) 380 , mrbIgnoreLeadingSpace( rIgnLeadSpace ) 381 { 382 OUString sShow; 383 const SvXMLTokenMap& rTokenMap = GetImport().GetTextImport()->GetTextHyperlinkAttrTokenMap(); 384 385 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 386 for ( sal_Int16 i = 0; i < nAttrCount; i++ ) 387 { 388 const OUString& rAttrName = xAttrList->getNameByIndex( i ); 389 const OUString& rValue = xAttrList->getValueByIndex( i ); 390 391 OUString aLocalName; 392 const sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName ); 393 switch (rTokenMap.Get( nPrefix, aLocalName )) 394 { 395 case XML_TOK_TEXT_HYPERLINK_HREF: 396 mpHint->SetHRef( GetImport().GetAbsoluteReference( rValue ) ); 397 break; 398 case XML_TOK_TEXT_HYPERLINK_NAME: 399 mpHint->SetName( rValue ); 400 break; 401 case XML_TOK_TEXT_HYPERLINK_TARGET_FRAME: 402 mpHint->SetTargetFrameName( rValue ); 403 break; 404 case XML_TOK_TEXT_HYPERLINK_SHOW: 405 sShow = rValue; 406 break; 407 case XML_TOK_TEXT_HYPERLINK_STYLE_NAME: 408 mpHint->SetStyleName( rValue ); 409 break; 410 case XML_TOK_TEXT_HYPERLINK_VIS_STYLE_NAME: 411 mpHint->SetVisitedStyleName( rValue ); 412 break; 413 } 414 } 415 416 if( sShow.getLength() && !mpHint->GetTargetFrameName().getLength() ) 417 { 418 if( IsXMLToken( sShow, XML_NEW ) ) 419 mpHint->SetTargetFrameName( 420 OUString( RTL_CONSTASCII_USTRINGPARAM("_blank" ) ) ); 421 else if( IsXMLToken( sShow, XML_REPLACE ) ) 422 mpHint->SetTargetFrameName( 423 OUString( RTL_CONSTASCII_USTRINGPARAM("_self" ) ) ); 424 } 425 426 if ( mpHint->GetHRef().isEmpty() ) 427 { 428 // hyperlink without an URL is not imported. 429 delete mpHint; 430 mpHint = NULL; 431 } 432 else 433 { 434 mrHints.Insert( mpHint, mrHints.Count() ); 435 } 436 } 437 438 XMLImpHyperlinkContext_Impl::~XMLImpHyperlinkContext_Impl() 439 { 440 if( mpHint != NULL ) 441 mpHint->SetEnd( GetImport().GetTextImport() 442 ->GetCursorAsRange()->getStart() ); 443 } 444 445 SvXMLImportContext *XMLImpHyperlinkContext_Impl::CreateChildContext( 446 sal_uInt16 nPrefix, const OUString& rLocalName, 447 const Reference< xml::sax::XAttributeList > & xAttrList ) 448 { 449 if ( (nPrefix == XML_NAMESPACE_OFFICE) && 450 IsXMLToken(rLocalName, XML_EVENT_LISTENERS) ) 451 { 452 XMLEventsImportContext* pCtxt = new XMLEventsImportContext( 453 GetImport(), nPrefix, rLocalName); 454 mpHint->SetEventsContext(pCtxt); 455 return pCtxt; 456 } 457 else 458 { 459 const SvXMLTokenMap& rTokenMap = 460 GetImport().GetTextImport()->GetTextPElemTokenMap(); 461 sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName ); 462 463 return XMLImpSpanContext_Impl::CreateChildContext( 464 GetImport(), nPrefix, rLocalName, xAttrList, 465 nToken, mrHints, mrbIgnoreLeadingSpace ); 466 } 467 } 468 469 void XMLImpHyperlinkContext_Impl::Characters( const OUString& rChars ) 470 { 471 GetImport().GetTextImport()->InsertString( rChars, mrbIgnoreLeadingSpace ); 472 } 473 474 // --------------------------------------------------------------------- 475 476 class XMLImpRubyBaseContext_Impl : public SvXMLImportContext 477 { 478 XMLHints_Impl& rHints; 479 480 sal_Bool& rIgnoreLeadingSpace; 481 482 public: 483 484 TYPEINFO(); 485 486 XMLImpRubyBaseContext_Impl( 487 SvXMLImport& rImport, 488 sal_uInt16 nPrfx, 489 const OUString& rLName, 490 const Reference< xml::sax::XAttributeList > & xAttrList, 491 XMLHints_Impl& rHnts, 492 sal_Bool& rIgnLeadSpace ); 493 494 virtual ~XMLImpRubyBaseContext_Impl(); 495 496 virtual SvXMLImportContext *CreateChildContext( 497 sal_uInt16 nPrefix, const OUString& rLocalName, 498 const Reference< xml::sax::XAttributeList > & xAttrList ); 499 500 virtual void Characters( const OUString& rChars ); 501 }; 502 503 TYPEINIT1( XMLImpRubyBaseContext_Impl, SvXMLImportContext ); 504 505 XMLImpRubyBaseContext_Impl::XMLImpRubyBaseContext_Impl( 506 SvXMLImport& rImport, 507 sal_uInt16 nPrfx, 508 const OUString& rLName, 509 const Reference< xml::sax::XAttributeList > &, 510 XMLHints_Impl& rHnts, 511 sal_Bool& rIgnLeadSpace ) : 512 SvXMLImportContext( rImport, nPrfx, rLName ), 513 rHints( rHnts ), 514 rIgnoreLeadingSpace( rIgnLeadSpace ) 515 { 516 } 517 518 XMLImpRubyBaseContext_Impl::~XMLImpRubyBaseContext_Impl() 519 { 520 } 521 522 SvXMLImportContext *XMLImpRubyBaseContext_Impl::CreateChildContext( 523 sal_uInt16 nPrefix, const OUString& rLocalName, 524 const Reference< xml::sax::XAttributeList > & xAttrList ) 525 { 526 const SvXMLTokenMap& rTokenMap = 527 GetImport().GetTextImport()->GetTextPElemTokenMap(); 528 sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName ); 529 530 return XMLImpSpanContext_Impl::CreateChildContext( GetImport(), nPrefix, 531 rLocalName, xAttrList, 532 nToken, rHints, rIgnoreLeadingSpace ); 533 } 534 535 void XMLImpRubyBaseContext_Impl::Characters( const OUString& rChars ) 536 { 537 GetImport().GetTextImport()->InsertString( rChars, rIgnoreLeadingSpace ); 538 } 539 540 // --------------------------------------------------------------------- 541 542 class XMLImpRubyContext_Impl : public SvXMLImportContext 543 { 544 XMLHints_Impl& rHints; 545 546 sal_Bool& rIgnoreLeadingSpace; 547 548 Reference < XTextRange > m_xStart; 549 OUString m_sStyleName; 550 OUString m_sTextStyleName; 551 OUString m_sText; 552 553 public: 554 555 TYPEINFO(); 556 557 XMLImpRubyContext_Impl( 558 SvXMLImport& rImport, 559 sal_uInt16 nPrfx, 560 const OUString& rLName, 561 const Reference< xml::sax::XAttributeList > & xAttrList, 562 XMLHints_Impl& rHnts, 563 sal_Bool& rIgnLeadSpace ); 564 565 virtual ~XMLImpRubyContext_Impl(); 566 567 virtual SvXMLImportContext *CreateChildContext( 568 sal_uInt16 nPrefix, const OUString& rLocalName, 569 const Reference< xml::sax::XAttributeList > & xAttrList ); 570 571 void SetTextStyleName( const OUString& s ) { m_sTextStyleName = s; } 572 void AppendText( const OUString& s ) { m_sText += s; } 573 }; 574 575 // --------------------------------------------------------------------- 576 577 class XMLImpRubyTextContext_Impl : public SvXMLImportContext 578 { 579 XMLImpRubyContext_Impl & m_rRubyContext; 580 581 public: 582 583 TYPEINFO(); 584 585 XMLImpRubyTextContext_Impl( 586 SvXMLImport& rImport, 587 sal_uInt16 nPrfx, 588 const OUString& rLName, 589 const Reference< xml::sax::XAttributeList > & xAttrList, 590 XMLImpRubyContext_Impl & rParent ); 591 592 virtual ~XMLImpRubyTextContext_Impl(); 593 594 virtual void Characters( const OUString& rChars ); 595 }; 596 597 TYPEINIT1( XMLImpRubyTextContext_Impl, SvXMLImportContext ); 598 599 XMLImpRubyTextContext_Impl::XMLImpRubyTextContext_Impl( 600 SvXMLImport& rImport, 601 sal_uInt16 nPrfx, 602 const OUString& rLName, 603 const Reference< xml::sax::XAttributeList > & xAttrList, 604 XMLImpRubyContext_Impl & rParent ) 605 : SvXMLImportContext( rImport, nPrfx, rLName ) 606 , m_rRubyContext( rParent ) 607 { 608 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 609 for( sal_Int16 i=0; i < nAttrCount; i++ ) 610 { 611 const OUString& rAttrName = xAttrList->getNameByIndex( i ); 612 const OUString& rValue = xAttrList->getValueByIndex( i ); 613 614 OUString aLocalName; 615 sal_uInt16 nPrefix = 616 GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, 617 &aLocalName ); 618 if( XML_NAMESPACE_TEXT == nPrefix && 619 IsXMLToken( aLocalName, XML_STYLE_NAME ) ) 620 { 621 m_rRubyContext.SetTextStyleName( rValue ); 622 break; 623 } 624 } 625 } 626 627 XMLImpRubyTextContext_Impl::~XMLImpRubyTextContext_Impl() 628 { 629 } 630 631 void XMLImpRubyTextContext_Impl::Characters( const OUString& rChars ) 632 { 633 m_rRubyContext.AppendText( rChars ); 634 } 635 636 // --------------------------------------------------------------------- 637 638 TYPEINIT1( XMLImpRubyContext_Impl, SvXMLImportContext ); 639 640 XMLImpRubyContext_Impl::XMLImpRubyContext_Impl( 641 SvXMLImport& rImport, 642 sal_uInt16 nPrfx, 643 const OUString& rLName, 644 const Reference< xml::sax::XAttributeList > & xAttrList, 645 XMLHints_Impl& rHnts, 646 sal_Bool& rIgnLeadSpace ) : 647 SvXMLImportContext( rImport, nPrfx, rLName ), 648 rHints( rHnts ), 649 rIgnoreLeadingSpace( rIgnLeadSpace ) 650 , m_xStart( GetImport().GetTextImport()->GetCursorAsRange()->getStart() ) 651 { 652 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 653 for( sal_Int16 i=0; i < nAttrCount; i++ ) 654 { 655 const OUString& rAttrName = xAttrList->getNameByIndex( i ); 656 const OUString& rValue = xAttrList->getValueByIndex( i ); 657 658 OUString aLocalName; 659 sal_uInt16 nPrefix = 660 GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, 661 &aLocalName ); 662 if( XML_NAMESPACE_TEXT == nPrefix && 663 IsXMLToken( aLocalName, XML_STYLE_NAME ) ) 664 { 665 m_sStyleName = rValue; 666 break; 667 } 668 } 669 } 670 671 XMLImpRubyContext_Impl::~XMLImpRubyContext_Impl() 672 { 673 const UniReference < XMLTextImportHelper > xTextImport( 674 GetImport().GetTextImport()); 675 const Reference < XTextCursor > xAttrCursor( 676 xTextImport->GetText()->createTextCursorByRange( m_xStart )); 677 xAttrCursor->gotoRange(xTextImport->GetCursorAsRange()->getStart(), 678 sal_True); 679 xTextImport->SetRuby( GetImport(), xAttrCursor, 680 m_sStyleName, m_sTextStyleName, m_sText ); 681 } 682 683 SvXMLImportContext *XMLImpRubyContext_Impl::CreateChildContext( 684 sal_uInt16 nPrefix, const OUString& rLocalName, 685 const Reference< xml::sax::XAttributeList > & xAttrList ) 686 { 687 SvXMLImportContext *pContext; 688 if( XML_NAMESPACE_TEXT == nPrefix ) 689 { 690 if( IsXMLToken( rLocalName, XML_RUBY_BASE ) ) 691 pContext = new XMLImpRubyBaseContext_Impl( GetImport(), nPrefix, 692 rLocalName, 693 xAttrList, 694 rHints, 695 rIgnoreLeadingSpace ); 696 else if( IsXMLToken( rLocalName, XML_RUBY_TEXT ) ) 697 pContext = new XMLImpRubyTextContext_Impl( GetImport(), nPrefix, 698 rLocalName, 699 xAttrList, 700 *this ); 701 else 702 pContext = new SvXMLImportContext( 703 GetImport(), nPrefix, rLocalName ); 704 } 705 else 706 pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, 707 xAttrList ); 708 709 return pContext; 710 } 711 712 // --------------------------------------------------------------------- 713 714 /** for text:meta and text:meta-field 715 */ 716 class XMLMetaImportContextBase : public SvXMLImportContext 717 { 718 XMLHints_Impl& m_rHints; 719 720 sal_Bool& m_rIgnoreLeadingSpace; 721 722 /// start position 723 Reference<XTextRange> m_xStart; 724 725 protected: 726 OUString m_XmlId; 727 728 public: 729 TYPEINFO(); 730 731 XMLMetaImportContextBase( 732 SvXMLImport& i_rImport, 733 const sal_uInt16 i_nPrefix, 734 const OUString& i_rLocalName, 735 XMLHints_Impl& i_rHints, 736 sal_Bool & i_rIgnoreLeadingSpace ); 737 738 virtual ~XMLMetaImportContextBase(); 739 740 virtual void StartElement( 741 const Reference<xml::sax::XAttributeList> & i_xAttrList); 742 743 virtual void EndElement(); 744 745 virtual SvXMLImportContext *CreateChildContext( 746 sal_uInt16 i_nPrefix, const OUString& i_rLocalName, 747 const Reference< xml::sax::XAttributeList > & i_xAttrList); 748 749 virtual void Characters( const OUString& i_rChars ); 750 751 virtual void ProcessAttribute(sal_uInt16 const i_nPrefix, 752 OUString const & i_rLocalName, OUString const & i_rValue); 753 754 virtual void InsertMeta(const Reference<XTextRange> & i_xInsertionRange) 755 = 0; 756 }; 757 758 TYPEINIT1( XMLMetaImportContextBase, SvXMLImportContext ); 759 760 XMLMetaImportContextBase::XMLMetaImportContextBase( 761 SvXMLImport& i_rImport, 762 const sal_uInt16 i_nPrefix, 763 const OUString& i_rLocalName, 764 XMLHints_Impl& i_rHints, 765 sal_Bool & i_rIgnoreLeadingSpace ) 766 : SvXMLImportContext( i_rImport, i_nPrefix, i_rLocalName ) 767 , m_rHints( i_rHints ) 768 , m_rIgnoreLeadingSpace( i_rIgnoreLeadingSpace ) 769 , m_xStart( GetImport().GetTextImport()->GetCursorAsRange()->getStart() ) 770 { 771 } 772 773 XMLMetaImportContextBase::~XMLMetaImportContextBase() 774 { 775 } 776 777 void XMLMetaImportContextBase::StartElement( 778 const Reference<xml::sax::XAttributeList> & i_xAttrList) 779 { 780 const sal_Int16 nAttrCount(i_xAttrList.is() ? i_xAttrList->getLength() : 0); 781 for ( sal_Int16 i = 0; i < nAttrCount; ++i ) 782 { 783 const OUString& rAttrName( i_xAttrList->getNameByIndex( i ) ); 784 const OUString& rValue( i_xAttrList->getValueByIndex( i ) ); 785 786 OUString sLocalName; 787 const sal_uInt16 nPrefix( 788 GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, 789 &sLocalName )); 790 ProcessAttribute(nPrefix, sLocalName, rValue); 791 } 792 } 793 794 void XMLMetaImportContextBase::EndElement() 795 { 796 OSL_ENSURE(m_xStart.is(), "no mxStart?"); 797 if (!m_xStart.is()) return; 798 799 const Reference<XTextRange> xEndRange( 800 GetImport().GetTextImport()->GetCursorAsRange()->getStart() ); 801 802 // create range for insertion 803 const Reference<XTextCursor> xInsertionCursor( 804 GetImport().GetTextImport()->GetText()->createTextCursorByRange( 805 xEndRange) ); 806 xInsertionCursor->gotoRange(m_xStart, sal_True); 807 808 const Reference<XTextRange> xInsertionRange(xInsertionCursor, UNO_QUERY); 809 810 InsertMeta(xInsertionRange); 811 } 812 813 SvXMLImportContext * XMLMetaImportContextBase::CreateChildContext( 814 sal_uInt16 i_nPrefix, const OUString& i_rLocalName, 815 const Reference< xml::sax::XAttributeList > & i_xAttrList ) 816 { 817 const SvXMLTokenMap& rTokenMap( 818 GetImport().GetTextImport()->GetTextPElemTokenMap() ); 819 const sal_uInt16 nToken( rTokenMap.Get( i_nPrefix, i_rLocalName ) ); 820 821 return XMLImpSpanContext_Impl::CreateChildContext( GetImport(), i_nPrefix, 822 i_rLocalName, i_xAttrList, nToken, m_rHints, m_rIgnoreLeadingSpace ); 823 } 824 825 void XMLMetaImportContextBase::Characters( const OUString& i_rChars ) 826 { 827 GetImport().GetTextImport()->InsertString(i_rChars, m_rIgnoreLeadingSpace); 828 } 829 830 void XMLMetaImportContextBase::ProcessAttribute(sal_uInt16 const i_nPrefix, 831 OUString const & i_rLocalName, OUString const & i_rValue) 832 { 833 if ( (XML_NAMESPACE_XML == i_nPrefix) && IsXMLToken(i_rLocalName, XML_ID) ) 834 { 835 m_XmlId = i_rValue; 836 } 837 } 838 839 840 // --------------------------------------------------------------------- 841 842 /** text:meta */ 843 class XMLMetaImportContext : public XMLMetaImportContextBase 844 { 845 // RDFa 846 bool m_bHaveAbout; 847 ::rtl::OUString m_sAbout; 848 ::rtl::OUString m_sProperty; 849 ::rtl::OUString m_sContent; 850 ::rtl::OUString m_sDatatype; 851 852 public: 853 TYPEINFO(); 854 855 XMLMetaImportContext( 856 SvXMLImport& i_rImport, 857 const sal_uInt16 i_nPrefix, 858 const OUString& i_rLocalName, 859 XMLHints_Impl& i_rHints, 860 sal_Bool & i_rIgnoreLeadingSpace ); 861 862 virtual void ProcessAttribute(sal_uInt16 const i_nPrefix, 863 OUString const & i_rLocalName, OUString const & i_rValue); 864 865 virtual void InsertMeta(const Reference<XTextRange> & i_xInsertionRange); 866 }; 867 868 TYPEINIT1( XMLMetaImportContext, XMLMetaImportContextBase ); 869 870 XMLMetaImportContext::XMLMetaImportContext( 871 SvXMLImport& i_rImport, 872 const sal_uInt16 i_nPrefix, 873 const OUString& i_rLocalName, 874 XMLHints_Impl& i_rHints, 875 sal_Bool & i_rIgnoreLeadingSpace ) 876 : XMLMetaImportContextBase( i_rImport, i_nPrefix, i_rLocalName, 877 i_rHints, i_rIgnoreLeadingSpace ) 878 , m_bHaveAbout(false) 879 { 880 } 881 882 void XMLMetaImportContext::ProcessAttribute(sal_uInt16 const i_nPrefix, 883 OUString const & i_rLocalName, OUString const & i_rValue) 884 { 885 if ( XML_NAMESPACE_XHTML == i_nPrefix ) 886 { 887 // RDFa 888 if ( IsXMLToken( i_rLocalName, XML_ABOUT) ) 889 { 890 m_sAbout = i_rValue; 891 m_bHaveAbout = true; 892 } 893 else if ( IsXMLToken( i_rLocalName, XML_PROPERTY) ) 894 { 895 m_sProperty = i_rValue; 896 } 897 else if ( IsXMLToken( i_rLocalName, XML_CONTENT) ) 898 { 899 m_sContent = i_rValue; 900 } 901 else if ( IsXMLToken( i_rLocalName, XML_DATATYPE) ) 902 { 903 m_sDatatype = i_rValue; 904 } 905 } 906 else 907 { 908 XMLMetaImportContextBase::ProcessAttribute( 909 i_nPrefix, i_rLocalName, i_rValue); 910 } 911 } 912 913 void XMLMetaImportContext::InsertMeta( 914 const Reference<XTextRange> & i_xInsertionRange) 915 { 916 OSL_ENSURE(!m_bHaveAbout == !m_sProperty.getLength(), 917 "XMLMetaImportContext::InsertMeta: invalid RDFa?"); 918 if (m_XmlId.getLength() || (m_bHaveAbout && m_sProperty.getLength())) 919 { 920 // insert mark 921 const uno::Reference<rdf::XMetadatable> xMeta( 922 XMLTextMarkImportContext::CreateAndInsertMark( 923 GetImport(), 924 OUString::createFromAscii( 925 "com.sun.star.text.InContentMetadata"), 926 OUString(), 927 i_xInsertionRange, m_XmlId), 928 uno::UNO_QUERY); 929 OSL_ENSURE(xMeta.is(), "cannot insert Meta?"); 930 931 if (xMeta.is() && m_bHaveAbout) 932 { 933 GetImport().AddRDFa(xMeta, 934 m_sAbout, m_sProperty, m_sContent, m_sDatatype); 935 } 936 } 937 else 938 { 939 OSL_TRACE("invalid <text:meta>: no xml:id, no valid RDFa"); 940 } 941 } 942 943 // --------------------------------------------------------------------- 944 945 /** text:meta-field */ 946 class XMLMetaFieldImportContext : public XMLMetaImportContextBase 947 { 948 OUString m_DataStyleName; 949 950 public: 951 TYPEINFO(); 952 953 XMLMetaFieldImportContext( 954 SvXMLImport& i_rImport, 955 const sal_uInt16 i_nPrefix, 956 const OUString& i_rLocalName, 957 XMLHints_Impl& i_rHints, 958 sal_Bool & i_rIgnoreLeadingSpace ); 959 960 virtual void ProcessAttribute(sal_uInt16 const i_nPrefix, 961 OUString const & i_rLocalName, OUString const & i_rValue); 962 963 virtual void InsertMeta(const Reference<XTextRange> & i_xInsertionRange); 964 }; 965 966 TYPEINIT1( XMLMetaFieldImportContext, XMLMetaImportContextBase ); 967 968 XMLMetaFieldImportContext::XMLMetaFieldImportContext( 969 SvXMLImport& i_rImport, 970 const sal_uInt16 i_nPrefix, 971 const OUString& i_rLocalName, 972 XMLHints_Impl& i_rHints, 973 sal_Bool & i_rIgnoreLeadingSpace ) 974 : XMLMetaImportContextBase( i_rImport, i_nPrefix, i_rLocalName, 975 i_rHints, i_rIgnoreLeadingSpace ) 976 { 977 } 978 979 void XMLMetaFieldImportContext::ProcessAttribute(sal_uInt16 const i_nPrefix, 980 OUString const & i_rLocalName, OUString const & i_rValue) 981 { 982 if ( XML_NAMESPACE_STYLE == i_nPrefix && 983 IsXMLToken( i_rLocalName, XML_DATA_STYLE_NAME ) ) 984 { 985 m_DataStyleName = i_rValue; 986 } 987 else 988 { 989 XMLMetaImportContextBase::ProcessAttribute( 990 i_nPrefix, i_rLocalName, i_rValue); 991 } 992 } 993 994 void XMLMetaFieldImportContext::InsertMeta( 995 const Reference<XTextRange> & i_xInsertionRange) 996 { 997 if (m_XmlId.getLength()) // valid? 998 { 999 // insert mark 1000 const Reference<XPropertySet> xPropertySet( 1001 XMLTextMarkImportContext::CreateAndInsertMark( 1002 GetImport(), 1003 OUString::createFromAscii( 1004 "com.sun.star.text.textfield.MetadataField"), 1005 OUString(), 1006 i_xInsertionRange, m_XmlId), 1007 UNO_QUERY); 1008 OSL_ENSURE(xPropertySet.is(), "cannot insert MetaField?"); 1009 if (!xPropertySet.is()) return; 1010 1011 if (m_DataStyleName.getLength()) 1012 { 1013 sal_Bool isDefaultLanguage(sal_True); 1014 1015 const sal_Int32 nKey( GetImport().GetTextImport()->GetDataStyleKey( 1016 m_DataStyleName, & isDefaultLanguage) ); 1017 1018 if (-1 != nKey) 1019 { 1020 static ::rtl::OUString sPropertyIsFixedLanguage( 1021 ::rtl::OUString::createFromAscii("IsFixedLanguage") ); 1022 Any any; 1023 any <<= nKey; 1024 xPropertySet->setPropertyValue( 1025 OUString::createFromAscii("NumberFormat"), any); 1026 if ( xPropertySet->getPropertySetInfo()-> 1027 hasPropertyByName( sPropertyIsFixedLanguage ) ) 1028 { 1029 any <<= static_cast<bool>(!isDefaultLanguage); 1030 xPropertySet->setPropertyValue( sPropertyIsFixedLanguage, 1031 any ); 1032 } 1033 } 1034 } 1035 } 1036 else 1037 { 1038 OSL_TRACE("invalid <text:meta-field>: no xml:id"); 1039 } 1040 } 1041 1042 1043 // --------------------------------------------------------------------- 1044 1045 1046 /** 1047 * Process index marks. 1048 * 1049 * All *-mark-end index marks should instantiate *this* class (because 1050 * it doesn't process attributes other than ID), while the *-mark and 1051 * *-mark-start classes should instantiate the apporpiate subclasses. 1052 */ 1053 class XMLIndexMarkImportContext_Impl : public SvXMLImportContext 1054 { 1055 const OUString sAlternativeText; 1056 1057 XMLHints_Impl& rHints; 1058 const enum XMLTextPElemTokens eToken; 1059 OUString sID; 1060 1061 public: 1062 TYPEINFO(); 1063 1064 XMLIndexMarkImportContext_Impl( 1065 SvXMLImport& rImport, 1066 sal_uInt16 nPrefix, 1067 const OUString& rLocalName, 1068 enum XMLTextPElemTokens nTok, 1069 XMLHints_Impl& rHnts); 1070 1071 void StartElement(const Reference<xml::sax::XAttributeList> & xAttrList); 1072 1073 protected: 1074 1075 /// process all attributes 1076 void ProcessAttributes(const Reference<xml::sax::XAttributeList> & xAttrList, 1077 Reference<beans::XPropertySet>& rPropSet); 1078 1079 /** 1080 * All marks can be created immediately. Since we don't care about 1081 * the element content, ProcessAttribute should set the properties 1082 * immediately. 1083 * 1084 * This method tolerates an empty PropertySet; subclasses however 1085 * are not expected to. 1086 */ 1087 virtual void ProcessAttribute(sal_uInt16 nNamespace, 1088 OUString sLocalName, 1089 OUString sValue, 1090 Reference<beans::XPropertySet>& rPropSet); 1091 1092 static void GetServiceName(OUString& sServiceName, 1093 enum XMLTextPElemTokens nToken); 1094 1095 sal_Bool CreateMark(Reference<beans::XPropertySet>& rPropSet, 1096 const OUString& rServiceName); 1097 }; 1098 1099 1100 TYPEINIT1( XMLIndexMarkImportContext_Impl, SvXMLImportContext ); 1101 1102 XMLIndexMarkImportContext_Impl::XMLIndexMarkImportContext_Impl( 1103 SvXMLImport& rImport, 1104 sal_uInt16 nPrefix, 1105 const OUString& rLocalName, 1106 enum XMLTextPElemTokens eTok, 1107 XMLHints_Impl& rHnts) : 1108 SvXMLImportContext(rImport, nPrefix, rLocalName), 1109 sAlternativeText(RTL_CONSTASCII_USTRINGPARAM("AlternativeText")), 1110 rHints(rHnts), 1111 eToken(eTok) 1112 { 1113 } 1114 1115 void XMLIndexMarkImportContext_Impl::StartElement( 1116 const Reference<xml::sax::XAttributeList> & xAttrList) 1117 { 1118 // get Cursor position (needed for all cases) 1119 Reference<XTextRange> xPos( 1120 GetImport().GetTextImport()->GetCursor()->getStart()); 1121 Reference<beans::XPropertySet> xMark; 1122 1123 switch (eToken) 1124 { 1125 case XML_TOK_TEXT_TOC_MARK: 1126 case XML_TOK_TEXT_USER_INDEX_MARK: 1127 case XML_TOK_TEXT_ALPHA_INDEX_MARK: 1128 { 1129 // single mark: create mark and insert 1130 OUString sService; 1131 GetServiceName(sService, eToken); 1132 if (CreateMark(xMark, sService)) 1133 { 1134 ProcessAttributes(xAttrList, xMark); 1135 XMLHint_Impl* pHint = new XMLIndexMarkHint_Impl(xMark, xPos); 1136 rHints.Insert(pHint, rHints.Count()); 1137 } 1138 // else: can't create mark -> ignore 1139 break; 1140 } 1141 1142 case XML_TOK_TEXT_TOC_MARK_START: 1143 case XML_TOK_TEXT_USER_INDEX_MARK_START: 1144 case XML_TOK_TEXT_ALPHA_INDEX_MARK_START: 1145 { 1146 // start: create mark and insert (if ID is found) 1147 OUString sService; 1148 GetServiceName(sService, eToken); 1149 if (CreateMark(xMark, sService)) 1150 { 1151 ProcessAttributes(xAttrList, xMark); 1152 if (sID.getLength() > 0) 1153 { 1154 // process only if we find an ID 1155 XMLHint_Impl* pHint = 1156 new XMLIndexMarkHint_Impl(xMark, xPos, sID); 1157 rHints.Insert(pHint, rHints.Count()); 1158 } 1159 // else: no ID -> we'll never find the end -> ignore 1160 } 1161 // else: can't create mark -> ignore 1162 break; 1163 } 1164 1165 case XML_TOK_TEXT_TOC_MARK_END: 1166 case XML_TOK_TEXT_USER_INDEX_MARK_END: 1167 case XML_TOK_TEXT_ALPHA_INDEX_MARK_END: 1168 { 1169 // end: search for ID and set end of mark 1170 1171 // call process attributes with empty XPropertySet: 1172 ProcessAttributes(xAttrList, xMark); 1173 if (sID.getLength() > 0) 1174 { 1175 // if we have an ID, find the hint and set the end position 1176 sal_uInt16 nCount = rHints.Count(); 1177 for(sal_uInt16 nPos = 0; nPos < nCount; nPos++) 1178 { 1179 XMLHint_Impl *pHint = rHints[nPos]; 1180 if ( pHint->IsIndexMark() && 1181 sID.equals( 1182 ((XMLIndexMarkHint_Impl *)pHint)->GetID()) ) 1183 { 1184 // set end and stop searching 1185 pHint->SetEnd(xPos); 1186 break; 1187 } 1188 } 1189 } 1190 // else: no ID -> ignore 1191 break; 1192 } 1193 1194 default: 1195 DBG_ERROR("unknown index mark type!"); 1196 break; 1197 } 1198 } 1199 1200 void XMLIndexMarkImportContext_Impl::ProcessAttributes( 1201 const Reference<xml::sax::XAttributeList> & xAttrList, 1202 Reference<beans::XPropertySet>& rPropSet) 1203 { 1204 // process attributes 1205 sal_Int16 nLength = xAttrList->getLength(); 1206 for(sal_Int16 i=0; i<nLength; i++) 1207 { 1208 OUString sLocalName; 1209 sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). 1210 GetKeyByAttrName( xAttrList->getNameByIndex(i), &sLocalName ); 1211 1212 ProcessAttribute(nPrefix, sLocalName, 1213 xAttrList->getValueByIndex(i), 1214 rPropSet); 1215 } 1216 } 1217 1218 void XMLIndexMarkImportContext_Impl::ProcessAttribute( 1219 sal_uInt16 nNamespace, 1220 OUString sLocalName, 1221 OUString sValue, 1222 Reference<beans::XPropertySet>& rPropSet) 1223 { 1224 // we only know ID + string-value attribute; 1225 // (former: marks, latter: -start + -end-marks) 1226 // the remainder is handled in sub-classes 1227 switch (eToken) 1228 { 1229 case XML_TOK_TEXT_TOC_MARK: 1230 case XML_TOK_TEXT_USER_INDEX_MARK: 1231 case XML_TOK_TEXT_ALPHA_INDEX_MARK: 1232 if ( (XML_NAMESPACE_TEXT == nNamespace) && 1233 IsXMLToken( sLocalName, XML_STRING_VALUE ) ) 1234 { 1235 rPropSet->setPropertyValue(sAlternativeText, uno::makeAny(sValue)); 1236 } 1237 // else: ignore! 1238 break; 1239 1240 case XML_TOK_TEXT_TOC_MARK_START: 1241 case XML_TOK_TEXT_USER_INDEX_MARK_START: 1242 case XML_TOK_TEXT_ALPHA_INDEX_MARK_START: 1243 case XML_TOK_TEXT_TOC_MARK_END: 1244 case XML_TOK_TEXT_USER_INDEX_MARK_END: 1245 case XML_TOK_TEXT_ALPHA_INDEX_MARK_END: 1246 if ( (XML_NAMESPACE_TEXT == nNamespace) && 1247 IsXMLToken( sLocalName, XML_ID ) ) 1248 { 1249 sID = sValue; 1250 } 1251 // else: ignore 1252 break; 1253 1254 default: 1255 DBG_ERROR("unknown index mark type!"); 1256 break; 1257 } 1258 } 1259 1260 static const sal_Char sAPI_com_sun_star_text_ContentIndexMark[] = 1261 "com.sun.star.text.ContentIndexMark"; 1262 static const sal_Char sAPI_com_sun_star_text_UserIndexMark[] = 1263 "com.sun.star.text.UserIndexMark"; 1264 static const sal_Char sAPI_com_sun_star_text_DocumentIndexMark[] = 1265 "com.sun.star.text.DocumentIndexMark"; 1266 1267 1268 void XMLIndexMarkImportContext_Impl::GetServiceName( 1269 OUString& sServiceName, 1270 enum XMLTextPElemTokens eToken) 1271 { 1272 switch (eToken) 1273 { 1274 case XML_TOK_TEXT_TOC_MARK: 1275 case XML_TOK_TEXT_TOC_MARK_START: 1276 case XML_TOK_TEXT_TOC_MARK_END: 1277 { 1278 OUString sTmp(RTL_CONSTASCII_USTRINGPARAM( 1279 sAPI_com_sun_star_text_ContentIndexMark)); 1280 sServiceName = sTmp; 1281 break; 1282 } 1283 1284 case XML_TOK_TEXT_USER_INDEX_MARK: 1285 case XML_TOK_TEXT_USER_INDEX_MARK_START: 1286 case XML_TOK_TEXT_USER_INDEX_MARK_END: 1287 { 1288 OUString sTmp(RTL_CONSTASCII_USTRINGPARAM( 1289 sAPI_com_sun_star_text_UserIndexMark)); 1290 sServiceName = sTmp; 1291 break; 1292 } 1293 1294 case XML_TOK_TEXT_ALPHA_INDEX_MARK: 1295 case XML_TOK_TEXT_ALPHA_INDEX_MARK_START: 1296 case XML_TOK_TEXT_ALPHA_INDEX_MARK_END: 1297 { 1298 OUString sTmp(RTL_CONSTASCII_USTRINGPARAM( 1299 sAPI_com_sun_star_text_DocumentIndexMark)); 1300 sServiceName = sTmp; 1301 break; 1302 } 1303 1304 default: 1305 { 1306 DBG_ERROR("unknown index mark type!"); 1307 OUString sTmp; 1308 sServiceName = sTmp; 1309 break; 1310 } 1311 } 1312 } 1313 1314 1315 sal_Bool XMLIndexMarkImportContext_Impl::CreateMark( 1316 Reference<beans::XPropertySet>& rPropSet, 1317 const OUString& rServiceName) 1318 { 1319 Reference<lang::XMultiServiceFactory> 1320 xFactory(GetImport().GetModel(), UNO_QUERY); 1321 1322 if( xFactory.is() ) 1323 { 1324 Reference<beans::XPropertySet> xPropSet( xFactory->createInstance(rServiceName), UNO_QUERY ); 1325 if (xPropSet.is()) 1326 rPropSet = xPropSet; 1327 return sal_True; 1328 } 1329 1330 return sal_False; 1331 } 1332 1333 1334 class XMLTOCMarkImportContext_Impl : public XMLIndexMarkImportContext_Impl 1335 { 1336 const OUString sLevel; 1337 1338 public: 1339 TYPEINFO(); 1340 1341 XMLTOCMarkImportContext_Impl( 1342 SvXMLImport& rImport, 1343 sal_uInt16 nPrefix, 1344 const OUString& rLocalName, 1345 enum XMLTextPElemTokens nTok, 1346 XMLHints_Impl& rHnts); 1347 1348 protected: 1349 1350 /** process outline level */ 1351 virtual void ProcessAttribute(sal_uInt16 nNamespace, 1352 OUString sLocalName, 1353 OUString sValue, 1354 Reference<beans::XPropertySet>& rPropSet); 1355 }; 1356 1357 TYPEINIT1( XMLTOCMarkImportContext_Impl, XMLIndexMarkImportContext_Impl ); 1358 1359 1360 XMLTOCMarkImportContext_Impl::XMLTOCMarkImportContext_Impl( 1361 SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName, 1362 enum XMLTextPElemTokens nTok, XMLHints_Impl& rHnts) : 1363 XMLIndexMarkImportContext_Impl(rImport, nPrefix, rLocalName, 1364 nTok, rHnts), 1365 sLevel(RTL_CONSTASCII_USTRINGPARAM("Level")) 1366 { 1367 } 1368 1369 void XMLTOCMarkImportContext_Impl::ProcessAttribute( 1370 sal_uInt16 nNamespace, 1371 OUString sLocalName, 1372 OUString sValue, 1373 Reference<beans::XPropertySet>& rPropSet) 1374 { 1375 DBG_ASSERT(rPropSet.is(), "need PropertySet"); 1376 1377 if ((XML_NAMESPACE_TEXT == nNamespace) && 1378 IsXMLToken( sLocalName, XML_OUTLINE_LEVEL ) ) 1379 { 1380 // ouline level: set Level property 1381 sal_Int32 nTmp; 1382 if ( SvXMLUnitConverter::convertNumber( nTmp, sValue ) 1383 && nTmp >= 1 1384 && nTmp < GetImport().GetTextImport()-> 1385 GetChapterNumbering()->getCount() ) 1386 { 1387 rPropSet->setPropertyValue(sLevel, uno::makeAny((sal_Int16)(nTmp - 1))); 1388 } 1389 // else: value out of range -> ignore 1390 } 1391 else 1392 { 1393 // else: delegate to superclass 1394 XMLIndexMarkImportContext_Impl::ProcessAttribute( 1395 nNamespace, sLocalName, sValue, rPropSet); 1396 } 1397 } 1398 1399 class XMLUserIndexMarkImportContext_Impl : public XMLIndexMarkImportContext_Impl 1400 { 1401 const OUString sUserIndexName; 1402 const OUString sLevel; 1403 1404 public: 1405 TYPEINFO(); 1406 1407 XMLUserIndexMarkImportContext_Impl( 1408 SvXMLImport& rImport, 1409 sal_uInt16 nPrefix, 1410 const OUString& rLocalName, 1411 enum XMLTextPElemTokens nTok, 1412 XMLHints_Impl& rHnts); 1413 1414 protected: 1415 1416 /** process index name */ 1417 virtual void ProcessAttribute(sal_uInt16 nNamespace, 1418 OUString sLocalName, 1419 OUString sValue, 1420 Reference<beans::XPropertySet>& rPropSet); 1421 }; 1422 1423 TYPEINIT1( XMLUserIndexMarkImportContext_Impl, XMLIndexMarkImportContext_Impl); 1424 1425 XMLUserIndexMarkImportContext_Impl::XMLUserIndexMarkImportContext_Impl( 1426 SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName, 1427 enum XMLTextPElemTokens nTok, XMLHints_Impl& rHnts) : 1428 XMLIndexMarkImportContext_Impl(rImport, nPrefix, rLocalName, 1429 nTok, rHnts), 1430 sUserIndexName(RTL_CONSTASCII_USTRINGPARAM("UserIndexName")), 1431 sLevel(RTL_CONSTASCII_USTRINGPARAM("Level")) 1432 { 1433 } 1434 1435 void XMLUserIndexMarkImportContext_Impl::ProcessAttribute( 1436 sal_uInt16 nNamespace, OUString sLocalName, OUString sValue, 1437 Reference<beans::XPropertySet>& rPropSet) 1438 { 1439 if ( XML_NAMESPACE_TEXT == nNamespace ) 1440 { 1441 if ( IsXMLToken( sLocalName, XML_INDEX_NAME ) ) 1442 { 1443 rPropSet->setPropertyValue(sUserIndexName, uno::makeAny(sValue)); 1444 } 1445 else if ( IsXMLToken( sLocalName, XML_OUTLINE_LEVEL ) ) 1446 { 1447 // ouline level: set Level property 1448 sal_Int32 nTmp; 1449 if (SvXMLUnitConverter::convertNumber( 1450 nTmp, sValue, 0, 1451 GetImport().GetTextImport()->GetChapterNumbering()->getCount())) 1452 { 1453 rPropSet->setPropertyValue(sLevel, uno::makeAny(static_cast<sal_Int16>(nTmp - 1))); 1454 } 1455 // else: value out of range -> ignore 1456 } 1457 else 1458 { 1459 // else: unknown text property: delegate to super class 1460 XMLIndexMarkImportContext_Impl::ProcessAttribute( 1461 nNamespace, sLocalName, sValue, rPropSet); 1462 } 1463 } 1464 else 1465 { 1466 // else: unknown namespace: delegate to super class 1467 XMLIndexMarkImportContext_Impl::ProcessAttribute( 1468 nNamespace, sLocalName, sValue, rPropSet); 1469 } 1470 } 1471 1472 1473 class XMLAlphaIndexMarkImportContext_Impl : public XMLIndexMarkImportContext_Impl 1474 { 1475 const OUString sPrimaryKey; 1476 const OUString sSecondaryKey; 1477 const OUString sTextReading; 1478 const OUString sPrimaryKeyReading; 1479 const OUString sSecondaryKeyReading; 1480 const OUString sMainEntry; 1481 1482 public: 1483 TYPEINFO(); 1484 1485 XMLAlphaIndexMarkImportContext_Impl( 1486 SvXMLImport& rImport, 1487 sal_uInt16 nPrefix, 1488 const OUString& rLocalName, 1489 enum XMLTextPElemTokens nTok, 1490 XMLHints_Impl& rHnts); 1491 1492 protected: 1493 1494 /** process primary + secondary keys */ 1495 virtual void ProcessAttribute(sal_uInt16 nNamespace, 1496 OUString sLocalName, 1497 OUString sValue, 1498 Reference<beans::XPropertySet>& rPropSet); 1499 }; 1500 1501 TYPEINIT1( XMLAlphaIndexMarkImportContext_Impl, 1502 XMLIndexMarkImportContext_Impl ); 1503 1504 XMLAlphaIndexMarkImportContext_Impl::XMLAlphaIndexMarkImportContext_Impl( 1505 SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName, 1506 enum XMLTextPElemTokens nTok, XMLHints_Impl& rHnts) : 1507 XMLIndexMarkImportContext_Impl(rImport, nPrefix, rLocalName, 1508 nTok, rHnts), 1509 sPrimaryKey(RTL_CONSTASCII_USTRINGPARAM("PrimaryKey")), 1510 sSecondaryKey(RTL_CONSTASCII_USTRINGPARAM("SecondaryKey")), 1511 sTextReading(RTL_CONSTASCII_USTRINGPARAM("TextReading")), 1512 sPrimaryKeyReading(RTL_CONSTASCII_USTRINGPARAM("PrimaryKeyReading")), 1513 sSecondaryKeyReading(RTL_CONSTASCII_USTRINGPARAM("SecondaryKeyReading")), 1514 sMainEntry(RTL_CONSTASCII_USTRINGPARAM("IsMainEntry")) 1515 { 1516 } 1517 1518 void XMLAlphaIndexMarkImportContext_Impl::ProcessAttribute( 1519 sal_uInt16 nNamespace, OUString sLocalName, OUString sValue, 1520 Reference<beans::XPropertySet>& rPropSet) 1521 { 1522 if (XML_NAMESPACE_TEXT == nNamespace) 1523 { 1524 if ( IsXMLToken( sLocalName, XML_KEY1 ) ) 1525 { 1526 rPropSet->setPropertyValue(sPrimaryKey, uno::makeAny(sValue)); 1527 } 1528 else if ( IsXMLToken( sLocalName, XML_KEY2 ) ) 1529 { 1530 rPropSet->setPropertyValue(sSecondaryKey, uno::makeAny(sValue)); 1531 } 1532 else if ( IsXMLToken( sLocalName, XML_KEY1_PHONETIC ) ) 1533 { 1534 rPropSet->setPropertyValue(sPrimaryKeyReading, uno::makeAny(sValue)); 1535 } 1536 else if ( IsXMLToken( sLocalName, XML_KEY2_PHONETIC ) ) 1537 { 1538 rPropSet->setPropertyValue(sSecondaryKeyReading, uno::makeAny(sValue)); 1539 } 1540 else if ( IsXMLToken( sLocalName, XML_STRING_VALUE_PHONETIC ) ) 1541 { 1542 rPropSet->setPropertyValue(sTextReading, uno::makeAny(sValue)); 1543 } 1544 else if ( IsXMLToken( sLocalName, XML_MAIN_ENTRY ) ) 1545 { 1546 sal_Bool bMainEntry = sal_False, bTmp; 1547 1548 if (SvXMLUnitConverter::convertBool(bTmp, sValue)) 1549 bMainEntry = bTmp; 1550 1551 rPropSet->setPropertyValue(sMainEntry, uno::makeAny(bMainEntry)); 1552 } 1553 else 1554 { 1555 XMLIndexMarkImportContext_Impl::ProcessAttribute( 1556 nNamespace, sLocalName, sValue, rPropSet); 1557 } 1558 } 1559 else 1560 { 1561 XMLIndexMarkImportContext_Impl::ProcessAttribute( 1562 nNamespace, sLocalName, sValue, rPropSet); 1563 } 1564 } 1565 1566 1567 // --------------------------------------------------------------------- 1568 1569 TYPEINIT1( XMLImpSpanContext_Impl, SvXMLImportContext ); 1570 1571 XMLImpSpanContext_Impl::XMLImpSpanContext_Impl( 1572 SvXMLImport& rImport, 1573 sal_uInt16 nPrfx, 1574 const OUString& rLName, 1575 const Reference< xml::sax::XAttributeList > & xAttrList, 1576 XMLHints_Impl& rHnts, 1577 sal_Bool& rIgnLeadSpace 1578 ,sal_uInt8 nSFConvFlags 1579 ) 1580 : SvXMLImportContext( rImport, nPrfx, rLName ) 1581 , sTextFrame(RTL_CONSTASCII_USTRINGPARAM("TextFrame")) 1582 , rHints( rHnts ) 1583 , pHint( 0 ) 1584 , rIgnoreLeadingSpace( rIgnLeadSpace ) 1585 , nStarFontsConvFlags( nSFConvFlags & (CONV_FROM_STAR_BATS|CONV_FROM_STAR_MATH) ) 1586 { 1587 OUString aStyleName; 1588 1589 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 1590 for( sal_Int16 i=0; i < nAttrCount; i++ ) 1591 { 1592 const OUString& rAttrName = xAttrList->getNameByIndex( i ); 1593 1594 OUString aLocalName; 1595 sal_uInt16 nPrefix = 1596 GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, 1597 &aLocalName ); 1598 if( XML_NAMESPACE_TEXT == nPrefix && 1599 IsXMLToken( aLocalName, XML_STYLE_NAME ) ) 1600 aStyleName = xAttrList->getValueByIndex( i ); 1601 } 1602 1603 if( aStyleName.getLength() ) 1604 { 1605 pHint = new XMLStyleHint_Impl( aStyleName, 1606 GetImport().GetTextImport()->GetCursorAsRange()->getStart() ); 1607 rHints.Insert( pHint, rHints.Count() ); 1608 } 1609 } 1610 1611 XMLImpSpanContext_Impl::~XMLImpSpanContext_Impl() 1612 { 1613 if( pHint ) 1614 pHint->SetEnd( GetImport().GetTextImport() 1615 ->GetCursorAsRange()->getStart() ); 1616 } 1617 1618 SvXMLImportContext *XMLImpSpanContext_Impl::CreateChildContext( 1619 SvXMLImport& rImport, 1620 sal_uInt16 nPrefix, const OUString& rLocalName, 1621 const Reference< xml::sax::XAttributeList > & xAttrList, 1622 sal_uInt16 nToken, 1623 XMLHints_Impl& rHints, 1624 sal_Bool& rIgnoreLeadingSpace 1625 ,sal_uInt8 nStarFontsConvFlags 1626 ) 1627 { 1628 SvXMLImportContext *pContext = 0; 1629 1630 switch( nToken ) 1631 { 1632 case XML_TOK_TEXT_SPAN: 1633 pContext = new XMLImpSpanContext_Impl( rImport, nPrefix, 1634 rLocalName, xAttrList, 1635 rHints, 1636 rIgnoreLeadingSpace 1637 ,nStarFontsConvFlags 1638 ); 1639 break; 1640 1641 case XML_TOK_TEXT_TAB_STOP: 1642 pContext = new XMLCharContext( rImport, nPrefix, 1643 rLocalName, xAttrList, 1644 0x0009, sal_False ); 1645 rIgnoreLeadingSpace = sal_False; 1646 break; 1647 1648 case XML_TOK_TEXT_LINE_BREAK: 1649 pContext = new XMLCharContext( rImport, nPrefix, 1650 rLocalName, xAttrList, 1651 ControlCharacter::LINE_BREAK ); 1652 rIgnoreLeadingSpace = sal_False; 1653 break; 1654 1655 case XML_TOK_TEXT_S: 1656 pContext = new XMLCharContext( rImport, nPrefix, 1657 rLocalName, xAttrList, 1658 0x0020, sal_True ); 1659 break; 1660 1661 case XML_TOK_TEXT_HYPERLINK: 1662 { 1663 // test for HyperLinkURL property. If present, insert link as 1664 // text property (StarWriter), else try to insert as text 1665 // field (StarCalc, StarDraw, ...) 1666 Reference< beans::XPropertySet > xPropSet( rImport.GetTextImport()->GetCursor(), UNO_QUERY ); 1667 1668 static const OUString sHyperLinkURL( RTL_CONSTASCII_USTRINGPARAM( "HyperLinkURL" ) ); 1669 1670 if ( xPropSet->getPropertySetInfo()->hasPropertyByName( sHyperLinkURL ) ) 1671 { 1672 pContext = new XMLImpHyperlinkContext_Impl( 1673 rImport, 1674 nPrefix, 1675 rLocalName, 1676 xAttrList, 1677 rHints, 1678 rIgnoreLeadingSpace ); 1679 } 1680 else 1681 { 1682 pContext = new XMLUrlFieldImportContext( rImport, *rImport.GetTextImport().get(), nPrefix, rLocalName ); 1683 //whitespace handling like other fields 1684 rIgnoreLeadingSpace = sal_False; 1685 1686 } 1687 break; 1688 } 1689 1690 case XML_TOK_TEXT_RUBY: 1691 pContext = new XMLImpRubyContext_Impl( rImport, nPrefix, 1692 rLocalName, xAttrList, 1693 rHints, 1694 rIgnoreLeadingSpace ); 1695 break; 1696 1697 case XML_TOK_TEXT_NOTE: 1698 #ifndef SVX_LIGHT 1699 if (rImport.GetTextImport()->IsInFrame()) 1700 { 1701 // we must not insert footnotes into text frames 1702 pContext = new SvXMLImportContext( rImport, nPrefix, 1703 rLocalName ); 1704 } 1705 else 1706 { 1707 pContext = new XMLFootnoteImportContext( rImport, 1708 *rImport.GetTextImport().get(), 1709 nPrefix, rLocalName ); 1710 } 1711 #else 1712 // create default context to skip content 1713 pContext = new SvXMLImportContext( rImport, nPrefix, rLocalName ); 1714 #endif // #ifndef SVX_LIGHT 1715 rIgnoreLeadingSpace = sal_False; 1716 break; 1717 1718 case XML_TOK_TEXT_REFERENCE: 1719 case XML_TOK_TEXT_BOOKMARK: 1720 case XML_TOK_TEXT_BOOKMARK_START: 1721 case XML_TOK_TEXT_BOOKMARK_END: 1722 pContext = new XMLTextMarkImportContext( rImport, 1723 *rImport.GetTextImport().get(), 1724 nPrefix, rLocalName ); 1725 break; 1726 1727 case XML_TOK_TEXT_FIELDMARK: 1728 case XML_TOK_TEXT_FIELDMARK_START: 1729 case XML_TOK_TEXT_FIELDMARK_END: 1730 pContext = new XMLTextMarkImportContext( rImport, 1731 *rImport.GetTextImport().get(), 1732 nPrefix, rLocalName ); 1733 break; 1734 1735 case XML_TOK_TEXT_REFERENCE_START: 1736 pContext = new XMLStartReferenceContext_Impl( rImport, 1737 nPrefix, rLocalName, 1738 rHints, xAttrList ); 1739 break; 1740 1741 case XML_TOK_TEXT_REFERENCE_END: 1742 pContext = new XMLEndReferenceContext_Impl( rImport, 1743 nPrefix, rLocalName, 1744 rHints, xAttrList ); 1745 break; 1746 1747 case XML_TOK_TEXT_FRAME: 1748 { 1749 Reference < XTextRange > xAnchorPos = 1750 rImport.GetTextImport()->GetCursor()->getStart(); 1751 XMLTextFrameContext *pTextFrameContext = 1752 new XMLTextFrameContext( rImport, nPrefix, 1753 rLocalName, xAttrList, 1754 TextContentAnchorType_AS_CHARACTER ); 1755 // --> OD 2004-08-24 #i33242# - remove check for text content. 1756 // Check for text content is done on the processing of the hint 1757 if( TextContentAnchorType_AT_CHARACTER == 1758 pTextFrameContext->GetAnchorType() ) 1759 // <-- 1760 { 1761 rHints.Insert( new XMLTextFrameHint_Impl( 1762 pTextFrameContext, xAnchorPos ), 1763 rHints.Count() ); 1764 } 1765 pContext = pTextFrameContext; 1766 rIgnoreLeadingSpace = sal_False; 1767 } 1768 break; 1769 case XML_TOK_DRAW_A: 1770 { 1771 Reference < XTextRange > xAnchorPos(rImport.GetTextImport()->GetCursor()->getStart()); 1772 pContext = 1773 new XMLTextFrameHyperlinkContext( rImport, nPrefix, 1774 rLocalName, xAttrList, 1775 TextContentAnchorType_AS_CHARACTER ); 1776 XMLTextFrameHint_Impl *pHint = 1777 new XMLTextFrameHint_Impl( pContext, xAnchorPos); 1778 rHints.Insert( pHint, rHints.Count() ); 1779 } 1780 break; 1781 1782 case XML_TOK_TEXT_TOC_MARK: 1783 case XML_TOK_TEXT_TOC_MARK_START: 1784 pContext = new XMLTOCMarkImportContext_Impl( 1785 rImport, nPrefix, rLocalName, 1786 (enum XMLTextPElemTokens)nToken, rHints); 1787 break; 1788 1789 case XML_TOK_TEXT_USER_INDEX_MARK: 1790 case XML_TOK_TEXT_USER_INDEX_MARK_START: 1791 pContext = new XMLUserIndexMarkImportContext_Impl( 1792 rImport, nPrefix, rLocalName, 1793 (enum XMLTextPElemTokens)nToken, rHints); 1794 break; 1795 1796 case XML_TOK_TEXT_ALPHA_INDEX_MARK: 1797 case XML_TOK_TEXT_ALPHA_INDEX_MARK_START: 1798 pContext = new XMLAlphaIndexMarkImportContext_Impl( 1799 rImport, nPrefix, rLocalName, 1800 (enum XMLTextPElemTokens)nToken, rHints); 1801 break; 1802 1803 case XML_TOK_TEXT_TOC_MARK_END: 1804 case XML_TOK_TEXT_USER_INDEX_MARK_END: 1805 case XML_TOK_TEXT_ALPHA_INDEX_MARK_END: 1806 pContext = new XMLIndexMarkImportContext_Impl( 1807 rImport, nPrefix, rLocalName, (enum XMLTextPElemTokens)nToken, 1808 rHints); 1809 break; 1810 1811 case XML_TOK_TEXTP_CHANGE_START: 1812 case XML_TOK_TEXTP_CHANGE_END: 1813 case XML_TOK_TEXTP_CHANGE: 1814 pContext = new XMLChangeImportContext( 1815 rImport, nPrefix, rLocalName, 1816 (nToken != XML_TOK_TEXTP_CHANGE_END), 1817 (nToken != XML_TOK_TEXTP_CHANGE_START), 1818 sal_False); 1819 break; 1820 1821 case XML_TOK_TEXT_META: 1822 pContext = new XMLMetaImportContext(rImport, nPrefix, rLocalName, 1823 rHints, rIgnoreLeadingSpace ); 1824 break; 1825 1826 case XML_TOK_TEXT_META_FIELD: 1827 pContext = new XMLMetaFieldImportContext(rImport, nPrefix, rLocalName, 1828 rHints, rIgnoreLeadingSpace ); 1829 break; 1830 1831 default: 1832 // none of the above? then it's probably a text field! 1833 pContext = 1834 XMLTextFieldImportContext::CreateTextFieldImportContext( 1835 rImport, *rImport.GetTextImport().get(), nPrefix, rLocalName, 1836 nToken); 1837 // #108784# import draw elements (except control shapes in headers) 1838 if( pContext == NULL && 1839 !( rImport.GetTextImport()->IsInHeaderFooter() && 1840 nPrefix == XML_NAMESPACE_DRAW && 1841 IsXMLToken( rLocalName, XML_CONTROL ) ) ) 1842 { 1843 Reference < XShapes > xShapes; 1844 SvXMLShapeContext* pShapeContext = rImport.GetShapeImport()->CreateGroupChildContext( 1845 rImport, nPrefix, rLocalName, xAttrList, xShapes ); 1846 pContext = pShapeContext; 1847 // OD 2004-04-20 #i26791# - keep shape in a text frame hint to 1848 // adjust its anchor position, if its at-character anchored 1849 Reference < XTextRange > xAnchorPos = 1850 rImport.GetTextImport()->GetCursor()->getStart(); 1851 rHints.Insert( new XMLDrawHint_Impl( pShapeContext, xAnchorPos ), 1852 rHints.Count() ); 1853 } 1854 if( !pContext ) 1855 { 1856 // ignore unknown content 1857 pContext = 1858 new SvXMLImportContext( rImport, nPrefix, rLocalName ); 1859 } 1860 // Behind fields, shapes and any unknown content blanks aren't ignored 1861 rIgnoreLeadingSpace = sal_False; 1862 } 1863 1864 return pContext; 1865 } 1866 1867 SvXMLImportContext *XMLImpSpanContext_Impl::CreateChildContext( 1868 sal_uInt16 nPrefix, const OUString& rLocalName, 1869 const Reference< xml::sax::XAttributeList > & xAttrList ) 1870 { 1871 const SvXMLTokenMap& rTokenMap = 1872 GetImport().GetTextImport()->GetTextPElemTokenMap(); 1873 sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName ); 1874 1875 return CreateChildContext( GetImport(), nPrefix, rLocalName, xAttrList, 1876 nToken, rHints, rIgnoreLeadingSpace 1877 ,nStarFontsConvFlags 1878 ); 1879 } 1880 1881 void XMLImpSpanContext_Impl::Characters( const OUString& rChars ) 1882 { 1883 OUString sStyleName; 1884 if( pHint ) 1885 sStyleName = pHint->GetStyleName(); 1886 OUString sChars = 1887 GetImport().GetTextImport()->ConvertStarFonts( rChars, sStyleName, 1888 nStarFontsConvFlags, 1889 sal_False, GetImport() ); 1890 GetImport().GetTextImport()->InsertString( sChars, rIgnoreLeadingSpace ); 1891 } 1892 1893 // --------------------------------------------------------------------- 1894 1895 TYPEINIT1( XMLParaContext, SvXMLImportContext ); 1896 1897 XMLParaContext::XMLParaContext( 1898 SvXMLImport& rImport, 1899 sal_uInt16 nPrfx, 1900 const OUString& rLName, 1901 const Reference< xml::sax::XAttributeList > & xAttrList, 1902 sal_Bool bHead ) : 1903 SvXMLImportContext( rImport, nPrfx, rLName ), 1904 xStart( rImport.GetTextImport()->GetCursorAsRange()->getStart() ), 1905 m_bHaveAbout(false), 1906 nOutlineLevel( IsXMLToken( rLName, XML_H ) ? 1 : -1 ), 1907 pHints( 0 ), 1908 // --> OD 2007-07-25 #i73509# 1909 mbOutlineLevelAttrFound( sal_False ), 1910 // <-- 1911 bIgnoreLeadingSpace( sal_True ), 1912 bHeading( bHead ), 1913 bIsListHeader( false ), 1914 bIsRestart (false), 1915 nStartValue(0) 1916 ,nStarFontsConvFlags( 0 ) 1917 { 1918 const SvXMLTokenMap& rTokenMap = 1919 GetImport().GetTextImport()->GetTextPAttrTokenMap(); 1920 1921 bool bHaveXmlId( false ); 1922 OUString aCondStyleName, sClassNames; 1923 1924 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 1925 for( sal_Int16 i=0; i < nAttrCount; i++ ) 1926 { 1927 const OUString& rAttrName = xAttrList->getNameByIndex( i ); 1928 const OUString& rValue = xAttrList->getValueByIndex( i ); 1929 1930 OUString aLocalName; 1931 sal_uInt16 nPrefix = 1932 GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, 1933 &aLocalName ); 1934 switch( rTokenMap.Get( nPrefix, aLocalName ) ) 1935 { 1936 case XML_TOK_TEXT_P_XMLID: 1937 m_sXmlId = rValue; 1938 bHaveXmlId = true; 1939 break; 1940 case XML_TOK_TEXT_P_ABOUT: 1941 m_sAbout = rValue; 1942 m_bHaveAbout = true; 1943 break; 1944 case XML_TOK_TEXT_P_PROPERTY: 1945 m_sProperty = rValue; 1946 break; 1947 case XML_TOK_TEXT_P_CONTENT: 1948 m_sContent = rValue; 1949 break; 1950 case XML_TOK_TEXT_P_DATATYPE: 1951 m_sDatatype = rValue; 1952 break; 1953 case XML_TOK_TEXT_P_TEXTID: 1954 if (!bHaveXmlId) { m_sXmlId = rValue; } 1955 break; 1956 case XML_TOK_TEXT_P_STYLE_NAME: 1957 sStyleName = rValue; 1958 break; 1959 case XML_TOK_TEXT_P_CLASS_NAMES: 1960 sClassNames = rValue; 1961 break; 1962 case XML_TOK_TEXT_P_COND_STYLE_NAME: 1963 aCondStyleName = rValue; 1964 break; 1965 case XML_TOK_TEXT_P_LEVEL: 1966 { 1967 sal_Int32 nTmp = rValue.toInt32(); 1968 if( nTmp > 0L ) 1969 { 1970 if( nTmp > 127 ) 1971 nTmp = 127; 1972 nOutlineLevel = (sal_Int8)nTmp; 1973 } 1974 // --> OD 2007-07-25 #i73509# 1975 mbOutlineLevelAttrFound = sal_True; 1976 // <-- 1977 } 1978 break; 1979 case XML_TOK_TEXT_P_IS_LIST_HEADER: 1980 { 1981 sal_Bool bBool; 1982 if( SvXMLUnitConverter::convertBool( bBool, rValue ) ) 1983 { 1984 bIsListHeader = bBool; 1985 } 1986 } 1987 break; 1988 case XML_TOK_TEXT_P_RESTART_NUMBERING: 1989 { 1990 sal_Bool bBool; 1991 if (SvXMLUnitConverter::convertBool(bBool, rValue)) 1992 { 1993 bIsRestart = bBool; 1994 } 1995 } 1996 break; 1997 case XML_TOK_TEXT_P_START_VALUE: 1998 { 1999 nStartValue = sal::static_int_cast< sal_Int16 >( 2000 rValue.toInt32()); 2001 } 2002 break; 2003 } 2004 } 2005 2006 if( aCondStyleName.getLength() ) 2007 sStyleName = aCondStyleName; 2008 else if( sClassNames.getLength() ) 2009 { 2010 sal_Int32 nDummy = 0; 2011 sStyleName = sClassNames.getToken( 0, ' ', nDummy ); 2012 } 2013 } 2014 2015 XMLParaContext::~XMLParaContext() 2016 { 2017 UniReference < XMLTextImportHelper > xTxtImport( 2018 GetImport().GetTextImport()); 2019 Reference < XTextRange > xCrsrRange( xTxtImport->GetCursorAsRange() ); 2020 if( !xCrsrRange.is() ) 2021 return; // Robust (defect file) 2022 Reference < XTextRange > xEnd(xCrsrRange->getStart()); 2023 2024 // if we have an id set for this paragraph, get a cursor for this 2025 // paragraph and register it with the given identifier 2026 // FIXME: this is just temporary, and should be removed when 2027 // EditEngine paragraphs implement XMetadatable! 2028 if (m_sXmlId.getLength()) 2029 { 2030 Reference < XTextCursor > xIdCursor( xTxtImport->GetText()->createTextCursorByRange( xStart ) ); 2031 if( xIdCursor.is() ) 2032 { 2033 xIdCursor->gotoRange( xEnd, sal_True ); 2034 Reference< XInterface > xRef( xIdCursor, UNO_QUERY ); 2035 GetImport().getInterfaceToIdentifierMapper().registerReference( 2036 m_sXmlId, xRef); 2037 } 2038 } 2039 2040 // insert a paragraph break 2041 xTxtImport->InsertControlCharacter( ControlCharacter::APPEND_PARAGRAPH ); 2042 2043 // create a cursor that select the whole last paragraph 2044 Reference < XTextCursor > xAttrCursor( 2045 xTxtImport->GetText()->createTextCursorByRange( xStart )); 2046 if( !xAttrCursor.is() ) 2047 return; // Robust (defect file) 2048 xAttrCursor->gotoRange( xEnd, sal_True ); 2049 2050 // xml:id for RDF metadata 2051 if (m_sXmlId.getLength() || m_bHaveAbout || m_sProperty.getLength()) 2052 { 2053 try { 2054 const uno::Reference<container::XEnumerationAccess> xEA 2055 (xAttrCursor, uno::UNO_QUERY_THROW); 2056 const uno::Reference<container::XEnumeration> xEnum( 2057 xEA->createEnumeration(), uno::UNO_QUERY_THROW); 2058 OSL_ENSURE(xEnum->hasMoreElements(), "xml:id: no paragraph?"); 2059 if (xEnum->hasMoreElements()) { 2060 uno::Reference<rdf::XMetadatable> xMeta; 2061 xEnum->nextElement() >>= xMeta; 2062 OSL_ENSURE(xMeta.is(), "xml:id: not XMetadatable"); 2063 GetImport().SetXmlId(xMeta, m_sXmlId); 2064 if (m_bHaveAbout) 2065 { 2066 GetImport().AddRDFa(xMeta, 2067 m_sAbout, m_sProperty, m_sContent, m_sDatatype); 2068 } 2069 OSL_ENSURE(!xEnum->hasMoreElements(), "xml:id: > 1 paragraph?"); 2070 } 2071 } catch (uno::Exception &) { 2072 OSL_TRACE("XMLParaContext::~XMLParaContext: exception"); 2073 } 2074 } 2075 2076 OUString const sCellParaStyleName(xTxtImport->GetCellParaStyleDefault()); 2077 if( sCellParaStyleName.getLength() > 0 ) 2078 { 2079 // --> OD 2007-08-16 #i80724# 2080 // suppress handling of outline and list attributes, 2081 // because of side effects of method <SetStyleAndAttrs(..)> 2082 xTxtImport->SetStyleAndAttrs( GetImport(), xAttrCursor, 2083 sCellParaStyleName, 2084 sal_True, 2085 sal_False, -1, // suppress outline handling 2086 sal_False ); // suppress list attributes handling 2087 // <-- 2088 } 2089 2090 // #103445# for headings without style name, find the proper style 2091 if( bHeading && (sStyleName.getLength() == 0) ) 2092 xTxtImport->FindOutlineStyleName( sStyleName, nOutlineLevel ); 2093 2094 // set style and hard attributes at the previous paragraph 2095 // --> OD 2007-07-25 #i73509# - add parameter <mbOutlineLevelAttrFound> 2096 sStyleName = xTxtImport->SetStyleAndAttrs( GetImport(), xAttrCursor, 2097 sStyleName, 2098 sal_True, 2099 mbOutlineLevelAttrFound, 2100 bHeading ? nOutlineLevel : -1 ); 2101 // <-- 2102 2103 // handle list style header 2104 if (bHeading && (bIsListHeader || bIsRestart)) 2105 { 2106 Reference<XPropertySet> xPropSet( xAttrCursor, UNO_QUERY ); 2107 2108 if (xPropSet.is()) 2109 { 2110 if (bIsListHeader) 2111 { 2112 OUString sNumberingIsNumber 2113 (RTL_CONSTASCII_USTRINGPARAM("NumberingIsNumber")); 2114 if(xPropSet->getPropertySetInfo()-> 2115 hasPropertyByName(sNumberingIsNumber)) 2116 { 2117 xPropSet->setPropertyValue 2118 (sNumberingIsNumber, makeAny( false ) ); 2119 } 2120 } 2121 if (bIsRestart) 2122 { 2123 OUString sParaIsNumberingRestart 2124 (RTL_CONSTASCII_USTRINGPARAM("ParaIsNumberingRestart")); 2125 OUString sNumberingStartValue 2126 (RTL_CONSTASCII_USTRINGPARAM("NumberingStartValue")); 2127 if (xPropSet->getPropertySetInfo()-> 2128 hasPropertyByName(sParaIsNumberingRestart)) 2129 { 2130 xPropSet->setPropertyValue 2131 (sParaIsNumberingRestart, makeAny(true)); 2132 } 2133 2134 if (xPropSet->getPropertySetInfo()-> 2135 hasPropertyByName(sNumberingStartValue)) 2136 { 2137 xPropSet->setPropertyValue 2138 (sNumberingStartValue, makeAny(nStartValue)); 2139 } 2140 } 2141 2142 } 2143 } 2144 2145 if( pHints && pHints->Count() ) 2146 { 2147 for( sal_uInt16 i=0; i<pHints->Count(); i++ ) 2148 { 2149 XMLHint_Impl *pHint = (*pHints)[i]; 2150 xAttrCursor->gotoRange( pHint->GetStart(), sal_False ); 2151 xAttrCursor->gotoRange( pHint->GetEnd(), sal_True ); 2152 switch( pHint->GetType() ) 2153 { 2154 case XML_HINT_STYLE: 2155 { 2156 const OUString& rStyleName = 2157 ((XMLStyleHint_Impl *)pHint)->GetStyleName(); 2158 if( rStyleName.getLength() ) 2159 xTxtImport->SetStyleAndAttrs( GetImport(), 2160 xAttrCursor, rStyleName, 2161 sal_False ); 2162 } 2163 break; 2164 case XML_HINT_REFERENCE: 2165 { 2166 const OUString& rRefName = 2167 ((XMLReferenceHint_Impl *)pHint)->GetRefName(); 2168 if( rRefName.getLength() ) 2169 { 2170 if( !pHint->GetEnd().is() ) 2171 pHint->SetEnd(xEnd); 2172 2173 // convert XCursor to XTextRange 2174 Reference<XTextRange> xRange(xAttrCursor, UNO_QUERY); 2175 2176 // reference name uses rStyleName member 2177 // borrow from XMLTextMarkImportContext 2178 XMLTextMarkImportContext::CreateAndInsertMark( 2179 GetImport(), 2180 OUString( 2181 RTL_CONSTASCII_USTRINGPARAM( 2182 "com.sun.star.text.ReferenceMark")), 2183 rRefName, 2184 xRange); 2185 } 2186 } 2187 break; 2188 case XML_HINT_HYPERLINK: 2189 { 2190 const XMLHyperlinkHint_Impl *pHHint = 2191 (const XMLHyperlinkHint_Impl *)pHint; 2192 xTxtImport->SetHyperlink( GetImport(), 2193 xAttrCursor, 2194 pHHint->GetHRef(), 2195 pHHint->GetName(), 2196 pHHint->GetTargetFrameName(), 2197 pHHint->GetStyleName(), 2198 pHHint->GetVisitedStyleName(), 2199 pHHint->GetEventsContext() ); 2200 } 2201 break; 2202 case XML_HINT_INDEX_MARK: 2203 { 2204 Reference<beans::XPropertySet> xMark( 2205 ((const XMLIndexMarkHint_Impl *)pHint)->GetMark()); 2206 Reference<XTextContent> xContent(xMark, UNO_QUERY); 2207 Reference<XTextRange> xRange(xAttrCursor, UNO_QUERY); 2208 xTxtImport->GetText()->insertTextContent( 2209 xRange, xContent, sal_True ); 2210 } 2211 break; 2212 case XML_HINT_TEXT_FRAME: 2213 { 2214 const XMLTextFrameHint_Impl *pFHint = 2215 (const XMLTextFrameHint_Impl *)pHint; 2216 // --> OD 2004-08-24 #i33242# - check for text content 2217 Reference < XTextContent > xTextContent = 2218 pFHint->GetTextContent(); 2219 if ( xTextContent.is() ) 2220 { 2221 // OD 2004-04-20 #i26791# 2222 Reference<XTextRange> xRange(xAttrCursor, UNO_QUERY); 2223 if ( pFHint->IsBoundAtChar() ) 2224 { 2225 xTextContent->attach( xRange ); 2226 } 2227 } 2228 // <-- 2229 // --> OD 2004-08-24 #i33242# - consider, that hint can 2230 // also contain a shape - e.g. drawing object of type 'Text'. 2231 else 2232 { 2233 Reference < XShape > xShape = pFHint->GetShape(); 2234 if ( xShape.is() ) 2235 { 2236 // determine anchor type 2237 Reference < XPropertySet > xPropSet( xShape, UNO_QUERY ); 2238 TextContentAnchorType eAnchorType = 2239 TextContentAnchorType_AT_PARAGRAPH; 2240 { 2241 OUString sAnchorType( RTL_CONSTASCII_USTRINGPARAM( "AnchorType" ) ); 2242 Any aAny = xPropSet->getPropertyValue( sAnchorType ); 2243 aAny >>= eAnchorType; 2244 } 2245 if ( TextContentAnchorType_AT_CHARACTER == eAnchorType ) 2246 { 2247 // set anchor position for at-character anchored objects 2248 Reference<XTextRange> xRange(xAttrCursor, UNO_QUERY); 2249 Any aPos; 2250 aPos <<= xRange; 2251 OUString sTextRange( RTL_CONSTASCII_USTRINGPARAM( "TextRange" ) ); 2252 xPropSet->setPropertyValue(sTextRange, aPos); 2253 } 2254 } 2255 } 2256 // <-- 2257 } 2258 break; 2259 // --> DVO, OD 2004-07-14 #i26791# 2260 case XML_HINT_DRAW: 2261 { 2262 const XMLDrawHint_Impl *pDHint = 2263 static_cast<const XMLDrawHint_Impl*>(pHint); 2264 // --> OD 2004-08-24 #i33242# - improvement: hint directly 2265 // provides the shape. 2266 Reference < XShape > xShape = pDHint->GetShape(); 2267 if ( xShape.is() ) 2268 { 2269 // determine anchor type 2270 Reference < XPropertySet > xPropSet( xShape, UNO_QUERY ); 2271 TextContentAnchorType eAnchorType = TextContentAnchorType_AT_PARAGRAPH; 2272 { 2273 OUString sAnchorType( RTL_CONSTASCII_USTRINGPARAM( "AnchorType" ) ); 2274 Any aAny = xPropSet->getPropertyValue( sAnchorType ); 2275 aAny >>= eAnchorType; 2276 } 2277 if ( TextContentAnchorType_AT_CHARACTER == eAnchorType ) 2278 { 2279 // set anchor position for at-character anchored objects 2280 Reference<XTextRange> xRange(xAttrCursor, UNO_QUERY); 2281 Any aPos; 2282 aPos <<= xRange; 2283 OUString sTextRange( RTL_CONSTASCII_USTRINGPARAM( "TextRange" ) ); 2284 xPropSet->setPropertyValue(sTextRange, aPos); 2285 } 2286 } 2287 // <-- 2288 } 2289 break; 2290 // <-- 2291 2292 default: 2293 DBG_ASSERT( sal_False, "What's this" ); 2294 break; 2295 } 2296 } 2297 } 2298 delete pHints; 2299 } 2300 2301 SvXMLImportContext *XMLParaContext::CreateChildContext( 2302 sal_uInt16 nPrefix, const OUString& rLocalName, 2303 const Reference< xml::sax::XAttributeList > & xAttrList ) 2304 { 2305 const SvXMLTokenMap& rTokenMap = 2306 GetImport().GetTextImport()->GetTextPElemTokenMap(); 2307 sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName ); 2308 if( !pHints ) 2309 pHints = new XMLHints_Impl; 2310 return XMLImpSpanContext_Impl::CreateChildContext( 2311 GetImport(), nPrefix, rLocalName, xAttrList, 2312 nToken, *pHints, bIgnoreLeadingSpace 2313 , nStarFontsConvFlags 2314 ); 2315 } 2316 2317 void XMLParaContext::Characters( const OUString& rChars ) 2318 { 2319 OUString sChars = 2320 GetImport().GetTextImport()->ConvertStarFonts( rChars, sStyleName, 2321 nStarFontsConvFlags, 2322 sal_True, GetImport() ); 2323 GetImport().GetTextImport()->InsertString( sChars, bIgnoreLeadingSpace ); 2324 } 2325 2326 2327 2328 TYPEINIT1( XMLNumberedParaContext, SvXMLImportContext ); 2329 2330 XMLNumberedParaContext::XMLNumberedParaContext( 2331 SvXMLImport& i_rImport, 2332 sal_uInt16 i_nPrefix, 2333 const OUString& i_rLocalName, 2334 const Reference< xml::sax::XAttributeList > & i_xAttrList ) : 2335 SvXMLImportContext( i_rImport, i_nPrefix, i_rLocalName ), 2336 m_Level(0), 2337 m_StartValue(-1), 2338 m_ListId(), 2339 m_xNumRules() 2340 { 2341 ::rtl::OUString StyleName; 2342 2343 const SvXMLTokenMap& rTokenMap( 2344 i_rImport.GetTextImport()->GetTextNumberedParagraphAttrTokenMap() ); 2345 2346 const sal_Int16 nAttrCount( i_xAttrList.is() ? 2347 i_xAttrList->getLength() : 0 ); 2348 for ( sal_Int16 i=0; i < nAttrCount; i++ ) 2349 { 2350 const ::rtl::OUString& rAttrName( i_xAttrList->getNameByIndex( i ) ); 2351 const ::rtl::OUString& rValue ( i_xAttrList->getValueByIndex( i ) ); 2352 2353 ::rtl::OUString aLocalName; 2354 const sal_uInt16 nPrefix( 2355 GetImport().GetNamespaceMap().GetKeyByAttrName( 2356 rAttrName, &aLocalName ) ); 2357 switch( rTokenMap.Get( nPrefix, aLocalName ) ) 2358 { 2359 case XML_TOK_TEXT_NUMBERED_PARAGRAPH_XMLID: 2360 m_XmlId = rValue; 2361 //FIXME: there is no UNO API for lists 2362 break; 2363 case XML_TOK_TEXT_NUMBERED_PARAGRAPH_LIST_ID: 2364 m_ListId = rValue; 2365 break; 2366 case XML_TOK_TEXT_NUMBERED_PARAGRAPH_LEVEL: 2367 { 2368 sal_Int32 nTmp = rValue.toInt32(); 2369 if ( nTmp >= 1 && nTmp <= SHRT_MAX ) { 2370 m_Level = static_cast<sal_uInt16>(nTmp) - 1; 2371 } 2372 } 2373 break; 2374 case XML_TOK_TEXT_NUMBERED_PARAGRAPH_STYLE_NAME: 2375 StyleName = rValue; 2376 break; 2377 case XML_TOK_TEXT_NUMBERED_PARAGRAPH_CONTINUE_NUMBERING: 2378 // this attribute is deprecated 2379 // ContinuteNumbering = IsXMLToken(rValue, XML_TRUE); 2380 break; 2381 case XML_TOK_TEXT_NUMBERED_PARAGRAPH_START_VALUE: 2382 { 2383 sal_Int32 nTmp = rValue.toInt32(); 2384 if ( nTmp >= 0 && nTmp <= SHRT_MAX ) { 2385 m_StartValue = static_cast<sal_Int16>(nTmp); 2386 } 2387 } 2388 break; 2389 } 2390 } 2391 2392 XMLTextListsHelper& rTextListsHelper( 2393 i_rImport.GetTextImport()->GetTextListHelper() ); 2394 if (!m_ListId.getLength()) { 2395 OSL_ENSURE( ! i_rImport.GetODFVersion().equalsAsciiL( 2396 RTL_CONSTASCII_STRINGPARAM("1.2") ), 2397 "invalid numbered-paragraph: no list-id (1.2)"); 2398 m_ListId = rTextListsHelper.GetNumberedParagraphListId(m_Level, 2399 StyleName); 2400 OSL_ENSURE(m_ListId.getLength(), "numbered-paragraph: no ListId"); 2401 if (!m_ListId.getLength()) { 2402 return; 2403 } 2404 } 2405 m_xNumRules = rTextListsHelper.EnsureNumberedParagraph( i_rImport, 2406 m_ListId, m_Level, StyleName); 2407 2408 OSL_ENSURE(m_xNumRules.is(), "numbered-paragraph: no NumRules"); 2409 2410 i_rImport.GetTextImport()->GetTextListHelper().PushListContext( this ); 2411 } 2412 2413 XMLNumberedParaContext::~XMLNumberedParaContext() 2414 { 2415 } 2416 2417 void XMLNumberedParaContext::EndElement() 2418 { 2419 if (m_ListId.getLength()) { 2420 GetImport().GetTextImport()->PopListContext(); 2421 } 2422 } 2423 2424 SvXMLImportContext *XMLNumberedParaContext::CreateChildContext( 2425 sal_uInt16 i_nPrefix, const OUString& i_rLocalName, 2426 const Reference< xml::sax::XAttributeList > & i_xAttrList ) 2427 { 2428 SvXMLImportContext *pContext( 0 ); 2429 2430 if ( XML_NAMESPACE_TEXT == i_nPrefix ) 2431 { 2432 bool bIsHeader( IsXMLToken( i_rLocalName, XML_H ) ); 2433 if ( bIsHeader || IsXMLToken( i_rLocalName, XML_P ) ) 2434 { 2435 pContext = new XMLParaContext( GetImport(), 2436 i_nPrefix, i_rLocalName, i_xAttrList, bIsHeader ); 2437 // ignore text:number } else if (IsXMLToken( i_rLocalName, XML_NUMBER )) { 2438 } 2439 } 2440 2441 if (!pContext) { 2442 pContext = SvXMLImportContext::CreateChildContext( 2443 i_nPrefix, i_rLocalName, i_xAttrList ); 2444 } 2445 2446 return pContext; 2447 } 2448