editeng/source/editeng/editeng.cxx                      |    8 ++--
 editeng/source/editeng/editobj.cxx                      |    4 +-
 editeng/source/editeng/editundo.hxx                     |    1 
 editeng/source/editeng/editview.cxx                     |    2 -
 editeng/source/editeng/impedit.hxx                      |    9 ++--
 editeng/source/editeng/impedit4.cxx                     |   10 ++---
 editeng/source/outliner/outliner.cxx                    |    7 +--
 editeng/source/outliner/outlobj.cxx                     |    8 ++--
 editeng/source/uno/unofored.cxx                         |    3 -
 include/editeng/editeng.hxx                             |    8 ++--
 include/editeng/editobj.hxx                             |    2 -
 include/editeng/editview.hxx                            |    2 -
 include/editeng/outlobj.hxx                             |    2 -
 sc/inc/column.hxx                                       |    4 +-
 sc/inc/document.hxx                                     |    2 -
 sc/inc/documentimport.hxx                               |    2 -
 sc/inc/editdataarray.hxx                                |   10 +++--
 sc/inc/editutil.hxx                                     |    4 +-
 sc/inc/formulacell.hxx                                  |    2 -
 sc/inc/table.hxx                                        |    2 -
 sc/inc/textuno.hxx                                      |    2 -
 sc/qa/unit/ucalc_column.cxx                             |    1 
 sc/source/core/data/attarray.cxx                        |    6 +--
 sc/source/core/data/attrib.cxx                          |   30 +++++++++-------
 sc/source/core/data/cellvalue.cxx                       |   16 ++++----
 sc/source/core/data/cellvalues.cxx                      |    2 -
 sc/source/core/data/column.cxx                          |   10 ++---
 sc/source/core/data/column2.cxx                         |    2 -
 sc/source/core/data/column3.cxx                         |   12 +++---
 sc/source/core/data/column4.cxx                         |    2 -
 sc/source/core/data/dociter.cxx                         |    2 -
 sc/source/core/data/document.cxx                        |    5 +-
 sc/source/core/data/documentimport.cxx                  |    4 +-
 sc/source/core/data/formulacell.cxx                     |    3 +
 sc/source/core/data/stlpool.cxx                         |   11 +----
 sc/source/core/data/table2.cxx                          |    5 +-
 sc/source/core/data/table3.cxx                          |    2 -
 sc/source/core/tool/editdataarray.cxx                   |   10 ++---
 sc/source/core/tool/editutil.cxx                        |    6 +--
 sc/source/filter/excel/xihelper.cxx                     |   10 ++---
 sc/source/filter/inc/richstring.hxx                     |    2 -
 sc/source/filter/inc/xihelper.hxx                       |    2 -
 sc/source/filter/oox/revisionfragment.cxx               |    4 +-
 sc/source/filter/oox/richstring.cxx                     |    2 -
 sc/source/filter/rtf/eeimpars.cxx                       |    4 +-
 sc/source/filter/xml/XMLTrackedChangesContext.cxx       |    3 +
 sc/source/ui/Accessibility/AccessiblePageHeaderArea.cxx |    2 -
 sc/source/ui/app/inputhdl.cxx                           |   10 +++--
 sc/source/ui/docshell/impex.cxx                         |    1 
 sc/source/ui/inc/tphfedit.hxx                           |    2 -
 sc/source/ui/inc/undocell.hxx                           |   10 ++---
 sc/source/ui/pagedlg/scuitphfedit.cxx                   |   26 +++++--------
 sc/source/ui/pagedlg/tphfedit.cxx                       |    2 -
 sc/source/ui/undo/undocell.cxx                          |   12 +++---
 sc/source/ui/unoobj/editsrc.cxx                         |    4 +-
 sc/source/ui/unoobj/fielduno.cxx                        |    3 -
 sc/source/ui/unoobj/textuno.cxx                         |    6 +--
 sc/source/ui/view/gridwin.cxx                           |    4 +-
 sc/source/ui/view/viewfun4.cxx                          |    7 ++-
 sc/source/ui/view/viewfunc.cxx                          |   10 ++---
 starmath/source/accessibility.cxx                       |    3 -
 sw/source/filter/ww8/ww8graf.cxx                        |    8 ++--
 sw/source/uibase/docvw/AnnotationWin2.cxx               |    1 
 63 files changed, 180 insertions(+), 181 deletions(-)

New commits:
commit ff8442fd85f2e281a564e3dc832a751a3a9c3072
Author: Noel Grandin <noel.gran...@collabora.co.uk>
Date:   Tue Apr 10 16:07:49 2018 +0200

    pass EditTextObject around using std::unique_ptr
    
    Change-Id: I71f4529c2e02fd0ac2561191e4cb35e18e206037
    Reviewed-on: https://gerrit.libreoffice.org/52682
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

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;
 }
 
 
diff --git a/include/editeng/editeng.hxx b/include/editeng/editeng.hxx
index ee4eb7baeb31..393e0068cb64 100644
--- a/include/editeng/editeng.hxx
+++ b/include/editeng/editeng.hxx
@@ -299,10 +299,10 @@ public:
     void            Clear();
     void            SetText( const OUString& rStr );
 
-    EditTextObject* CreateTextObject();
-    EditTextObject* GetEmptyTextObject() const;
-    EditTextObject* CreateTextObject( sal_Int32 nPara, sal_Int32 nParas = 1 );
-    EditTextObject* CreateTextObject( const ESelection& rESelection );
+    std::unique_ptr<EditTextObject> CreateTextObject();
+    std::unique_ptr<EditTextObject> GetEmptyTextObject() const;
+    std::unique_ptr<EditTextObject> CreateTextObject( sal_Int32 nPara, 
sal_Int32 nParas = 1 );
+    std::unique_ptr<EditTextObject> CreateTextObject( const ESelection& 
rESelection );
     void            SetText( const EditTextObject& rTextObject );
 
     void            RemoveParagraph(sal_Int32 nPara);
diff --git a/include/editeng/editobj.hxx b/include/editeng/editobj.hxx
index ea35311ac1b1..48d6bcb32415 100644
--- a/include/editeng/editobj.hxx
+++ b/include/editeng/editobj.hxx
@@ -90,7 +90,7 @@ public:
 
     SvtScriptType GetScriptType() const;
 
-    EditTextObject* Clone() const;
+    std::unique_ptr<EditTextObject> Clone() const;
 
     sal_Int32 GetParagraphCount() const;
 
diff --git a/include/editeng/editview.hxx b/include/editeng/editview.hxx
index 52f56d517de6..8d2a5ef2853d 100644
--- a/include/editeng/editview.hxx
+++ b/include/editeng/editview.hxx
@@ -230,7 +230,7 @@ public:
     void            SetControlWord( EVControlBits nWord );
     EVControlBits   GetControlWord() const;
 
-    EditTextObject* CreateTextObject();
+    std::unique_ptr<EditTextObject> CreateTextObject();
     void            InsertText( const EditTextObject& rTextObject );
     void            InsertText( css::uno::Reference< 
css::datatransfer::XTransferable > const & xDataObj, const OUString& rBaseURL, 
bool bUseSpecial );
 
diff --git a/include/editeng/outlobj.hxx b/include/editeng/outlobj.hxx
index db135f692ca2..0186ce72af16 100644
--- a/include/editeng/outlobj.hxx
+++ b/include/editeng/outlobj.hxx
@@ -42,7 +42,7 @@ struct OutlinerParaObjData
     bool                             mbIsEditDoc;
 
     // constructor
-    OutlinerParaObjData( EditTextObject* pEditTextObject, const 
ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc );
+    OutlinerParaObjData( std::unique_ptr<EditTextObject> pEditTextObject, 
const ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc );
 
     OutlinerParaObjData( const OutlinerParaObjData& r );
 
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 07bcdc15f855..9a10e90a9c61 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -327,8 +327,8 @@ public:
         SCROW nRow, SCTAB nTab, const OUString& rString, 
formula::FormulaGrammar::AddressConvention eConv,
         const ScSetStringParam* pParam = nullptr );
 
-    void SetEditText( SCROW nRow, EditTextObject* pEditText );
-    void SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, 
EditTextObject* pEditText );
+    void SetEditText( SCROW nRow, std::unique_ptr<EditTextObject> pEditText );
+    void SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, 
std::unique_ptr<EditTextObject> pEditText );
     void SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, const 
EditTextObject& rEditText );
     void SetEditText( SCROW nRow, const EditTextObject& rEditText, const 
SfxItemPool* pEditPool );
     void SetFormula( SCROW nRow, const ScTokenArray& rArray, 
formula::FormulaGrammar::Grammar eGram );
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 4ed169e10152..69302890958c 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1053,7 +1053,7 @@ public:
      * SfxItemPool instance returned from ScDocument::GetEditPool()</i>.
      * This is very important.</p>
      */
-    SC_DLLPUBLIC bool  SetEditText( const ScAddress& rPos, EditTextObject* 
pEditText );
+    SC_DLLPUBLIC bool  SetEditText( const ScAddress& rPos, 
std::unique_ptr<EditTextObject> pEditText );
     void               SetEditText( const ScAddress& rPos, const 
EditTextObject& rEditText, const SfxItemPool* pEditPool );
     SC_DLLPUBLIC void  SetEditText( const ScAddress& rPos, const OUString& 
rStr );
     SC_DLLPUBLIC SCROW GetFirstEditTextRow( const ScRange& rRange ) const;
