diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-07-10 14:06:47 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-07-11 08:07:42 +0200 |
commit | 877362dadf34c910365490ce53b2dcf902dab8cc (patch) | |
tree | 91b0c0b1fd827539e971ca20fd46d1fe69d25531 /sc/source | |
parent | 72eb6f7e47d7c8c19c76cea67330464af47648f1 (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')
-rw-r--r-- | sc/source/ui/dbgui/PivotLayoutDialog.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/inc/tabvwsh.hxx | 52 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh1.cxx | 7 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwsh4.cxx | 98 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwsh8.cxx | 12 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwshc.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwshe.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwshh.cxx | 2 |
8 files changed, 86 insertions, 92 deletions
diff --git a/sc/source/ui/dbgui/PivotLayoutDialog.cxx b/sc/source/ui/dbgui/PivotLayoutDialog.cxx index 70f436c0396e..e12be901ba99 100644 --- a/sc/source/ui/dbgui/PivotLayoutDialog.cxx +++ b/sc/source/ui/dbgui/PivotLayoutDialog.cxx @@ -13,6 +13,7 @@ #include <PivotLayoutDialog.hxx> #include <reffact.hxx> #include <svtools/treelistentry.hxx> +#include <o3tl/make_unique.hxx> #include <rangeutl.hxx> #include <uiitems.hxx> @@ -503,7 +504,7 @@ void ScPivotLayoutDialog::ApplyChanges() sal_uInt16 nWhichPivot = SC_MOD()->GetPool().GetWhich(SID_PIVOT_TABLE); ScPivotItem aPivotItem(nWhichPivot, &aSaveData, &aDestinationRange, bToNewSheet); - mpViewData->GetViewShell()->SetDialogDPObject(&maPivotTableObject); + mpViewData->GetViewShell()->SetDialogDPObject(o3tl::make_unique<ScDPObject>(maPivotTableObject)); SfxDispatcher* pDispatcher = GetBindings().GetDispatcher(); diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx index a59a0ae265ac..fd531de17a8b 100644 --- a/sc/source/ui/inc/tabvwsh.hxx +++ b/sc/source/ui/inc/tabvwsh.hxx @@ -99,26 +99,26 @@ private: sal_uInt16 nDrawSfxId; sal_uInt16 nFormSfxId; OUString sDrawCustom; // current custom shape type - ScDrawShell* pDrawShell; - ScDrawTextObjectBar* pDrawTextShell; - ScEditShell* pEditShell; - ScPivotShell* pPivotShell; - ScAuditingShell* pAuditingShell; - ScDrawFormShell* pDrawFormShell; - ScCellShell* pCellShell; - ScOleObjectShell* pOleObjectShell; - ScChartShell* pChartShell; - ScGraphicShell* pGraphicShell; - ScMediaShell* pMediaShell; - ScPageBreakShell* pPageBreakShell; - svx::ExtrusionBar* pExtrusionBarShell; - svx::FontworkBar* pFontworkBarShell; - - FmFormShell* pFormShell; + std::unique_ptr<ScDrawShell> pDrawShell; + std::unique_ptr<ScDrawTextObjectBar> pDrawTextShell; + std::unique_ptr<ScEditShell> pEditShell; + std::unique_ptr<ScPivotShell> pPivotShell; + std::unique_ptr<ScAuditingShell> pAuditingShell; + std::unique_ptr<ScDrawFormShell> pDrawFormShell; + std::unique_ptr<ScCellShell> pCellShell; + std::unique_ptr<ScOleObjectShell> pOleObjectShell; + std::unique_ptr<ScChartShell> pChartShell; + std::unique_ptr<ScGraphicShell> pGraphicShell; + std::unique_ptr<ScMediaShell> pMediaShell; + std::unique_ptr<ScPageBreakShell> pPageBreakShell; + std::unique_ptr<svx::ExtrusionBar> pExtrusionBarShell; + std::unique_ptr<svx::FontworkBar> pFontworkBarShell; + + std::unique_ptr<FmFormShell> pFormShell; std::unique_ptr<ScInputHandler, o3tl::default_delete<ScInputHandler>> mpInputHandler; // for OLE input cell - ::editeng::SvxBorderLine* pCurFrameLine; + std::unique_ptr<::editeng::SvxBorderLine> pCurFrameLine; css::uno::Reference< css::frame::XDispatchProviderInterceptor > xDisProvInterceptor; @@ -126,10 +126,10 @@ private: Point aWinPos; ScTabViewTarget aTarget; - ScArea* pPivotSource; - ScDPObject* pDialogDPObject; + std::unique_ptr<ScArea> pPivotSource; + std::unique_ptr<ScDPObject> pDialogDPObject; - ScNavigatorSettings* pNavSettings; + std::unique_ptr<ScNavigatorSettings> pNavSettings; // used in first Activate bool bFirstActivate; @@ -159,7 +159,7 @@ private: sal_uInt16 nCurRefDlgId; - SfxBroadcaster* pAccessibilityBroadcaster; + std::unique_ptr<SfxBroadcaster> pAccessibilityBroadcaster; // ugly hack for Add button in ScNameDlg std::map<OUString, std::unique_ptr<ScRangeName>> m_RangeMap; @@ -240,7 +240,7 @@ public: void SetActive(); - ::editeng::SvxBorderLine* GetDefaultFrameLine() const { return pCurFrameLine; } + ::editeng::SvxBorderLine* GetDefaultFrameLine() const { return pCurFrameLine.get(); } void SetDefaultFrameLine(const ::editeng::SvxBorderLine* pLine ); void Execute( SfxRequest& rReq ); @@ -279,8 +279,8 @@ public: void SetDrawTextShell( bool bActive ); void SetPivotShell( bool bActive ); - void SetDialogDPObject( const ScDPObject* pObj ); - const ScDPObject* GetDialogDPObject() const { return pDialogDPObject; } + void SetDialogDPObject( std::unique_ptr<ScDPObject> pObj ); + const ScDPObject* GetDialogDPObject() const { return pDialogDPObject.get(); } void SetDontSwitch(bool bFlag){bDontSwitch=bFlag;} @@ -333,8 +333,8 @@ public: void UpdateOleZoom(); - virtual const FmFormShell* GetFormShell() const override { return pFormShell; } - virtual FmFormShell* GetFormShell() override { return pFormShell; } + virtual const FmFormShell* GetFormShell() const override { return pFormShell.get(); } + virtual FmFormShell* GetFormShell() override { return pFormShell.get(); } void InsertURL( const OUString& rName, const OUString& rURL, const OUString& rTarget, sal_uInt16 nMode ); 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(); |