diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2024-08-03 10:23:20 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-08-03 21:15:09 +0200 |
commit | 1db0a141021778c66f2a922ddef8494b7a755ca2 (patch) | |
tree | 440b49b0b559091174b22e8a671b56e554ec68a7 | |
parent | b76af7f488217cb244a68cf4294576237c115aeb (diff) |
use more concrete UNO type in writerfilter
Change-Id: I80128e6b76c36070612fc2e9dda3ad82c865f6ce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171441
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sw/inc/unotext.hxx | 2 | ||||
-rw-r--r-- | sw/inc/unotextbodyhf.hxx | 2 | ||||
-rw-r--r-- | sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx | 17 | ||||
-rw-r--r-- | sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx | 5 | ||||
-rw-r--r-- | sw/source/writerfilter/dmapper/PropertyMap.cxx | 3 |
5 files changed, 17 insertions, 12 deletions
diff --git a/sw/inc/unotext.hxx b/sw/inc/unotext.hxx index 73fc1e4c57ba..751a1a213070 100644 --- a/sw/inc/unotext.hxx +++ b/sw/inc/unotext.hxx @@ -46,7 +46,7 @@ class SwPaM; class SwXTextCursor; class SwXParagraph; -class SAL_DLLPUBLIC_RTTI SwXText +class SAL_DLLPUBLIC_RTTI SAL_LOPLUGIN_ANNOTATE("crosscast") SwXText : public css::lang::XTypeProvider , public css::beans::XPropertySet , public css::text::XTextAppendAndConvert diff --git a/sw/inc/unotextbodyhf.hxx b/sw/inc/unotextbodyhf.hxx index 3c16da8f7574..cdaeb8e102af 100644 --- a/sw/inc/unotextbodyhf.hxx +++ b/sw/inc/unotextbodyhf.hxx @@ -37,7 +37,7 @@ typedef ::cppu::WeakImplHelper , css::container::XEnumerationAccess > SwXBodyText_Base; -class SwXBodyText final +class SW_DLLPUBLIC SwXBodyText final : public SwXBodyText_Base , public SwXText { diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx index 6138bc7834a6..50bdd274e6f0 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx @@ -148,6 +148,7 @@ #include <unocontentcontrol.hxx> #include <unofootnote.hxx> #include <unoport.hxx> +#include <unotextbodyhf.hxx> using namespace ::com::sun::star; using namespace oox; @@ -405,13 +406,11 @@ DomainMapper_Impl::DomainMapper_Impl( throw uno::Exception(u"failed to find body text of the insert position"_ustr, nullptr); } - uno::Reference< text::XTextAppend > xBodyTextAppend( m_xBodyText, uno::UNO_QUERY ); - m_aTextAppendStack.push(TextAppendContext(xBodyTextAppend, + m_aTextAppendStack.push(TextAppendContext(m_xBodyText, m_bIsNewDoc ? uno::Reference<text::XTextCursor>() : m_xBodyText->createTextCursorByRange(m_xInsertTextRange))); //todo: does it makes sense to set the body text as static text interface? - uno::Reference< text::XTextAppendAndConvert > xBodyTextAppendAndConvert( m_xBodyText, uno::UNO_QUERY ); - m_pTableHandler = new DomainMapperTableHandler(xBodyTextAppendAndConvert, *this); + m_pTableHandler = new DomainMapperTableHandler(m_xBodyText, *this); getTableManager( ).setHandler(m_pTableHandler); getTableManager( ).startLevel(); @@ -528,14 +527,18 @@ OUString DomainMapper_Impl::GetUnusedCharacterStyleName() return sPageStyleName; } -uno::Reference< text::XText > const & DomainMapper_Impl::GetBodyText() +rtl::Reference< SwXText > const & DomainMapper_Impl::GetBodyText() { if(!m_xBodyText.is()) { if (m_xInsertTextRange.is()) - m_xBodyText = m_xInsertTextRange->getText(); + { + uno::Reference<css::text::XText> xText = m_xInsertTextRange->getText(); + assert(!xText || dynamic_cast<SwXText*>(xText.get())); + m_xBodyText = dynamic_cast<SwXText*>(m_xInsertTextRange->getText().get()); + } else if (m_xTextDocument.is()) - m_xBodyText = m_xTextDocument->getText(); + m_xBodyText = m_xTextDocument->getBodyText(); } return m_xBodyText; } diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx index a22574fa3292..223992082645 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx @@ -61,6 +61,7 @@ class SwXTextSection; class SwXTextField; class SwXTextFrame; class SwXTextEmbeddedObject; +class SwXText; namespace com::sun::star{ namespace awt{ struct Size; @@ -553,7 +554,7 @@ private: // cache next available number, expensive to repeatedly compute std::optional<int> m_xNextUnusedCharacterStyleNo; - css::uno::Reference<css::text::XText> m_xBodyText; + rtl::Reference<SwXText> m_xBodyText; std::stack<TextAppendContext> m_aTextAppendStack; std::vector<AnchoredContext> m_vAnchoredStack; @@ -725,7 +726,7 @@ public: css::uno::Reference<css::container::XNameContainer> const & GetCharacterStyles(); css::uno::Reference<css::container::XNameContainer> const& GetParagraphStyles(); OUString GetUnusedCharacterStyleName(); - css::uno::Reference<css::text::XText> const & GetBodyText(); + rtl::Reference<SwXText> const & GetBodyText(); const rtl::Reference<SwXTextDocument>& GetTextDocument() const { return m_xTextDocument; diff --git a/sw/source/writerfilter/dmapper/PropertyMap.cxx b/sw/source/writerfilter/dmapper/PropertyMap.cxx index ea840aa6b536..ce9b20c2f1f9 100644 --- a/sw/source/writerfilter/dmapper/PropertyMap.cxx +++ b/sw/source/writerfilter/dmapper/PropertyMap.cxx @@ -68,6 +68,7 @@ #include <unosection.hxx> #include <unotxdoc.hxx> #include <unoxstyle.hxx> +#include <unotext.hxx> #include <utility> #include <frozen/bits/defines.h> @@ -1166,7 +1167,7 @@ static uno::Reference< beans::XPropertySet > lcl_GetRangeProperties( bool bIsFir uno::Reference< beans::XPropertySet > xRangeProperties; if ( bIsFirstSection && rDM_Impl.GetBodyText().is() ) { - uno::Reference< container::XEnumerationAccess > xEnumAccess( rDM_Impl.GetBodyText(), uno::UNO_QUERY_THROW ); + uno::Reference< container::XEnumerationAccess > xEnumAccess( dynamic_cast<container::XEnumerationAccess*>(rDM_Impl.GetBodyText().get()), uno::UNO_QUERY_THROW ); uno::Reference< container::XEnumeration > xEnum = xEnumAccess->createEnumeration(); xRangeProperties.set( xEnum->nextElement(), uno::UNO_QUERY_THROW ); if ( rDM_Impl.GetIsDummyParaAddedForTableInSection() && xEnum->hasMoreElements() ) |