diff --git a/sc/inc/documentimport.hxx b/sc/inc/documentimport.hxx
index d881da37cf2d..917b2398bfbb 100644
--- a/sc/inc/documentimport.hxx
+++ b/sc/inc/documentimport.hxx
@@ -95,7 +95,7 @@ public:
             const ScSetStringParam* pStringParam = nullptr);
     void setNumericCell(const ScAddress& rPos, double fVal);
     void setStringCell(const ScAddress& rPos, const OUString& rStr);
-    void setEditCell(const ScAddress& rPos, EditTextObject* pEditText);
+    void setEditCell(const ScAddress& rPos, std::unique_ptr<EditTextObject> 
pEditText);
 
     void setFormulaCell(
         const ScAddress& rPos, const OUString& rFormula, 
formula::FormulaGrammar::Grammar eGrammar,
diff --git a/sc/inc/editdataarray.hxx b/sc/inc/editdataarray.hxx
index 37fd1f93407d..810e75e95b54 100644
--- a/sc/inc/editdataarray.hxx
+++ b/sc/inc/editdataarray.hxx
@@ -36,7 +36,9 @@ public:
     public:
         Item() = delete;
         explicit Item(SCTAB nTab, SCCOL nCol, SCROW nRow,
-                      EditTextObject* pOldData, EditTextObject* pNewData);
+                      std::unique_ptr<EditTextObject> pOldData, 
std::unique_ptr<EditTextObject> pNewData);
+        Item(Item const &) = default;
+        Item(Item&&) = default;
         ~Item();
 
         const EditTextObject* GetOldData() const;
@@ -46,8 +48,8 @@ public:
         SCROW GetRow() const { return mnRow;}
 
     private:
-        std::shared_ptr<EditTextObject> mpOldData;
-        std::shared_ptr<EditTextObject> mpNewData;
+        std::unique_ptr<EditTextObject> mpOldData;
+        std::unique_ptr<EditTextObject> mpNewData;
         SCTAB mnTab;
         SCCOL mnCol;
         SCROW mnRow;
@@ -58,7 +60,7 @@ public:
     ~ScEditDataArray();
 
     void AddItem(SCTAB nTab, SCCOL nCol, SCROW nRow,
-                 EditTextObject* pOldData, EditTextObject* pNewData);
+                 std::unique_ptr<EditTextObject> pOldData, 
std::unique_ptr<EditTextObject> pNewData);
 
     const Item* First();
     const Item* Next();
diff --git a/sc/inc/editutil.hxx b/sc/inc/editutil.hxx
index cc96945dfd67..f70453bdec40 100644
--- a/sc/inc/editutil.hxx
+++ b/sc/inc/editutil.hxx
@@ -67,12 +67,12 @@ public:
      */
     SC_DLLPUBLIC static OUString GetString( const EditTextObject& rEditText, 
const ScDocument* pDoc );
 
-    static EditTextObject* CreateURLObjectFromURL(
+    static std::unique_ptr<EditTextObject> CreateURLObjectFromURL(
         ScDocument& rDoc, const OUString& rURL, const OUString& rText );
 
     static void RemoveCharAttribs( EditTextObject& rEditText, const 
ScPatternAttr& rAttr );
 
-    static EditTextObject* Clone( const EditTextObject& rSrc, ScDocument& 
rDestDoc );
+    static std::unique_ptr<EditTextObject> Clone( const EditTextObject& rSrc, 
ScDocument& rDestDoc );
 
     static OUString GetCellFieldValue(
         const SvxFieldData& rFieldData, const ScDocument* pDoc, Color** 
ppTextColor );
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index 52d5d9cfc7a6..376b0d0fbf5a 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -398,7 +398,7 @@ public:
     void SetResultError( FormulaError n );
 
     bool IsHyperLinkCell() const;
-    EditTextObject* CreateURLObject();
+    std::unique_ptr<EditTextObject> CreateURLObject();
     void GetURLResult( OUString& rURL, OUString& rCellText );
 
     /** Determines whether or not the result string contains more than one 
paragraph */
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index cb98a23f94af..d310d998abc7 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -408,7 +408,7 @@ public:
     bool        SetString( SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString& 
rString,
                            const ScSetStringParam * pParam = nullptr );
 
-    bool SetEditText( SCCOL nCol, SCROW nRow, EditTextObject* pEditText );
+    bool SetEditText( SCCOL nCol, SCROW nRow, std::unique_ptr<EditTextObject> 
pEditText );
     void SetEditText( SCCOL nCol, SCROW nRow, const EditTextObject& rEditText, 
const SfxItemPool* pEditPool );
     SCROW GetFirstEditTextRow( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW 
nRow2 ) const;
 
diff --git a/sc/inc/textuno.hxx b/sc/inc/textuno.hxx
index 0ffbcc483949..b31894c253f4 100644
--- a/sc/inc/textuno.hxx
+++ b/sc/inc/textuno.hxx
@@ -315,7 +315,7 @@ public:
         virtual         ~ScEditEngineTextObj() throw() override;
 
     void                SetText( const EditTextObject& rTextObject );
-    EditTextObject*     CreateTextObject();
+    std::unique_ptr<EditTextObject> CreateTextObject();
 };
 
 //  ScCellTextData: shared data between sub objects of a cell text object
diff --git a/sc/qa/unit/ucalc_column.cxx b/sc/qa/unit/ucalc_column.cxx
index 4a64f695a414..dcf188b11c25 100644
--- a/sc/qa/unit/ucalc_column.cxx
+++ b/sc/qa/unit/ucalc_column.cxx
@@ -10,6 +10,7 @@
 #include "ucalc.hxx"
 #include <editutil.hxx>
 #include <cellvalue.hxx>
+#include <editeng/editobj.hxx>
 #include <svl/languageoptions.hxx>
 
 void Test::testColumnFindEditCells()
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index 5b9aafbcb4da..83f101e53750 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -389,7 +389,7 @@ void ScAttrArray::RemoveCellCharAttribs( SCROW nStartRow, 
SCROW nEndRow,
         if (aCell.meType != CELLTYPE_EDIT || !aCell.mpEditText)
             continue;
 
-        EditTextObject* pOldData = nullptr;
+        std::unique_ptr<EditTextObject> pOldData;
         if (pDataArray)
             pOldData = aCell.mpEditText->Clone();
 
@@ -399,8 +399,8 @@ void ScAttrArray::RemoveCellCharAttribs( SCROW nStartRow, 
SCROW nEndRow,
 
         if (pDataArray)
         {
-            EditTextObject* pNewData = aCell.mpEditText->Clone();
-            pDataArray->AddItem(nTab, nCol, nRow, pOldData, pNewData);
+            std::unique_ptr<EditTextObject> pNewData = 
aCell.mpEditText->Clone();
+            pDataArray->AddItem(nTab, nCol, nRow, std::move(pOldData), 
std::move(pNewData));
         }
     }
 }
diff --git a/sc/source/core/data/attrib.cxx b/sc/source/core/data/attrib.cxx
index ee104e0cc08c..4dd0b2218726 100644
--- a/sc/source/core/data/attrib.cxx
+++ b/sc/source/core/data/attrib.cxx
@@ -389,11 +389,11 @@ ScPageHFItem::ScPageHFItem( const ScPageHFItem& rItem )
         pRightArea  ( nullptr )
 {
     if ( rItem.pLeftArea )
-        pLeftArea.reset(rItem.pLeftArea->Clone());
+        pLeftArea = rItem.pLeftArea->Clone();
     if ( rItem.pCenterArea )
-        pCenterArea.reset(rItem.pCenterArea->Clone());
+        pCenterArea = rItem.pCenterArea->Clone();
     if ( rItem.pRightArea )
-        pRightArea.reset(rItem.pRightArea->Clone());
+        pRightArea = rItem.pRightArea->Clone();
 }
 
 ScPageHFItem::~ScPageHFItem()
