xmloff/source/text/txtparae.cxx | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-)
New commits: commit a20c1fa2aef038bfae62eef72f836f6141c2434e Author: Mike Kaganski <[email protected]> AuthorDate: Sun Oct 12 17:56:24 2025 +0500 Commit: Mike Kaganski <[email protected]> CommitDate: Mon Oct 13 07:34:30 2025 +0200 Use lambda to deduplicate HyperlinkData ctor Change-Id: I869a55d59ed74ccc133d66e1647bcb9c463df1f7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192251 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index 28295dbce90e..60db48f76c59 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -298,7 +298,6 @@ namespace HyperlinkData::HyperlinkData(const css::uno::Reference<css::beans::XPropertySet>& rPropSet) { - const css::uno::Reference<css::beans::XPropertyState> xPropState(rPropSet, UNO_QUERY); const auto xPropSetInfo(rPropSet->getPropertySetInfo()); if (xPropSetInfo->hasPropertyByName(gsTextPortionType)) @@ -309,9 +308,16 @@ namespace return; } - if (xPropSetInfo->hasPropertyByName(gsHyperLinkURL) - && (!xPropState.is() - || PropertyState_DIRECT_VALUE == xPropState->getPropertyState(gsHyperLinkURL))) + auto hasDirectProperty + = [&xPropSetInfo, + xPropState = rPropSet.query<beans::XPropertyState>()](const OUString& prop) + { + return xPropSetInfo->hasPropertyByName(prop) + && (!xPropState.is() + || xPropState->getPropertyState(prop) == beans::PropertyState_DIRECT_VALUE); + }; + + if (hasDirectProperty(gsHyperLinkURL)) { rPropSet->getPropertyValue(gsHyperLinkURL) >>= href; } @@ -319,39 +325,27 @@ namespace if (href.isEmpty()) return; - if (xPropSetInfo->hasPropertyByName(gsHyperLinkName) - && (!xPropState.is() - || PropertyState_DIRECT_VALUE == xPropState->getPropertyState(gsHyperLinkName))) + if (hasDirectProperty(gsHyperLinkName)) { rPropSet->getPropertyValue(gsHyperLinkName) >>= name; } - if (xPropSetInfo->hasPropertyByName(gsHyperLinkTarget) - && (!xPropState.is() - || PropertyState_DIRECT_VALUE == xPropState->getPropertyState(gsHyperLinkTarget))) + if (hasDirectProperty(gsHyperLinkTarget)) { rPropSet->getPropertyValue(gsHyperLinkTarget) >>= targetFrame; } - if (xPropSetInfo->hasPropertyByName(gsServerMap) - && (!xPropState.is() - || PropertyState_DIRECT_VALUE == xPropState->getPropertyState(gsServerMap))) + if (hasDirectProperty(gsServerMap)) { serverMap = *o3tl::doAccess<bool>(rPropSet->getPropertyValue(gsServerMap)); } - if (xPropSetInfo->hasPropertyByName(gsUnvisitedCharStyleName) - && (!xPropState.is() - || PropertyState_DIRECT_VALUE - == xPropState->getPropertyState(gsUnvisitedCharStyleName))) + if (hasDirectProperty(gsUnvisitedCharStyleName)) { rPropSet->getPropertyValue(gsUnvisitedCharStyleName) >>= ustyleName; } - if (xPropSetInfo->hasPropertyByName(gsVisitedCharStyleName) - && (!xPropState.is() - || PropertyState_DIRECT_VALUE - == xPropState->getPropertyState(gsVisitedCharStyleName))) + if (hasDirectProperty(gsVisitedCharStyleName)) { rPropSet->getPropertyValue(gsVisitedCharStyleName) >>= vstyleName; }
