txtparai.cxx (63bba73c) | txtparai.cxx (c45df7c4) |
---|---|
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 --- 324 unchanged lines hidden (view full) --- 333 const Reference< xml::sax::XAttributeList > & xAttrList ); 334 335 virtual void Characters( const OUString& rChars ); 336}; 337// --------------------------------------------------------------------- 338 339class XMLImpHyperlinkContext_Impl : public SvXMLImportContext 340{ | 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 --- 324 unchanged lines hidden (view full) --- 333 const Reference< xml::sax::XAttributeList > & xAttrList ); 334 335 virtual void Characters( const OUString& rChars ); 336}; 337// --------------------------------------------------------------------- 338 339class XMLImpHyperlinkContext_Impl : public SvXMLImportContext 340{ |
341 XMLHints_Impl& rHints; 342 XMLHyperlinkHint_Impl *pHint; | 341 XMLHints_Impl& mrHints; 342 XMLHyperlinkHint_Impl *mpHint; |
343 | 343 |
344 sal_Bool& rIgnoreLeadingSpace; | 344 sal_Bool& mrbIgnoreLeadingSpace; |
345 346public: 347 348 TYPEINFO(); 349 350 XMLImpHyperlinkContext_Impl( 351 SvXMLImport& rImport, 352 sal_uInt16 nPrfx, --- 9 unchanged lines hidden (view full) --- 362 const Reference< xml::sax::XAttributeList > & xAttrList ); 363 364 virtual void Characters( const OUString& rChars ); 365}; 366 367TYPEINIT1( XMLImpHyperlinkContext_Impl, SvXMLImportContext ); 368 369XMLImpHyperlinkContext_Impl::XMLImpHyperlinkContext_Impl( | 345 346public: 347 348 TYPEINFO(); 349 350 XMLImpHyperlinkContext_Impl( 351 SvXMLImport& rImport, 352 sal_uInt16 nPrfx, --- 9 unchanged lines hidden (view full) --- 362 const Reference< xml::sax::XAttributeList > & xAttrList ); 363 364 virtual void Characters( const OUString& rChars ); 365}; 366 367TYPEINIT1( XMLImpHyperlinkContext_Impl, SvXMLImportContext ); 368 369XMLImpHyperlinkContext_Impl::XMLImpHyperlinkContext_Impl( |
370 SvXMLImport& rImport, 371 sal_uInt16 nPrfx, 372 const OUString& rLName, 373 const Reference< xml::sax::XAttributeList > & xAttrList, 374 XMLHints_Impl& rHnts, 375 sal_Bool& rIgnLeadSpace ) : 376 SvXMLImportContext( rImport, nPrfx, rLName ), 377 rHints( rHnts ), 378 pHint( new XMLHyperlinkHint_Impl( 379 GetImport().GetTextImport()->GetCursorAsRange()->getStart() ) ), 380 rIgnoreLeadingSpace( rIgnLeadSpace ) | 370 SvXMLImport& rImport, 371 sal_uInt16 nPrfx, 372 const OUString& rLName, 373 const Reference< xml::sax::XAttributeList > & xAttrList, 374 XMLHints_Impl& rHnts, 375 sal_Bool& rIgnLeadSpace ) 376 : SvXMLImportContext( rImport, nPrfx, rLName ) 377 , mrHints( rHnts ) 378 , mpHint( new XMLHyperlinkHint_Impl( GetImport().GetTextImport()->GetCursorAsRange()->getStart() ) ) 379 , mrbIgnoreLeadingSpace( rIgnLeadSpace ) |
381{ | 380{ |
382 OUString sShow; 383 const SvXMLTokenMap& rTokenMap = 384 GetImport().GetTextImport()->GetTextHyperlinkAttrTokenMap(); | 381 OUString sShow; 382 const SvXMLTokenMap& rTokenMap = GetImport().GetTextImport()->GetTextHyperlinkAttrTokenMap(); |
385 | 383 |
386 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 387 for( sal_Int16 i=0; i < nAttrCount; i++ ) 388 { 389 const OUString& rAttrName = xAttrList->getNameByIndex( i ); 390 const OUString& rValue = xAttrList->getValueByIndex( i ); | 384 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 385 for ( sal_Int16 i = 0; i < nAttrCount; i++ ) 386 { 387 const OUString& rAttrName = xAttrList->getNameByIndex( i ); 388 const OUString& rValue = xAttrList->getValueByIndex( i ); |
391 | 389 |
392 OUString aLocalName; 393 sal_uInt16 nPrefix = 394 GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, 395 &aLocalName ); 396 switch( rTokenMap.Get( nPrefix, aLocalName ) ) 397 { 398 case XML_TOK_TEXT_HYPERLINK_HREF: 399 pHint->SetHRef( GetImport().GetAbsoluteReference( rValue ) ); 400 break; 401 case XML_TOK_TEXT_HYPERLINK_NAME: 402 pHint->SetName( rValue ); 403 break; 404 case XML_TOK_TEXT_HYPERLINK_TARGET_FRAME: 405 pHint->SetTargetFrameName( rValue ); 406 break; 407 case XML_TOK_TEXT_HYPERLINK_SHOW: 408 sShow = rValue; 409 break; 410 case XML_TOK_TEXT_HYPERLINK_STYLE_NAME: 411 pHint->SetStyleName( rValue ); 412 break; 413 case XML_TOK_TEXT_HYPERLINK_VIS_STYLE_NAME: 414 pHint->SetVisitedStyleName( rValue ); 415 break; 416 } 417 } | 390 OUString aLocalName; 391 const sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName ); 392 switch (rTokenMap.Get( nPrefix, aLocalName )) 393 { 394 case XML_TOK_TEXT_HYPERLINK_HREF: 395 mpHint->SetHRef( GetImport().GetAbsoluteReference( rValue ) ); 396 break; 397 case XML_TOK_TEXT_HYPERLINK_NAME: 398 mpHint->SetName( rValue ); 399 break; 400 case XML_TOK_TEXT_HYPERLINK_TARGET_FRAME: 401 mpHint->SetTargetFrameName( rValue ); 402 break; 403 case XML_TOK_TEXT_HYPERLINK_SHOW: 404 sShow = rValue; 405 break; 406 case XML_TOK_TEXT_HYPERLINK_STYLE_NAME: 407 mpHint->SetStyleName( rValue ); 408 break; 409 case XML_TOK_TEXT_HYPERLINK_VIS_STYLE_NAME: 410 mpHint->SetVisitedStyleName( rValue ); 411 break; 412 } 413 } |
418 | 414 |
419 if( sShow.getLength() && !pHint->GetTargetFrameName().getLength() ) | 415 if( sShow.getLength() && !mpHint->GetTargetFrameName().getLength() ) |
420 { 421 if( IsXMLToken( sShow, XML_NEW ) ) | 416 { 417 if( IsXMLToken( sShow, XML_NEW ) ) |
422 pHint->SetTargetFrameName( | 418 mpHint->SetTargetFrameName( |
423 OUString( RTL_CONSTASCII_USTRINGPARAM("_blank" ) ) ); 424 else if( IsXMLToken( sShow, XML_REPLACE ) ) | 419 OUString( RTL_CONSTASCII_USTRINGPARAM("_blank" ) ) ); 420 else if( IsXMLToken( sShow, XML_REPLACE ) ) |
425 pHint->SetTargetFrameName( | 421 mpHint->SetTargetFrameName( |
426 OUString( RTL_CONSTASCII_USTRINGPARAM("_self" ) ) ); 427 } | 422 OUString( RTL_CONSTASCII_USTRINGPARAM("_self" ) ) ); 423 } |
428 rHints.Insert( pHint, rHints.Count() ); | 424 425 if ( mpHint->GetHRef().isEmpty() ) 426 { 427 // hyperlink without an URL is not imported. 428 delete mpHint; 429 mpHint = NULL; 430 } 431 else 432 { 433 mrHints.Insert( mpHint, mrHints.Count() ); 434 } |
429} 430 431XMLImpHyperlinkContext_Impl::~XMLImpHyperlinkContext_Impl() 432{ | 435} 436 437XMLImpHyperlinkContext_Impl::~XMLImpHyperlinkContext_Impl() 438{ |
433 if( pHint ) 434 pHint->SetEnd( GetImport().GetTextImport() | 439 if( mpHint != NULL ) 440 mpHint->SetEnd( GetImport().GetTextImport() |
435 ->GetCursorAsRange()->getStart() ); 436} 437 438SvXMLImportContext *XMLImpHyperlinkContext_Impl::CreateChildContext( 439 sal_uInt16 nPrefix, const OUString& rLocalName, 440 const Reference< xml::sax::XAttributeList > & xAttrList ) 441{ 442 if ( (nPrefix == XML_NAMESPACE_OFFICE) && 443 IsXMLToken(rLocalName, XML_EVENT_LISTENERS) ) 444 { 445 XMLEventsImportContext* pCtxt = new XMLEventsImportContext( 446 GetImport(), nPrefix, rLocalName); | 441 ->GetCursorAsRange()->getStart() ); 442} 443 444SvXMLImportContext *XMLImpHyperlinkContext_Impl::CreateChildContext( 445 sal_uInt16 nPrefix, const OUString& rLocalName, 446 const Reference< xml::sax::XAttributeList > & xAttrList ) 447{ 448 if ( (nPrefix == XML_NAMESPACE_OFFICE) && 449 IsXMLToken(rLocalName, XML_EVENT_LISTENERS) ) 450 { 451 XMLEventsImportContext* pCtxt = new XMLEventsImportContext( 452 GetImport(), nPrefix, rLocalName); |
447 pHint->SetEventsContext(pCtxt); | 453 mpHint->SetEventsContext(pCtxt); |
448 return pCtxt; 449 } 450 else 451 { 452 const SvXMLTokenMap& rTokenMap = 453 GetImport().GetTextImport()->GetTextPElemTokenMap(); 454 sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName ); 455 456 return XMLImpSpanContext_Impl::CreateChildContext( 457 GetImport(), nPrefix, rLocalName, xAttrList, | 454 return pCtxt; 455 } 456 else 457 { 458 const SvXMLTokenMap& rTokenMap = 459 GetImport().GetTextImport()->GetTextPElemTokenMap(); 460 sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName ); 461 462 return XMLImpSpanContext_Impl::CreateChildContext( 463 GetImport(), nPrefix, rLocalName, xAttrList, |
458 nToken, rHints, rIgnoreLeadingSpace ); | 464 nToken, mrHints, mrbIgnoreLeadingSpace ); |
459 } 460} 461 462void XMLImpHyperlinkContext_Impl::Characters( const OUString& rChars ) 463{ | 465 } 466} 467 468void XMLImpHyperlinkContext_Impl::Characters( const OUString& rChars ) 469{ |
464 GetImport().GetTextImport()->InsertString( rChars, rIgnoreLeadingSpace ); | 470 GetImport().GetTextImport()->InsertString( rChars, mrbIgnoreLeadingSpace ); |
465} 466 467// --------------------------------------------------------------------- 468 469class XMLImpRubyBaseContext_Impl : public SvXMLImportContext 470{ 471 XMLHints_Impl& rHints; 472 --- 1173 unchanged lines hidden (view full) --- 1646 break; 1647 1648 case XML_TOK_TEXT_S: 1649 pContext = new XMLCharContext( rImport, nPrefix, 1650 rLocalName, xAttrList, 1651 0x0020, sal_True ); 1652 break; 1653 | 471} 472 473// --------------------------------------------------------------------- 474 475class XMLImpRubyBaseContext_Impl : public SvXMLImportContext 476{ 477 XMLHints_Impl& rHints; 478 --- 1173 unchanged lines hidden (view full) --- 1652 break; 1653 1654 case XML_TOK_TEXT_S: 1655 pContext = new XMLCharContext( rImport, nPrefix, 1656 rLocalName, xAttrList, 1657 0x0020, sal_True ); 1658 break; 1659 |
1654 case XML_TOK_TEXT_HYPERLINK: 1655 { 1656 // test for HyperLinkURL property. If present, insert link as 1657 // text property (StarWriter), else try to insert as text 1658 // field (StarCalc, StarDraw, ...) 1659 Reference<beans::XPropertySet> xPropSet( 1660 rImport.GetTextImport()->GetCursor(), 1661 UNO_QUERY ); | 1660 case XML_TOK_TEXT_HYPERLINK: 1661 { 1662 // test for HyperLinkURL property. If present, insert link as 1663 // text property (StarWriter), else try to insert as text 1664 // field (StarCalc, StarDraw, ...) 1665 Reference< beans::XPropertySet > xPropSet( rImport.GetTextImport()->GetCursor(), UNO_QUERY ); |
1662 | 1666 |
1663 const OUString sHyperLinkURL( 1664 RTL_CONSTASCII_USTRINGPARAM("HyperLinkURL")); | 1667 static const OUString sHyperLinkURL( RTL_CONSTASCII_USTRINGPARAM( "HyperLinkURL" ) ); |
1665 | 1668 |
1666 if (xPropSet->getPropertySetInfo()->hasPropertyByName(sHyperLinkURL)) 1667 { 1668 pContext = new XMLImpHyperlinkContext_Impl( rImport, nPrefix, 1669 rLocalName, xAttrList, 1670 rHints, 1671 rIgnoreLeadingSpace ); 1672 } 1673 else 1674 { 1675 pContext = new XMLUrlFieldImportContext( rImport, 1676 *rImport.GetTextImport().get(), 1677 nPrefix, rLocalName); 1678 //whitespace handling like other fields 1679 rIgnoreLeadingSpace = sal_False; | 1669 if ( xPropSet->getPropertySetInfo()->hasPropertyByName( sHyperLinkURL ) ) 1670 { 1671 pContext = new XMLImpHyperlinkContext_Impl( 1672 rImport, 1673 nPrefix, 1674 rLocalName, 1675 xAttrList, 1676 rHints, 1677 rIgnoreLeadingSpace ); 1678 } 1679 else 1680 { 1681 pContext = new XMLUrlFieldImportContext( rImport, *rImport.GetTextImport().get(), nPrefix, rLocalName ); 1682 //whitespace handling like other fields 1683 rIgnoreLeadingSpace = sal_False; |
1680 | 1684 |
1681 } 1682 break; 1683 } | 1685 } 1686 break; 1687 } |
1684 1685 case XML_TOK_TEXT_RUBY: 1686 pContext = new XMLImpRubyContext_Impl( rImport, nPrefix, 1687 rLocalName, xAttrList, 1688 rHints, 1689 rIgnoreLeadingSpace ); 1690 break; 1691 --- 751 unchanged lines hidden --- | 1688 1689 case XML_TOK_TEXT_RUBY: 1690 pContext = new XMLImpRubyContext_Impl( rImport, nPrefix, 1691 rLocalName, xAttrList, 1692 rHints, 1693 rIgnoreLeadingSpace ); 1694 break; 1695 --- 751 unchanged lines hidden --- |