@@ -425,24 +425,30 @@ bool ScPageHFItem::PutValue( const uno::Any& rVal, 
sal_uInt8 /* nMemberId */ )
             if (pImp.is())
             {
                 const EditTextObject* pImpLeft = pImp->GetLeftEditObject();
-                pLeftArea.reset( pImpLeft ? pImpLeft->Clone() : nullptr );
+                pLeftArea.reset();
+                if (pImpLeft)
+                    pLeftArea = pImpLeft->Clone();
 
                 const EditTextObject* pImpCenter = pImp->GetCenterEditObject();
-                pCenterArea.reset( pImpCenter ? pImpCenter->Clone() : nullptr 
);
+                pCenterArea.reset();
+                if (pImpCenter)
+                    pCenterArea = pImpCenter->Clone();
 
                 const EditTextObject* pImpRight = pImp->GetRightEditObject();
-                pRightArea.reset( pImpRight ? pImpRight->Clone() : nullptr );
+                pRightArea.reset();
+                if (pImpRight)
+                    pRightArea = pImpRight->Clone();
 
                 if ( !pLeftArea || !pCenterArea || !pRightArea )
                 {
                     // no Text with Null are left
                     ScEditEngineDefaulter aEngine( EditEngine::CreatePool(), 
true );
                     if (!pLeftArea)
-                        pLeftArea.reset( aEngine.CreateTextObject() );
+                        pLeftArea = aEngine.CreateTextObject();
                     if (!pCenterArea)
-                        pCenterArea.reset( aEngine.CreateTextObject() );
+                        pCenterArea = aEngine.CreateTextObject();
                     if (!pRightArea)
-                        pRightArea.reset( aEngine.CreateTextObject() );
+                        pRightArea = aEngine.CreateTextObject();
                 }
 
                 bRet = true;
@@ -476,17 +482,17 @@ SfxPoolItem* ScPageHFItem::Clone( SfxItemPool* ) const
 
 void ScPageHFItem::SetLeftArea( const EditTextObject& rNew )
 {
-    pLeftArea.reset( rNew.Clone() );
+    pLeftArea = rNew.Clone();
 }
 
 void ScPageHFItem::SetCenterArea( const EditTextObject& rNew )
 {
-    pCenterArea.reset( rNew.Clone() );
+    pCenterArea = rNew.Clone();
 }
 
 void ScPageHFItem::SetRightArea( const EditTextObject& rNew )
 {
-    pRightArea.reset( rNew.Clone() );
+    pRightArea = rNew.Clone();
 }
 
 /**
diff --git a/sc/source/core/data/cellvalue.cxx 
b/sc/source/core/data/cellvalue.cxx
index 200b9b3c5282..b131debdb7a2 100644
--- a/sc/source/core/data/cellvalue.cxx
+++ b/sc/source/core/data/cellvalue.cxx
@@ -212,7 +212,7 @@ ScCellValue::ScCellValue( const ScRefCellValue& rCell ) : 
meType(rCell.meType),
             mpString = new svl::SharedString(*rCell.mpString);
         break;
         case CELLTYPE_EDIT:
-            mpEditText = rCell.mpEditText->Clone();
+            mpEditText = rCell.mpEditText->Clone().release();
         break;
         case CELLTYPE_FORMULA:
             mpFormula = rCell.mpFormula->Clone();
@@ -234,7 +234,7 @@ ScCellValue::ScCellValue( const ScCellValue& r ) : 
meType(r.meType), mfValue(r.m
             mpString = new svl::SharedString(*r.mpString);
         break;
         case CELLTYPE_EDIT:
-            mpEditText = r.mpEditText->Clone();
+            mpEditText = r.mpEditText->Clone().release();
         break;
         case CELLTYPE_FORMULA:
             mpFormula = r.mpFormula->Clone();
@@ -310,7 +310,7 @@ void ScCellValue::set( const EditTextObject& rEditText )
 {
     clear();
     meType = CELLTYPE_EDIT;
-    mpEditText = rEditText.Clone();
+    mpEditText = rEditText.Clone().release();
 }
 
 void ScCellValue::set( EditTextObject* pEditText )
@@ -341,7 +341,7 @@ void ScCellValue::assign( const ScDocument& rDoc, const 
ScAddress& rPos )
         break;
         case CELLTYPE_EDIT:
             if (aRefVal.mpEditText)
-                mpEditText = aRefVal.mpEditText->Clone();
+                mpEditText = aRefVal.mpEditText->Clone().release();
         break;
         case CELLTYPE_VALUE:
             mfValue = aRefVal.mfValue;
@@ -376,14 +376,14 @@ void ScCellValue::assign(const ScCellValue& rOther, 
ScDocument& rDestDoc, ScClon
                 if (bNewControl)
                     rEngine.SetControlWord(nControl | nSpellControl);
                 rEngine.SetText(*rOther.mpEditText);
-                mpEditText = rEngine.CreateTextObject();
+                mpEditText = rEngine.CreateTextObject().release();
                 if (bNewControl)
                     rEngine.SetControlWord(nControl);
             }
             else
             {
                 rEngine.SetText(*rOther.mpEditText);
-                mpEditText = rEngine.CreateTextObject();
+                mpEditText = rEngine.CreateTextObject().release();
             }
         }
         break;
@@ -444,7 +444,7 @@ void ScCellValue::release( ScDocument& rDoc, const 
ScAddress& rPos )
         break;
         case CELLTYPE_EDIT:
             // Cell takes the ownership of the text object.
-            rDoc.SetEditText(rPos, mpEditText);
+            rDoc.SetEditText(rPos, 
std::unique_ptr<EditTextObject>(mpEditText));
         break;
         case CELLTYPE_VALUE:
             rDoc.SetValue(rPos, mfValue);
@@ -474,7 +474,7 @@ void ScCellValue::release( ScColumn& rColumn, SCROW nRow, 
sc::StartListeningType
         break;
         case CELLTYPE_EDIT:
             // Cell takes the ownership of the text object.
-            rColumn.SetEditText(nRow, mpEditText);
+            rColumn.SetEditText(nRow, 
std::unique_ptr<EditTextObject>(mpEditText));
         break;
         case CELLTYPE_VALUE:
             rColumn.SetValue(nRow, mfValue);
diff --git a/sc/source/core/data/cellvalues.cxx 
b/sc/source/core/data/cellvalues.cxx
index 4b3842b74b03..459322e39608 100644
--- a/sc/source/core/data/cellvalues.cxx
+++ b/sc/source/core/data/cellvalues.cxx
@@ -194,7 +194,7 @@ void CellValues::copyCellsTo( ScColumn& rCol, SCROW nRow ) 
const
                 for (; it != itEnd; ++it)
                 {
                     const EditTextObject* p = *it;
-                    aVals.push_back(p->Clone());
+                    aVals.push_back(p->Clone().release());
                 }
                 itPos = rDest.set(itPos, nCurRow, aVals.begin(), aVals.end());
             }
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 3a1ab1803de3..ae6813988293 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -936,7 +936,7 @@ public:
                 std::vector<EditTextObject*> aCloned;
                 aCloned.reserve(nDataSize);
                 for (; it != itEnd; ++it)
-                    aCloned.push_back(ScEditUtil::Clone(**it, 
*mrDestCol.GetDoc()));
+                    aCloned.push_back(ScEditUtil::Clone(**it, 
*mrDestCol.GetDoc()).release());
 
                 maDestPos.miCellPos = mrDestCol.GetCellStore().set(
                     maDestPos.miCellPos, nTopRow, aCloned.begin(), 
aCloned.end());
@@ -1182,9 +1182,9 @@ void ScColumn::CopyCellToDocument( SCROW nSrcRow, SCROW 
nDestRow, ScColumn& rDes
         {
             EditTextObject* p = sc::edittext_block::at(*it->data, aPos.second);
             if (pDocument == rDestCol.GetDoc())
-                rDestCol.maCells.set(nDestRow, p->Clone());
+                rDestCol.maCells.set(nDestRow, p->Clone().release());
             else
-                rDestCol.maCells.set(nDestRow, ScEditUtil::Clone(*p, 
*rDestCol.GetDoc()));
+                rDestCol.maCells.set(nDestRow, ScEditUtil::Clone(*p, 
*rDestCol.GetDoc()).release());
         }
         break;
         case sc::element_type_formula:
@@ -1483,7 +1483,7 @@ class CopyByCloneHandler
                 EditEngine& rEngine = mrDestCol.GetDoc()->GetEditEngine();
                 rEngine.SetText(aStr.getString());
                 maDestPos.miCellPos =
-                    mrDestCol.GetCellStore().set(maDestPos.miCellPos, nRow, 
rEngine.CreateTextObject());
+                    mrDestCol.GetCellStore().set(maDestPos.miCellPos, nRow, 
rEngine.CreateTextObject().release());
             }
             else
             {
@@ -1627,7 +1627,7 @@ public:
                 std::vector<EditTextObject*> aCloned;
                 aCloned.reserve(nDataSize);
                 for (; it != itEnd; ++it)
-                    aCloned.push_back(ScEditUtil::Clone(**it, 
*mrDestCol.GetDoc()));
+                    aCloned.push_back(ScEditUtil::Clone(**it, 
*mrDestCol.GetDoc()).release());
 
                 maDestPos.miCellPos = mrDestCol.GetCellStore().set(
                     maDestPos.miCellPos, nRow, aCloned.begin(), aCloned.end());
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 415c1203c821..ba3896ddcc35 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1107,7 +1107,7 @@ public:
 
             // Overwrite the existing object.
             delete pObj;
-            pObj = mpEngine->CreateTextObject();
+            pObj = mpEngine->CreateTextObject().release();
         }
         else                                            // create String
         {
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 2907532f961e..114b132d797f 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1359,7 +1359,7 @@ public:
 
     void operator() (size_t nRow, const EditTextObject* p)
     {
-        miNewCellsPos = maNewCells.set(miNewCellsPos, nRow-mnRowOffset, 
p->Clone());
+        miNewCellsPos = maNewCells.set(miNewCellsPos, nRow-mnRowOffset, 
p->Clone().release());
     }
 
     void operator() (size_t nRow, const ScFormulaCell* p)
@@ -1475,7 +1475,7 @@ public:
                 {
                     EditTextObject* pObj = 
sc::edittext_block::at(*aPos.first->data, aPos.second);
                     miNewCellsPos = maNewCells.set(
-                            miNewCellsPos, nDestRow-mnRowOffset, 
pObj->Clone());
+                            miNewCellsPos, nDestRow-mnRowOffset, 
pObj->Clone().release());
                 }
                 break;
                 case sc::element_type_formula:
@@ -1877,22 +1877,22 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, 
const OUString& rString,
     return bNumFmtSet;
 }
 
-void ScColumn::SetEditText( SCROW nRow, EditTextObject* pEditText )
+void ScColumn::SetEditText( SCROW nRow, std::unique_ptr<EditTextObject> 
pEditText )
 {
     pEditText->NormalizeString(GetDoc()->GetSharedStringPool());
     sc::CellStoreType::iterator it = GetPositionToInsert(nRow);
-    maCells.set(it, nRow, pEditText);
+    maCells.set(it, nRow, pEditText.release());
     maCellTextAttrs.set(nRow, sc::CellTextAttr());
     CellStorageModified();
 
     BroadcastNewCell(nRow);
 }
 
-void ScColumn::SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, 
EditTextObject* pEditText )
+void ScColumn::SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, 
std::unique_ptr<EditTextObject> pEditText )
 {
     pEditText->NormalizeString(GetDoc()->GetSharedStringPool());
     rBlockPos.miCellPos = GetPositionToInsert(rBlockPos.miCellPos, nRow);
-    rBlockPos.miCellPos = maCells.set(rBlockPos.miCellPos, nRow, pEditText);
+    rBlockPos.miCellPos = maCells.set(rBlockPos.miCellPos, nRow, 
pEditText.release());
     rBlockPos.miCellTextAttrPos = maCellTextAttrs.set(
         rBlockPos.miCellTextAttrPos, nRow, sc::CellTextAttr());
 
diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index 3c8871f7b111..832351d275a7 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -261,7 +261,7 @@ void ScColumn::CopyOneCellFromClip( 
sc::CopyFromClipContext& rCxt, SCROW nRow1,
                 std::vector<EditTextObject*> aStrs;
                 aStrs.reserve(nDestSize);
                 for (size_t i = 0; i < nDestSize; ++i)
-                    aStrs.push_back(rSrcCell.mpEditText->Clone());
+                    aStrs.push_back(rSrcCell.mpEditText->Clone().release());
 
                 pBlockPos->miCellPos =
                     maCells.set(pBlockPos->miCellPos, nRow1, aStrs.begin(), 
aStrs.end());
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index f292d4bd6197..8f42651d2a6f 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -987,7 +987,7 @@ ScCellValue ScCellIterator::getCellValue() const
             aRet.mpString = new svl::SharedString(*maCurCell.mpString);
         break;
         case CELLTYPE_EDIT:
-            aRet.mpEditText = maCurCell.mpEditText->Clone();
+            aRet.mpEditText = maCurCell.mpEditText->Clone().release();
         break;
         case CELLTYPE_VALUE:
             aRet.mfValue = maCurCell.mfValue;
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 9bf363cec196..ace7ed8f0f7a 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3393,15 +3393,14 @@ bool ScDocument::SetString(
     return SetString(rPos.Col(), rPos.Row(), rPos.Tab(), rString, pParam);
 }
 
-bool ScDocument::SetEditText( const ScAddress& rPos, EditTextObject* pEditText 
)
+bool ScDocument::SetEditText( const ScAddress& rPos, 
std::unique_ptr<EditTextObject> pEditText )
 {
     if (!TableExists(rPos.Tab()))
     {
-        delete pEditText;
         return false;
     }
 
-    return maTabs[rPos.Tab()]->SetEditText(rPos.Col(), rPos.Row(), pEditText);
+    return maTabs[rPos.Tab()]->SetEditText(rPos.Col(), rPos.Row(), 
std::move(pEditText));
 }
 
 void ScDocument::SetEditText( const ScAddress& rPos, const EditTextObject& 
rEditText, const SfxItemPool* pEditPool )
diff --git a/sc/source/core/data/documentimport.cxx 
b/sc/source/core/data/documentimport.cxx
index 3db030880f1b..55aaadae1ce7 100644
--- a/sc/source/core/data/documentimport.cxx
+++ b/sc/source/core/data/documentimport.cxx
@@ -258,7 +258,7 @@ void ScDocumentImport::setStringCell(const ScAddress& rPos, 
const OUString& rStr
     pBlockPos->miCellPos = rCells.set(pBlockPos->miCellPos, rPos.Row(), aSS);
 }
 
-void ScDocumentImport::setEditCell(const ScAddress& rPos, EditTextObject* 
pEditText)
+void ScDocumentImport::setEditCell(const ScAddress& rPos, 
std::unique_ptr<EditTextObject> pEditText)
 {
     ScTable* pTab = mpImpl->mrDoc.FetchTable(rPos.Tab());
     if (!pTab)
@@ -271,7 +271,7 @@ void ScDocumentImport::setEditCell(const ScAddress& rPos, 
EditTextObject* pEditT
 
     pEditText->NormalizeString(mpImpl->mrDoc.GetSharedStringPool());
     sc::CellStoreType& rCells = pTab->aCol[rPos.Col()].maCells;
-    pBlockPos->miCellPos = rCells.set(pBlockPos->miCellPos, rPos.Row(), 
pEditText);
+    pBlockPos->miCellPos = rCells.set(pBlockPos->miCellPos, rPos.Row(), 
pEditText.release());
 }
 
 void ScDocumentImport::setFormulaCell(
diff --git a/sc/source/core/data/formulacell.cxx 
b/sc/source/core/data/formulacell.cxx
index ec230436ac26..a8c697f50630 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -49,6 +49,7 @@
 #include <tokenarray.hxx>
 
 #include <comphelper/threadpool.hxx>
+#include <editeng/editobj.hxx>
 #include <tools/cpuid.hxx>
 #include <formula/errorcodes.hxx>
 #include <formula/vectortoken.hxx>
@@ -2589,7 +2590,7 @@ bool ScFormulaCell::IsHyperLinkCell() const
     return pCode && pCode->IsHyperLink();
 }
 
-EditTextObject* ScFormulaCell::CreateURLObject()
+std::unique_ptr<EditTextObject> ScFormulaCell::CreateURLObject()
 {
     OUString aCellText;
     OUString aURL;
diff --git a/sc/source/core/data/stlpool.cxx b/sc/source/core/data/stlpool.cxx
index e82566b8d6b5..acd8b90bbaf4 100644
--- a/sc/source/core/data/stlpool.cxx
+++ b/sc/source/core/data/stlpool.cxx
@@ -222,8 +222,8 @@ void ScStyleSheetPool::CreateStandardStyles()
     SvxSetItem*     pHFSetItem      = nullptr;
     std::unique_ptr<ScEditEngineDefaulter> pEdEngine(new 
ScEditEngineDefaulter( EditEngine::CreatePool(), true ));
     pEdEngine->SetUpdateMode( false );
-    EditTextObject* pEmptyTxtObj    = pEdEngine->CreateTextObject();
-    EditTextObject* pTxtObj         = nullptr;
+    std::unique_ptr<EditTextObject> pEmptyTxtObj = 
pEdEngine->CreateTextObject();
+    std::unique_ptr<EditTextObject> pTxtObj;
     std::unique_ptr<ScPageHFItem> pHeaderItem(new ScPageHFItem( 
ATTR_PAGE_HEADERRIGHT ));
     std::unique_ptr<ScPageHFItem> pFooterItem(new ScPageHFItem( 
ATTR_PAGE_FOOTERRIGHT ));
     ScStyleSheet*   pSheet          = nullptr;
@@ -296,7 +296,6 @@ void ScStyleSheetPool::CreateStandardStyles()
     pHeaderItem->SetCenterArea( *pTxtObj );
     pHeaderItem->SetRightArea ( *pEmptyTxtObj );
     pSet->Put( *pHeaderItem );
-    delete pTxtObj;
 
     // Footer:
     // [empty][Page \STR_PAGE\][empty]
@@ -310,7 +309,6 @@ void ScStyleSheetPool::CreateStandardStyles()
     pFooterItem->SetCenterArea( *pTxtObj );
     pFooterItem->SetRightArea ( *pEmptyTxtObj );
     pSet->Put( *pFooterItem );
-    delete pTxtObj;
 
     // 2. Report
 
@@ -356,7 +354,6 @@ void ScStyleSheetPool::CreateStandardStyles()
     pTxtObj = pEdEngine->CreateTextObject();
     pHeaderItem->SetLeftArea( *pTxtObj );
     pHeaderItem->SetCenterArea( *pEmptyTxtObj );
-    delete pTxtObj;
     aStr = ", ";
     pEdEngine->SetText( aStr );
     pEdEngine->QuickInsertField( SvxFieldItem(SvxTimeField(), 
EE_FEATURE_FIELD), ESelection(0,2,0,2) );
@@ -364,7 +361,6 @@ void ScStyleSheetPool::CreateStandardStyles()
                                     ESelection() );
     pTxtObj = pEdEngine->CreateTextObject();
     pHeaderItem->SetRightArea( *pTxtObj );
-    delete pTxtObj;
     pSet->Put( *pHeaderItem );
 
     // Footer:
@@ -382,9 +378,6 @@ void ScStyleSheetPool::CreateStandardStyles()
     pFooterItem->SetCenterArea( *pTxtObj );
     pFooterItem->SetRightArea ( *pEmptyTxtObj );
     pSet->Put( *pFooterItem );
-    delete pTxtObj;
-
-    delete pEmptyTxtObj;
 
     bHasStandardStyles = true;
 }
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 340e087bb927..ccbadd6c0f51 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1409,15 +1409,14 @@ bool ScTable::SetString( SCCOL nCol, SCROW nRow, SCTAB 
nTabP, const OUString& rS
         return false;
 }
 
-bool ScTable::SetEditText( SCCOL nCol, SCROW nRow, EditTextObject* pEditText )
+bool ScTable::SetEditText( SCCOL nCol, SCROW nRow, 
std::unique_ptr<EditTextObject> pEditText )
 {
     if (!ValidColRow(nCol, nRow))
     {
-        delete pEditText;
         return false;
     }
 
-    aCol[nCol].SetEditText(nRow, pEditText);
+    aCol[nCol].SetEditText(nRow, std::move(pEditText));
     return true;
 }
 
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 84f6f964a2dd..c8b4ae8124a7 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -718,7 +718,7 @@ void fillSortedColumnArray(
                 break;
                 case CELLTYPE_EDIT:
                     assert(rCell.mpAttr);
-                    rCellStore.push_back(rCell.maCell.mpEditText->Clone());
+                    
rCellStore.push_back(rCell.maCell.mpEditText->Clone().release());
                 break;
                 case CELLTYPE_FORMULA:
                 {
diff --git a/sc/source/core/tool/editdataarray.cxx 
b/sc/source/core/tool/editdataarray.cxx
index 5a794326836e..00a2b6c71dd1 100644
--- a/sc/source/core/tool/editdataarray.cxx
+++ b/sc/source/core/tool/editdataarray.cxx
@@ -28,9 +28,9 @@ ScEditDataArray::~ScEditDataArray()
 }
 
 void ScEditDataArray::AddItem(SCTAB nTab, SCCOL nCol, SCROW nRow,
-                              EditTextObject* pOldData, EditTextObject* 
pNewData)
+                              std::unique_ptr<EditTextObject> pOldData, 
std::unique_ptr<EditTextObject> pNewData)
 {
-    maArray.emplace_back(nTab, nCol, nRow, pOldData, pNewData);
+    maArray.emplace_back(nTab, nCol, nRow, std::move(pOldData), 
std::move(pNewData));
 }
 
 const ScEditDataArray::Item* ScEditDataArray::First()
@@ -49,13 +49,13 @@ const ScEditDataArray::Item* ScEditDataArray::Next()
 }
 
 ScEditDataArray::Item::Item(SCTAB nTab, SCCOL nCol, SCROW nRow,
-                            EditTextObject* pOldData, EditTextObject* 
pNewData) :
+                            std::unique_ptr<EditTextObject> pOldData, 
std::unique_ptr<EditTextObject> pNewData) :
+    mpOldData(std::move(pOldData)),
+    mpNewData(std::move(pNewData)),
     mnTab(nTab),
     mnCol(nCol),
     mnRow(nRow)
 {
-    mpOldData.reset(pOldData);
-    mpNewData.reset(pNewData);
 }
 
 ScEditDataArray::Item::~Item()
diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx
index 3906dd06fbd7..6e4881eb1eab 100644
--- a/sc/source/core/tool/editutil.cxx
+++ b/sc/source/core/tool/editutil.cxx
@@ -131,7 +131,7 @@ OUString ScEditUtil::GetString( const EditTextObject& 
rEditText, const ScDocumen
     }
 }
 
-EditTextObject* ScEditUtil::CreateURLObjectFromURL( ScDocument& rDoc, const 
OUString& rURL, const OUString& rText )
+std::unique_ptr<EditTextObject> ScEditUtil::CreateURLObjectFromURL( 
ScDocument& rDoc, const OUString& rURL, const OUString& rText )
 {
     SvxURLField aUrlField( rURL, rText, SvxURLFormat::AppDefault);
     EditEngine& rEE = rDoc.GetEditEngine();
@@ -163,9 +163,9 @@ void ScEditUtil::RemoveCharAttribs( EditTextObject& 
rEditText, const ScPatternAt
     }
 }
 
-EditTextObject* ScEditUtil::Clone( const EditTextObject& rObj, ScDocument& 
rDestDoc )
+std::unique_ptr<EditTextObject> ScEditUtil::Clone( const EditTextObject& rObj, 
ScDocument& rDestDoc )
 {
-    EditTextObject* pNew = nullptr;
+    std::unique_ptr<EditTextObject> pNew;
 
     EditEngine& rEngine = rDestDoc.GetEditEngine();
     if (rObj.HasOnlineSpellErrors())
diff --git a/sc/source/filter/excel/xihelper.cxx 
b/sc/source/filter/excel/xihelper.cxx
index c2b65d12745d..862d9629104d 100644
--- a/sc/source/filter/excel/xihelper.cxx
+++ b/sc/source/filter/excel/xihelper.cxx
@@ -139,10 +139,10 @@ void XclImpAddressConverter::ConvertRangeList( 
ScRangeList& rScRanges,
 
 namespace {
 
-EditTextObject* lclCreateTextObject( const XclImpRoot& rRoot,
+std::unique_ptr<EditTextObject> lclCreateTextObject( const XclImpRoot& rRoot,
         const XclImpString& rString, XclFontItemType eType, sal_uInt16 
nXFIndex )
 {
-    EditTextObject* pTextObj = nullptr;
+    std::unique_ptr<EditTextObject> pTextObj;
 
     const XclImpXFBuffer& rXFBuffer = rRoot.GetXFBuffer();
     const XclImpFont* pFirstFont = rXFBuffer.GetFont( nXFIndex );
@@ -215,7 +215,7 @@ EditTextObject* lclCreateTextObject( const XclImpRoot& 
rRoot,
 
 } // namespace
 
-EditTextObject* XclImpStringHelper::CreateTextObject(
+std::unique_ptr<EditTextObject> XclImpStringHelper::CreateTextObject(
         const XclImpRoot& rRoot, const XclImpString& rString )
 {
     return lclCreateTextObject( rRoot, rString, XclFontItemType::Editeng, 0 );
@@ -232,7 +232,7 @@ void XclImpStringHelper::SetToDocument(
 
     if (pTextObj.get())
     {
-        rDoc.setEditCell(rPos, pTextObj.release());
+        rDoc.setEditCell(rPos, std::move(pTextObj));
     }
     else
     {
@@ -567,7 +567,7 @@ void XclImpHFConverter::CreateCurrObject()
 {
     InsertText();
     SetAttribs();
-    GetCurrObj().reset( mrEE.CreateTextObject() );
+    GetCurrObj() = mrEE.CreateTextObject();
 }
 
 void XclImpHFConverter::SetNewPortion( XclImpHFPortion eNew )
diff --git a/sc/source/filter/inc/richstring.hxx 
b/sc/source/filter/inc/richstring.hxx
index d22aa6d2e2b3..69598b62d362 100644
--- a/sc/source/filter/inc/richstring.hxx
+++ b/sc/source/filter/inc/richstring.hxx
@@ -235,7 +235,7 @@ public:
         @param rxText  The XText interface of the target object.
      */
     void                convert( const css::uno::Reference< css::text::XText 
>& rxText ) const;
-    ::EditTextObject*   convert( ScEditEngineDefaulter& rEE, const 
oox::xls::Font* pFont ) const;
+    std::unique_ptr<EditTextObject> convert( ScEditEngineDefaulter& rEE, const 
oox::xls::Font* pFont ) const;
 
 private:
     /** Creates, appends, and returns a new empty string portion. */
diff --git a/sc/source/filter/inc/xihelper.hxx 
b/sc/source/filter/inc/xihelper.hxx
index 09a1f698257f..a4e8c2527103 100644
--- a/sc/source/filter/inc/xihelper.hxx
+++ b/sc/source/filter/inc/xihelper.hxx
@@ -116,7 +116,7 @@ public:
     XclImpStringHelper() = delete;
     /** Returns a new edit engine text object.
         @param nXFIndex  Index to XF for first text portion (for escapement). 
*/
-    static EditTextObject* CreateTextObject(
+    static std::unique_ptr<EditTextObject> CreateTextObject(
                             const XclImpRoot& rRoot,
                             const XclImpString& rString );
 
diff --git a/sc/source/filter/oox/revisionfragment.cxx 
b/sc/source/filter/oox/revisionfragment.cxx
index bd38fb4ffb0d..e63487b0c1db 100644
--- a/sc/source/filter/oox/revisionfragment.cxx
+++ b/sc/source/filter/oox/revisionfragment.cxx
@@ -141,12 +141,12 @@ protected:
                 {
                     // The value is a rich text string.
                     ScDocument& rDoc = getScDocument();
-                    EditTextObject* pTextObj = 
mxRichString->convert(rDoc.GetEditEngine(), nullptr);
+                    std::unique_ptr<EditTextObject> pTextObj = 
mxRichString->convert(rDoc.GetEditEngine(), nullptr);
                     if (pTextObj)
                     {
                         svl::SharedStringPool& rPool = 
rDoc.GetSharedStringPool();
                         pTextObj->NormalizeString(rPool);
-                        mrCellValue.set(pTextObj);
+                        mrCellValue.set(pTextObj.release());
                     }
                 }
             }
diff --git a/sc/source/filter/oox/richstring.cxx 
b/sc/source/filter/oox/richstring.cxx
index 69a51051c13f..19b2c5531012 100644
--- a/sc/source/filter/oox/richstring.cxx
+++ b/sc/source/filter/oox/richstring.cxx
@@ -391,7 +391,7 @@ void RichString::convert( const Reference< XText >& rxText 
) const
     }
 }
 
