sw/inc/unoxstyle.hxx | 7 ++++++- sw/source/core/unocore/unostyle.cxx | 18 +++++++++++++++--- sw/source/writerfilter/dmapper/StyleSheetTable.cxx | 2 +- 3 files changed, 22 insertions(+), 5 deletions(-)
New commits: commit 572508a390f3c0ace9f6502db7becb997be19e3e Author: Noel Grandin <[email protected]> AuthorDate: Tue Feb 3 16:23:32 2026 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Thu Feb 5 09:28:05 2026 +0100 tdf#170595 elide some exception throw overhead which we are just going to ignore Change-Id: I4921a1871437f3d51733e790e631290aa40d1389 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198600 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/sw/inc/unoxstyle.hxx b/sw/inc/unoxstyle.hxx index 896fd218c3bf..d11a761974a1 100644 --- a/sw/inc/unoxstyle.hxx +++ b/sw/inc/unoxstyle.hxx @@ -82,7 +82,8 @@ protected: void SetPropertyValue(const SfxItemPropertyMapEntry&, const SfxItemPropertySet&, const css::uno::Any&, SwStyleBase_Impl&); void SetPropertyValues_Impl(const css::uno::Sequence<OUString>& aPropertyNames, - const css::uno::Sequence<css::uno::Any>& aValues); + const css::uno::Sequence<css::uno::Any>& aValues, + bool bIgnoreUnknown); SfxStyleSheetBase* GetStyleSheetBase(); void PrepareStyleBase(SwStyleBase_Impl& rBase); template <sal_uInt16> @@ -219,6 +220,10 @@ public: css::awt::FontSlant& reCharStylePosture, css::awt::FontSlant& reCharStylePostureComplex, sal_Int16& rnCharStyleCaseMap, sal_Int16& rnCharStyleRelief, bool& rbCharStyleContoured, bool& rbCharStyleShadowed, sal_Int16& rnCharStyleStrikeThrough, bool& rbCharStyleHidden); + // Set without throwing exceptions for unknown props, which is faster than throwing and then + // ignoring. + SW_DLLPUBLIC void setPropertyValueIgnoreUnknown(const OUString& aPropertyName, + const css::uno::Any& aValue); }; typedef cppu::ImplInheritanceHelper<SwXStyle, css::document::XEventsSupplier> SwXFrameStyle_Base; diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 969a56cfca03..e6a0028295ea 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -2046,7 +2046,7 @@ void SwXStyle::SetStyleProperty(const SfxItemPropertyMapEntry& rEntry, const Sfx } } -void SwXStyle::SetPropertyValues_Impl(const uno::Sequence<OUString>& rPropertyNames, const uno::Sequence<uno::Any>& rValues) +void SwXStyle::SetPropertyValues_Impl(const uno::Sequence<OUString>& rPropertyNames, const uno::Sequence<uno::Any>& rValues, bool bIgnoreUnknown) { if(!m_pDoc) throw uno::RuntimeException(); @@ -2074,7 +2074,11 @@ void SwXStyle::SetPropertyValues_Impl(const uno::Sequence<OUString>& rPropertyNa { const SfxItemPropertyMapEntry* pEntry = rMap.getByName(pNames[nProp]); if(!pEntry || (!m_bIsConditional && pNames[nProp] == UNO_NAME_PARA_STYLE_CONDITIONS)) + { + if (bIgnoreUnknown) + continue; throw beans::UnknownPropertyException("Unknown property: " + pNames[nProp], getXWeak()); + } if(pEntry->nFlags & beans::PropertyAttribute::READONLY) throw beans::PropertyVetoException ("Property is read-only: " + pNames[nProp], getXWeak()); if(aBaseImpl.getNewBase().is()) @@ -2093,7 +2097,7 @@ void SwXStyle::setPropertyValues(const uno::Sequence<OUString>& rPropertyNames, // workaround for bad designed API try { - SetPropertyValues_Impl( rPropertyNames, rValues ); + SetPropertyValues_Impl( rPropertyNames, rValues, /*bIgnoreUnknown*/false ); } catch (const beans::UnknownPropertyException &rException) { @@ -2565,7 +2569,15 @@ void SwXStyle::setPropertyValue(const OUString& rPropertyName, const uno::Any& r SolarMutexGuard aGuard; const uno::Sequence<OUString> aProperties(&rPropertyName, 1); const uno::Sequence<uno::Any> aValues(&rValue, 1); - SetPropertyValues_Impl(aProperties, aValues); + SetPropertyValues_Impl(aProperties, aValues, /*bIgnoreUnknown*/false); +} + +void SwXStyle::setPropertyValueIgnoreUnknown(const OUString& rPropertyName, const uno::Any& rValue) +{ + SolarMutexGuard aGuard; + const uno::Sequence<OUString> aProperties(&rPropertyName, 1); + const uno::Sequence<uno::Any> aValues(&rValue, 1); + SetPropertyValues_Impl(aProperties, aValues, /*bIgnoreUnknown*/true); } beans::PropertyState SwXStyle::getPropertyState(const OUString& rPropertyName) diff --git a/sw/source/writerfilter/dmapper/StyleSheetTable.cxx b/sw/source/writerfilter/dmapper/StyleSheetTable.cxx index 10892b7b3f47..1cfa71e0043b 100644 --- a/sw/source/writerfilter/dmapper/StyleSheetTable.cxx +++ b/sw/source/writerfilter/dmapper/StyleSheetTable.cxx @@ -2204,7 +2204,7 @@ OUString StyleSheetTable::getOrCreateCharStyle( const PropertyValueVector_t& rCh { try { - xStyle->setPropertyValue( rCharProp.Name, rCharProp.Value ); + xStyle->setPropertyValueIgnoreUnknown( rCharProp.Name, rCharProp.Value ); } catch( const uno::Exception& ) {
