summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-05-04 15:52:54 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-05-07 08:33:37 +0200
commit5c632220d3aa8faa66b44ba29fbcc560813a369a (patch)
tree04620865c3d66edc2332002c4a3cf760acfe15bc
parent91af898b2a9193219bd28aa64296eaf0e145beb6 (diff)
loplugin:useuniqueptr in SdrObjEditView
Change-Id: Ie980c0f50483235663e9560fbcf61cf284663228 Reviewed-on: https://gerrit.libreoffice.org/53878 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--include/svx/svdedxv.hxx6
-rw-r--r--svx/source/svdraw/svdedxv.cxx37
2 files changed, 20 insertions, 23 deletions
diff --git a/include/svx/svdedxv.hxx b/include/svx/svdedxv.hxx
index 70472aab20b2..97abbc9e2d93 100644
--- a/include/svx/svdedxv.hxx
+++ b/include/svx/svdedxv.hxx
@@ -77,7 +77,7 @@ protected:
tools::WeakReference<SdrTextObj>
mxTextEditObj; // current object in TextEdit
SdrPageView* pTextEditPV;
- SdrOutliner* pTextEditOutliner; // outliner for the TextEdit
+ std::unique_ptr<SdrOutliner> pTextEditOutliner; // outliner for the TextEdit
OutlinerView* pTextEditOutlinerView; // current view of the outliners
VclPtr<vcl::Window> pTextEditWin; // matching window to pTextEditOutlinerView
vcl::Cursor* pTextEditCursorMerker; // to restore the cursor in each window
@@ -229,8 +229,8 @@ public:
// Now at this outliner, events can be send, attributes can be set,
// call Cut/Copy/Paste, call Undo/Redo, and so on...
- const SdrOutliner* GetTextEditOutliner() const { return pTextEditOutliner; }
- SdrOutliner* GetTextEditOutliner() { return pTextEditOutliner; }
+ const SdrOutliner* GetTextEditOutliner() const { return pTextEditOutliner.get(); }
+ SdrOutliner* GetTextEditOutliner() { return pTextEditOutliner.get(); }
const OutlinerView* GetTextEditOutlinerView() const { return pTextEditOutlinerView; }
OutlinerView* GetTextEditOutlinerView() { return pTextEditOutlinerView; }
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 211537d4c411..bab1f5e71898 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -73,7 +73,7 @@
void SdrObjEditView::ImpClearVars()
{
bQuickTextEditMode=true;
- pTextEditOutliner=nullptr;
+ pTextEditOutliner.reset();
pTextEditOutlinerView=nullptr;
pTextEditPV=nullptr;
pTextEditWin=nullptr;
@@ -103,7 +103,7 @@ SdrObjEditView::~SdrObjEditView()
assert(!IsTextEdit());
if (IsTextEdit())
SdrEndTextEdit();
- delete pTextEditOutliner;
+ pTextEditOutliner.reset();
assert(nullptr == mpOldTextEditUndoManager); // should have been reset
}
@@ -822,7 +822,7 @@ OutlinerView* SdrObjEditView::ImpMakeOutlinerView(vcl::Window* pWin, OutlinerVie
if (pOutlView == nullptr)
{
- pOutlView = new OutlinerView(pTextEditOutliner, pWin);
+ pOutlView = new OutlinerView(pTextEditOutliner.get(), pWin);
}
else
{
@@ -1080,8 +1080,7 @@ bool SdrObjEditView::SdrBeginTextEdit(
if(pTextEditOutliner)
{
OSL_FAIL("SdrObjEditView::SdrBeginTextEdit(): Old Outliner still exists.");
- delete pTextEditOutliner;
- pTextEditOutliner = nullptr;
+ pTextEditOutliner.reset();
}
if(!bBrk)
@@ -1089,9 +1088,13 @@ bool SdrObjEditView::SdrBeginTextEdit(
pTextEditWin=pWin;
pTextEditPV=pPV;
mxTextEditObj.reset( pObj );
- pTextEditOutliner=pGivenOutliner;
- if (pTextEditOutliner==nullptr)
- pTextEditOutliner = SdrMakeOutliner( OutlinerMode::TextObject, mxTextEditObj->getSdrModelFromSdrObject() ).release();
+ if (pGivenOutliner)
+ {
+ pTextEditOutliner.reset(pGivenOutliner);
+ pGivenOutliner = nullptr; // so we don't delete it on the error path
+ }
+ else
+ pTextEditOutliner = SdrMakeOutliner( OutlinerMode::TextObject, mxTextEditObj->getSdrModelFromSdrObject() );
{
SvtAccessibilityOptions aOptions;
@@ -1326,20 +1329,15 @@ bool SdrObjEditView::SdrBeginTextEdit(
// something went wrong...
if(!bDontDeleteOutliner)
{
- if(pGivenOutliner!=nullptr)
- {
- delete pGivenOutliner;
- pTextEditOutliner = nullptr;
- }
+ delete pGivenOutliner;
if(pGivenOutlinerView!=nullptr)
{
delete pGivenOutlinerView;
pGivenOutlinerView = nullptr;
}
}
- delete pTextEditOutliner;
+ pTextEditOutliner.reset();
- pTextEditOutliner=nullptr;
pTextEditOutlinerView=nullptr;
mxTextEditObj.reset(nullptr);
pTextEditPV=nullptr;
@@ -1354,16 +1352,15 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(bool bDontDeleteReally)
SdrEndTextEditKind eRet=SdrEndTextEditKind::Unchanged;
SdrTextObj* pTEObj = mxTextEditObj.get();
vcl::Window* pTEWin =pTextEditWin;
- SdrOutliner* pTEOutliner =pTextEditOutliner;
OutlinerView* pTEOutlinerView=pTextEditOutlinerView;
vcl::Cursor* pTECursorMerker=pTextEditCursorMerker;
SdrUndoManager* pUndoEditUndoManager = nullptr;
bool bNeedToUndoSavedRedoTextEdit(false);
- if (GetModel() && IsUndoEnabled() && pTEObj && pTEOutliner && !GetModel()->GetDisableTextEditUsesCommonUndoManager())
+ if (GetModel() && IsUndoEnabled() && pTEObj && pTextEditOutliner && !GetModel()->GetDisableTextEditUsesCommonUndoManager())
{
// change back the UndoManager to the remembered original one
- ::svl::IUndoManager* pOriginal = pTEOutliner->SetUndoManager(mpOldTextEditUndoManager);
+ ::svl::IUndoManager* pOriginal = pTextEditOutliner->SetUndoManager(mpOldTextEditUndoManager);
mpOldTextEditUndoManager = nullptr;
if(pOriginal)
@@ -1424,7 +1421,7 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(bool bDontDeleteReally)
mxTextEditObj.reset(nullptr);
pTextEditPV=nullptr;
pTextEditWin=nullptr;
- pTextEditOutliner=nullptr;
+ SdrOutliner* pTEOutliner = pTextEditOutliner.release();
pTextEditOutlinerView=nullptr;
pTextEditCursorMerker=nullptr;
aTextEditArea=tools::Rectangle();
@@ -1928,7 +1925,7 @@ bool SdrObjEditView::ImpIsTextEditAllSelected() const
bool bRet=false;
if (pTextEditOutliner!=nullptr && pTextEditOutlinerView!=nullptr)
{
- if(SdrTextObj::HasTextImpl( pTextEditOutliner ) )
+ if(SdrTextObj::HasTextImpl( pTextEditOutliner.get() ) )
{
const sal_Int32 nParaCnt=pTextEditOutliner->GetParagraphCount();
Paragraph* pLastPara=pTextEditOutliner->GetParagraph( nParaCnt > 1 ? nParaCnt - 1 : 0 );