-::EditTextObject* RichString::convert( ScEditEngineDefaulter& rEE, const 
oox::xls::Font* pFirstPortionFont ) const
+std::unique_ptr<EditTextObject> RichString::convert( ScEditEngineDefaulter& 
rEE, const oox::xls::Font* pFirstPortionFont ) const
 {
     ESelection aSelection;
 
diff --git a/sc/source/filter/rtf/eeimpars.cxx 
b/sc/source/filter/rtf/eeimpars.cxx
index e553df1130ff..3f7803f8a536 100644
--- a/sc/source/filter/rtf/eeimpars.cxx
+++ b/sc/source/filter/rtf/eeimpars.cxx
@@ -412,10 +412,10 @@ void ScEEImport::WriteToDocument( bool bSizeColsRows, 
double nOutputFactor, SvNu
                     mpDoc->SetString(nCol, nRow, nTab, aStr, &aParam);
                 }
             }
-            else if (EditTextObject* pTextObject = IsValidSel(*mpEngine, 
pE->aSel) ? mpEngine->CreateTextObject(pE->aSel) : nullptr)
+            else if (std::unique_ptr<EditTextObject> pTextObject = 
IsValidSel(*mpEngine, pE->aSel) ? mpEngine->CreateTextObject(pE->aSel) : 
nullptr)
             {
                 // The cell will own the text object instance.
-                mpDoc->SetEditText(ScAddress(nCol,nRow,nTab), pTextObject);
+                mpDoc->SetEditText(ScAddress(nCol,nRow,nTab), 
std::move(pTextObject));
             }
             if ( !pE->maImageList.empty() )
                 bHasGraphics |= GraphicSize( nCol, nRow, pE );
