summaryrefslogtreecommitdiff
path: root/sc/source/ui/view
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-07-10 14:06:47 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-07-11 08:07:42 +0200
commit877362dadf34c910365490ce53b2dcf902dab8cc (patch)
tree91b0c0b1fd827539e971ca20fd46d1fe69d25531 /sc/source/ui/view
parent72eb6f7e47d7c8c19c76cea67330464af47648f1 (diff)
loplugin:useuniqueptr in ScTabViewShell
Change-Id: I35061f62244ea40ce66bbb0ba09edf9b45d62742 Reviewed-on: https://gerrit.libreoffice.org/57244 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/ui/view')
-rw-r--r--sc/source/ui/view/cellsh1.cxx7
-rw-r--r--sc/source/ui/view/tabvwsh4.cxx98
-rw-r--r--sc/source/ui/view/tabvwsh8.cxx12
-rw-r--r--sc/source/ui/view/tabvwshc.cxx2
-rw-r--r--sc/source/ui/view/tabvwshe.cxx2
-rw-r--r--sc/source/ui/view/tabvwshh.cxx2
6 files changed, 58 insertions, 65 deletions
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index be04ff40351b..400a0273c9dd 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2758,7 +2758,7 @@ void ScCellShell::ExecuteDataPilotDialog()
ScViewData* pData = GetViewData();
ScDocument* pDoc = pData->GetDocument();
- std::unique_ptr<ScDPObject> pNewDPObject(nullptr);
+ std::unique_ptr<ScDPObject> pNewDPObject;
// ScPivot is no longer used...
ScDPObject* pDPObj = pDoc->GetDPAtCursor(
@@ -2917,8 +2917,9 @@ void ScCellShell::ExecuteDataPilotDialog()
pNewDPObject->SetOutRange( aDestPos );
}
- pTabViewShell->SetDialogDPObject( pNewDPObject.get() ); // is copied
- if ( pNewDPObject )
+ bool bHadNewDPObject = pNewDPObject != nullptr;
+ pTabViewShell->SetDialogDPObject( std::move(pNewDPObject) );
+ if ( bHadNewDPObject )
{
// start layout dialog
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index 6012975b26a6..7490a92c7e7d 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -747,7 +747,7 @@ void ScTabViewShell::SetEditShell(EditView* pView, bool bActive )
if (pEditShell)
pEditShell->SetEditView( pView );
else
- pEditShell = new ScEditShell( pView, &GetViewData() );
+ pEditShell.reset( new ScEditShell( pView, &GetViewData() ) );
SetCurSubShell(OST_Editing);
}
@@ -767,7 +767,7 @@ void ScTabViewShell::SetCurSubShell(ObjectSelectionType eOST, bool bForce)
if(!pCellShell) // is anyway always used
{
- pCellShell = new ScCellShell( &GetViewData(), GetFrameWin() );
+ pCellShell.reset( new ScCellShell( &GetViewData(), GetFrameWin() ) );
pCellShell->SetRepeatTarget( &aTarget );
}
@@ -775,7 +775,7 @@ void ScTabViewShell::SetCurSubShell(ObjectSelectionType eOST, bool bForce)
if(bPgBrk && !pPageBreakShell)
{
- pPageBreakShell = new ScPageBreakShell( this );
+ pPageBreakShell.reset( new ScPageBreakShell( this ) );
pPageBreakShell->SetRepeatTarget( &aTarget );
}
@@ -814,7 +814,7 @@ void ScTabViewShell::SetCurSubShell(ObjectSelectionType eOST, bool bForce)
if ( !pDrawTextShell )
{
pDocSh->MakeDrawLayer();
- pDrawTextShell = new ScDrawTextObjectBar( &GetViewData() );
+ pDrawTextShell.reset( new ScDrawTextObjectBar( &GetViewData() ) );
}
AddSubShell(*pDrawTextShell);
}
@@ -824,21 +824,21 @@ void ScTabViewShell::SetCurSubShell(ObjectSelectionType eOST, bool bForce)
if (svx::checkForSelectedCustomShapes(
GetScDrawView(), true /* bOnlyExtruded */ )) {
if (pExtrusionBarShell == nullptr)
- pExtrusionBarShell = new svx::ExtrusionBar(this);
+ pExtrusionBarShell.reset( new svx::ExtrusionBar(this) );
AddSubShell( *pExtrusionBarShell );
}
sal_uInt32 nCheckStatus = 0;
if (svx::checkForSelectedFontWork(
GetScDrawView(), nCheckStatus )) {
if (pFontworkBarShell == nullptr)
- pFontworkBarShell = new svx::FontworkBar(this);
+ pFontworkBarShell.reset( new svx::FontworkBar(this) );
AddSubShell( *pFontworkBarShell );
}
if ( !pDrawShell )
{
pDocSh->MakeDrawLayer();
- pDrawShell = new ScDrawShell( &GetViewData() );
+ pDrawShell.reset( new ScDrawShell( &GetViewData() ) );
pDrawShell->SetRepeatTarget( &aTarget );
}
AddSubShell(*pDrawShell);
@@ -851,7 +851,7 @@ void ScTabViewShell::SetCurSubShell(ObjectSelectionType eOST, bool bForce)
if ( !pDrawFormShell )
{
pDocSh->MakeDrawLayer();
- pDrawFormShell = new ScDrawFormShell( &GetViewData() );
+ pDrawFormShell.reset( new ScDrawFormShell( &GetViewData() ) );
pDrawFormShell->SetRepeatTarget( &aTarget );
}
AddSubShell(*pDrawFormShell);
@@ -864,7 +864,7 @@ void ScTabViewShell::SetCurSubShell(ObjectSelectionType eOST, bool bForce)
if ( !pChartShell )
{
pDocSh->MakeDrawLayer();
- pChartShell = new ScChartShell( &GetViewData() );
+ pChartShell.reset( new ScChartShell( &GetViewData() ) );
pChartShell->SetRepeatTarget( &aTarget );
}
AddSubShell(*pChartShell);
@@ -877,7 +877,7 @@ void ScTabViewShell::SetCurSubShell(ObjectSelectionType eOST, bool bForce)
if ( !pOleObjectShell )
{
pDocSh->MakeDrawLayer();
- pOleObjectShell = new ScOleObjectShell( &GetViewData() );
+ pOleObjectShell.reset( new ScOleObjectShell( &GetViewData() ) );
pOleObjectShell->SetRepeatTarget( &aTarget );
}
AddSubShell(*pOleObjectShell);
@@ -890,7 +890,7 @@ void ScTabViewShell::SetCurSubShell(ObjectSelectionType eOST, bool bForce)
if ( !pGraphicShell)
{
pDocSh->MakeDrawLayer();
- pGraphicShell = new ScGraphicShell( &GetViewData() );
+ pGraphicShell.reset( new ScGraphicShell( &GetViewData() ) );
pGraphicShell->SetRepeatTarget( &aTarget );
}
AddSubShell(*pGraphicShell);
@@ -903,7 +903,7 @@ void ScTabViewShell::SetCurSubShell(ObjectSelectionType eOST, bool bForce)
if ( !pMediaShell)
{
pDocSh->MakeDrawLayer();
- pMediaShell = new ScMediaShell( &GetViewData() );
+ pMediaShell.reset( new ScMediaShell( &GetViewData() ) );
pMediaShell->SetRepeatTarget( &aTarget );
}
AddSubShell(*pMediaShell);
@@ -917,7 +917,7 @@ void ScTabViewShell::SetCurSubShell(ObjectSelectionType eOST, bool bForce)
if ( !pPivotShell )
{
- pPivotShell = new ScPivotShell( this );
+ pPivotShell.reset( new ScPivotShell( this ) );
pPivotShell->SetRepeatTarget( &aTarget );
}
AddSubShell(*pPivotShell);
@@ -933,7 +933,7 @@ void ScTabViewShell::SetCurSubShell(ObjectSelectionType eOST, bool bForce)
{
pDocSh->MakeDrawLayer(); // the waiting time rather now as on the click
- pAuditingShell = new ScAuditingShell( &GetViewData() );
+ pAuditingShell.reset( new ScAuditingShell( &GetViewData() ) );
pAuditingShell->SetRepeatTarget( &aTarget );
}
AddSubShell(*pAuditingShell);
@@ -985,10 +985,10 @@ SfxShell* ScTabViewShell::GetMySubShell() const
SfxShell* pSub = const_cast<ScTabViewShell*>(this)->GetSubShell(nPos);
while (pSub)
{
- if ( pSub == pDrawShell || pSub == pDrawTextShell || pSub == pEditShell ||
- pSub == pPivotShell || pSub == pAuditingShell || pSub == pDrawFormShell ||
- pSub == pCellShell || pSub == pOleObjectShell|| pSub == pChartShell ||
- pSub == pGraphicShell || pSub == pMediaShell || pSub == pPageBreakShell)
+ if ( pSub == pDrawShell.get() || pSub == pDrawTextShell.get() || pSub == pEditShell.get() ||
+ pSub == pPivotShell.get() || pSub == pAuditingShell.get() || pSub == pDrawFormShell.get() ||
+ pSub == pCellShell.get() || pSub == pOleObjectShell.get() || pSub == pChartShell.get() ||
+ pSub == pGraphicShell.get() || pSub == pMediaShell.get() || pSub == pPageBreakShell.get())
return pSub; // found
pSub = const_cast<ScTabViewShell*>(this)->GetSubShell(++nPos);
@@ -998,12 +998,12 @@ SfxShell* ScTabViewShell::GetMySubShell() const
bool ScTabViewShell::IsDrawTextShell() const
{
- return ( pDrawTextShell && ( GetMySubShell() == pDrawTextShell ) );
+ return ( pDrawTextShell && ( GetMySubShell() == pDrawTextShell.get() ) );
}
bool ScTabViewShell::IsAuditShell() const
{
- return ( pAuditingShell && ( GetMySubShell() == pAuditingShell ) );
+ return ( pAuditingShell && ( GetMySubShell() == pAuditingShell.get() ) );
}
void ScTabViewShell::SetDrawTextUndo( ::svl::IUndoManager* pNewUndoMgr )
@@ -1441,8 +1441,8 @@ void ScTabViewShell::Construct( TriState nForceDesignMode )
SetPool( &SC_MOD()->GetPool() );
SetWindow( GetActiveWin() );
- pCurFrameLine = new ::editeng::SvxBorderLine(&aColBlack, 20, SvxBorderLineStyle::SOLID);
- pPivotSource = new ScArea;
+ pCurFrameLine.reset( new ::editeng::SvxBorderLine(&aColBlack, 20, SvxBorderLineStyle::SOLID) );
+ pPivotSource.reset( new ScArea );
StartListening(*GetViewData().GetDocShell(), DuplicateHandling::Prevent);
StartListening(*GetViewFrame(), DuplicateHandling::Prevent);
StartListening(*pSfxApp, DuplicateHandling::Prevent); // #i62045# #i62046# application is needed for Calc's own hints
@@ -1499,7 +1499,7 @@ void ScTabViewShell::Construct( TriState nForceDesignMode )
// create FormShell before MakeDrawView, so that DrawView can be registered at the
// FormShell in every case
// the FormShell is pushed in the first activate
- pFormShell = new FmFormShell(this);
+ pFormShell.reset( new FmFormShell(this) );
pFormShell->SetControlActivationHandler( LINK( this, ScTabViewShell, FormControlActivated ) );
// DrawView must not be created in TabView - ctor,
@@ -1783,37 +1783,33 @@ ScTabViewShell::~ScTabViewShell()
RemoveSubShell(); // all
SetWindow(nullptr);
- DELETEZ(pFontworkBarShell);
- DELETEZ(pExtrusionBarShell);
- DELETEZ(pCellShell);
- DELETEZ(pPageBreakShell);
- DELETEZ(pDrawShell);
- DELETEZ(pDrawFormShell);
- DELETEZ(pOleObjectShell);
- DELETEZ(pChartShell);
- DELETEZ(pGraphicShell);
- DELETEZ(pMediaShell);
- DELETEZ(pDrawTextShell);
- DELETEZ(pEditShell);
- DELETEZ(pPivotShell);
- DELETEZ(pAuditingShell);
- DELETEZ(pCurFrameLine);
+ pFontworkBarShell.reset();
+ pExtrusionBarShell.reset();
+ pCellShell.reset();
+ pPageBreakShell.reset();
+ pDrawShell.reset();
+ pDrawFormShell.reset();
+ pOleObjectShell.reset();
+ pChartShell.reset();
+ pGraphicShell.reset();
+ pMediaShell.reset();
+ pDrawTextShell.reset();
+ pEditShell.reset();
+ pPivotShell.reset();
+ pAuditingShell.reset();
+ pCurFrameLine.reset();
mpInputHandler.reset();
- DELETEZ(pPivotSource);
- DELETEZ(pDialogDPObject);
- DELETEZ(pNavSettings);
+ pPivotSource.reset();
+ pDialogDPObject.reset();
+ pNavSettings.reset();
- DELETEZ(pFormShell);
- DELETEZ(pAccessibilityBroadcaster);
+ pFormShell.reset();
+ pAccessibilityBroadcaster.reset();
}
-void ScTabViewShell::SetDialogDPObject( const ScDPObject* pObj )
+void ScTabViewShell::SetDialogDPObject( std::unique_ptr<ScDPObject> pObj )
{
- delete pDialogDPObject;
- if (pObj)
- pDialogDPObject = new ScDPObject( *pObj );
- else
- pDialogDPObject = nullptr;
+ pDialogDPObject = std::move(pObj);
}
void ScTabViewShell::FillFieldData( ScHeaderFieldData& rData )
@@ -1845,8 +1841,8 @@ void ScTabViewShell::FillFieldData( ScHeaderFieldData& rData )
ScNavigatorSettings* ScTabViewShell::GetNavigatorSettings()
{
if( !pNavSettings )
- pNavSettings = new ScNavigatorSettings;
- return pNavSettings;
+ pNavSettings.reset(new ScNavigatorSettings);
+ return pNavSettings.get();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabvwsh8.cxx b/sc/source/ui/view/tabvwsh8.cxx
index bc83876ab6c3..3672d819be55 100644
--- a/sc/source/ui/view/tabvwsh8.cxx
+++ b/sc/source/ui/view/tabvwsh8.cxx
@@ -27,16 +27,12 @@ void ScTabViewShell::SetDefaultFrameLine( const ::editeng::SvxBorderLine* pLine
{
if ( pLine )
{
- delete pCurFrameLine;
- pCurFrameLine = new ::editeng::SvxBorderLine( &pLine->GetColor(),
+ pCurFrameLine.reset( new ::editeng::SvxBorderLine( &pLine->GetColor(),
pLine->GetWidth(),
- pLine->GetBorderLineStyle() );
- }
- else if ( pCurFrameLine )
- {
- delete pCurFrameLine;
- pCurFrameLine = nullptr;
+ pLine->GetBorderLineStyle() ) );
}
+ else
+ pCurFrameLine.reset();
}
bool ScTabViewShell::HasSelection( bool bText ) const
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index c3d4516c5d3e..85f7dba8d8ca 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -419,7 +419,7 @@ VclPtr<SfxModelessDialog> ScTabViewShell::CreateRefDialog(
ScViewData& rViewData = GetViewData();
rViewData.SetRefTabNo( rViewData.GetTabNo() );
ScDPObject* pObj = pDoc->GetDPAtCursor(rViewData.GetCurX(), rViewData.GetCurY(), rViewData.GetTabNo());
- pResult = VclPtr<ScPivotLayoutDialog>::Create(pB, pCW, pParent, &rViewData, pDialogDPObject, pObj == nullptr);
+ pResult = VclPtr<ScPivotLayoutDialog>::Create(pB, pCW, pParent, &rViewData, pDialogDPObject.get(), pObj == nullptr);
}
}
break;
diff --git a/sc/source/ui/view/tabvwshe.cxx b/sc/source/ui/view/tabvwshe.cxx
index d7cac6b903b0..0059534c22dd 100644
--- a/sc/source/ui/view/tabvwshe.cxx
+++ b/sc/source/ui/view/tabvwshe.cxx
@@ -46,7 +46,7 @@ OUString ScTabViewShell::GetSelectionText( bool bWholeWord )
{
OUString aStrSelection;
- if ( pEditShell && pEditShell == GetMySubShell() )
+ if ( pEditShell && pEditShell.get() == GetMySubShell() )
{
aStrSelection = pEditShell->GetSelectionText( bWholeWord );
}
diff --git a/sc/source/ui/view/tabvwshh.cxx b/sc/source/ui/view/tabvwshh.cxx
index ae6215d04cea..aebcfee4c932 100644
--- a/sc/source/ui/view/tabvwshh.cxx
+++ b/sc/source/ui/view/tabvwshh.cxx
@@ -208,7 +208,7 @@ void ScTabViewShell::GetObjectState( SfxItemSet& rSet )
void ScTabViewShell::AddAccessibilityObject( SfxListener& rObject )
{
if (!pAccessibilityBroadcaster)
- pAccessibilityBroadcaster = new SfxBroadcaster;
+ pAccessibilityBroadcaster.reset( new SfxBroadcaster );
rObject.StartListening( *pAccessibilityBroadcaster );
ScDocument* pDoc = GetViewData().GetDocument();