diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-07-20 12:31:57 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-07-20 21:32:26 +0200 |
commit | 8e8d3f4db94e0069a1d84378d295268f5037b016 (patch) | |
tree | c06b2ec6e696531799bd709be18a7d4d5a4aec26 | |
parent | a11a06d38e145139a2a1c7d51510b4fc2222c3e1 (diff) |
EditTextObject: use virtual interface instead of pimpl
Makes it simpler, and avoids extra allocations
Change-Id: I301f628a2898f6421242808cbf8ce36c5acf9b0b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119241
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | editeng/source/editeng/editobj.cxx | 208 | ||||
-rw-r--r-- | editeng/source/editeng/editobj2.hxx | 82 | ||||
-rw-r--r-- | editeng/source/editeng/fieldupdater.cxx | 4 | ||||
-rw-r--r-- | editeng/source/editeng/impedit4.cxx | 29 | ||||
-rw-r--r-- | include/editeng/editobj.hxx | 87 | ||||
-rw-r--r-- | include/editeng/fieldupdater.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/column.cxx | 8 | ||||
-rw-r--r-- | sw/qa/extras/layout/layout.cxx | 2 |
8 files changed, 116 insertions, 306 deletions
diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx index 7dd9bdd2459d..cf4e474df6b6 100644 --- a/editeng/source/editeng/editobj.cxx +++ b/editeng/source/editeng/editobj.cxx @@ -206,197 +206,20 @@ bool ContentInfo::Equals(const ContentInfo& rCompare, bool bComparePool) const && maCharAttribs == rCompare.maCharAttribs; } -EditTextObject::EditTextObject( SfxItemPool* pPool ) : - mpImpl(new EditTextObjectImpl(this, pPool)) -{ -} - -EditTextObject::EditTextObject( const EditTextObject& r ) : - mpImpl(new EditTextObjectImpl(this, *r.mpImpl)) -{ -} - -EditTextObject::~EditTextObject() -{ -} - -sal_Int32 EditTextObject::GetParagraphCount() const -{ - return mpImpl->GetParagraphCount(); -} - -OUString EditTextObject::GetText(sal_Int32 nPara) const -{ - return mpImpl->GetText(nPara); -} - -void EditTextObject::ClearPortionInfo() -{ - mpImpl->ClearPortionInfo(); -} - -bool EditTextObject::HasOnlineSpellErrors() const -{ - return mpImpl->HasOnlineSpellErrors(); -} - -void EditTextObject::GetCharAttribs( sal_Int32 nPara, std::vector<EECharAttrib>& rLst ) const -{ - mpImpl->GetCharAttribs(nPara, rLst); -} - -bool EditTextObject::IsFieldObject() const -{ - return mpImpl->IsFieldObject(); -} - -const SvxFieldItem* EditTextObject::GetField() const -{ - return mpImpl->GetField(); -} - -const SvxFieldData* EditTextObject::GetFieldData(sal_Int32 nPara, size_t nPos, sal_Int32 nType) const -{ - return mpImpl->GetFieldData(nPara, nPos, nType); -} - -bool EditTextObject::HasField( sal_Int32 nType ) const -{ - return mpImpl->HasField(nType); -} - -const SfxItemSet& EditTextObject::GetParaAttribs(sal_Int32 nPara) const -{ - return mpImpl->GetParaAttribs(nPara); -} - -bool EditTextObject::RemoveCharAttribs( sal_uInt16 nWhich ) -{ - return mpImpl->RemoveCharAttribs(nWhich); -} - -void EditTextObject::GetAllSections( std::vector<editeng::Section>& rAttrs ) const -{ - mpImpl->GetAllSections(rAttrs); -} - -void EditTextObject::GetStyleSheet(sal_Int32 nPara, OUString& rName, SfxStyleFamily& eFamily) const -{ - mpImpl->GetStyleSheet(nPara, rName, eFamily); -} - -void EditTextObject::SetStyleSheet(sal_Int32 nPara, const OUString& rName, const SfxStyleFamily& eFamily) -{ - mpImpl->SetStyleSheet(nPara, rName, eFamily); -} - -bool EditTextObject::ChangeStyleSheets( - std::u16string_view rOldName, SfxStyleFamily eOldFamily, const OUString& rNewName, SfxStyleFamily eNewFamily) -{ - return mpImpl->ChangeStyleSheets(rOldName, eOldFamily, rNewName, eNewFamily); -} - -void EditTextObject::ChangeStyleSheetName( - SfxStyleFamily eFamily, std::u16string_view rOldName, const OUString& rNewName) -{ - mpImpl->ChangeStyleSheetName(eFamily, rOldName, rNewName); -} - -editeng::FieldUpdater EditTextObject::GetFieldUpdater() const -{ - return mpImpl->GetFieldUpdater(); -} - -void EditTextObject::NormalizeString( svl::SharedStringPool& rPool ) -{ - mpImpl->NormalizeString(rPool); -} - -std::vector<svl::SharedString> EditTextObject::GetSharedStrings() const -{ - return mpImpl->GetSharedStrings(); -} - -const SfxItemPool* EditTextObject::GetPool() const -{ - return mpImpl->GetPool(); -} - -OutlinerMode EditTextObject::GetUserType() const -{ - return mpImpl->GetUserType(); -} - -void EditTextObject::SetUserType( OutlinerMode n ) -{ - mpImpl->SetUserType(n); -} - -bool EditTextObject::IsVertical() const -{ - return mpImpl->IsVertical(); -} - -bool EditTextObject::GetDirectVertical() const -{ - return mpImpl->GetDirectVertical(); -} - -bool EditTextObject::IsTopToBottom() const -{ - return mpImpl->IsTopToBottom(); -} - -void EditTextObject::SetVertical( bool bVertical ) -{ - return mpImpl->SetVertical(bVertical); -} - -void EditTextObject::SetRotation( TextRotation nRotation ) -{ - mpImpl->SetRotation(nRotation); -} - -TextRotation EditTextObject::GetRotation() const -{ - return mpImpl->GetRotation(); -} +EditTextObject::~EditTextObject() = default; -SvtScriptType EditTextObject::GetScriptType() const +std::unique_ptr<EditTextObject> EditTextObjectImpl::Clone() const { - return mpImpl->GetScriptType(); -} - - -std::unique_ptr<EditTextObject> EditTextObject::Clone() const -{ - return std::unique_ptr<EditTextObject>(new EditTextObject(*this)); -} - -bool EditTextObject::operator==( const EditTextObject& rCompare ) const -{ - return mpImpl->operator==(*rCompare.mpImpl); + return std::make_unique<EditTextObjectImpl>(*this); } bool EditTextObject::Equals( const EditTextObject& rCompare ) const { - return mpImpl->Equals(*rCompare.mpImpl, false/*bComparePool*/); + return static_cast<const EditTextObjectImpl*>(this)->Equals( + static_cast<const EditTextObjectImpl&>(rCompare), false /*bComparePool*/); } -// #i102062# -bool EditTextObject::isWrongListEqual(const EditTextObject& rCompare) const -{ - return mpImpl->isWrongListEqual(*rCompare.mpImpl); -} - -#if DEBUG_EDIT_ENGINE -void EditTextObject::Dump() const -{ - mpImpl->Dump(); -} -#endif - -void EditTextObject::dumpAsXml(xmlTextWriterPtr pWriter) const +void EditTextObjectImpl::dumpAsXml(xmlTextWriterPtr pWriter) const { bool bOwns = false; if (!pWriter) @@ -412,7 +235,7 @@ void EditTextObject::dumpAsXml(xmlTextWriterPtr pWriter) const sal_Int32 nCount = GetParagraphCount(); for (sal_Int32 i = 0; i < nCount; ++i) { - mpImpl->aContents[i]->dumpAsXml(pWriter); + aContents[i]->dumpAsXml(pWriter); } (void)xmlTextWriterEndElement(pWriter); @@ -448,9 +271,8 @@ static EditEngineItemPool* getEditEngineItemPool(SfxItemPool* pPool) return pRetval; } -EditTextObjectImpl::EditTextObjectImpl( EditTextObject* pFront, SfxItemPool* pP ) - : mpFront(pFront) - , nMetric(0xFFFF) +EditTextObjectImpl::EditTextObjectImpl( SfxItemPool* pP ) + : nMetric(0xFFFF) , nUserType(OutlinerMode::DontKnow) , nScriptType(SvtScriptType::NONE) , bVertical(false) @@ -475,9 +297,8 @@ EditTextObjectImpl::EditTextObjectImpl( EditTextObject* pFront, SfxItemPool* pP } } -EditTextObjectImpl::EditTextObjectImpl( EditTextObject* pFront, const EditTextObjectImpl& r ) - : mpFront(pFront) - , nMetric(r.nMetric) +EditTextObjectImpl::EditTextObjectImpl( const EditTextObjectImpl& r ) + : nMetric(r.nMetric) , nUserType(r.nUserType) , nScriptType(r.nScriptType) , bVertical(r.bVertical) @@ -959,9 +780,9 @@ void EditTextObjectImpl::ChangeStyleSheetName( SfxStyleFamily eFamily, ImpChangeStyleSheets( rOldName, eFamily, rNewName, eFamily ); } -bool EditTextObjectImpl::operator==( const EditTextObjectImpl& rCompare ) const +bool EditTextObjectImpl::operator==( const EditTextObject& rCompare ) const { - return Equals( rCompare, true); + return Equals( static_cast<const EditTextObjectImpl&>(rCompare), true); } bool EditTextObjectImpl::Equals( const EditTextObjectImpl& rCompare, bool bComparePool ) const @@ -988,8 +809,9 @@ bool EditTextObjectImpl::Equals( const EditTextObjectImpl& rCompare, bool bCompa } // #i102062# -bool EditTextObjectImpl::isWrongListEqual(const EditTextObjectImpl& rCompare) const +bool EditTextObjectImpl::isWrongListEqual(const EditTextObject& rComp) const { + const EditTextObjectImpl& rCompare = static_cast<const EditTextObjectImpl&>(rComp); if (aContents.size() != rCompare.aContents.size()) { return false; diff --git a/editeng/source/editeng/editobj2.hxx b/editeng/source/editeng/editobj2.hxx index 3c7f171d2da5..f00f9ef72139 100644 --- a/editeng/source/editeng/editobj2.hxx +++ b/editeng/source/editeng/editobj2.hxx @@ -163,15 +163,12 @@ public: #endif }; -class EditTextObjectImpl +class EditTextObjectImpl final : public EditTextObject { -friend class EditTextObject; public: typedef std::vector<std::unique_ptr<ContentInfo> > ContentInfosType; private: - EditTextObject* mpFront; - ContentInfosType aContents; rtl::Reference<SfxItemPool> pPool; std::unique_ptr<XParaPortionList> pPortionInfo; @@ -188,68 +185,70 @@ private: const OUString& rNewName, SfxStyleFamily eNewFamily ); public: - EditTextObjectImpl( EditTextObject* pFront, SfxItemPool* pPool ); - EditTextObjectImpl( EditTextObject* pFront, const EditTextObjectImpl& r ); - ~EditTextObjectImpl(); + EditTextObjectImpl( SfxItemPool* pPool ); + EditTextObjectImpl( const EditTextObjectImpl& r ); + virtual ~EditTextObjectImpl() override; - EditTextObjectImpl(const EditTextObjectImpl&) = delete; EditTextObjectImpl& operator=(const EditTextObjectImpl&) = delete; - OutlinerMode GetUserType() const { return nUserType;} - void SetUserType( OutlinerMode n ); + virtual OutlinerMode GetUserType() const override { return nUserType;} + virtual void SetUserType( OutlinerMode n ) override; - void NormalizeString( svl::SharedStringPool& rPool ); - std::vector<svl::SharedString> GetSharedStrings() const; + virtual void NormalizeString( svl::SharedStringPool& rPool ) override; + virtual std::vector<svl::SharedString> GetSharedStrings() const override; - bool IsVertical() const; - bool GetDirectVertical() const; - bool IsTopToBottom() const; - void SetVertical( bool bVert); - void SetRotation(TextRotation nRotation); - TextRotation GetRotation() const; + virtual bool IsVertical() const override; + virtual bool GetDirectVertical() const override; + virtual bool IsTopToBottom() const override; + virtual void SetVertical( bool bVert) override; + virtual void SetRotation(TextRotation nRotation) override; + virtual TextRotation GetRotation() const override; - SvtScriptType GetScriptType() const { return nScriptType;} + virtual SvtScriptType GetScriptType() const override { return nScriptType;} void SetScriptType( SvtScriptType nType ); + virtual std::unique_ptr<EditTextObject> Clone() const override; + ContentInfo* CreateAndInsertContent(); XEditAttribute CreateAttrib( const SfxPoolItem& rItem, sal_Int32 nStart, sal_Int32 nEnd ); void DestroyAttrib( const XEditAttribute& rAttr ); ContentInfosType& GetContents() { return aContents;} const ContentInfosType& GetContents() const { return aContents;} - SfxItemPool* GetPool() const { return pPool.get(); } + SfxItemPool* GetPool() { return pPool.get(); } + virtual const SfxItemPool* GetPool() const override { return pPool.get(); } XParaPortionList* GetPortionInfo() const { return pPortionInfo.get(); } void SetPortionInfo( std::unique_ptr<XParaPortionList> pP ) { pPortionInfo = std::move(pP); } - sal_Int32 GetParagraphCount() const; - OUString GetText(sal_Int32 nParagraph) const; + virtual sal_Int32 GetParagraphCount() const override; + virtual OUString GetText(sal_Int32 nParagraph) const override; - void ClearPortionInfo(); + virtual void ClearPortionInfo() override; - bool HasOnlineSpellErrors() const; + virtual bool HasOnlineSpellErrors() const override; - void GetCharAttribs( sal_Int32 nPara, std::vector<EECharAttrib>& rLst ) const; + virtual void GetCharAttribs( sal_Int32 nPara, std::vector<EECharAttrib>& rLst ) const override; - bool RemoveCharAttribs( sal_uInt16 nWhich ); + virtual bool RemoveCharAttribs( sal_uInt16 nWhich ) override; - void GetAllSections( std::vector<editeng::Section>& rAttrs ) const; + virtual void GetAllSections( std::vector<editeng::Section>& rAttrs ) const override; - bool IsFieldObject() const; - const SvxFieldItem* GetField() const; - const SvxFieldData* GetFieldData(sal_Int32 nPara, size_t nPos, sal_Int32 nType) const; + virtual bool IsFieldObject() const override; + virtual const SvxFieldItem* GetField() const override; + virtual const SvxFieldData* GetFieldData(sal_Int32 nPara, size_t nPos, sal_Int32 nType) const override; - bool HasField( sal_Int32 nType ) const; + virtual bool HasField( sal_Int32 nType = css::text::textfield::Type::UNSPECIFIED ) const override; - const SfxItemSet& GetParaAttribs(sal_Int32 nPara) const; + virtual const SfxItemSet& GetParaAttribs(sal_Int32 nPara) const override; - void GetStyleSheet(sal_Int32 nPara, OUString& rName, SfxStyleFamily& eFamily) const; - void SetStyleSheet(sal_Int32 nPara, const OUString& rName, const SfxStyleFamily& eFamily); - bool ChangeStyleSheets( - std::u16string_view rOldName, SfxStyleFamily eOldFamily, const OUString& rNewName, SfxStyleFamily eNewFamily); - void ChangeStyleSheetName(SfxStyleFamily eFamily, std::u16string_view rOldName, const OUString& rNewName); + virtual void GetStyleSheet(sal_Int32 nPara, OUString& rName, SfxStyleFamily& eFamily) const override; + virtual void SetStyleSheet(sal_Int32 nPara, const OUString& rName, const SfxStyleFamily& eFamily) override; + virtual bool ChangeStyleSheets( + std::u16string_view rOldName, SfxStyleFamily eOldFamily, const OUString& rNewName, SfxStyleFamily eNewFamily) override; + virtual void ChangeStyleSheetName(SfxStyleFamily eFamily, std::u16string_view rOldName, const OUString& rNewName) override; - editeng::FieldUpdater GetFieldUpdater() const { return editeng::FieldUpdater(*mpFront);} + virtual editeng::FieldUpdater GetFieldUpdater() override { return editeng::FieldUpdater(*this); } bool HasMetric() const { return nMetric != 0xFFFF; } sal_uInt16 GetMetric() const { return nMetric; } @@ -257,15 +256,16 @@ public: bool IsOwnerOfPool() const { return bOwnerOfPool; } - bool operator==( const EditTextObjectImpl& rCompare ) const; + virtual bool operator==( const EditTextObject& rCompare ) const override; bool Equals( const EditTextObjectImpl& rCompare, bool bComparePool ) const; // #i102062# - bool isWrongListEqual(const EditTextObjectImpl& rCompare) const; + virtual bool isWrongListEqual(const EditTextObject& rCompare) const override; #if DEBUG_EDIT_ENGINE - void Dump() const; + virtual void Dump() const override; #endif + virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/source/editeng/fieldupdater.cxx b/editeng/source/editeng/fieldupdater.cxx index b342aacca48b..78891dac499b 100644 --- a/editeng/source/editeng/fieldupdater.cxx +++ b/editeng/source/editeng/fieldupdater.cxx @@ -22,7 +22,7 @@ class FieldUpdaterImpl { EditTextObjectImpl& mrObj; public: - explicit FieldUpdaterImpl(EditTextObject const & rObj) : mrObj(*rObj.mpImpl) {} + explicit FieldUpdaterImpl(EditTextObject& rObj) : mrObj(static_cast<EditTextObjectImpl&>(rObj)) {} void updateTableFields(int nTab) { @@ -53,7 +53,7 @@ public: } }; -FieldUpdater::FieldUpdater(EditTextObject const & rObj) : mpImpl(new FieldUpdaterImpl(rObj)) {} +FieldUpdater::FieldUpdater(EditTextObject& rObj) : mpImpl(new FieldUpdaterImpl(rObj)) {} FieldUpdater::FieldUpdater(const FieldUpdater& r) : mpImpl(new FieldUpdaterImpl(*r.mpImpl)) {} FieldUpdater::~FieldUpdater() diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx index cc44ac847163..5b11662eda1b 100644 --- a/editeng/source/editeng/impedit4.cxx +++ b/editeng/source/editeng/impedit4.cxx @@ -989,13 +989,13 @@ std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject(const EditSelect std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject( EditSelection aSel, SfxItemPool* pPool, bool bAllowBigObjects, sal_Int32 nBigObjectStart ) { - std::unique_ptr<EditTextObject> pTxtObj(new EditTextObject(pPool)); + std::unique_ptr<EditTextObjectImpl> pTxtObj(std::make_unique<EditTextObjectImpl>(pPool)); pTxtObj->SetVertical( GetDirectVertical() ); pTxtObj->SetRotation( GetRotation() ); MapUnit eMapUnit = aEditDoc.GetItemPool().GetMetric( DEF_METRIC ); - pTxtObj->mpImpl->SetMetric( static_cast<sal_uInt16>(eMapUnit) ); - if ( pTxtObj->mpImpl->IsOwnerOfPool() ) - pTxtObj->mpImpl->GetPool()->SetDefaultMetric( eMapUnit ); + pTxtObj->SetMetric( static_cast<sal_uInt16>(eMapUnit) ); + if ( pTxtObj->IsOwnerOfPool() ) + pTxtObj->GetPool()->SetDefaultMetric( eMapUnit ); sal_Int32 nStartNode, nEndNode; sal_Int32 nTextPortions = 0; @@ -1009,7 +1009,7 @@ std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject( EditSelection a // Templates are not saved! // (Only the name and family, template itself must be in App!) - pTxtObj->mpImpl->SetScriptType(GetItemScriptType(aSel)); + pTxtObj->SetScriptType(GetItemScriptType(aSel)); // iterate over the paragraphs ... sal_Int32 nNode; @@ -1035,7 +1035,7 @@ std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject( EditSelection a nEndPos = aSel.Max().GetIndex(); - ContentInfo *pC = pTxtObj->mpImpl->CreateAndInsertContent(); + ContentInfo *pC = pTxtObj->CreateAndInsertContent(); // The paragraph attributes ... pC->GetParaAttribs().Set( pNode->GetContentAttribs().GetItems() ); @@ -1060,7 +1060,7 @@ std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject( EditSelection a if ( bEmptyPara || ( ( pAttr->GetEnd() > nStartPos ) && ( pAttr->GetStart() < nEndPos ) ) ) { - XEditAttribute aX = pTxtObj->mpImpl->CreateAttrib(*pAttr->GetItem(), pAttr->GetStart(), pAttr->GetEnd()); + XEditAttribute aX = pTxtObj->CreateAttrib(*pAttr->GetItem(), pAttr->GetStart(), pAttr->GetEnd()); // Possibly Correct ... if ( ( nNode == nStartNode ) && ( nStartPos != 0 ) ) { @@ -1075,7 +1075,7 @@ std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject( EditSelection a } DBG_ASSERT( aX.GetEnd() <= (nEndPos-nStartPos), "CreateBinTextObject: Attribute too long!" ); if ( !aX.GetLen() && !bEmptyPara ) - pTxtObj->mpImpl->DestroyAttrib(aX); + pTxtObj->DestroyAttrib(aX); else rCAttriblist.push_back(std::move(aX)); } @@ -1094,7 +1094,7 @@ std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject( EditSelection a if ( bAllowBigObjects && bOnlyFullParagraphs && IsFormatted() && GetUpdateMode() && ( nTextPortions >= nBigObjectStart ) ) { XParaPortionList* pXList = new XParaPortionList( GetRefDevice(), GetColumnWidth(aPaperSize), nStretchX, nStretchY ); - pTxtObj->mpImpl->SetPortionInfo(std::unique_ptr<XParaPortionList>(pXList)); + pTxtObj->SetPortionInfo(std::unique_ptr<XParaPortionList>(pXList)); for ( nNode = nStartNode; nNode <= nEndNode; nNode++ ) { const ParaPortion& rParaPortion = GetParaPortions()[nNode]; @@ -1174,7 +1174,8 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject DBG_ASSERT( !aSel.DbgIsBuggy( aEditDoc ), "InsertBibTextObject: Selection broken!(1)" ); bool bUsePortionInfo = false; - XParaPortionList* pPortionInfo = rTextObject.mpImpl->GetPortionInfo(); + const EditTextObjectImpl& rTextObjectImpl = static_cast<const EditTextObjectImpl&>(rTextObject); + XParaPortionList* pPortionInfo = rTextObjectImpl.GetPortionInfo(); if ( pPortionInfo && ( static_cast<tools::Long>(pPortionInfo->GetPaperWidth()) == GetColumnWidth(aPaperSize) ) && ( pPortionInfo->GetRefMapMode() == GetRefDevice()->GetMapMode() ) @@ -1188,9 +1189,9 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject bool bConvertMetricOfItems = false; MapUnit eSourceUnit = MapUnit(), eDestUnit = MapUnit(); - if (rTextObject.mpImpl->HasMetric()) + if (rTextObjectImpl.HasMetric()) { - eSourceUnit = static_cast<MapUnit>(rTextObject.mpImpl->GetMetric()); + eSourceUnit = static_cast<MapUnit>(rTextObjectImpl.GetMetric()); eDestUnit = aEditDoc.GetItemPool().GetMetric( DEF_METRIC ); if ( eSourceUnit != eDestUnit ) bConvertMetricOfItems = true; @@ -1199,13 +1200,13 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject // Before, paragraph count was of type sal_uInt16 so if nContents exceeded // 0xFFFF this wouldn't have worked anyway, given that nPara is used to // number paragraphs and is fearlessly incremented. - sal_Int32 nContents = static_cast<sal_Int32>(rTextObject.mpImpl->GetContents().size()); + sal_Int32 nContents = static_cast<sal_Int32>(rTextObjectImpl.GetContents().size()); SAL_WARN_IF( nContents < 0, "editeng", "ImpEditEngine::InsertTextObject - contents overflow " << nContents); sal_Int32 nPara = aEditDoc.GetPos( aPaM.GetNode() ); for (sal_Int32 n = 0; n < nContents; ++n, ++nPara) { - const ContentInfo* pC = rTextObject.mpImpl->GetContents()[n].get(); + const ContentInfo* pC = rTextObjectImpl.GetContents()[n].get(); bool bNewContent = aPaM.GetNode()->Len() == 0; const sal_Int32 nStartPos = aPaM.GetIndex(); diff --git a/include/editeng/editobj.hxx b/include/editeng/editobj.hxx index 1c838b75a9e8..530601082cc1 100644 --- a/include/editeng/editobj.hxx +++ b/include/editeng/editobj.hxx @@ -40,7 +40,6 @@ struct EECharAttrib; namespace editeng { class FieldUpdater; -class FieldUpdaterImpl; struct Section; } @@ -54,58 +53,46 @@ class SharedStringPool; enum class TextRotation { NONE, TOPTOBOTTOM, BOTTOMTOTOP }; -class EditTextObjectImpl; - -class EDITENG_DLLPUBLIC EditTextObject final +class EDITENG_DLLPUBLIC EditTextObject { - friend class EditTextObjectImpl; - friend class editeng::FieldUpdaterImpl; - friend class ImpEditEngine; - - std::unique_ptr<EditTextObjectImpl> mpImpl; - - EditTextObject( SfxItemPool* pPool ); - public: - EditTextObject( const EditTextObject& r ); - ~EditTextObject(); - EditTextObject& operator=( const EditTextObject& ) = delete; + virtual ~EditTextObject(); /** * Set paragraph strings to the shared string pool. * * @param rPool shared string pool. */ - void NormalizeString( svl::SharedStringPool& rPool ); + virtual void NormalizeString( svl::SharedStringPool& rPool ) = 0; - std::vector<svl::SharedString> GetSharedStrings() const; + virtual std::vector<svl::SharedString> GetSharedStrings() const = 0; - const SfxItemPool* GetPool() const; - OutlinerMode GetUserType() const; // For OutlinerMode, it can however not save in compatible format - void SetUserType( OutlinerMode n ); + virtual const SfxItemPool* GetPool() const = 0; + virtual OutlinerMode GetUserType() const = 0; // For OutlinerMode, it can however not save in compatible format + virtual void SetUserType( OutlinerMode n ) = 0; - bool IsVertical() const; - bool GetDirectVertical() const; - bool IsTopToBottom() const; - void SetVertical( bool bVertical ); - void SetRotation( TextRotation nRotation ); - TextRotation GetRotation() const; + virtual bool IsVertical() const = 0; + virtual bool GetDirectVertical() const = 0; + virtual bool IsTopToBottom() const = 0; + virtual void SetVertical( bool bVertical ) = 0; + virtual void SetRotation( TextRotation nRotation ) = 0; + virtual TextRotation GetRotation() const = 0; - SvtScriptType GetScriptType() const; + virtual SvtScriptType GetScriptType() const = 0; - std::unique_ptr<EditTextObject> Clone() const; + virtual std::unique_ptr<EditTextObject> Clone() const = 0; - sal_Int32 GetParagraphCount() const; + virtual sal_Int32 GetParagraphCount() const = 0; - OUString GetText(sal_Int32 nPara) const; + virtual OUString GetText(sal_Int32 nPara) const = 0; - void ClearPortionInfo(); + virtual void ClearPortionInfo() = 0; - bool HasOnlineSpellErrors() const; + virtual bool HasOnlineSpellErrors() const = 0; - void GetCharAttribs( sal_Int32 nPara, std::vector<EECharAttrib>& rLst ) const; + virtual void GetCharAttribs( sal_Int32 nPara, std::vector<EECharAttrib>& rLst ) const = 0; - bool RemoveCharAttribs( sal_uInt16 nWhich ); + virtual bool RemoveCharAttribs( sal_uInt16 nWhich ) = 0; /** * Get all text sections in this content. Sections are non-overlapping @@ -113,36 +100,36 @@ public: * boundaries. Each section object contains all applied formats and/or a * field item. */ - void GetAllSections( std::vector<editeng::Section>& rAttrs ) const; + virtual void GetAllSections( std::vector<editeng::Section>& rAttrs ) const = 0; - bool IsFieldObject() const; - const SvxFieldItem* GetField() const; - const SvxFieldData* GetFieldData(sal_Int32 nPara, size_t nPos, sal_Int32 nType) const; - bool HasField( sal_Int32 nType = css::text::textfield::Type::UNSPECIFIED ) const; + virtual bool IsFieldObject() const = 0; + virtual const SvxFieldItem* GetField() const = 0; + virtual const SvxFieldData* GetFieldData(sal_Int32 nPara, size_t nPos, sal_Int32 nType) const = 0; + virtual bool HasField( sal_Int32 nType = css::text::textfield::Type::UNSPECIFIED ) const = 0; - const SfxItemSet& GetParaAttribs(sal_Int32 nPara) const; + virtual const SfxItemSet& GetParaAttribs(sal_Int32 nPara) const = 0; - void GetStyleSheet(sal_Int32 nPara, OUString& rName, SfxStyleFamily& eFamily) const; - void SetStyleSheet(sal_Int32 nPara, const OUString& rName, const SfxStyleFamily& eFamily); - bool ChangeStyleSheets( - std::u16string_view rOldName, SfxStyleFamily eOldFamily, const OUString& rNewName, SfxStyleFamily eNewFamily); - void ChangeStyleSheetName(SfxStyleFamily eFamily, std::u16string_view rOldName, const OUString& rNewName); + virtual void GetStyleSheet(sal_Int32 nPara, OUString& rName, SfxStyleFamily& eFamily) const = 0; + virtual void SetStyleSheet(sal_Int32 nPara, const OUString& rName, const SfxStyleFamily& eFamily) = 0; + virtual bool ChangeStyleSheets( + std::u16string_view rOldName, SfxStyleFamily eOldFamily, const OUString& rNewName, SfxStyleFamily eNewFamily) = 0; + virtual void ChangeStyleSheetName(SfxStyleFamily eFamily, std::u16string_view rOldName, const OUString& rNewName) = 0; - editeng::FieldUpdater GetFieldUpdater() const; + virtual editeng::FieldUpdater GetFieldUpdater() = 0; - bool operator==( const EditTextObject& rCompare ) const; + virtual bool operator==( const EditTextObject& rCompare ) const = 0; /** Compare, ignoring SfxItemPool pointer. */ bool Equals( const EditTextObject& rCompare ) const; // #i102062# - bool isWrongListEqual(const EditTextObject& rCompare) const; + virtual bool isWrongListEqual(const EditTextObject& rCompare) const = 0; #if DEBUG_EDIT_ENGINE - void Dump() const; + virtual void Dump() const = 0; #endif - void dumpAsXml(xmlTextWriterPtr pWriter) const; + virtual void dumpAsXml(xmlTextWriterPtr pWriter) const = 0; }; #endif // INCLUDED_EDITENG_EDITOBJ_HXX diff --git a/include/editeng/fieldupdater.hxx b/include/editeng/fieldupdater.hxx index aba367653308..e15754ffdd0c 100644 --- a/include/editeng/fieldupdater.hxx +++ b/include/editeng/fieldupdater.hxx @@ -28,7 +28,7 @@ class EDITENG_DLLPUBLIC FieldUpdater std::unique_ptr<FieldUpdaterImpl> mpImpl; public: - FieldUpdater(EditTextObject const& rObj); + FieldUpdater(EditTextObject& rObj); FieldUpdater(const FieldUpdater& r); ~FieldUpdater(); diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 8cdbf7e9386c..5c8ed516deca 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -2617,7 +2617,7 @@ public: mbModified = true; } - void operator() (size_t nRow, const EditTextObject* pCell) + void operator() (size_t nRow, EditTextObject* pCell) { editeng::FieldUpdater aUpdater = pCell->GetFieldUpdater(); aUpdater.updateTableFields(mnTab); @@ -2649,7 +2649,7 @@ public: mbModified = true; } - void operator() (size_t nRow, const EditTextObject* pCell) + void operator() (size_t nRow, EditTextObject* pCell) { editeng::FieldUpdater aUpdater = pCell->GetFieldUpdater(); aUpdater.updateTableFields(mnTab); @@ -2681,7 +2681,7 @@ public: mbModified = true; } - void operator() (size_t nRow, const EditTextObject* pCell) + void operator() (size_t nRow, EditTextObject* pCell) { editeng::FieldUpdater aUpdater = pCell->GetFieldUpdater(); aUpdater.updateTableFields(mnTab); @@ -2713,7 +2713,7 @@ public: mbModified = true; } - void operator() (size_t nRow, const EditTextObject* pCell) + void operator() (size_t nRow, EditTextObject* pCell) { editeng::FieldUpdater aUpdater = pCell->GetFieldUpdater(); aUpdater.updateTableFields(mnTab); diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index 8dd576987d9a..5c8d8201df95 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -3594,7 +3594,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf137185) CPPUNIT_ASSERT_EQUAL(OUString("Align me!"), xTextFrame->getText()->getString()); SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(pObj); CPPUNIT_ASSERT(pTextObj); - auto aOutStr = pTextObj->GetOutlinerParaObject()->GetTextObject(); + const auto& aOutStr = pTextObj->GetOutlinerParaObject()->GetTextObject(); CPPUNIT_ASSERT(aOutStr.GetText(0).isEmpty()); // Before the patch it failed, because the text appeared 2 times on each other. |