diff --git a/sc/source/filter/xml/XMLTrackedChangesContext.cxx 
b/sc/source/filter/xml/XMLTrackedChangesContext.cxx
index 86e1dcba2efc..9710415925c7 100644
--- a/sc/source/filter/xml/XMLTrackedChangesContext.cxx
+++ b/sc/source/filter/xml/XMLTrackedChangesContext.cxx
@@ -26,6 +26,7 @@
 #include <textuno.hxx>
 #include <editutil.hxx>
 #include <document.hxx>
+#include <editeng/editobj.hxx>
 #include <xmloff/xmltoken.hxx>
 #include <xmloff/xmlnmspe.hxx>
 #include <xmloff/nmspmap.hxx>
@@ -930,7 +931,7 @@ void SAL_CALL ScXMLChangeCellContext::endFastElement( 
sal_Int32 /*nElement*/ )
 
             // The cell will own the text object instance.
             mrOldCell.meType = CELLTYPE_EDIT;
-            mrOldCell.mpEditText = mpEditTextObj->CreateTextObject();
+            mrOldCell.mpEditText = mpEditTextObj->CreateTextObject().release();
             GetScImport().GetTextImport()->ResetCursor();
             mpEditTextObj.clear();
         }
diff --git a/sc/source/ui/Accessibility/AccessiblePageHeaderArea.cxx 
b/sc/source/ui/Accessibility/AccessiblePageHeaderArea.cxx
index 3eb0b30fde23..2bd2d38664e6 100644
--- a/sc/source/ui/Accessibility/AccessiblePageHeaderArea.cxx
+++ b/sc/source/ui/Accessibility/AccessiblePageHeaderArea.cxx
@@ -53,7 +53,7 @@ ScAccessiblePageHeaderArea::ScAccessiblePageHeaderArea(
         bool bHeader,
         SvxAdjust eAdjust)
         : ScAccessibleContextBase(rxParent, AccessibleRole::TEXT),
