sd/inc/textapi.hxx | 6 +++--- sd/source/core/text/textapi.cxx | 39 +++++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 21 deletions(-)
New commits: commit a377a7c5aa7f1ad9aae7d7bc8da4cbf5ba6b6478 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Fri Apr 19 17:12:15 2024 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Wed May 1 11:18:40 2024 +0200 annot: make TextApi use SdrModel instead of SdDrawDocument Also it uses SdrOutliner instead of SdOutliner. This change is important for moving the implementation to svx, where we don't have sd specifics available and it seems in this case they are not even needed. Change-Id: I6c63ba4953bb5281aa951a0048a08fdd2813c530 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166495 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/sd/inc/textapi.hxx b/sd/inc/textapi.hxx index 70110349053a..5491382e0564 100644 --- a/sd/inc/textapi.hxx +++ b/sd/inc/textapi.hxx @@ -23,7 +23,7 @@ #include <rtl/ref.hxx> #include <editeng/outliner.hxx> -class SdDrawDocument; +class SdrModel; namespace sd { @@ -32,9 +32,9 @@ class TextAPIEditSource; class TextApiObject final : public SvxUnoText { public: - static rtl::Reference< TextApiObject > create( SdDrawDocument* pDoc ); + static rtl::Reference<TextApiObject> create(SdrModel* pModel); - virtual ~TextApiObject() noexcept override; + virtual ~TextApiObject() noexcept override; /// @throws css::uno::RuntimeException void dispose(); diff --git a/sd/source/core/text/textapi.cxx b/sd/source/core/text/textapi.cxx index e35b051d25f5..afb3c80714e5 100644 --- a/sd/source/core/text/textapi.cxx +++ b/sd/source/core/text/textapi.cxx @@ -87,9 +87,9 @@ namespace { struct TextAPIEditSource_Impl { - SdDrawDocument* mpDoc; - Outliner* mpOutliner; - SvxOutlinerForwarder* mpTextForwarder; + SdrModel* mpModel; + Outliner* mpOutliner; + SvxOutlinerForwarder* mpTextForwarder; }; } @@ -105,13 +105,14 @@ class TextAPIEditSource : public SvxEditSource explicit TextAPIEditSource( const TextAPIEditSource& rSource ); public: - explicit TextAPIEditSource(SdDrawDocument* pDoc); + explicit TextAPIEditSource(SdrModel* pModel); void Dispose(); void SetText( OutlinerParaObject const & rText ); std::optional<OutlinerParaObject> CreateText(); OUString GetText() const; - SdDrawDocument* GetDoc() { return m_xImpl->mpDoc; } + + SdrModel* getModel() { return m_xImpl->mpModel; } }; static const SvxItemPropertySet* ImplGetSdTextPortionPropertyMap() @@ -143,9 +144,9 @@ TextApiObject::~TextApiObject() noexcept dispose(); } -rtl::Reference< TextApiObject > TextApiObject::create( SdDrawDocument* pDoc ) +rtl::Reference<TextApiObject> TextApiObject::create(SdrModel* pModel) { - rtl::Reference< TextApiObject > xRet( new TextApiObject( std::make_unique<TextAPIEditSource>( pDoc ) ) ); + rtl::Reference<TextApiObject> xRet(new TextApiObject(std::make_unique<TextAPIEditSource>(pModel))); return xRet; } @@ -166,7 +167,7 @@ std::optional<OutlinerParaObject> TextApiObject::CreateText() void TextApiObject::SetText( OutlinerParaObject const & rText ) { - SdrModel* pModel = mpSource->GetDoc(); + SdrModel* pModel = mpSource->getModel(); if( pModel && pModel->IsUndoEnabled() ) pModel->AddUndo( std::make_unique<UndoTextAPIChanged>( *pModel, this ) ); @@ -205,17 +206,17 @@ void TextAPIEditSource::UpdateData() // data is kept in outliner all the time } -TextAPIEditSource::TextAPIEditSource(SdDrawDocument* pDoc) +TextAPIEditSource::TextAPIEditSource(SdrModel* pModel) : m_xImpl(std::make_shared<TextAPIEditSource_Impl>()) { - m_xImpl->mpDoc = pDoc; + m_xImpl->mpModel = pModel; m_xImpl->mpOutliner = nullptr; m_xImpl->mpTextForwarder = nullptr; } void TextAPIEditSource::Dispose() { - m_xImpl->mpDoc=nullptr; + m_xImpl->mpModel = nullptr; delete m_xImpl->mpTextForwarder; m_xImpl->mpTextForwarder = nullptr; @@ -225,13 +226,14 @@ void TextAPIEditSource::Dispose() SvxTextForwarder* TextAPIEditSource::GetTextForwarder() { - if(!m_xImpl->mpDoc) - return nullptr; // mpDoc == 0 can be used to flag this as disposed + if(!m_xImpl->mpModel) + return nullptr; // mpModel == 0 can be used to flag this as disposed if (!m_xImpl->mpOutliner) { //init draw model first - m_xImpl->mpOutliner = new SdOutliner(m_xImpl->mpDoc, OutlinerMode::TextObject); + SfxItemPool* pPool = &m_xImpl->mpModel->GetItemPool(); + m_xImpl->mpOutliner = new SdrOutliner(pPool, OutlinerMode::TextObject); SdDrawDocument::SetCalcFieldValueHdl(m_xImpl->mpOutliner); } @@ -243,12 +245,13 @@ SvxTextForwarder* TextAPIEditSource::GetTextForwarder() void TextAPIEditSource::SetText( OutlinerParaObject const & rText ) { - if (m_xImpl->mpDoc) + if (m_xImpl->mpModel) { if (!m_xImpl->mpOutliner) { //init draw model first - m_xImpl->mpOutliner = new SdOutliner(m_xImpl->mpDoc, OutlinerMode::TextObject); + SfxItemPool* pPool = &m_xImpl->mpModel->GetItemPool(); + m_xImpl->mpOutliner = new SdrOutliner(pPool, OutlinerMode::TextObject); SdDrawDocument::SetCalcFieldValueHdl(m_xImpl->mpOutliner); } @@ -258,7 +261,7 @@ void TextAPIEditSource::SetText( OutlinerParaObject const & rText ) std::optional<OutlinerParaObject> TextAPIEditSource::CreateText() { - if (m_xImpl->mpDoc && m_xImpl->mpOutliner) + if (m_xImpl->mpModel && m_xImpl->mpOutliner) return m_xImpl->mpOutliner->CreateParaObject(); else return std::nullopt; @@ -266,7 +269,7 @@ std::optional<OutlinerParaObject> TextAPIEditSource::CreateText() OUString TextAPIEditSource::GetText() const { - if (m_xImpl->mpDoc && m_xImpl->mpOutliner) + if (m_xImpl->mpModel && m_xImpl->mpOutliner) return m_xImpl->mpOutliner->GetEditEngine().GetText(); else return OUString();