diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-04-24 14:06:45 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-04-28 18:57:59 +0200 |
commit | 14ed2224269426ab68b6591c178c8a0d636e51a8 (patch) | |
tree | a4b57e5728df04f72554b68d169ea0828c6511d0 /sw | |
parent | 192f76cbb2718b9d83f4b674a71ddf8d1c467184 (diff) |
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/unotxdoc.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/inc/unosection.hxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 8 | ||||
-rw-r--r-- | sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx | 13 | ||||
-rw-r--r-- | sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx | 3 | ||||
-rw-r--r-- | sw/source/writerfilter/dmapper/PropertyMap.cxx | 9 | ||||
-rw-r--r-- | sw/source/writerfilter/dmapper/PropertyMap.hxx | 4 |
7 files changed, 28 insertions, 14 deletions
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index 477f2792912b..9c1e5e39b29c 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -108,6 +108,7 @@ class SwXRedlines; class SwXDocumentSettings; class SwXTextDefaults; class SwXBookmark; +class SwXTextSection; namespace com::sun::star::container { class XNameContainer; } namespace com::sun::star::frame { class XController; } namespace com::sun::star::lang { struct Locale; } @@ -514,6 +515,7 @@ public: SW_DLLPUBLIC rtl::Reference<SwXTextDefaults> createTextDefaults(); SW_DLLPUBLIC rtl::Reference<SwXBookmark> createBookmark(); SW_DLLPUBLIC rtl::Reference<SwXBookmark> createFieldmark(); + SW_DLLPUBLIC rtl::Reference<SwXTextSection> createTextSection(); }; class SwXLinkTargetSupplier final : public cppu::WeakImplHelper 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 <swdllapi.h> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertyState.hpp> @@ -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 <unocontentcontrol.hxx> #include <unoport.hxx> #include <unobookmark.hxx> +#include <unosection.hxx> #include <SwXTextDefaults.hxx> 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 <SwXDocumentSettings.hxx> #include <SwXTextDefaults.hxx> #include <unobookmark.hxx> +#include <unosection.hxx> #define REFFLDFLAG_STYLE_FROM_BOTTOM 0xc100 #define REFFLDFLAG_STYLE_HIDE_NON_NUMERICAL 0xc200 @@ -3640,12 +3641,12 @@ static void copyAllProps(const css::uno::Reference<css::uno::XInterface>& 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<OLEHandler>& pOleHandler ); void appendStarMath( const Value& v); void adjustLastPara(sal_Int8 nAlign); - css::uno::Reference<css::beans::XPropertySet> appendTextSectionAfter(css::uno::Reference<css::text::XTextRange> const & xBefore); + rtl::Reference<SwXTextSection> appendTextSectionAfter(css::uno::Reference<css::text::XTextRange> 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 <o3tl/sorted_vector.hxx> #include <o3tl/unit_conversion.hxx> +#include <unosection.hxx> #include <unotxdoc.hxx> #include <utility> @@ -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<container::XEnumerationAccess> const xCursor( xTextAppend->createTextCursorByRange( - uno::Reference<text::XTextContent>(xSection, uno::UNO_QUERY_THROW)->getAnchor()), + uno::Reference<text::XTextContent>(static_cast<cppu::OWeakObject*>(xSection.get()), uno::UNO_QUERY_THROW)->getAnchor()), uno::UNO_QUERY_THROW); uno::Reference<container::XEnumeration> 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 <rtl/ustring.hxx> +#include <rtl/ref.hxx> #include <tools/ref.hxx> #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/text/XText.hpp> @@ -37,6 +38,7 @@ #include <set> #include <deque> +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<SwXTextSection>& xSection, DomainMapper_Impl& rDM_Impl ); css::uno::Reference< css::text::XTextColumns > ApplyColumnProperties(const css::uno::Reference<css::beans::XPropertySet>& xPageStyle, DomainMapper_Impl& rDM_Impl); |