-        mpEditObj(pEditObj->Clone()),
+        mpEditObj(pEditObj->Clone().release()),
         mpTextHelper(nullptr),
         mpViewShell(pViewShell),
         mbHeader(bHeader),
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index b78a2a18c1c4..5ac088044ac6 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -2821,7 +2821,7 @@ void ScInputHandler::EnterHandler( ScEnterMode nBlockMode 
)
         if (bAttrib)
         {
             mpEditEngine->ClearSpellErrors();
-            pObject.reset(mpEditEngine->CreateTextObject());
+            pObject = mpEditEngine->CreateTextObject();
         }
         else if (bAutoComplete) // Adjust Upper/Lower case
         {
@@ -3890,9 +3890,9 @@ bool ScInputHandler::GetTextAndFields( 
ScEditEngineDefaulter& rDestEngine )
         if ( eFieldState == SfxItemState::DONTCARE || eFieldState == 
SfxItemState::SET )
         {
             // Copy content
-            EditTextObject* pObj = mpEditEngine->CreateTextObject();
+            std::unique_ptr<EditTextObject> pObj = 
mpEditEngine->CreateTextObject();
             rDestEngine.SetText(*pObj);
-            delete pObj;
+            pObj.reset();
 
             // Delete attributes
             for (sal_Int32 i=0; i<nParCnt; i++)
@@ -4055,7 +4055,9 @@ ScInputHdlState& ScInputHdlState::operator=( const 
ScInputHdlState& r )
     aStartPos   = r.aStartPos;
     aEndPos     = r.aEndPos;
     aString     = r.aString;
-    pEditData.reset( r.pEditData ? r.pEditData->Clone() : nullptr );
+    pEditData.reset();
+    if (r.pEditData)
+        pEditData = r.pEditData->Clone();
 
     return *this;
 }
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index d6372e89ab0c..b517bab9911e 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -58,6 +58,7 @@
 #include <unotools/configmgr.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/weld.hxx>
+#include <editeng/editobj.hxx>
 
 #include <memory>
 #include <osl/endian.h>
diff --git a/sc/source/ui/inc/tphfedit.hxx b/sc/source/ui/inc/tphfedit.hxx
index 3d1f9d20c09c..741f432d95bc 100644
--- a/sc/source/ui/inc/tphfedit.hxx
+++ b/sc/source/ui/inc/tphfedit.hxx
@@ -59,7 +59,7 @@ public:
     void            SetFont( const ScPatternAttr& rPattern );
     using Control::SetText;
     void            SetText( const EditTextObject& rTextObject );
-    EditTextObject* CreateTextObject();
+    std::unique_ptr<EditTextObject> CreateTextObject();
     void            SetCharAttributes();
 
     void            InsertField( const SvxFieldItem& rFld );
diff --git a/sc/source/ui/inc/undocell.hxx b/sc/source/ui/inc/undocell.hxx
index cbdd78a7c4b9..67306e5d6e71 100644
--- a/sc/source/ui/inc/undocell.hxx
+++ b/sc/source/ui/inc/undocell.hxx
@@ -61,7 +61,7 @@ public:
     /** once the objects are passed to this class, their life-cycle is
         managed by this class; the calling function must pass new'ed
         objects to this method. */
-    void            SetEditData( EditTextObject* pOld, EditTextObject* pNew );
+    void            SetEditData( std::unique_ptr<EditTextObject> pOld, 
std::unique_ptr<EditTextObject> pNew );
 
 private:
     SCCOL           nCol;
@@ -70,10 +70,10 @@ private:
     ScPatternAttr*  pOldPattern;
     ScPatternAttr*  pNewPattern;
     ScPatternAttr*  pApplyPattern;
-    std::shared_ptr<EditTextObject> pOldEditData;
-    std::shared_ptr<EditTextObject> pNewEditData;
+    std::unique_ptr<EditTextObject> pOldEditData;
+    std::unique_ptr<EditTextObject> pNewEditData;
 
-    void            DoChange( const ScPatternAttr* pWhichPattern, const 
std::shared_ptr<EditTextObject>& pEditData ) const;
+    void            DoChange( const ScPatternAttr* pWhichPattern, const 
std::unique_ptr<EditTextObject>& pEditData ) const;
 };
 
 class ScUndoEnterData: public ScSimpleUndo
@@ -94,7 +94,7 @@ public:
 
     ScUndoEnterData(
         ScDocShell* pNewDocShell, const ScAddress& rPos,
-        ValuesType& rOldValues, const OUString& rNewStr, EditTextObject* pObj 
);
+        ValuesType& rOldValues, const OUString& rNewStr, 
std::unique_ptr<EditTextObject> pObj );
 
     virtual void    Undo() override;
     virtual void    Redo() override;
