diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-04-10 16:07:49 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-04-11 08:42:59 +0200 |
commit | ff8442fd85f2e281a564e3dc832a751a3a9c3072 (patch) | |
tree | 05d4a59e914d53a357f99a8ce6146cb3e35f47c3 /editeng | |
parent | 672660031e4ca38205e2068b1e321268a844a68b (diff) |
pass EditTextObject around using std::unique_ptr
Change-Id: I71f4529c2e02fd0ac2561191e4cb35e18e206037
Reviewed-on: https://gerrit.libreoffice.org/52682
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/editeng.cxx | 8 | ||||
-rw-r--r-- | editeng/source/editeng/editobj.cxx | 4 | ||||
-rw-r--r-- | editeng/source/editeng/editundo.hxx | 1 | ||||
-rw-r--r-- | editeng/source/editeng/editview.cxx | 2 | ||||
-rw-r--r-- | editeng/source/editeng/impedit.hxx | 9 | ||||
-rw-r--r-- | editeng/source/editeng/impedit4.cxx | 10 | ||||
-rw-r--r-- | editeng/source/outliner/outliner.cxx | 7 | ||||
-rw-r--r-- | editeng/source/outliner/outlobj.cxx | 8 | ||||
-rw-r--r-- | editeng/source/uno/unofored.cxx | 3 |
9 files changed, 25 insertions, 27 deletions
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index 6e7ffce529f3..0b0305ab06cc 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -1512,18 +1512,18 @@ void EditEngine::Write( SvStream& rOutput, EETextFormat eFormat ) pImpEditEngine->Write( rOutput, eFormat, EditSelection( aStartPaM, aEndPaM ) ); } -EditTextObject* EditEngine::CreateTextObject() +std::unique_ptr<EditTextObject> EditEngine::CreateTextObject() { return pImpEditEngine->CreateTextObject(); } -EditTextObject* EditEngine::CreateTextObject( const ESelection& rESelection ) +std::unique_ptr<EditTextObject> EditEngine::CreateTextObject( const ESelection& rESelection ) { EditSelection aSel( pImpEditEngine->CreateSel( rESelection ) ); return pImpEditEngine->CreateTextObject( aSel ); } -EditTextObject* EditEngine::GetEmptyTextObject() const +std::unique_ptr<EditTextObject> EditEngine::GetEmptyTextObject() const { return pImpEditEngine->GetEmptyTextObject(); } @@ -1603,7 +1603,7 @@ void EditEngine::SetEndPasteOrDropHdl( const Link<PasteOrDropInfos&,void>& rLink pImpEditEngine->aEndPasteOrDropHdl = rLink; } -EditTextObject* EditEngine::CreateTextObject( sal_Int32 nPara, sal_Int32 nParas ) +std::unique_ptr<EditTextObject> EditEngine::CreateTextObject( sal_Int32 nPara, sal_Int32 nParas ) { DBG_ASSERT( 0 <= nPara && nPara < pImpEditEngine->GetEditDoc().Count(), "CreateTextObject: Startpara out of Range" ); DBG_ASSERT( nParas <= pImpEditEngine->GetEditDoc().Count() - nPara, "CreateTextObject: Endpara out of Range" ); diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx index 8d54e04851dc..5ae80f43b67c 100644 --- a/editeng/source/editeng/editobj.cxx +++ b/editeng/source/editeng/editobj.cxx @@ -389,9 +389,9 @@ SvtScriptType EditTextObject::GetScriptType() const } -EditTextObject* EditTextObject::Clone() const +std::unique_ptr<EditTextObject> EditTextObject::Clone() const { - return new EditTextObject(*this); + return std::unique_ptr<EditTextObject>(new EditTextObject(*this)); } bool EditTextObject::operator==( const EditTextObject& rCompare ) const diff --git a/editeng/source/editeng/editundo.hxx b/editeng/source/editeng/editundo.hxx index 71211435adda..dc3423c9151a 100644 --- a/editeng/source/editeng/editundo.hxx +++ b/editeng/source/editeng/editundo.hxx @@ -262,6 +262,7 @@ public: void SetText( const OUString& rText ) { aText = rText; } void SetText( EditTextObject* pObj ) { pTxtObj.reset( pObj ); } + void SetText( std::unique_ptr<EditTextObject> pObj ) { pTxtObj = std::move( pObj ); } void SetNewSelection( const ESelection& rSel ) { aNewESel = rSel; } virtual void Undo() override; diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx index a762fd935f03..4ea99caea93e 100644 --- a/editeng/source/editeng/editview.cxx +++ b/editeng/source/editeng/editview.cxx @@ -685,7 +685,7 @@ EVControlBits EditView::GetControlWord() const return pImpEditView->nControl; } -EditTextObject* EditView::CreateTextObject() +std::unique_ptr<EditTextObject> EditView::CreateTextObject() { return pImpEditView->pEditEngine->pImpEditEngine->CreateTextObject( pImpEditView->GetEditSelection() ); } diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index 0d282605c428..56ff504827b7 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -555,7 +555,7 @@ private: EditUndoSetAttribs* CreateAttribUndo( EditSelection aSel, const SfxItemSet& rSet ); - EditTextObject* GetEmptyTextObject(); + std::unique_ptr<EditTextObject> GetEmptyTextObject(); EditPaM GetPaM( Point aDocPos, bool bSmart = true ); EditPaM GetPaM( ParaPortion* pPortion, Point aPos, bool bSmart ); @@ -568,7 +568,8 @@ private: void ParaAttribsToCharAttribs( ContentNode* pNode ); void GetCharAttribs( sal_Int32 nPara, std::vector<EECharAttrib>& rLst ) const; - EditTextObject* CreateTextObject(EditSelection aSelection, SfxItemPool*, bool bAllowBigObjects = false, sal_Int32 nBigObjStart = 0); + std::unique_ptr<EditTextObject> + CreateTextObject(EditSelection aSelection, SfxItemPool*, bool bAllowBigObjects = false, sal_Int32 nBigObjStart = 0); EditSelection InsertTextObject( const EditTextObject&, EditPaM aPaM ); EditSelection PasteText( css::uno::Reference< css::datatransfer::XTransferable > const & rxDataObj, const OUString& rBaseURL, const EditPaM& rPaM, bool bUseSpecial ); @@ -821,8 +822,8 @@ public: EditPaM Read(SvStream& rInput, const OUString& rBaseURL, EETextFormat eFormat, const EditSelection& rSel, SvKeyValueIterator* pHTTPHeaderAttrs = nullptr); void Write(SvStream& rOutput, EETextFormat eFormat, const EditSelection& rSel); - EditTextObject* CreateTextObject(); - EditTextObject* CreateTextObject(const EditSelection& rSel); + std::unique_ptr<EditTextObject> CreateTextObject(); + std::unique_ptr<EditTextObject> CreateTextObject(const EditSelection& rSel); void SetText( const EditTextObject& rTextObject ); EditSelection InsertText( const EditTextObject& rTextObject, EditSelection aSel ); diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx index 4061a3b6f9fa..930f873d7fd6 100644 --- a/editeng/source/editeng/impedit4.cxx +++ b/editeng/source/editeng/impedit4.cxx @@ -967,7 +967,7 @@ void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, } } -EditTextObject* ImpEditEngine::GetEmptyTextObject() +std::unique_ptr<EditTextObject> ImpEditEngine::GetEmptyTextObject() { EditSelection aEmptySel; aEmptySel.Min() = aEditDoc.GetStartPaM(); @@ -976,7 +976,7 @@ EditTextObject* ImpEditEngine::GetEmptyTextObject() return CreateTextObject( aEmptySel ); } -EditTextObject* ImpEditEngine::CreateTextObject() +std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject() { EditSelection aCompleteSelection; aCompleteSelection.Min() = aEditDoc.GetStartPaM(); @@ -985,14 +985,14 @@ EditTextObject* ImpEditEngine::CreateTextObject() return CreateTextObject( aCompleteSelection ); } -EditTextObject* ImpEditEngine::CreateTextObject(const EditSelection& rSel) +std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject(const EditSelection& rSel) { return CreateTextObject(rSel, GetEditTextObjectPool(), aStatus.AllowBigObjects(), nBigTextObjectStart); } -EditTextObject* ImpEditEngine::CreateTextObject( EditSelection aSel, SfxItemPool* pPool, bool bAllowBigObjects, sal_Int32 nBigObjectStart ) +std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject( EditSelection aSel, SfxItemPool* pPool, bool bAllowBigObjects, sal_Int32 nBigObjectStart ) { - EditTextObject* pTxtObj = new EditTextObject(pPool); + std::unique_ptr<EditTextObject> pTxtObj(new EditTextObject(pPool)); pTxtObj->SetVertical( IsVertical(), IsTopToBottom()); MapUnit eMapUnit = aEditDoc.GetItemPool().GetMetric( DEF_METRIC ); pTxtObj->mpImpl->SetMetric( static_cast<sal_uInt16>(eMapUnit) ); diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx index 64f0dc4e4816..d3de3a85f89b 100644 --- a/editeng/source/outliner/outliner.cxx +++ b/editeng/source/outliner/outliner.cxx @@ -385,7 +385,7 @@ OutlinerParaObject* Outliner::CreateParaObject( sal_Int32 nStartPara, sal_Int32 if (nCount <= 0) return nullptr; - EditTextObject* pText = pEditEngine->CreateTextObject( nStartPara, nCount ); + std::unique_ptr<EditTextObject> pText = pEditEngine->CreateTextObject( nStartPara, nCount ); const bool bIsEditDoc(OutlinerMode::TextObject == ImplGetOutlinerMode()); ParagraphDataVector aParagraphDataVector(nCount); const sal_Int32 nLastPara(nStartPara + nCount - 1); @@ -397,7 +397,6 @@ OutlinerParaObject* Outliner::CreateParaObject( sal_Int32 nStartPara, sal_Int32 OutlinerParaObject* pPObj = new OutlinerParaObject(*pText, aParagraphDataVector, bIsEditDoc); pPObj->SetOutlinerMode(GetMode()); - delete pText; return pPObj; } @@ -2119,11 +2118,9 @@ NonOverflowingText *Outliner::GetNonOverflowingText() const OutlinerParaObject *Outliner::GetEmptyParaObject() const { - EditTextObject *pEmptyText = pEditEngine->GetEmptyTextObject(); + std::unique_ptr<EditTextObject> pEmptyText = pEditEngine->GetEmptyTextObject(); OutlinerParaObject* pPObj = new OutlinerParaObject( *pEmptyText ); pPObj->SetOutlinerMode(GetMode()); - - delete pEmptyText; return pPObj; } diff --git a/editeng/source/outliner/outlobj.cxx b/editeng/source/outliner/outlobj.cxx index 1efb5a5ea75d..8abcdf7417e8 100644 --- a/editeng/source/outliner/outlobj.cxx +++ b/editeng/source/outliner/outlobj.cxx @@ -35,13 +35,13 @@ #include <o3tl/cow_wrapper.hxx> #include <libxml/xmlwriter.h> -OutlinerParaObjData::OutlinerParaObjData( EditTextObject* pEditTextObject, const ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc ) : - mpEditTextObject(pEditTextObject), +OutlinerParaObjData::OutlinerParaObjData( std::unique_ptr<EditTextObject> pEditTextObject, const ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc ) : + mpEditTextObject(std::move(pEditTextObject)), maParagraphDataVector(rParagraphDataVector), mbIsEditDoc(bIsEditDoc) { - if( maParagraphDataVector.empty() && (pEditTextObject->GetParagraphCount() != 0) ) - maParagraphDataVector.resize(pEditTextObject->GetParagraphCount()); + if( maParagraphDataVector.empty() && (mpEditTextObject->GetParagraphCount() != 0) ) + maParagraphDataVector.resize(mpEditTextObject->GetParagraphCount()); } OutlinerParaObjData::OutlinerParaObjData( const OutlinerParaObjData& r ): diff --git a/editeng/source/uno/unofored.cxx b/editeng/source/uno/unofored.cxx index 406c0d7a13d6..31c3e4a05def 100644 --- a/editeng/source/uno/unofored.cxx +++ b/editeng/source/uno/unofored.cxx @@ -498,9 +498,8 @@ void SvxEditEngineForwarder::CopyText(const SvxTextForwarder& rSource) const SvxEditEngineForwarder* pSourceForwarder = dynamic_cast< const SvxEditEngineForwarder* >( &rSource ); if( !pSourceForwarder ) return; - EditTextObject* pNewTextObject = pSourceForwarder->rEditEngine.CreateTextObject(); + std::unique_ptr<EditTextObject> pNewTextObject = pSourceForwarder->rEditEngine.CreateTextObject(); rEditEngine.SetText( *pNewTextObject ); - delete pNewTextObject; } |