[Libreoffice-commits] core.git: 3 commits - include/svx svx/source
Noel Grandin
noel.grandin at collabora.co.uk
Mon May 7 06:34:01 UTC 2018
include/svx/sdr/table/tablecontroller.hxx | 3 +
include/svx/svdedxv.hxx | 6 +--
svx/source/svdraw/svdedxv.cxx | 37 ++++++++-----------
svx/source/table/tablecontroller.cxx | 5 +-
svx/source/unodraw/unoshtxt.cxx | 57 ++++++++++--------------------
5 files changed, 43 insertions(+), 65 deletions(-)
New commits:
commit f7a0627c9a5ebd5827fc793ae023fb28e99a6525
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Fri May 4 16:26:30 2018 +0200
loplugin:useuniqueptr in SvxTextEditSourceImpl
Change-Id: I69b3fcbdb8a41ed227acdc65232ca013e63bc82d
Reviewed-on: https://gerrit.libreoffice.org/53880
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/svx/source/unodraw/unoshtxt.cxx b/svx/source/unodraw/unoshtxt.cxx
index 779d7c066e8e..5c9f669b37cc 100644
--- a/svx/source/unodraw/unoshtxt.cxx
+++ b/svx/source/unodraw/unoshtxt.cxx
@@ -86,8 +86,8 @@ private:
VclPtr<const vcl::Window> mpWindow;
SdrModel* mpModel; // TTTT probably not needed -> use SdrModel from SdrObject (?)
SdrOutliner* mpOutliner;
- SvxOutlinerForwarder* mpTextForwarder;
- SvxDrawOutlinerViewForwarder* mpViewForwarder; // if non-NULL, use GetViewModeTextForwarder text forwarder
+ std::unique_ptr<SvxOutlinerForwarder> mpTextForwarder;
+ std::unique_ptr<SvxDrawOutlinerViewForwarder> mpViewForwarder; // if non-NULL, use GetViewModeTextForwarder text forwarder
css::uno::Reference< css::linguistic2::XLinguServiceManager2 > m_xLinguServiceManager;
Point maTextOffset;
bool mbDataValid;
@@ -103,7 +103,7 @@ private:
SvxTextForwarder* GetBackgroundTextForwarder();
SvxTextForwarder* GetEditModeTextForwarder();
- SvxDrawOutlinerViewForwarder* CreateViewForwarder();
+ std::unique_ptr<SvxDrawOutlinerViewForwarder> CreateViewForwarder();
void SetupOutliner();
@@ -272,11 +272,7 @@ void SvxTextEditSourceImpl::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
if (&rBC == mpView)
{
mpView = nullptr;
- if (mpViewForwarder)
- {
- delete mpViewForwarder;
- mpViewForwarder = nullptr;
- }
+ mpViewForwarder.reset();
}
}
else if (const SvxViewChangedHint* pViewHint = dynamic_cast<const SvxViewChangedHint*>(&rHint))
@@ -334,8 +330,7 @@ void SvxTextEditSourceImpl::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
// invalidate old forwarder
if( !mbForwarderIsEditMode )
{
- delete mpTextForwarder;
- mpTextForwarder = nullptr;
+ mpTextForwarder.reset();
}
// register as listener - need to broadcast state change messages
@@ -370,8 +365,7 @@ void SvxTextEditSourceImpl::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
// destroy view forwarder, OutlinerView no longer
// valid (no need for UpdateData(), it's been
// synched on SdrEndTextEdit)
- delete mpViewForwarder;
- mpViewForwarder = nullptr;
+ mpViewForwarder.reset();
// Invalidate text forwarder, we might
// not be called again before entering edit mode a
@@ -380,8 +374,7 @@ void SvxTextEditSourceImpl::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
if( mbForwarderIsEditMode )
{
mbForwarderIsEditMode = false;
- delete mpTextForwarder;
- mpTextForwarder = nullptr;
+ mpTextForwarder.reset();
}
}
break;
@@ -406,17 +399,8 @@ void SvxTextEditSourceImpl::ObjectInDestruction(const SdrObject&)
/* unregister at all objects and set all references to 0 */
void SvxTextEditSourceImpl::dispose()
{
- if( mpTextForwarder )
- {
- delete mpTextForwarder;
- mpTextForwarder = nullptr;
- }
-
- if( mpViewForwarder )
- {
- delete mpViewForwarder;
- mpViewForwarder = nullptr;
- }
+ mpTextForwarder.reset();
+ mpViewForwarder.reset();
if( mpOutliner )
{
@@ -548,7 +532,7 @@ SvxTextForwarder* SvxTextEditSourceImpl::GetBackgroundTextForwarder()
}
- mpTextForwarder = new SvxOutlinerForwarder( *mpOutliner, (mpObject->GetObjInventor() == SdrInventor::Default) && (mpObject->GetObjIdentifier() == OBJ_OUTLINETEXT) );
+ mpTextForwarder.reset(new SvxOutlinerForwarder( *mpOutliner, (mpObject->GetObjInventor() == SdrInventor::Default) && (mpObject->GetObjIdentifier() == OBJ_OUTLINETEXT) ));
// delay listener subscription and UAA initialization until Outliner is fully setup
bCreated = true;
@@ -635,7 +619,7 @@ SvxTextForwarder* SvxTextEditSourceImpl::GetBackgroundTextForwarder()
// prevent EE/Outliner notifications during setup
mbNotificationsDisabled = false;
- return mpTextForwarder;
+ return mpTextForwarder.get();
}
@@ -647,12 +631,12 @@ SvxTextForwarder* SvxTextEditSourceImpl::GetEditModeTextForwarder()
if( pEditOutliner )
{
- mpTextForwarder = new SvxOutlinerForwarder( *pEditOutliner, (mpObject->GetObjInventor() == SdrInventor::Default) && (mpObject->GetObjIdentifier() == OBJ_OUTLINETEXT) );
+ mpTextForwarder.reset(new SvxOutlinerForwarder( *pEditOutliner, (mpObject->GetObjInventor() == SdrInventor::Default) && (mpObject->GetObjIdentifier() == OBJ_OUTLINETEXT) ));
mbForwarderIsEditMode = true;
}
}
- return mpTextForwarder;
+ return mpTextForwarder.get();
}
@@ -672,8 +656,7 @@ SvxTextForwarder* SvxTextEditSourceImpl::GetTextForwarder()
if( IsEditMode() != mbForwarderIsEditMode )
{
// forwarder mismatch - create new
- delete mpTextForwarder;
- mpTextForwarder = nullptr;
+ mpTextForwarder.reset();
}
if( IsEditMode() )
@@ -686,7 +669,7 @@ SvxTextForwarder* SvxTextEditSourceImpl::GetTextForwarder()
}
-SvxDrawOutlinerViewForwarder* SvxTextEditSourceImpl::CreateViewForwarder()
+std::unique_ptr<SvxDrawOutlinerViewForwarder> SvxTextEditSourceImpl::CreateViewForwarder()
{
if( mpView->GetTextEditOutlinerView() && mpObject )
{
@@ -700,7 +683,7 @@ SvxDrawOutlinerViewForwarder* SvxTextEditSourceImpl::CreateViewForwarder()
tools::Rectangle aBoundRect( pTextObj->GetCurrentBoundRect() );
OutlinerView& rOutlView = *mpView->GetTextEditOutlinerView();
- return new SvxDrawOutlinerViewForwarder( rOutlView, aBoundRect.TopLeft() );
+ return std::unique_ptr<SvxDrawOutlinerViewForwarder>(new SvxDrawOutlinerViewForwarder( rOutlView, aBoundRect.TopLeft() ));
}
}
@@ -722,8 +705,7 @@ SvxEditViewForwarder* SvxTextEditSourceImpl::GetEditViewForwarder( bool bCreate
{
// destroy all forwarders (no need for UpdateData(),
// it's been synched on SdrEndTextEdit)
- delete mpViewForwarder;
- mpViewForwarder = nullptr;
+ mpViewForwarder.reset();
}
}
// which to create? Directly in edit mode, create new, or none?
@@ -739,8 +721,7 @@ SvxEditViewForwarder* SvxTextEditSourceImpl::GetEditViewForwarder( bool bCreate
// dispose old text forwarder
UpdateData();
- delete mpTextForwarder;
- mpTextForwarder = nullptr;
+ mpTextForwarder.reset();
// enter edit mode
mpView->SdrEndTextEdit();
@@ -763,7 +744,7 @@ SvxEditViewForwarder* SvxTextEditSourceImpl::GetEditViewForwarder( bool bCreate
}
}
- return mpViewForwarder;
+ return mpViewForwarder.get();
}
commit babaa7afcf38763511a152dcc467c2812349207b
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Fri May 4 16:12:47 2018 +0200
loplugin:useuniqueptr in SvxTableController
Change-Id: I505f0fe1626e6b935c4194cceaa0f4d0f8756656
Reviewed-on: https://gerrit.libreoffice.org/53879
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/svx/sdr/table/tablecontroller.hxx b/include/svx/sdr/table/tablecontroller.hxx
index fe03d7353a2b..b16b5f30f0b2 100644
--- a/include/svx/sdr/table/tablecontroller.hxx
+++ b/include/svx/sdr/table/tablecontroller.hxx
@@ -28,6 +28,7 @@
#include <svx/selectioncontroller.hxx>
#include <svx/svdotable.hxx>
#include <svx/svdview.hxx>
+#include <memory>
class SdrView;
class SdrObject;
@@ -178,7 +179,7 @@ private:
bool mbCellSelectionMode;
CellPos maMouseDownPos;
bool mbLeftButtonDown;
- sdr::overlay::OverlayObjectList* mpSelectionOverlay;
+ std::unique_ptr<sdr::overlay::OverlayObjectList> mpSelectionOverlay;
SdrView& mrView;
tools::WeakReference<SdrTableObj> mxTableObj;
css::uno::Reference< css::util::XModifyListener > mxModifyListener;
diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx
index ecdd0a233be5..9e70356369e3 100644
--- a/svx/source/table/tablecontroller.cxx
+++ b/svx/source/table/tablecontroller.cxx
@@ -2183,7 +2183,7 @@ void SvxTableController::updateSelectionOverlay()
sdr::overlay::OverlayObjectCell* pOverlay = new sdr::overlay::OverlayObjectCell( aHighlight, aRanges );
xOverlayManager->add(*pOverlay);
- mpSelectionOverlay = new sdr::overlay::OverlayObjectList;
+ mpSelectionOverlay.reset(new sdr::overlay::OverlayObjectList);
mpSelectionOverlay->append(pOverlay);
}
}
@@ -2221,8 +2221,7 @@ void SvxTableController::destroySelectionOverlay()
{
if( mpSelectionOverlay )
{
- delete mpSelectionOverlay;
- mpSelectionOverlay = nullptr;
+ mpSelectionOverlay.reset();
if (comphelper::LibreOfficeKit::isActive())
{
commit 5c632220d3aa8faa66b44ba29fbcc560813a369a
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Fri May 4 15:52:54 2018 +0200
loplugin:useuniqueptr in SdrObjEditView
Change-Id: Ie980c0f50483235663e9560fbcf61cf284663228
Reviewed-on: https://gerrit.libreoffice.org/53878
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
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 );
More information about the Libreoffice-commits
mailing list