diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2022-07-12 11:22:25 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2022-07-13 09:54:03 +0200 |
commit | 454e182898cdf9c8a9ce1b575591910bbff3a762 (patch) | |
tree | 9d6bad7af3d2156befb1404a709caac5d2ec0e37 /xmloff | |
parent | 54a97eb9ddd66294f303189ca12ef726177453cb (diff) |
Simplify XMLTextParagraphExport::addHyperlinkAttributes
Change-Id: I283fc348d1ecaee92095f50c6f7d92fff8b09dce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136994
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/text/txtparae.cxx | 64 |
1 files changed, 22 insertions, 42 deletions
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index 63232f8b2822..5b2cb233dd38 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -3369,18 +3369,13 @@ bool XMLTextParagraphExport::addHyperlinkAttributes( const Reference< XPropertyState > & rPropState, const Reference< XPropertySetInfo > & rPropSetInfo ) { - bool bExport = false; - OUString sHRef, sName, sTargetFrame, sUStyleName, sVStyleName; - bool bServerMap = false; + OUString sHRef; if( rPropSetInfo->hasPropertyByName( gsHyperLinkURL ) && ( !rPropState.is() || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( gsHyperLinkURL ) ) ) { rPropSet->getPropertyValue( gsHyperLinkURL ) >>= sHRef; - - if( !sHRef.isEmpty() ) - bExport = true; } if ( sHRef.isEmpty() ) @@ -3390,81 +3385,66 @@ bool XMLTextParagraphExport::addHyperlinkAttributes( return false; } + GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE); + GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_HREF, + GetExport().GetRelativeReference(sHRef)); + if ( rPropSetInfo->hasPropertyByName( gsHyperLinkName ) && ( !rPropState.is() || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( gsHyperLinkName ) ) ) { + OUString sName; rPropSet->getPropertyValue( gsHyperLinkName ) >>= sName; if( !sName.isEmpty() ) - bExport = true; + GetExport().AddAttribute(XML_NAMESPACE_OFFICE, XML_NAME, sName); } if ( rPropSetInfo->hasPropertyByName( gsHyperLinkTarget ) && ( !rPropState.is() || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( gsHyperLinkTarget ) ) ) { + OUString sTargetFrame; rPropSet->getPropertyValue( gsHyperLinkTarget ) >>= sTargetFrame; if( !sTargetFrame.isEmpty() ) - bExport = true; + { + GetExport().AddAttribute(XML_NAMESPACE_OFFICE, XML_TARGET_FRAME_NAME, sTargetFrame); + enum XMLTokenEnum eTok = sTargetFrame == "_blank" ? XML_NEW : XML_REPLACE; + GetExport().AddAttribute(XML_NAMESPACE_XLINK, XML_SHOW, eTok); + } } if ( rPropSetInfo->hasPropertyByName( gsServerMap ) && ( !rPropState.is() || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( gsServerMap ) ) ) { - bServerMap = *o3tl::doAccess<bool>(rPropSet->getPropertyValue( gsServerMap )); + bool bServerMap = *o3tl::doAccess<bool>(rPropSet->getPropertyValue( gsServerMap )); if ( bServerMap ) - bExport = true; + GetExport().AddAttribute(XML_NAMESPACE_OFFICE, XML_SERVER_MAP, XML_TRUE); } if ( rPropSetInfo->hasPropertyByName( gsUnvisitedCharStyleName ) && ( !rPropState.is() || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( gsUnvisitedCharStyleName ) ) ) { + OUString sUStyleName; rPropSet->getPropertyValue( gsUnvisitedCharStyleName ) >>= sUStyleName; if( !sUStyleName.isEmpty() ) - bExport = true; + GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_STYLE_NAME, + GetExport().EncodeStyleName(sUStyleName)); } if ( rPropSetInfo->hasPropertyByName( gsVisitedCharStyleName ) && ( !rPropState.is() || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( gsVisitedCharStyleName ) ) ) { + OUString sVStyleName; rPropSet->getPropertyValue( gsVisitedCharStyleName ) >>= sVStyleName; if( !sVStyleName.isEmpty() ) - bExport = true; - } - - if ( bExport ) - { - GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE ); - GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, GetExport().GetRelativeReference( sHRef ) ); - - if( !sName.isEmpty() ) - GetExport().AddAttribute( XML_NAMESPACE_OFFICE, XML_NAME, sName ); - - if( !sTargetFrame.isEmpty() ) - { - GetExport().AddAttribute( XML_NAMESPACE_OFFICE, - XML_TARGET_FRAME_NAME, sTargetFrame ); - enum XMLTokenEnum eTok = sTargetFrame == "_blank" ? XML_NEW : XML_REPLACE; - GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, eTok ); - } - - if( bServerMap ) - GetExport().AddAttribute( XML_NAMESPACE_OFFICE, - XML_SERVER_MAP, XML_TRUE ); - - if( !sUStyleName.isEmpty() ) - GetExport().AddAttribute( XML_NAMESPACE_TEXT, - XML_STYLE_NAME, GetExport().EncodeStyleName( sUStyleName ) ); - - if( !sVStyleName.isEmpty() ) - GetExport().AddAttribute( XML_NAMESPACE_TEXT, - XML_VISITED_STYLE_NAME, GetExport().EncodeStyleName( sVStyleName ) ); + GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_VISITED_STYLE_NAME, + GetExport().EncodeStyleName(sVStyleName)); } - return bExport; + return true; } void XMLTextParagraphExport::exportTextRangeSpan( |