sw/inc/unoxstyle.hxx | 4 ++++ sw/source/core/unocore/unostyle.cxx | 13 +++++++++++++ sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx | 5 ++--- sw/source/writerfilter/dmapper/StyleSheetTable.cxx | 16 ++++++++-------- 4 files changed, 27 insertions(+), 11 deletions(-)
New commits: commit 00b3d2aa9a8ec1a6af7bb9dbe8affbd8dae2dfeb Author: Noel Grandin <[email protected]> AuthorDate: Mon Aug 12 19:00:05 2024 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Tue Aug 13 08:38:27 2024 +0200 use more concrete UNO type in writerfilter Change-Id: Id21630fb997c11574b76f5c22de1a2a31d099d4f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171801 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/sw/inc/unoxstyle.hxx b/sw/inc/unoxstyle.hxx index 20924a315c62..a51305651741 100644 --- a/sw/inc/unoxstyle.hxx +++ b/sw/inc/unoxstyle.hxx @@ -41,6 +41,7 @@ struct SfxItemPropertyMapEntry; class SwDoc; class SfxItemPropertySet; class SwDocShell; +class SwXNumberingRules; class SAL_DLLPUBLIC_RTTI SwXStyle : public cppu::ImplInheritanceHelper< @@ -166,6 +167,9 @@ public: virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override; //SvtListener virtual void Notify(const SfxHint&) override; + + SW_DLLPUBLIC rtl::Reference<SwXNumberingRules> getNumberingRules(); + const OUString& GetStyleName() const { return m_sStyleName; } SfxStyleFamily GetFamily() const; diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 0cdb0d119764..5e5202bd5a6f 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -2356,6 +2356,19 @@ uno::Any SwXStyle::GetPropertyValue_Impl(const SfxItemPropertySet* pPropSet, SwS return aValue; } +rtl::Reference<SwXNumberingRules> SwXStyle::getNumberingRules() +{ + SwStyleBase_Impl aBase(*m_pDoc, m_sStyleName, &m_pDoc->GetDfltTextFormatColl()->GetAttrSet()); // add pDfltTextFormatColl as parent + if(m_pBasePool) + { + PrepareStyleBase(aBase); + const SwNumRule* pRule = aBase.getNewBase()->GetNumRule(); + assert(pRule && "Where is the NumRule?"); + return new SwXNumberingRules(*pRule, GetDoc()); + } + return nullptr; +} + uno::Any SwXStyle::getPropertyValue(const OUString& rPropertyName) { SolarMutexGuard aGuard; diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx index 57a6a306205d..a24e13449966 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx @@ -9881,9 +9881,8 @@ sal_Int32 DomainMapper_Impl::getNumberingProperty(const sal_Int32 nListId, sal_I const OUString aListName = pList->GetStyleName(); const rtl::Reference< SwXStyleFamilies > xStyleFamilies = m_xTextDocument->getSwStyleFamilies(); rtl::Reference<SwXStyleFamily> xNumberingStyles = xStyleFamilies->GetNumberingStyles(); - const rtl::Reference<SwXBaseStyle> xStyle = xNumberingStyles->getStyleByName(aListName); - const rtl::Reference<SwXNumberingRules> xNumberingRules = - dynamic_cast<SwXNumberingRules*>(xStyle->getPropertyValue(u"NumberingRules"_ustr).get<uno::Reference<uno::XInterface>>().get()); + const rtl::Reference<SwXStyle> xStyle = dynamic_cast<SwXStyle*>(xNumberingStyles->getStyleByName(aListName).get()); + const rtl::Reference<SwXNumberingRules> xNumberingRules = xStyle->getNumberingRules(); if (xNumberingRules.is()) { xNumberingRules->getPropertyByIndex(nNumberingLevel, aProp) >>= nRet; diff --git a/sw/source/writerfilter/dmapper/StyleSheetTable.cxx b/sw/source/writerfilter/dmapper/StyleSheetTable.cxx index f0db6d3fafa7..f45249431015 100644 --- a/sw/source/writerfilter/dmapper/StyleSheetTable.cxx +++ b/sw/source/writerfilter/dmapper/StyleSheetTable.cxx @@ -56,6 +56,7 @@ #include <unotxdoc.hxx> #include <unoxstyle.hxx> #include <unostyle.hxx> +#include <unosett.hxx> #include <SwXTextDefaults.hxx> using namespace ::com::sun::star; @@ -1167,12 +1168,14 @@ void StyleSheetTable::ApplyStyleSheetsImpl(const FontTablePtr& rFontTable, std:: else { bInsert = true; + rtl::Reference<SwXStyle> xNewStyle; if (bParaStyle) - xStyle = m_pImpl->m_xTextDocument->createParagraphStyle(); + xNewStyle = m_pImpl->m_xTextDocument->createParagraphStyle(); else if (bListStyle) - xStyle = m_pImpl->m_xTextDocument->createNumberingStyle(); + xNewStyle = m_pImpl->m_xTextDocument->createNumberingStyle(); else - xStyle = m_pImpl->m_xTextDocument->createCharacterStyle(); + xNewStyle = m_pImpl->m_xTextDocument->createCharacterStyle(); + xStyle = xNewStyle; // Numbering styles have to be inserted early, as e.g. the NumberingRules property is only available after insertion. if (bListStyle) @@ -1184,17 +1187,14 @@ void StyleSheetTable::ApplyStyleSheetsImpl(const FontTablePtr& rFontTable, std:: if (pPropertyMap && pPropertyMap->props().GetListId() == -1) { // No properties? Word default is 'none', Writer one is 'arabic', handle this. - uno::Reference<container::XIndexReplace> xNumberingRules; - xStyle->getPropertyValue(u"NumberingRules"_ustr) >>= xNumberingRules; - uno::Reference<container::XIndexAccess> xIndexAccess(xNumberingRules, uno::UNO_QUERY_THROW); - for (sal_Int32 i = 0; i < xIndexAccess->getCount(); ++i) + rtl::Reference<SwXNumberingRules> xNumberingRules = xNewStyle->getNumberingRules(); + for (sal_Int32 i = 0; i < xNumberingRules->getCount(); ++i) { uno::Sequence< beans::PropertyValue > aLvlProps{ comphelper::makePropertyValue( u"NumberingType"_ustr, style::NumberingType::NUMBER_NONE) }; xNumberingRules->replaceByIndex(i, uno::Any(aLvlProps)); - xStyle->setPropertyValue(u"NumberingRules"_ustr, uno::Any(xNumberingRules)); } } }
