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

return unique_ptr from CreateDefaultObject in sc/

Change-Id: I8981050aeadc1efe907e7e9a47d18dc3c72956c2
Reviewed-on: https://gerrit.libreoffice.org/61439
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst e6f52edc
...@@ -116,20 +116,20 @@ void FuConstArc::Deactivate() ...@@ -116,20 +116,20 @@ void FuConstArc::Deactivate()
} }
// Create default drawing objects via keyboard // Create default drawing objects via keyboard
SdrObject* FuConstArc::CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) SdrObjectUniquePtr FuConstArc::CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle)
{ {
// case SID_DRAW_ARC: // case SID_DRAW_ARC:
// case SID_DRAW_PIE: // case SID_DRAW_PIE:
// case SID_DRAW_CIRCLECUT: // case SID_DRAW_CIRCLECUT:
SdrObject* pObj = SdrObjFactory::MakeNewObject( SdrObjectUniquePtr pObj(SdrObjFactory::MakeNewObject(
*pDrDoc, *pDrDoc,
pView->GetCurrentObjInventor(), pView->GetCurrentObjInventor(),
pView->GetCurrentObjIdentifier()); pView->GetCurrentObjIdentifier()));
if(pObj) if(pObj)
{ {
if(dynamic_cast<const SdrCircObj*>( pObj) != nullptr) if(dynamic_cast<const SdrCircObj*>( pObj.get() ) != nullptr)
{ {
tools::Rectangle aRect(rRectangle); tools::Rectangle aRect(rRectangle);
......
...@@ -129,17 +129,17 @@ void FuConstCustomShape::Deactivate() ...@@ -129,17 +129,17 @@ void FuConstCustomShape::Deactivate()
} }
// Create default drawing objects via keyboard // Create default drawing objects via keyboard
SdrObject* FuConstCustomShape::CreateDefaultObject(const sal_uInt16 /* nID */, const tools::Rectangle& rRectangle) SdrObjectUniquePtr FuConstCustomShape::CreateDefaultObject(const sal_uInt16 /* nID */, const tools::Rectangle& rRectangle)
{ {
SdrObject* pObj = SdrObjFactory::MakeNewObject( SdrObjectUniquePtr pObj(SdrObjFactory::MakeNewObject(
*pDrDoc, *pDrDoc,
pView->GetCurrentObjInventor(), pView->GetCurrentObjInventor(),
pView->GetCurrentObjIdentifier()); pView->GetCurrentObjIdentifier()));
if( pObj ) if( pObj )
{ {
tools::Rectangle aRectangle( rRectangle ); tools::Rectangle aRectangle( rRectangle );
SetAttributes( pObj ); SetAttributes( pObj.get() );
if ( SdrObjCustomShape::doConstructOrthogonal( aCustomShape ) ) if ( SdrObjCustomShape::doConstructOrthogonal( aCustomShape ) )
ImpForceQuadratic( aRectangle ); ImpForceQuadratic( aRectangle );
pObj->SetLogicRect( aRectangle ); pObj->SetLogicRect( aRectangle );
......
...@@ -173,7 +173,7 @@ void FuConstPolygon::Deactivate() ...@@ -173,7 +173,7 @@ void FuConstPolygon::Deactivate()
} }
// Create default drawing objects via keyboard // Create default drawing objects via keyboard
SdrObject* FuConstPolygon::CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) SdrObjectUniquePtr FuConstPolygon::CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle)
{ {
// case SID_DRAW_XPOLYGON: // case SID_DRAW_XPOLYGON:
// case SID_DRAW_XPOLYGON_NOFILL: // case SID_DRAW_XPOLYGON_NOFILL:
...@@ -184,14 +184,14 @@ SdrObject* FuConstPolygon::CreateDefaultObject(const sal_uInt16 nID, const tools ...@@ -184,14 +184,14 @@ SdrObject* FuConstPolygon::CreateDefaultObject(const sal_uInt16 nID, const tools
// case SID_DRAW_FREELINE: // case SID_DRAW_FREELINE:
// case SID_DRAW_FREELINE_NOFILL: // case SID_DRAW_FREELINE_NOFILL:
SdrObject* pObj = SdrObjFactory::MakeNewObject( SdrObjectUniquePtr pObj(SdrObjFactory::MakeNewObject(
*pDrDoc, *pDrDoc,
pView->GetCurrentObjInventor(), pView->GetCurrentObjInventor(),
pView->GetCurrentObjIdentifier()); pView->GetCurrentObjIdentifier()));
if(pObj) if(pObj)
{ {
if(dynamic_cast<const SdrPathObj*>( pObj) != nullptr) if(dynamic_cast<const SdrPathObj*>( pObj.get() ) != nullptr)
{ {
basegfx::B2DPolyPolygon aPoly; basegfx::B2DPolyPolygon aPoly;
...@@ -271,7 +271,7 @@ SdrObject* FuConstPolygon::CreateDefaultObject(const sal_uInt16 nID, const tools ...@@ -271,7 +271,7 @@ SdrObject* FuConstPolygon::CreateDefaultObject(const sal_uInt16 nID, const tools
} }
} }
static_cast<SdrPathObj*>(pObj)->SetPathPoly(aPoly); static_cast<SdrPathObj*>(pObj.get())->SetPathPoly(aPoly);
} }
else else
{ {
......
...@@ -353,12 +353,12 @@ void FuConstRectangle::Deactivate() ...@@ -353,12 +353,12 @@ void FuConstRectangle::Deactivate()
} }
// Create default drawing objects via keyboard // Create default drawing objects via keyboard
SdrObject* FuConstRectangle::CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) SdrObjectUniquePtr FuConstRectangle::CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle)
{ {
SdrObject* pObj = SdrObjFactory::MakeNewObject( SdrObjectUniquePtr pObj(SdrObjFactory::MakeNewObject(
*pDrDoc, *pDrDoc,
pView->GetCurrentObjInventor(), pView->GetCurrentObjInventor(),
pView->GetCurrentObjIdentifier()); pView->GetCurrentObjIdentifier()));
if(pObj) if(pObj)
{ {
...@@ -378,13 +378,13 @@ SdrObject* FuConstRectangle::CreateDefaultObject(const sal_uInt16 nID, const too ...@@ -378,13 +378,13 @@ SdrObject* FuConstRectangle::CreateDefaultObject(const sal_uInt16 nID, const too
case SID_LINE_SQUARE_ARROW: case SID_LINE_SQUARE_ARROW:
case SID_LINE_ARROWS: case SID_LINE_ARROWS:
{ {
if(dynamic_cast<const SdrPathObj*>( pObj) != nullptr) if(auto pPathObj = dynamic_cast<SdrPathObj*>( pObj.get() ))
{ {
sal_Int32 nYMiddle((aRect.Top() + aRect.Bottom()) / 2); sal_Int32 nYMiddle((aRect.Top() + aRect.Bottom()) / 2);
basegfx::B2DPolygon aPoly; basegfx::B2DPolygon aPoly;
aPoly.append(basegfx::B2DPoint(aStart.X(), nYMiddle)); aPoly.append(basegfx::B2DPoint(aStart.X(), nYMiddle));
aPoly.append(basegfx::B2DPoint(aEnd.X(), nYMiddle)); aPoly.append(basegfx::B2DPoint(aEnd.X(), nYMiddle));
static_cast<SdrPathObj*>(pObj)->SetPathPoly(basegfx::B2DPolyPolygon(aPoly)); pPathObj->SetPathPoly(basegfx::B2DPolyPolygon(aPoly));
} }
else else
{ {
...@@ -396,11 +396,11 @@ SdrObject* FuConstRectangle::CreateDefaultObject(const sal_uInt16 nID, const too ...@@ -396,11 +396,11 @@ SdrObject* FuConstRectangle::CreateDefaultObject(const sal_uInt16 nID, const too
case SID_DRAW_MEASURELINE: case SID_DRAW_MEASURELINE:
{ {
if(dynamic_cast<const SdrMeasureObj*>( pObj) != nullptr) if(auto pMeasureObj = dynamic_cast<SdrMeasureObj*>( pObj.get() ))
{ {
sal_Int32 nYMiddle((aRect.Top() + aRect.Bottom()) / 2); sal_Int32 nYMiddle((aRect.Top() + aRect.Bottom()) / 2);
static_cast<SdrMeasureObj*>(pObj)->SetPoint(Point(aStart.X(), nYMiddle), 0); pMeasureObj->SetPoint(Point(aStart.X(), nYMiddle), 0);
static_cast<SdrMeasureObj*>(pObj)->SetPoint(Point(aEnd.X(), nYMiddle), 1); pMeasureObj->SetPoint(Point(aEnd.X(), nYMiddle), 1);
} }
break; break;
...@@ -409,11 +409,11 @@ SdrObject* FuConstRectangle::CreateDefaultObject(const sal_uInt16 nID, const too ...@@ -409,11 +409,11 @@ SdrObject* FuConstRectangle::CreateDefaultObject(const sal_uInt16 nID, const too
case SID_DRAW_CAPTION: case SID_DRAW_CAPTION:
case SID_DRAW_CAPTION_VERTICAL: case SID_DRAW_CAPTION_VERTICAL:
{ {
if(dynamic_cast<const SdrCaptionObj*>( pObj) != nullptr) if(auto pCaptionObj = dynamic_cast<SdrCaptionObj*>( pObj.get() ))
{ {
bool bIsVertical(SID_DRAW_CAPTION_VERTICAL == nID); bool bIsVertical(SID_DRAW_CAPTION_VERTICAL == nID);
static_cast<SdrTextObj*>(pObj)->SetVerticalWriting(bIsVertical); pCaptionObj->SetVerticalWriting(bIsVertical);
if(bIsVertical) if(bIsVertical)
{ {
...@@ -427,8 +427,8 @@ SdrObject* FuConstRectangle::CreateDefaultObject(const sal_uInt16 nID, const too ...@@ -427,8 +427,8 @@ SdrObject* FuConstRectangle::CreateDefaultObject(const sal_uInt16 nID, const too
// (Edit mode is started in ScTabViewShell::ExecDraw, because // (Edit mode is started in ScTabViewShell::ExecDraw, because
// it must be handled by FuText) // it must be handled by FuText)
static_cast<SdrCaptionObj*>(pObj)->SetLogicRect(aRect); pCaptionObj->SetLogicRect(aRect);
static_cast<SdrCaptionObj*>(pObj)->SetTailPos( pCaptionObj->SetTailPos(
aRect.TopLeft() - Point(aRect.GetWidth() / 2, aRect.GetHeight() / 2)); aRect.TopLeft() - Point(aRect.GetWidth() / 2, aRect.GetHeight() / 2));
} }
else else
......
...@@ -106,14 +106,14 @@ void FuConstUnoControl::Deactivate() ...@@ -106,14 +106,14 @@ void FuConstUnoControl::Deactivate()
} }
// Create default drawing objects via keyboard // Create default drawing objects via keyboard
SdrObject* FuConstUnoControl::CreateDefaultObject(const sal_uInt16 /* nID */, const tools::Rectangle& rRectangle) SdrObjectUniquePtr FuConstUnoControl::CreateDefaultObject(const sal_uInt16 /* nID */, const tools::Rectangle& rRectangle)
{ {
// case SID_FM_CREATE_CONTROL: // case SID_FM_CREATE_CONTROL:
SdrObject* pObj = SdrObjFactory::MakeNewObject( SdrObjectUniquePtr pObj(SdrObjFactory::MakeNewObject(
*pDrDoc, *pDrDoc,
pView->GetCurrentObjInventor(), pView->GetCurrentObjInventor(),
pView->GetCurrentObjIdentifier()); pView->GetCurrentObjIdentifier()));
if(pObj) if(pObj)
{ {
......
...@@ -223,7 +223,7 @@ void FuPoor::StopDragTimer() ...@@ -223,7 +223,7 @@ void FuPoor::StopDragTimer()
} }
// Create default drawing objects via keyboard // Create default drawing objects via keyboard
SdrObject* FuPoor::CreateDefaultObject(const sal_uInt16 /* nID */, const tools::Rectangle& /* rRectangle */) SdrObjectUniquePtr FuPoor::CreateDefaultObject(const sal_uInt16 /* nID */, const tools::Rectangle& /* rRectangle */)
{ {
// empty base implementation // empty base implementation
return nullptr; return nullptr;
......
...@@ -636,23 +636,22 @@ void FuText::SetInEditMode(SdrObject* pObj, const Point* pMousePixel, ...@@ -636,23 +636,22 @@ void FuText::SetInEditMode(SdrObject* pObj, const Point* pMousePixel,
} }
// Create default drawing objects via keyboard // Create default drawing objects via keyboard
SdrObject* FuText::CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) SdrObjectUniquePtr FuText::CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle)
{ {
// 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:
SdrObject* pObj = SdrObjFactory::MakeNewObject( SdrObjectUniquePtr pObj(SdrObjFactory::MakeNewObject(
*pDrDoc, *pDrDoc,
pView->GetCurrentObjInventor(), pView->GetCurrentObjInventor(),
pView->GetCurrentObjIdentifier()); pView->GetCurrentObjIdentifier()));
if(pObj) if(pObj)
{ {
if(dynamic_cast<const SdrTextObj*>( pObj) != nullptr) if(auto pText = dynamic_cast<SdrTextObj*>( pObj.get() ))
{ {
SdrTextObj* pText = static_cast<SdrTextObj*>(pObj);
pText->SetLogicRect(rRectangle); pText->SetLogicRect(rRectangle);
// don't set default text, start edit mode instead // don't set default text, start edit mode instead
...@@ -690,7 +689,7 @@ SdrObject* FuText::CreateDefaultObject(const sal_uInt16 nID, const tools::Rectan ...@@ -690,7 +689,7 @@ SdrObject* FuText::CreateDefaultObject(const sal_uInt16 nID, const tools::Rectan
pObj->SetMergedItemSetAndBroadcast(aSet); pObj->SetMergedItemSetAndBroadcast(aSet);
} }
SetInEditMode( pObj ); // start edit mode SetInEditMode( pObj.get() ); // start edit mode
} }
else else
{ {
......
...@@ -38,7 +38,7 @@ public: ...@@ -38,7 +38,7 @@ public:
virtual void Deactivate() override; virtual void Deactivate() override;
// Create default drawing objects via keyboard // Create default drawing objects via keyboard
virtual SdrObject* CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) override; virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) override;
}; };
#endif // _SD_FUCONARC_HXX #endif // _SD_FUCONARC_HXX
......
...@@ -41,7 +41,7 @@ public: ...@@ -41,7 +41,7 @@ public:
virtual void Deactivate() override; virtual void Deactivate() override;
// Create default drawing objects via keyboard // Create default drawing objects via keyboard
virtual SdrObject* CreateDefaultObject( const sal_uInt16 nID, const tools::Rectangle& rRectangle ) override; virtual SdrObjectUniquePtr CreateDefaultObject( const sal_uInt16 nID, const tools::Rectangle& rRectangle ) override;
// #i33136# // #i33136#
virtual bool doConstructOrthogonal() const override; virtual bool doConstructOrthogonal() const override;
......
...@@ -39,7 +39,7 @@ public: ...@@ -39,7 +39,7 @@ public:
virtual void Deactivate() override; virtual void Deactivate() override;
// Create default drawing objects via keyboard // Create default drawing objects via keyboard
virtual SdrObject* CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) override; virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) override;
}; };
#endif // _FUCONPOL_HXX #endif // _FUCONPOL_HXX
......
...@@ -39,7 +39,7 @@ public: ...@@ -39,7 +39,7 @@ public:
static void SetLineEnds(SfxItemSet& rAttr, const SdrObject& rObj, sal_uInt16 nSlotId); static void SetLineEnds(SfxItemSet& rAttr, const SdrObject& rObj, sal_uInt16 nSlotId);
// Create default drawing objects via keyboard // Create default drawing objects via keyboard
virtual SdrObject* CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) override; virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) override;
}; };
#endif // _SD_FUCONREC_HXX #endif // _SD_FUCONREC_HXX
......
...@@ -43,7 +43,7 @@ public: ...@@ -43,7 +43,7 @@ public:
virtual void Deactivate() override; virtual void Deactivate() override;
// Create default drawing objects via keyboard // Create default drawing objects via keyboard
virtual SdrObject* CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) override; virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) override;
}; };
#endif // _SD_FUCONCTL_HXX #endif // _SD_FUCONCTL_HXX
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <vcl/event.hxx> #include <vcl/event.hxx>
#include <vcl/timer.hxx> #include <vcl/timer.hxx>
#include <sfx2/request.hxx> #include <sfx2/request.hxx>
#include <svx/svdobj.hxx>
class ScDrawView; class ScDrawView;
class ScTabViewShell; class ScTabViewShell;
...@@ -97,7 +98,7 @@ public: ...@@ -97,7 +98,7 @@ public:
void StopDragTimer(); void StopDragTimer();
// Create default drawing objects via keyboard // Create default drawing objects via keyboard
virtual SdrObject* CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle); virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle);
protected: protected:
static void ImpForceQuadratic(tools::Rectangle& rRect); static void ImpForceQuadratic(tools::Rectangle& rRect);
......
...@@ -50,7 +50,7 @@ public: ...@@ -50,7 +50,7 @@ public:
void StopEditMode(); void StopEditMode();
// Create default drawing objects via keyboard // Create default drawing objects via keyboard
virtual SdrObject* CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) override; virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle& rRectangle) override;
private: private:
std::unique_ptr<SdrOutliner> MakeOutliner(); std::unique_ptr<SdrOutliner> MakeOutliner();
......
...@@ -335,12 +335,12 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq) ...@@ -335,12 +335,12 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq)
if(pPageView) if(pPageView)
{ {
// create the default object // create the default object
SdrObject* pObj = pFuActual->CreateDefaultObject(nNewId, aNewObjectRectangle); SdrObjectUniquePtr pObj = pFuActual->CreateDefaultObject(nNewId, aNewObjectRectangle);
if(pObj) if(pObj)
{ {
// insert into page // insert into page
pView->InsertObjectAtView(pObj, *pPageView); pView->InsertObjectAtView(pObj.release(), *pPageView);
if ( nNewId == SID_DRAW_CAPTION || nNewId == SID_DRAW_CAPTION_VERTICAL ) if ( nNewId == SID_DRAW_CAPTION || nNewId == SID_DRAW_CAPTION_VERTICAL )
{ {
......
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