diff --git a/sc/source/ui/pagedlg/scuitphfedit.cxx 
b/sc/source/ui/pagedlg/scuitphfedit.cxx
index 671012b2395a..04691a62f84b 100644
--- a/sc/source/ui/pagedlg/scuitphfedit.cxx
+++ b/sc/source/ui/pagedlg/scuitphfedit.cxx
@@ -216,16 +216,13 @@ void ScHFEditPage::Reset( const SfxItemSet* rCoreSet )
 bool ScHFEditPage::FillItemSet( SfxItemSet* rCoreSet )
 {
     ScPageHFItem    aItem( nWhich );
-    EditTextObject* pLeft   = m_pWndLeft->CreateTextObject();
-    EditTextObject* pCenter = m_pWndCenter->CreateTextObject();
-    EditTextObject* pRight  = m_pWndRight->CreateTextObject();
+    std::unique_ptr<EditTextObject> pLeft   = m_pWndLeft->CreateTextObject();
+    std::unique_ptr<EditTextObject> pCenter = m_pWndCenter->CreateTextObject();
+    std::unique_ptr<EditTextObject> pRight  = m_pWndRight->CreateTextObject();
 
     aItem.SetLeftArea  ( *pLeft );
     aItem.SetCenterArea( *pCenter );
     aItem.SetRightArea ( *pRight );
-    delete pLeft;
-    delete pCenter;
-    delete pRight;
 
     rCoreSet->Put( aItem );
 
@@ -316,9 +313,9 @@ void ScHFEditPage::SetSelectDefinedList()
     OUString aCenterEntry;
     OUString aRightEntry;
 
-    pLeftObj.reset(m_pWndLeft->GetEditEngine()->CreateTextObject());
-    pCenterObj.reset(m_pWndCenter->GetEditEngine()->CreateTextObject());
-    pRightObj.reset(m_pWndRight->GetEditEngine()->CreateTextObject());
+    pLeftObj = m_pWndLeft->GetEditEngine()->CreateTextObject();
+    pCenterObj = m_pWndCenter->GetEditEngine()->CreateTextObject();
+    pRightObj = m_pWndRight->GetEditEngine()->CreateTextObject();
 
     bool bFound = false;
 
@@ -505,8 +502,7 @@ bool ScHFEditPage::IsPageEntry(EditEngine*pEngine, const 
EditTextObject* pTextOb
             {
                 aSel.nStartPos = aSel.nEndPos;
                 aSel.nEndPos++;
-                std::unique_ptr< EditTextObject > pPageObj;
-                pPageObj.reset(pEngine->CreateTextObject(aSel));
+                std::unique_ptr< EditTextObject > pPageObj = 
pEngine->CreateTextObject(aSel);
                 if(pPageObj.get() && pPageObj->IsFieldObject() )
                 {
                     const SvxFieldItem* pFieldItem = pPageObj->GetField();
@@ -598,7 +594,7 @@ void ScHFEditPage::ProcessDefinedListSel(ScHFEntryId eSel, 
bool bTravelling)
             
m_pWndCenter->GetEditEngine()->QuickInsertText(aPageOfEntry,ESelection(aSel.nEndPara,aSel.nEndPos,
 aSel.nEndPara, aSel.nEndPos));
             aSel.nEndPos = aSel.nEndPos + aPageOfEntry.getLength();
             
m_pWndCenter->GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPagesField(), 
EE_FEATURE_FIELD), ESelection(aSel.nEndPara,aSel.nEndPos, aSel.nEndPara, 
aSel.nEndPos));
-            pTextObj.reset(m_pWndCenter->GetEditEngine()->CreateTextObject());
+            pTextObj = m_pWndCenter->GetEditEngine()->CreateTextObject();
             m_pWndCenter->SetText(*pTextObj);
             if(!bTravelling)
                 m_pWndCenter->GrabFocus();
@@ -638,7 +634,7 @@ void ScHFEditPage::ProcessDefinedListSel(ScHFEntryId eSel, 
bool bTravelling)
             aSel.nStartPos = aSel.nEndPos;
             aSel.nEndPos = aSel.nEndPos + aPageEntry.getLength();
             
m_pWndCenter->GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPageField(), 
EE_FEATURE_FIELD), ESelection(aSel.nEndPara,aSel.nEndPos, aSel.nEndPara, 
aSel.nEndPos));
-            pTextObj.reset(m_pWndCenter->GetEditEngine()->CreateTextObject());
+            pTextObj = m_pWndCenter->GetEditEngine()->CreateTextObject();
             m_pWndCenter->SetText(*pTextObj);
             if(!bTravelling)
                 m_pWndCenter->GrabFocus();
@@ -667,7 +663,7 @@ void ScHFEditPage::ProcessDefinedListSel(ScHFEntryId eSel, 
bool bTravelling)
             
