Kaydet (Commit) c7f76297 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in ScTabView

and remove pDrawOld, was not being used for anything useful.

Change-Id: I65ded5758ca5f7636bf7188012707410f59fb81d
Reviewed-on: https://gerrit.libreoffice.org/56910
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 3e837f44
...@@ -668,8 +668,8 @@ void ScDrawShell::ExecFormatPaintbrush( const SfxRequest& rReq ) ...@@ -668,8 +668,8 @@ void ScDrawShell::ExecFormatPaintbrush( const SfxRequest& rReq )
ScDrawView* pDrawView = pViewData->GetScDrawView(); ScDrawView* pDrawView = pViewData->GetScDrawView();
if ( pDrawView && pDrawView->AreObjectsMarked() ) if ( pDrawView && pDrawView->AreObjectsMarked() )
{ {
SfxItemSet* pItemSet = new SfxItemSet( pDrawView->GetAttrFromMarked(true/*bOnlyHardAttr*/) ); std::unique_ptr<SfxItemSet> pItemSet(new SfxItemSet( pDrawView->GetAttrFromMarked(true/*bOnlyHardAttr*/) ));
pView->SetDrawBrushSet( pItemSet, bLock ); pView->SetDrawBrushSet( std::move(pItemSet), bLock );
} }
} }
} }
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <sfx2/ipclient.hxx> #include <sfx2/ipclient.hxx>
#include "fupoor.hxx"
#include "hiranges.hxx" #include "hiranges.hxx"
#include "viewutil.hxx" #include "viewutil.hxx"
#include "select.hxx" #include "select.hxx"
...@@ -147,8 +148,7 @@ private: ...@@ -147,8 +148,7 @@ private:
Size aFrameSize; // passed on as for DoResize Size aFrameSize; // passed on as for DoResize
Point aBorderPos; Point aBorderPos;
FuPoor* pDrawActual; std::unique_ptr<FuPoor> pDrawActual;
FuPoor* pDrawOld;
std::array<VclPtr<ScGridWindow>, 4> pGridWin; std::array<VclPtr<ScGridWindow>, 4> pGridWin;
std::array<VclPtr<ScColBar>, 2> pColBar; std::array<VclPtr<ScColBar>, 2> pColBar;
...@@ -168,11 +168,11 @@ private: ...@@ -168,11 +168,11 @@ private:
std::unique_ptr<sdr::overlay::OverlayObjectList> mxInputHintOO; // help hint for data validation std::unique_ptr<sdr::overlay::OverlayObjectList> mxInputHintOO; // help hint for data validation
ScPageBreakData* pPageBreakData; std::unique_ptr<ScPageBreakData> pPageBreakData;
std::vector<ScHighlightEntry> maHighlightRanges; std::vector<ScHighlightEntry> maHighlightRanges;
ScDocument* pBrushDocument; // cell formats for format paint brush std::unique_ptr<ScDocument> pBrushDocument; // cell formats for format paint brush
SfxItemSet* pDrawBrushSet; // drawing object attributes for paint brush std::unique_ptr<SfxItemSet> pDrawBrushSet; // drawing object attributes for paint brush
Timer aScrollTimer; Timer aScrollTimer;
VclPtr<ScGridWindow> pTimerWindow; VclPtr<ScGridWindow> pTimerWindow;
...@@ -325,16 +325,14 @@ public: ...@@ -325,16 +325,14 @@ public:
bool IsDrawSelMode() const { return bDrawSelMode; } bool IsDrawSelMode() const { return bDrawSelMode; }
void SetDrawSelMode(bool bNew) { bDrawSelMode = bNew; } void SetDrawSelMode(bool bNew) { bDrawSelMode = bNew; }
void SetDrawFuncPtr(FuPoor* pFuncPtr) { pDrawActual = pFuncPtr; } void SetDrawFuncPtr(std::unique_ptr<FuPoor> pFuncPtr);
void SetDrawFuncOldPtr(FuPoor* pFuncPtr) { pDrawOld = pFuncPtr; } FuPoor* GetDrawFuncPtr() { return pDrawActual.get(); }
FuPoor* GetDrawFuncPtr() { return pDrawActual; }
FuPoor* GetDrawFuncOldPtr() { return pDrawOld; }
void DrawDeselectAll(); void DrawDeselectAll();
void DrawMarkListHasChanged(); void DrawMarkListHasChanged();
void UpdateAnchorHandles(); void UpdateAnchorHandles();
ScPageBreakData* GetPageBreakData() { return pPageBreakData; } ScPageBreakData* GetPageBreakData() { return pPageBreakData.get(); }
const std::vector<ScHighlightEntry>& GetHighlightRanges() { return maHighlightRanges; } const std::vector<ScHighlightEntry>& GetHighlightRanges() { return maHighlightRanges; }
void UpdatePageBreakData( bool bForcePaint = false ); void UpdatePageBreakData( bool bForcePaint = false );
...@@ -594,11 +592,11 @@ public: ...@@ -594,11 +592,11 @@ public:
vcl::Window* GetFrameWin() const { return pFrameWin; } vcl::Window* GetFrameWin() const { return pFrameWin; }
bool HasPaintBrush() const { return pBrushDocument || pDrawBrushSet; } bool HasPaintBrush() const { return pBrushDocument || pDrawBrushSet; }
ScDocument* GetBrushDocument() const { return pBrushDocument; } ScDocument* GetBrushDocument() const { return pBrushDocument.get(); }
SfxItemSet* GetDrawBrushSet() const { return pDrawBrushSet; } SfxItemSet* GetDrawBrushSet() const { return pDrawBrushSet.get(); }
bool IsPaintBrushLocked() const { return bLockPaintBrush; } bool IsPaintBrushLocked() const { return bLockPaintBrush; }
void SetBrushDocument( ScDocument* pNew, bool bLock ); void SetBrushDocument( std::unique_ptr<ScDocument> pNew, bool bLock );
void SetDrawBrushSet( SfxItemSet* pNew, bool bLock ); void SetDrawBrushSet( std::unique_ptr<SfxItemSet> pNew, bool bLock );
void ResetBrushDocument(); void ResetBrushDocument();
bool ContinueOnlineSpelling(); bool ContinueOnlineSpelling();
......
...@@ -2796,9 +2796,9 @@ void ScFormatShell::ExecFormatPaintbrush( const SfxRequest& rReq ) ...@@ -2796,9 +2796,9 @@ void ScFormatShell::ExecFormatPaintbrush( const SfxRequest& rReq )
if ( pViewData->GetSimpleArea(aDummy) != SC_MARK_SIMPLE ) if ( pViewData->GetSimpleArea(aDummy) != SC_MARK_SIMPLE )
pView->Unmark(); pView->Unmark();
ScDocument* pBrushDoc = new ScDocument( SCDOCMODE_CLIP ); std::unique_ptr<ScDocument> pBrushDoc(new ScDocument( SCDOCMODE_CLIP ));
pView->CopyToClip( pBrushDoc, false, true ); pView->CopyToClip( pBrushDoc.get(), false, true );
pView->SetBrushDocument( pBrushDoc, bLock ); pView->SetBrushDocument( std::move(pBrushDoc), bLock );
} }
} }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <vcl/help.hxx> #include <vcl/help.hxx>
#include <vcl/settings.hxx> #include <vcl/settings.hxx>
#include <pagedata.hxx>
#include <tabview.hxx> #include <tabview.hxx>
#include <tabvwsh.hxx> #include <tabvwsh.hxx>
#include <document.hxx> #include <document.hxx>
......
...@@ -1446,7 +1446,7 @@ void ScTabView::ErrorMessage(const char* pGlobStrId) ...@@ -1446,7 +1446,7 @@ void ScTabView::ErrorMessage(const char* pGlobStrId)
void ScTabView::UpdatePageBreakData( bool bForcePaint ) void ScTabView::UpdatePageBreakData( bool bForcePaint )
{ {
ScPageBreakData* pNewData = nullptr; std::unique_ptr<ScPageBreakData> pNewData;
if (aViewData.IsPagebreakMode()) if (aViewData.IsPagebreakMode())
{ {
...@@ -1457,9 +1457,9 @@ void ScTabView::UpdatePageBreakData( bool bForcePaint ) ...@@ -1457,9 +1457,9 @@ void ScTabView::UpdatePageBreakData( bool bForcePaint )
sal_uInt16 nCount = rDoc.GetPrintRangeCount(nTab); sal_uInt16 nCount = rDoc.GetPrintRangeCount(nTab);
if (!nCount) if (!nCount)
nCount = 1; nCount = 1;
pNewData = new ScPageBreakData(nCount); pNewData.reset( new ScPageBreakData(nCount) );
ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab, 0,0,nullptr, nullptr, pNewData ); ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab, 0,0,nullptr, nullptr, pNewData.get() );
// ScPrintFunc fills the PageBreakData in ctor // ScPrintFunc fills the PageBreakData in ctor
if ( nCount > 1 ) if ( nCount > 1 )
{ {
...@@ -1472,8 +1472,7 @@ void ScTabView::UpdatePageBreakData( bool bForcePaint ) ...@@ -1472,8 +1472,7 @@ void ScTabView::UpdatePageBreakData( bool bForcePaint )
PaintGrid(); PaintGrid();
} }
delete pPageBreakData; pPageBreakData = std::move(pNewData);
pPageBreakData = pNewData;
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <sfx2/dispatch.hxx> #include <sfx2/dispatch.hxx>
#include <sfx2/lokhelper.hxx> #include <sfx2/lokhelper.hxx>
#include <sfx2/objsh.hxx> #include <sfx2/objsh.hxx>
#include <o3tl/make_unique.hxx>
#include <tabview.hxx> #include <tabview.hxx>
#include <tabvwsh.hxx> #include <tabvwsh.hxx>
...@@ -130,7 +131,6 @@ void ScTabView::Init() ...@@ -130,7 +131,6 @@ void ScTabView::Init()
// UpdateShow is done during resize or a copy of an existing view from ctor // UpdateShow is done during resize or a copy of an existing view from ctor
pDrawActual = nullptr; pDrawActual = nullptr;
pDrawOld = nullptr;
// DrawView cannot be create in the TabView - ctor // DrawView cannot be create in the TabView - ctor
// when the ViewShell isn't constructed yet... // when the ViewShell isn't constructed yet...
...@@ -153,13 +153,12 @@ ScTabView::~ScTabView() ...@@ -153,13 +153,12 @@ ScTabView::~ScTabView()
TransferableHelper::ClearSelection( GetActiveWin() ); // may delete pOld TransferableHelper::ClearSelection( GetActiveWin() ); // may delete pOld
} }
DELETEZ(pBrushDocument); pBrushDocument.reset();
DELETEZ(pDrawBrushSet); pDrawBrushSet.reset();
DELETEZ(pPageBreakData); pPageBreakData.reset();
DELETEZ(pDrawOld); pDrawActual.reset();
DELETEZ(pDrawActual);
if (comphelper::LibreOfficeKit::isActive()) if (comphelper::LibreOfficeKit::isActive())
{ {
...@@ -247,7 +246,7 @@ void ScTabView::MakeDrawView( TriState nForceDesignMode ) ...@@ -247,7 +246,7 @@ void ScTabView::MakeDrawView( TriState nForceDesignMode )
// so that immediately can be drawn // so that immediately can be drawn
} }
SfxRequest aSfxRequest(SID_OBJECT_SELECT, SfxCallMode::SLOT, aViewData.GetViewShell()->GetPool()); SfxRequest aSfxRequest(SID_OBJECT_SELECT, SfxCallMode::SLOT, aViewData.GetViewShell()->GetPool());
SetDrawFuncPtr(new FuSelection(*aViewData.GetViewShell(), GetActiveWin(), pDrawView, SetDrawFuncPtr(o3tl::make_unique<FuSelection>(*aViewData.GetViewShell(), GetActiveWin(), pDrawView,
pLayer,aSfxRequest)); pLayer,aSfxRequest));
// used when switching back from page preview: restore saved design mode state // used when switching back from page preview: restore saved design mode state
...@@ -613,26 +612,20 @@ void ScTabView::MakeVisible( const tools::Rectangle& rHMMRect ) ...@@ -613,26 +612,20 @@ void ScTabView::MakeVisible( const tools::Rectangle& rHMMRect )
} }
} }
void ScTabView::SetBrushDocument( ScDocument* pNew, bool bLock ) void ScTabView::SetBrushDocument( std::unique_ptr<ScDocument> pNew, bool bLock )
{ {
delete pBrushDocument; pDrawBrushSet.reset();
delete pDrawBrushSet; pBrushDocument = std::move(pNew);
pBrushDocument = pNew;
pDrawBrushSet = nullptr;
bLockPaintBrush = bLock; bLockPaintBrush = bLock;
aViewData.GetBindings().Invalidate(SID_FORMATPAINTBRUSH); aViewData.GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
} }
void ScTabView::SetDrawBrushSet( SfxItemSet* pNew, bool bLock ) void ScTabView::SetDrawBrushSet( std::unique_ptr<SfxItemSet> pNew, bool bLock )
{ {
delete pBrushDocument; pBrushDocument.reset();
delete pDrawBrushSet; pDrawBrushSet = std::move(pNew);
pBrushDocument = nullptr;
pDrawBrushSet = pNew;
bLockPaintBrush = bLock; bLockPaintBrush = bLock;
...@@ -691,4 +684,11 @@ void ScTabView::OnLOKNoteStateChanged(const ScPostIt* pNote) ...@@ -691,4 +684,11 @@ void ScTabView::OnLOKNoteStateChanged(const ScPostIt* pNote)
} }
} }
void ScTabView::SetDrawFuncPtr(std::unique_ptr<FuPoor> pNew)
{
if (pDrawActual)
pDrawActual->Deactivate();
pDrawActual = std::move(pNew);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <unotools/moduleoptions.hxx> #include <unotools/moduleoptions.hxx>
#include <svl/languageoptions.hxx> #include <svl/languageoptions.hxx>
#include <sfx2/dispatch.hxx> #include <sfx2/dispatch.hxx>
#include <o3tl/make_unique.hxx>
#include <tabvwsh.hxx> #include <tabvwsh.hxx>
#include <drawsh.hxx> #include <drawsh.hxx>
...@@ -198,14 +199,7 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq) ...@@ -198,14 +199,7 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq)
} }
if (pTabView->GetDrawFuncPtr()) if (pTabView->GetDrawFuncPtr())
{
if (pTabView->GetDrawFuncOldPtr() != pTabView->GetDrawFuncPtr())
delete pTabView->GetDrawFuncOldPtr();
pTabView->GetDrawFuncPtr()->Deactivate();
pTabView->SetDrawFuncOldPtr(pTabView->GetDrawFuncPtr());
pTabView->SetDrawFuncPtr(nullptr); pTabView->SetDrawFuncPtr(nullptr);
}
SfxRequest aNewReq(rReq); SfxRequest aNewReq(rReq);
aNewReq.SetSlot(nDrawSfxId); aNewReq.SetSlot(nDrawSfxId);
...@@ -217,7 +211,7 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq) ...@@ -217,7 +211,7 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq)
case SID_OBJECT_SELECT: case SID_OBJECT_SELECT:
// not always switch back // not always switch back
if(pView->GetMarkedObjectList().GetMarkCount() == 0) SetDrawShell(bEx); if(pView->GetMarkedObjectList().GetMarkCount() == 0) SetDrawShell(bEx);
pTabView->SetDrawFuncPtr(new FuSelection(*this, pWin, pView, pDoc, aNewReq)); pTabView->SetDrawFuncPtr(o3tl::make_unique<FuSelection>(*this, pWin, pView, pDoc, aNewReq));
break; break;
case SID_DRAW_LINE: case SID_DRAW_LINE:
...@@ -232,12 +226,12 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq) ...@@ -232,12 +226,12 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq)
case SID_DRAW_RECT: case SID_DRAW_RECT:
case SID_DRAW_ELLIPSE: case SID_DRAW_ELLIPSE:
case SID_DRAW_MEASURELINE: case SID_DRAW_MEASURELINE:
pTabView->SetDrawFuncPtr(new FuConstRectangle(*this, pWin, pView, pDoc, aNewReq)); pTabView->SetDrawFuncPtr(o3tl::make_unique<FuConstRectangle>(*this, pWin, pView, pDoc, aNewReq));
break; break;
case SID_DRAW_CAPTION: case SID_DRAW_CAPTION:
case SID_DRAW_CAPTION_VERTICAL: case SID_DRAW_CAPTION_VERTICAL:
pTabView->SetDrawFuncPtr(new FuConstRectangle(*this, pWin, pView, pDoc, aNewReq)); pTabView->SetDrawFuncPtr(o3tl::make_unique<FuConstRectangle>(*this, pWin, pView, pDoc, aNewReq));
pView->SetFrameDragSingles( false ); pView->SetFrameDragSingles( false );
rBindings.Invalidate( SID_BEZIER_EDIT ); rBindings.Invalidate( SID_BEZIER_EDIT );
break; break;
...@@ -250,25 +244,25 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq) ...@@ -250,25 +244,25 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq)
case SID_DRAW_BEZIER_FILL: case SID_DRAW_BEZIER_FILL:
case SID_DRAW_FREELINE: case SID_DRAW_FREELINE:
case SID_DRAW_FREELINE_NOFILL: case SID_DRAW_FREELINE_NOFILL:
pTabView->SetDrawFuncPtr(new FuConstPolygon(*this, pWin, pView, pDoc, aNewReq)); pTabView->SetDrawFuncPtr(o3tl::make_unique<FuConstPolygon>(*this, pWin, pView, pDoc, aNewReq));
break; break;
case SID_DRAW_ARC: case SID_DRAW_ARC:
case SID_DRAW_PIE: case SID_DRAW_PIE:
case SID_DRAW_CIRCLECUT: case SID_DRAW_CIRCLECUT:
pTabView->SetDrawFuncPtr(new FuConstArc(*this, pWin, pView, pDoc, aNewReq)); pTabView->SetDrawFuncPtr(o3tl::make_unique<FuConstArc>(*this, pWin, pView, pDoc, aNewReq));
break; break;
case SID_DRAW_TEXT: case SID_DRAW_TEXT:
case SID_DRAW_TEXT_VERTICAL: case SID_DRAW_TEXT_VERTICAL:
case SID_DRAW_TEXT_MARQUEE: case SID_DRAW_TEXT_MARQUEE:
case SID_DRAW_NOTEEDIT: case SID_DRAW_NOTEEDIT:
pTabView->SetDrawFuncPtr(new FuText(*this, pWin, pView, pDoc, aNewReq)); pTabView->SetDrawFuncPtr(o3tl::make_unique<FuText>(*this, pWin, pView, pDoc, aNewReq));
break; break;
case SID_FM_CREATE_CONTROL: case SID_FM_CREATE_CONTROL:
SetDrawFormShell(true); SetDrawFormShell(true);
pTabView->SetDrawFuncPtr(new FuConstUnoControl(*this, pWin, pView, pDoc, aNewReq)); pTabView->SetDrawFuncPtr(o3tl::make_unique<FuConstUnoControl>(*this, pWin, pView, pDoc, aNewReq));
nFormSfxId = nNewFormId; nFormSfxId = nNewFormId;
break; break;
...@@ -280,7 +274,7 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq) ...@@ -280,7 +274,7 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq)
case SID_DRAWTBX_CS_STAR : case SID_DRAWTBX_CS_STAR :
case SID_DRAW_CS_ID : case SID_DRAW_CS_ID :
{ {
pTabView->SetDrawFuncPtr( new FuConstCustomShape(*this, pWin, pView, pDoc, aNewReq)); pTabView->SetDrawFuncPtr( o3tl::make_unique<FuConstCustomShape>(*this, pWin, pView, pDoc, aNewReq));
if ( nNewId != SID_DRAW_CS_ID ) if ( nNewId != SID_DRAW_CS_ID )
{ {
const SfxStringItem* pEnumCommand = rReq.GetArg<SfxStringItem>(nNewId); const SfxStringItem* pEnumCommand = rReq.GetArg<SfxStringItem>(nNewId);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment