From 14ed2224269426ab68b6591c178c8a0d636e51a8 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 24 Apr 2024 14:06:45 +0200 Subject: use more concrete UNO classes in writerfilter (SwXTextSection) Change-Id: I407d165ccdfcb23e2b922701dc9753c72c439cc4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166788 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/source/core/inc/unosection.hxx | 3 ++- sw/source/uibase/uno/unotxdoc.cxx | 8 ++++++++ sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx | 13 ++++++------- sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx | 3 ++- sw/source/writerfilter/dmapper/PropertyMap.cxx | 9 +++++---- sw/source/writerfilter/dmapper/PropertyMap.hxx | 4 +++- 6 files changed, 26 insertions(+), 14 deletions(-) (limited to 'sw/source') diff --git a/sw/source/core/inc/unosection.hxx b/sw/source/core/inc/unosection.hxx index ec235f03dfae..209b905e162a 100644 --- a/sw/source/core/inc/unosection.hxx +++ b/sw/source/core/inc/unosection.hxx @@ -19,6 +19,7 @@ #pragma once +#include #include #include #include @@ -44,7 +45,7 @@ typedef ::cppu::ImplInheritanceHelper , css::text::XTextSection > SwXTextSection_Base; -class SwXTextSection final +class SW_DLLPUBLIC SwXTextSection final : public SwXTextSection_Base { diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 400d9db8b805..0d5a46f692ef 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -176,6 +176,7 @@ #include #include #include +#include #include using namespace ::com::sun::star; @@ -1682,6 +1683,13 @@ rtl::Reference< SwXBookmark > SwXTextDocument::createFieldmark() return SwXFieldmark::CreateXFieldmark(GetDocOrThrow(), nullptr); } +rtl::Reference< SwXTextSection > SwXTextDocument::createTextSection() +{ + SolarMutexGuard aGuard; + ThrowIfInvalid(); + return SwXTextSection::CreateXTextSection(nullptr, false); +} + Reference< XInterface > SwXTextDocument::createInstance(const OUString& rServiceName) { return create(rServiceName, nullptr); diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx index 7f0b57ab483a..241783ab848c 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx @@ -135,6 +135,7 @@ #include #include #include +#include #define REFFLDFLAG_STYLE_FROM_BOTTOM 0xc100 #define REFFLDFLAG_STYLE_HIDE_NON_NUMERICAL 0xc200 @@ -3640,12 +3641,12 @@ static void copyAllProps(const css::uno::Reference& from, } } -uno::Reference< beans::XPropertySet > DomainMapper_Impl::appendTextSectionAfter( +rtl::Reference< SwXTextSection > DomainMapper_Impl::appendTextSectionAfter( uno::Reference< text::XTextRange > const & xBefore ) { - uno::Reference< beans::XPropertySet > xRet; + rtl::Reference< SwXTextSection > xSection; if (m_aTextAppendStack.empty()) - return xRet; + return xSection; uno::Reference< text::XTextAppend > xTextAppend = m_aTextAppendStack.top().xTextAppend; if(xTextAppend.is()) { @@ -3672,13 +3673,11 @@ uno::Reference< beans::XPropertySet > DomainMapper_Impl::appendTextSectionAfter( // to the newly appended paragraph, which will be kept in the end. copyAllProps(xEndPara, xNewPara); - uno::Reference< text::XTextContent > xSection( m_xTextDocument->createInstance("com.sun.star.text.TextSection"), uno::UNO_QUERY_THROW ); + xSection = m_xTextDocument->createTextSection(); xSection->attach(xCursor); // Remove the extra paragraph (last inside the section) xEndPara->dispose(); - - xRet.set(xSection, uno::UNO_QUERY ); } catch(const uno::Exception&) { @@ -3686,7 +3685,7 @@ uno::Reference< beans::XPropertySet > DomainMapper_Impl::appendTextSectionAfter( } - return xRet; + return xSection; } void DomainMapper_Impl::appendGlossaryEntry() diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx index 6ad54a050505..19f4d2cf0d23 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx @@ -57,6 +57,7 @@ class SwXTextDocument; class SwXDocumentSettings; +class SwXTextSection; namespace com::sun::star{ namespace awt{ struct Size; @@ -810,7 +811,7 @@ public: void appendOLE( const OUString& rStreamName, const std::shared_ptr& pOleHandler ); void appendStarMath( const Value& v); void adjustLastPara(sal_Int8 nAlign); - css::uno::Reference appendTextSectionAfter(css::uno::Reference const & xBefore); + rtl::Reference appendTextSectionAfter(css::uno::Reference const & xBefore); /// AutoText import: each entry is placed in the separate section void appendGlossaryEntry(); diff --git a/sw/source/writerfilter/dmapper/PropertyMap.cxx b/sw/source/writerfilter/dmapper/PropertyMap.cxx index b416ca400f6f..fd67ac04cda0 100644 --- a/sw/source/writerfilter/dmapper/PropertyMap.cxx +++ b/sw/source/writerfilter/dmapper/PropertyMap.cxx @@ -65,6 +65,7 @@ #include "PropertyMapHelper.hxx" #include #include +#include #include #include @@ -769,7 +770,7 @@ void SectionPropertyMap::ApplySectionProperties( const uno::Reference< beans::XP } } -void SectionPropertyMap::ApplyProtectionProperties( uno::Reference< beans::XPropertySet >& xSection, DomainMapper_Impl& rDM_Impl ) +void SectionPropertyMap::ApplyProtectionProperties( rtl::Reference< SwXTextSection >& xSection, DomainMapper_Impl& rDM_Impl ) { try { @@ -1582,7 +1583,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) && !rDM_Impl.IsInComments()) { //todo: insert a section or access the already inserted section - uno::Reference< beans::XPropertySet > xSection = + rtl::Reference< SwXTextSection > xSection = rDM_Impl.appendTextSectionAfter( m_xStartingRange ); if ( xSection.is() ) { @@ -1616,7 +1617,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) auto xTextAppend = rDM_Impl.GetCurrentXText(); uno::Reference const xCursor( xTextAppend->createTextCursorByRange( - uno::Reference(xSection, uno::UNO_QUERY_THROW)->getAnchor()), + uno::Reference(static_cast(xSection.get()), uno::UNO_QUERY_THROW)->getAnchor()), uno::UNO_QUERY_THROW); uno::Reference const xEnum( xCursor->createEnumeration()); @@ -1707,7 +1708,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) } else if (!rDM_Impl.IsInComments()) { - uno::Reference< beans::XPropertySet > xSection; + rtl::Reference< SwXTextSection > xSection; ApplyProtectionProperties( xSection, rDM_Impl ); //get the properties and create appropriate page styles diff --git a/sw/source/writerfilter/dmapper/PropertyMap.hxx b/sw/source/writerfilter/dmapper/PropertyMap.hxx index 711ef47195a0..6b624e089dad 100644 --- a/sw/source/writerfilter/dmapper/PropertyMap.hxx +++ b/sw/source/writerfilter/dmapper/PropertyMap.hxx @@ -19,6 +19,7 @@ #pragma once #include +#include #include #include #include @@ -37,6 +38,7 @@ #include #include +class SwXTextSection; namespace com::sun::star { namespace beans { struct PropertyValue; @@ -320,7 +322,7 @@ private: void ApplySectionProperties( const css::uno::Reference< css::beans::XPropertySet >& xSection, DomainMapper_Impl& rDM_Impl ); /// Check if document is protected. If so, ensure a section exists, and apply its protected value. - void ApplyProtectionProperties( css::uno::Reference< css::beans::XPropertySet >& xSection, DomainMapper_Impl& rDM_Impl ); + void ApplyProtectionProperties( rtl::Reference& xSection, DomainMapper_Impl& rDM_Impl ); css::uno::Reference< css::text::XTextColumns > ApplyColumnProperties(const css::uno::Reference& xPageStyle, DomainMapper_Impl& rDM_Impl); -- cgit