sw/inc/unoxstyle.hxx | 7 ++++++- sw/source/core/unocore/unostyle.cxx | 18 +++++++++++++++--- sw/source/writerfilter/dmapper/StyleSheetTable.cxx | 17 ++++++++++------- 3 files changed, 31 insertions(+), 11 deletions(-)
New commits: commit a03abe71e7999eee7880a7d15924333245399632 Author: Noel Grandin <[email protected]> AuthorDate: Tue Feb 3 16:23:32 2026 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Thu Feb 26 06:50:45 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/+/198663 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> (cherry picked from commit aac7afb4c1703be5c4a3b136d054d4c7b1265c77) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200317 Reviewed-by: Noel Grandin <[email protected]> diff --git a/sw/inc/unoxstyle.hxx b/sw/inc/unoxstyle.hxx index 332dd5616992..49014c3abc7c 100644 --- a/sw/inc/unoxstyle.hxx +++ b/sw/inc/unoxstyle.hxx @@ -81,7 +81,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> @@ -218,6 +219,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 41aaddc3d1ea..35cff7c4ce43 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -2044,7 +2044,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(); @@ -2072,7 +2072,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()) @@ -2091,7 +2095,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) { @@ -2563,7 +2567,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 9dedc8e96541..efb350209537 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& ) { commit 18aeafd376f3167a66e2ff26b6568d8eb7ad958a Author: Noel Grandin <[email protected]> AuthorDate: Tue Feb 3 15:56:29 2026 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Thu Feb 26 06:50:34 2026 +0100 tdf#170595 no need to call HasListCharStyle if we are just going to create a new style anyway Change-Id: Ib7c70b1fe64bd12ed2e500c0fee686f45b94985f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198662 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Miklos Vajna <[email protected]> (cherry picked from commit 625c7541a9ed252c2f360ffb70bdd6b375527fda) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200316 Tested-by: Noel Grandin <[email protected]> Reviewed-by: Noel Grandin <[email protected]> diff --git a/sw/source/writerfilter/dmapper/StyleSheetTable.cxx b/sw/source/writerfilter/dmapper/StyleSheetTable.cxx index 847cb1ae6994..9dedc8e96541 100644 --- a/sw/source/writerfilter/dmapper/StyleSheetTable.cxx +++ b/sw/source/writerfilter/dmapper/StyleSheetTable.cxx @@ -2183,15 +2183,18 @@ void StyleSheetTable::applyDefaults(bool bParaProperties) OUString StyleSheetTable::getOrCreateCharStyle( const PropertyValueVector_t& rCharProperties, bool bAlwaysCreate ) { - //find out if any of the styles already has the required properties then return its name - OUString sListLabel = HasListCharStyle(rCharProperties); - // Don't try to reuse an existing character style if requested. - if( !sListLabel.isEmpty() && !bAlwaysCreate) - return sListLabel; + if (!bAlwaysCreate) + { + //find out if any of the styles already has the required properties then return its name + OUString sListLabel = HasListCharStyle(rCharProperties); + // Don't try to reuse an existing character style if requested. + if( !sListLabel.isEmpty()) + return sListLabel; + } //create a new one otherwise const rtl::Reference< SwXStyleFamily >& xCharStyles = m_rDMapper.GetCharacterStyles(); - sListLabel = m_rDMapper.GetUnusedCharacterStyleName(); + OUString sListLabel = m_rDMapper.GetUnusedCharacterStyleName(); if (!m_xTextDocument) throw uno::RuntimeException(); try