m_pWndCenter->GetEditEngine()->QuickInsertText(aCommaSpace,ESelection(aSel.nEndPara,
 aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
             aSel.nEndPos = aSel.nEndPos + aCommaSpace.getLength();
             m_pWndCenter->GetEditEngine()->QuickInsertField( 
SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, 
aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
-            pTextObj.reset(m_pWndCenter->GetEditEngine()->CreateTextObject());
+            pTextObj = m_pWndCenter->GetEditEngine()->CreateTextObject();
             m_pWndCenter->SetText(*pTextObj);
             if(!bTravelling)
                 m_pWndCenter->GrabFocus();
@@ -687,7 +683,7 @@ void ScHFEditPage::ProcessDefinedListSel(ScHFEntryId eSel, 
bool bTravelling)
             
m_pWndCenter->GetEditEngine()->QuickInsertText(aCommaSpace,ESelection(aSel.nEndPara,
 aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
             aSel.nEndPos = aSel.nEndPos + aCommaSpace.getLength();
             m_pWndCenter->GetEditEngine()->QuickInsertField( 
SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, 
aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
-            pTextObj.reset(m_pWndCenter->GetEditEngine()->CreateTextObject());
+            pTextObj = m_pWndCenter->GetEditEngine()->CreateTextObject();
             m_pWndCenter->SetText(*pTextObj);
             if(!bTravelling)
                 m_pWndCenter->GrabFocus();
diff --git a/sc/source/ui/pagedlg/tphfedit.cxx 
b/sc/source/ui/pagedlg/tphfedit.cxx
index d3bc68faabbb..819a16f26f18 100644
--- a/sc/source/ui/pagedlg/tphfedit.cxx
+++ b/sc/source/ui/pagedlg/tphfedit.cxx
@@ -141,7 +141,7 @@ void ScEditWindow::SetNumType(SvxNumType eNumType)
     pEdEngine->UpdateFields();
 }
 
-EditTextObject* ScEditWindow::CreateTextObject()
+std::unique_ptr<EditTextObject> ScEditWindow::CreateTextObject()
 {
     //  reset paragraph attributes
     //  (GetAttribs at creation of format dialog always returns the set items)
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
index 0af818eb34c4..16e022bfaea9 100644
--- a/sc/source/ui/undo/undocell.cxx
+++ b/sc/source/ui/undo/undocell.cxx
@@ -100,13 +100,13 @@ OUString ScUndoCursorAttr::GetComment() const
     return ScGlobal::GetRscString( STR_UNDO_CURSORATTR ); // "Attribute"
 }
 
-void ScUndoCursorAttr::SetEditData( EditTextObject* pOld, EditTextObject* pNew 
)
+void ScUndoCursorAttr::SetEditData( std::unique_ptr<EditTextObject> pOld, 
std::unique_ptr<EditTextObject> pNew )
 {
-    pOldEditData.reset(pOld);
-    pNewEditData.reset(pNew);
+    pOldEditData = std::move(pOld);
+    pNewEditData = std::move(pNew);
 }
 
-void ScUndoCursorAttr::DoChange( const ScPatternAttr* pWhichPattern, const 
shared_ptr<EditTextObject>& pEditData ) const
+void ScUndoCursorAttr::DoChange( const ScPatternAttr* pWhichPattern, const 
std::unique_ptr<EditTextObject>& pEditData ) const
 {
     ScDocument& rDoc = pDocShell->GetDocument();
     ScAddress aPos(nCol, nRow, nTab);
@@ -165,10 +165,10 @@ ScUndoEnterData::Value::Value() : mnTab(-1), 
mbHasFormat(false), mnFormat(0) {}
 
 ScUndoEnterData::ScUndoEnterData(
     ScDocShell* pNewDocShell, const ScAddress& rPos, ValuesType& rOldValues,
-    const OUString& rNewStr, EditTextObject* pObj ) :
+    const OUString& rNewStr, std::unique_ptr<EditTextObject> pObj ) :
     ScSimpleUndo( pNewDocShell ),
     maNewString(rNewStr),
-    mpNewEditData(pObj),
+    mpNewEditData(std::move(pObj)),
     mnEndChangeAction(0),
     maPos(rPos)
 {
diff --git a/sc/source/ui/unoobj/editsrc.cxx b/sc/source/ui/unoobj/editsrc.cxx
index a333bcde08df..b30fb6909b23 100644
--- a/sc/source/ui/unoobj/editsrc.cxx
+++ b/sc/source/ui/unoobj/editsrc.cxx
@@ -178,9 +178,9 @@ void ScAnnotationEditSource::UpdateData()
 
         if( SdrObject* pObj = GetCaptionObj() )
         {
-            EditTextObject* pEditObj = pEditEngine->CreateTextObject();
+            std::unique_ptr<EditTextObject> pEditObj = 
pEditEngine->CreateTextObject();
             OutlinerParaObject* pOPO = new OutlinerParaObject( *pEditObj );
-            delete pEditObj;
+            pEditObj.reset();
             pOPO->SetOutlinerMode( OutlinerMode::TextObject );
             pObj->NbcSetOutlinerParaObject( pOPO );
             pObj->ActionChanged();
diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx
index afc4fb7e3cde..6b00a69097e6 100644
--- a/sc/source/ui/unoobj/fielduno.cxx
+++ b/sc/source/ui/unoobj/fielduno.cxx
@@ -197,9 +197,8 @@ ScUnoEditEngine::ScUnoEditEngine(ScEditEngineDefaulter* 
pSource)
     , nFieldPos(0)
     , nFieldIndex(0)
 {
-    EditTextObject* pData = pSource->CreateTextObject();
+    std::unique_ptr<EditTextObject> pData = pSource->CreateTextObject();
     SetText( *pData );
-    delete pData;
 }
 
 OUString ScUnoEditEngine::CalcFieldValue( const SvxFieldItem& rField,
diff --git a/sc/source/ui/unoobj/textuno.cxx b/sc/source/ui/unoobj/textuno.cxx
index 5d4576636105..c1071f85d57c 100644
--- a/sc/source/ui/unoobj/textuno.cxx
+++ b/sc/source/ui/unoobj/textuno.cxx
@@ -253,13 +253,13 @@ void ScHeaderFooterTextData::UpdateData()
 {
     if (pEditEngine)
     {
-        mpTextObj.reset(pEditEngine->CreateTextObject());
+        mpTextObj = pEditEngine->CreateTextObject();
     }
 }
 
 void ScHeaderFooterTextData::UpdateData(EditEngine& rEditEngine)
 {
-    mpTextObj.reset(rEditEngine.CreateTextObject());
+    mpTextObj = rEditEngine.CreateTextObject();
     bDataValid = false;
 }
 
@@ -859,7 +859,7 @@ void ScEditEngineTextObj::SetText( const EditTextObject& 
rTextObject )
     SetSelection( aSel );
 }
 
-EditTextObject* ScEditEngineTextObj::CreateTextObject()
+std::unique_ptr<EditTextObject> ScEditEngineTextObj::CreateTextObject()
 {
     return GetEditEngine()->CreateTextObject();
 }
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 309ef81bb842..e6d9ad63a164 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5180,9 +5180,9 @@ bool ScGridWindow::GetEditUrl( const Point& rPos,
           // cell ( or other type ? ) with a hyperlink associated with it.
     {
         if (sURL.isEmpty())
-            pTextObj.reset(aCell.mpFormula->CreateURLObject());
+            pTextObj = aCell.mpFormula->CreateURLObject();
         else
-            pTextObj.reset(ScEditUtil::CreateURLObjectFromURL(rDoc, sURL, 
sURL));
+            pTextObj = ScEditUtil::CreateURLObjectFromURL(rDoc, sURL, sURL);
 
         if (pTextObj.get())
             pEngine->SetText(*pTextObj);
diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx
index e0de8ce0383a..4312e4616e88 100644
--- a/sc/source/ui/view/viewfun4.cxx
+++ b/sc/source/ui/view/viewfun4.cxx
@@ -412,9 +412,10 @@ void ScViewFunc::DoThesaurus()
         if (aOldText.meType == CELLTYPE_EDIT)
         {
             // The cell will own the text object instance.
-            EditTextObject* pText = pThesaurusEngine->CreateTextObject();
-            if (rDoc.SetEditText(ScAddress(nCol,nRow,nTab), pText))
-                aNewText.set(*pText);
+            std::unique_ptr<EditTextObject> pText = 
pThesaurusEngine->CreateTextObject();
+            auto tmp = pText.get();
+            if (rDoc.SetEditText(ScAddress(nCol,nRow,nTab), std::move(pText)))
+                aNewText.set(*tmp);
         }
         else
         {
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 8e516e358593..a9cb736e67bd 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -684,7 +684,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB 
nTab,
 
         //      undo
 
-        EditTextObject* pUndoData = nullptr;
+        std::unique_ptr<EditTextObject> pUndoData;
         ScUndoEnterData::ValuesType aOldValues;
 
         if (bRecord && !bSimple)
@@ -725,7 +725,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB 
nTab,
             if ( bRecord )
             {   //  because of ChangeTrack current first
                 pDocSh->GetUndoManager()->AddUndoAction(
-                    new ScUndoEnterData(pDocSh, ScAddress(nCol,nRow,nTab), 
aOldValues, aString, pUndoData));
+                    new ScUndoEnterData(pDocSh, ScAddress(nCol,nRow,nTab), 
aOldValues, aString, std::move(pUndoData)));
             }
 
             HideAllCursors();
@@ -1212,8 +1212,8 @@ void ScViewFunc::ApplySelectionPattern( const 
ScPatternAttr& rAttr, bool bCursor
         SCROW nRow = rViewData.GetCurY();
         SCTAB nTab = rViewData.GetTabNo();
 
-        EditTextObject* pOldEditData = nullptr;
-        EditTextObject* pNewEditData = nullptr;
+        std::unique_ptr<EditTextObject> pOldEditData;
+        std::unique_ptr<EditTextObject> pNewEditData;
         ScAddress aPos(nCol, nRow, nTab);
         ScRefCellValue aCell(rDoc, aPos);
         if (aCell.meType == CELLTYPE_EDIT)
@@ -1236,7 +1236,7 @@ void ScViewFunc::ApplySelectionPattern( const 
ScPatternAttr& rAttr, bool bCursor
         {
             ScUndoCursorAttr* pUndo = new ScUndoCursorAttr(
                 pDocSh, nCol, nRow, nTab, pOldPat.get(), pNewPat, &rAttr );
-            pUndo->SetEditData(pOldEditData, pNewEditData);
+            pUndo->SetEditData(std::move(pOldEditData), 
std::move(pNewEditData));
             pDocSh->GetUndoManager()->AddUndoAction(pUndo);
         }
         pOldPat.reset();     // is copied in undo (Pool)
diff --git a/starmath/source/accessibility.cxx 
b/starmath/source/accessibility.cxx
index 8f2e4017234b..84eb1b1c0911 100644
--- a/starmath/source/accessibility.cxx
+++ b/starmath/source/accessibility.cxx
@@ -1389,9 +1389,8 @@ void SmTextForwarder::CopyText(const SvxTextForwarder& 
rSource)
     EditEngine *pEditEngine = rEditAcc.GetEditEngine();
     if (pEditEngine && pSourceEditEngine )
     {
-        EditTextObject* pNewTextObject = pSourceEditEngine->CreateTextObject();
+        std::unique_ptr<EditTextObject> pNewTextObject = 
pSourceEditEngine->CreateTextObject();
         pEditEngine->SetText( *pNewTextObject );
-        delete pNewTextObject;
     }
 }
 
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index 1b165cfdef64..bf921f3c9c44 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -984,10 +984,10 @@ OutlinerParaObject* 
SwWW8ImplReader::ImportAsOutliner(OUString &rString, WW8_CP
                 m_pDrawEditEngine->QuickDelete(aFirstChar);
         }
 
-        EditTextObject* pTemporaryText = m_pDrawEditEngine->CreateTextObject();
+        std::unique_ptr<EditTextObject> pTemporaryText = 
m_pDrawEditEngine->CreateTextObject();
         pRet = new OutlinerParaObject(*pTemporaryText);
         pRet->SetOutlinerMode( OutlinerMode::TextObject );
-        delete pTemporaryText;
+        pTemporaryText.reset();
 
         m_pDrawEditEngine->SetText( OUString() );
         m_pDrawEditEngine->SetParaAttribs(0, 
m_pDrawEditEngine->GetEmptyItemSet());
@@ -1193,11 +1193,11 @@ void SwWW8ImplReader::InsertTxbxText(SdrTextObj* 
pTextObj,
         }
 
         bool bVertical = pTextObj->IsVerticalWriting();
-        EditTextObject* pTemporaryText = m_pDrawEditEngine->CreateTextObject();
+        std::unique_ptr<EditTextObject> pTemporaryText = 
m_pDrawEditEngine->CreateTextObject();
         OutlinerParaObject* pOp = new OutlinerParaObject(*pTemporaryText);
         pOp->SetOutlinerMode( OutlinerMode::TextObject );
         pOp->SetVertical( bVertical );
-        delete pTemporaryText;
+        pTemporaryText.reset();
         pTextObj->NbcSetOutlinerParaObject( pOp );
         pTextObj->SetVerticalWriting(bVertical);
 
diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx 
b/sw/source/uibase/docvw/AnnotationWin2.cxx
index 8a10fe16eed8..eaf0b9d07356 100644
--- a/sw/source/uibase/docvw/AnnotationWin2.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin2.cxx
@@ -39,6 +39,7 @@
 #include <viewopt.hxx>
 #include <cmdid.h>
 
+#include <editeng/editobj.hxx>
 #include <editeng/fontitem.hxx>
 #include <editeng/fhgtitem.hxx>
 #include <editeng/langitem.hxx>
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to