sw/inc/unocoll.hxx | 2 ++ sw/inc/unotxdoc.hxx | 3 +++ sw/source/core/unocore/unocoll.cxx | 14 ++++++++++---- sw/source/ui/index/cntex.cxx | 16 ++++++++-------- sw/source/ui/index/cnttab.cxx | 1 + sw/source/uibase/inc/swuicnttab.hxx | 13 ++++--------- sw/source/uibase/uno/unotxdoc.cxx | 16 ++++++++++++++++ 7 files changed, 44 insertions(+), 21 deletions(-)
New commits: commit 2f0725152df82cc8948bc3717b71f728185b216c Author: Noel Grandin <[email protected]> AuthorDate: Sun Nov 30 13:20:36 2025 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Sun Nov 30 16:43:59 2025 +0100 use more concrete UNO in SwIndexSections_Impl Change-Id: Ifd39a398ab18a8814b0e783c9e2e58a6f0c46392 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194840 Reviewed-by: Noel Grandin <[email protected]> Tested-by: Jenkins diff --git a/sw/inc/unocoll.hxx b/sw/inc/unocoll.hxx index 0c72964d714e..f9f3261d298b 100644 --- a/sw/inc/unocoll.hxx +++ b/sw/inc/unocoll.hxx @@ -397,6 +397,8 @@ public: virtual OUString SAL_CALL getImplementationName() override; virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + SW_DLLPUBLIC rtl::Reference<SwXTextSection> getSwTextSectionByName(const OUString& Name); }; class SwXBookmarks final : public SwCollectionBaseClass, diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index 793159a9eeb1..8f463b3cc7b0 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -553,6 +553,7 @@ public: rtl::Reference< SwXRedlines > getSwRedlines(); rtl::Reference<SwXTextFieldTypes> getSwTextFields(); rtl::Reference<SwXTextFrames> getSwTextFrames(); + rtl::Reference<SwXTextSections> getSwTextSections(); }; class SwXLinkTargetSupplier final : public cppu::WeakImplHelper diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 9d8c33453baa..2ce0d3e2f269 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -1391,11 +1391,18 @@ uno::Any SwXTextSections::getByIndex(sal_Int32 nIndex) uno::Any SwXTextSections::getByName(const OUString& rName) { - SolarMutexGuard aGuard; + rtl::Reference< SwXTextSection > xSect = getSwTextSectionByName(rName); uno::Any aRet; + aRet <<= uno::Reference< XTextSection >(xSect); + return aRet; +} + +rtl::Reference<SwXTextSection> SwXTextSections::getSwTextSectionByName(const OUString& rName) +{ + SolarMutexGuard aGuard; SwSectionFormats& rFormats = GetDoc().GetSections(); - uno::Reference< XTextSection > xSect; + rtl::Reference< SwXTextSection > xSect; for(size_t i = 0; i < rFormats.size(); ++i) { SwSectionFormat* pFormat = rFormats[i]; @@ -1403,14 +1410,13 @@ uno::Any SwXTextSections::getByName(const OUString& rName) && (rName == pFormat->GetSection()->GetSectionName())) { xSect = SwXTextSection::CreateXTextSection(pFormat); - aRet <<= xSect; break; } } if(!xSect.is()) throw NoSuchElementException(); - return aRet; + return xSect; } uno::Sequence< OUString > SwXTextSections::getElementNames() diff --git a/sw/source/ui/index/cntex.cxx b/sw/source/ui/index/cntex.cxx index e2f1347bdbe7..10e9562034c2 100644 --- a/sw/source/ui/index/cntex.cxx +++ b/sw/source/ui/index/cntex.cxx @@ -94,14 +94,14 @@ IMPL_LINK_NOARG(SwMultiTOXTabDialog, CreateExample_Hdl, SwOneExampleFrame&, void if( xDoc ) xDoc->GetDocShell()->LoadStyles_( *m_rWrtShell.GetView().GetDocShell(), true ); - uno::Reference< container::XNameAccess > xSections = - xDoc->getTextSections(); + rtl::Reference< SwXTextSections > xSections = + xDoc->getSwTextSections(); for(int i = 0; i < 7; ++i ) { OUString sTmp = "IndexSection_" + OUString::number(i); - uno::Any aSection = xSections->getByName( sTmp ); - aSection >>= m_vTypeData[i].m_oIndexSections->xContainerSection; + m_vTypeData[i].m_oIndexSections->xContainerSection = + xSections->getSwTextSectionByName( sTmp ); } rtl::Reference< SwXDocumentIndexes > xIdxs = xDoc->getSwDocumentIndexes(); int n = xIdxs->getCount(); @@ -160,7 +160,7 @@ void SwMultiTOXTabDialog::CreateOrUpdateExample( } for(sal_uInt16 i = 0 ; i <= TOX_AUTHORITIES; i++) { - uno::Reference< beans::XPropertySet > xSectPr(m_vTypeData[i].m_oIndexSections->xContainerSection, uno::UNO_QUERY); + rtl::Reference< SwXTextSection > xSectPr(m_vTypeData[i].m_oIndexSections->xContainerSection); if(xSectPr.is()) { xSectPr->setPropertyValue(UNO_NAME_IS_VISIBLE, Any(i == nTOXIndex)); diff --git a/sw/source/uibase/inc/swuicnttab.hxx b/sw/source/uibase/inc/swuicnttab.hxx index 8289968470db..cba087638db1 100644 --- a/sw/source/uibase/inc/swuicnttab.hxx +++ b/sw/source/uibase/inc/swuicnttab.hxx @@ -39,16 +39,11 @@ class SwTOXEntryTabPage; class SwOneExampleFrame; class SwWrtShell; class SwXDocumentIndex; - -namespace com::sun::star{ - namespace text{ - class XTextSection; - } -} +class SwXTextSection; struct SwIndexSections_Impl { - css::uno::Reference< css::text::XTextSection > xContainerSection; + rtl::Reference< SwXTextSection > xContainerSection; rtl::Reference< SwXDocumentIndex > xDocumentIndex; }; diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 60e42f1fa105..ccd71c75ff8d 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -1234,6 +1234,11 @@ Reference< XNameAccess > SwXTextDocument::getBookmarks() } Reference< XNameAccess > SwXTextDocument::getTextSections() +{ + return getSwTextSections(); +} + +rtl::Reference< SwXTextSections > SwXTextDocument::getSwTextSections() { SolarMutexGuard aGuard; ThrowIfInvalid(); commit 292fb9492cc3e976e74652f762bcab5b3bdd7b3b Author: Noel Grandin <[email protected]> AuthorDate: Sun Nov 30 13:07:37 2025 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Sun Nov 30 16:43:44 2025 +0100 use more concrete UNO in SwIndexSections_Impl Change-Id: Ia9b7935e319afc291501cdb38ec7a5946346bccc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194839 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index 7462a448319f..793159a9eeb1 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -120,6 +120,7 @@ class SvXMLEmbeddedObjectHelper; class SwXFieldmark; class SwXSection; class SwXFieldMaster; +class SwXDocumentIndex; class SvNumberFormatsSupplierObj; namespace com::sun::star::frame { class XController; } @@ -527,6 +528,7 @@ public: rtl::Reference<SwXFieldMaster> createFieldMaster(std::u16string_view sServiceName); rtl::Reference<SwXTextField> createTextField(std::u16string_view sServiceName); rtl::Reference<SwXFieldmark> createFieldmark(std::u16string_view sServiceName); + rtl::Reference<SwXDocumentIndex> createDocumentIndex(std::u16string_view sServiceName); /// returns either SwXDocumentIndex or SwXTextSection rtl::Reference<SwXSection> createSection(std::u16string_view rObjectType); rtl::Reference<SwXDocumentSettings> createDocumentSettings(); diff --git a/sw/source/ui/index/cntex.cxx b/sw/source/ui/index/cntex.cxx index a10084d16d51..e2f1347bdbe7 100644 --- a/sw/source/ui/index/cntex.cxx +++ b/sw/source/ui/index/cntex.cxx @@ -154,8 +154,8 @@ void SwMultiTOXTabDialog::CreateOrUpdateExample( OUString sIndexTypeName(OUString::createFromAscii( IndexServiceNames[ nTOXIndex <= TOX_AUTHORITIES ? nTOXIndex : TOX_USER] )); - m_vTypeData[nTOXIndex].m_oIndexSections->xDocumentIndex.set(xModel->createInstance(sIndexTypeName), uno::UNO_QUERY); - uno::Reference< text::XTextContent > xContent = m_vTypeData[nTOXIndex].m_oIndexSections->xDocumentIndex; + m_vTypeData[nTOXIndex].m_oIndexSections->xDocumentIndex = xModel->createDocumentIndex(sIndexTypeName); + uno::Reference< text::XTextContent > xContent = static_cast<SwXSection*>(m_vTypeData[nTOXIndex].m_oIndexSections->xDocumentIndex.get()); xCursor->getText()->insertTextContent(xCursor, xContent, false); } for(sal_uInt16 i = 0 ; i <= TOX_AUTHORITIES; i++) @@ -167,7 +167,7 @@ void SwMultiTOXTabDialog::CreateOrUpdateExample( } } // set properties - uno::Reference< beans::XPropertySet > xIdxProps(m_vTypeData[nTOXIndex].m_oIndexSections->xDocumentIndex, uno::UNO_QUERY); + rtl::Reference< SwXDocumentIndex > xIdxProps(m_vTypeData[nTOXIndex].m_oIndexSections->xDocumentIndex); uno::Reference< beans::XPropertySetInfo > xInfo = xIdxProps->getPropertySetInfo(); SwTOXDescription& rDesc = GetTOXDescription(m_eCurrentTOXType); SwTOIOptions nIdxOptions = rDesc.GetIndexOptions(); diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index 39c48b81a17b..65a39de1a9e4 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -52,6 +52,7 @@ #include <fldbas.hxx> #include <expfld.hxx> #include <unotools.hxx> +#include <unoidx.hxx> #include <docsh.hxx> #include <swmodule.hxx> #include <modcfg.hxx> diff --git a/sw/source/uibase/inc/swuicnttab.hxx b/sw/source/uibase/inc/swuicnttab.hxx index ace46b75a0f5..8289968470db 100644 --- a/sw/source/uibase/inc/swuicnttab.hxx +++ b/sw/source/uibase/inc/swuicnttab.hxx @@ -38,18 +38,18 @@ class SwTOXButton; class SwTOXEntryTabPage; class SwOneExampleFrame; class SwWrtShell; +class SwXDocumentIndex; namespace com::sun::star{ namespace text{ class XTextSection; - class XDocumentIndex; } } struct SwIndexSections_Impl { css::uno::Reference< css::text::XTextSection > xContainerSection; - css::uno::Reference< css::text::XDocumentIndex > xDocumentIndex; + rtl::Reference< SwXDocumentIndex > xDocumentIndex; }; class SwMultiTOXTabDialog final : public SfxTabDialogController diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 0d8a2542dbda..60e42f1fa105 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -1707,6 +1707,17 @@ rtl::Reference< SwXSection > SwXTextDocument::createSection(std::u16string_view return dynamic_cast<SwXSection*>(xTmp.get()); } +rtl::Reference< SwXDocumentIndex > SwXTextDocument::createDocumentIndex(std::u16string_view rObjectType) +{ + SolarMutexGuard aGuard; + ThrowIfInvalid(); + const SwServiceType nType = SwXServiceProvider::GetProviderType(rObjectType); + assert(nType != SwServiceType::Invalid); + auto xTmp = SwXServiceProvider::MakeInstance(nType, GetDocOrThrow()); + assert(!xTmp || dynamic_cast<SwXDocumentIndex*>(xTmp.get())); + return dynamic_cast<SwXDocumentIndex*>(xTmp.get()); +} + rtl::Reference<SwXFieldMaster> SwXTextDocument::createFieldMaster( std::u16string_view rServiceName) {
