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

return by unique_ptr from CreateDefaultObject in sd/

Change-Id: I6e103ef4b858ceb0d350069f523cb3cb670fe95b
Reviewed-on: https://gerrit.libreoffice.org/61440
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 94bf82a8
......@@ -380,7 +380,7 @@ void FuConstruct3dObject::Activate()
FuConstruct::Activate();
}
SdrObject* FuConstruct3dObject::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle)
SdrObjectUniquePtr FuConstruct3dObject::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle)
{
E3dCompoundObject* p3DObj = ImpCreateBasic3DShape();
......@@ -393,7 +393,7 @@ SdrObject* FuConstruct3dObject::CreateDefaultObject(const sal_uInt16 nID, const
double fW(aVolume.getWidth());
double fH(aVolume.getHeight());
::tools::Rectangle a3DRect(0, 0, static_cast<long>(fW), static_cast<long>(fH));
E3dScene* pScene = new E3dScene(*mpDoc);
std::unique_ptr< E3dScene, SdrObjectFreeOp > pScene(new E3dScene(*mpDoc));
// copied code from E3dView::InitScene
double fCamZ(aVolume.getMaxZ() + ((fW + fH) / 4.0));
......@@ -409,7 +409,7 @@ SdrObject* FuConstruct3dObject::CreateDefaultObject(const sal_uInt16 nID, const
pScene->SetCamera(aCam);
pScene->InsertObject(p3DObj);
pScene->NbcSetSnapRect(a3DRect);
ImpPrepareBasic3DShape(p3DObj, pScene);
ImpPrepareBasic3DShape(p3DObj, pScene.get());
SfxItemSet aAttr(mpDoc->GetPool());
SetStyleSheet(aAttr, p3DObj);
aAttr.Put(XLineStyleItem (drawing::LineStyle_NONE));
......@@ -451,7 +451,7 @@ SdrObject* FuConstruct3dObject::CreateDefaultObject(const sal_uInt16 nID, const
// use changed rectangle, not original one
pScene->SetLogicRect(aRect);
return pScene;
return SdrObjectUniquePtr(pScene.release());
}
} // end of namespace sd
......
......@@ -200,17 +200,17 @@ void FuConstructArc::Activate()
FuConstruct::Activate();
}
SdrObject* FuConstructArc::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle)
SdrObjectUniquePtr FuConstructArc::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle)
{
SdrObject* pObj = SdrObjFactory::MakeNewObject(
SdrObjectUniquePtr pObj(SdrObjFactory::MakeNewObject(
mpView->getSdrModelFromSdrView(),
mpView->GetCurrentObjInventor(),
mpView->GetCurrentObjIdentifier());
mpView->GetCurrentObjIdentifier()));
if(pObj)
{
if( dynamic_cast< const SdrCircObj *>( pObj ) != nullptr)
if( dynamic_cast< const SdrCircObj *>( pObj.get() ) != nullptr)
{
::tools::Rectangle aRect(rRectangle);
......
......@@ -298,7 +298,7 @@ void FuConstructBezierPolygon::SetEditMode(sal_uInt16 nMode)
rBindings.Invalidate(SID_BEZIER_INSERT);
}
SdrObject* FuConstructBezierPolygon::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle)
SdrObjectUniquePtr FuConstructBezierPolygon::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle)
{
// case SID_DRAW_POLYGON:
// case SID_DRAW_POLYGON_NOFILL:
......@@ -309,14 +309,14 @@ SdrObject* FuConstructBezierPolygon::CreateDefaultObject(const sal_uInt16 nID, c
// case SID_DRAW_BEZIER_FILL: // BASIC
// case SID_DRAW_BEZIER_NOFILL: // BASIC
SdrObject* pObj = SdrObjFactory::MakeNewObject(
SdrObjectUniquePtr pObj(SdrObjFactory::MakeNewObject(
mpView->getSdrModelFromSdrView(),
mpView->GetCurrentObjInventor(),
mpView->GetCurrentObjIdentifier());
mpView->GetCurrentObjIdentifier()));
if(pObj)
{
if( dynamic_cast< const SdrPathObj *>( pObj ) != nullptr)
if( auto pPathObj = dynamic_cast< SdrPathObj *>( pObj.get() ) )
{
basegfx::B2DPolyPolygon aPoly;
......@@ -435,7 +435,7 @@ SdrObject* FuConstructBezierPolygon::CreateDefaultObject(const sal_uInt16 nID, c
}
}
static_cast<SdrPathObj*>(pObj)->SetPathPoly(aPoly);
pPathObj->SetPathPoly(aPoly);
}
else
{
......
......@@ -234,12 +234,12 @@ const OUString& FuConstructCustomShape::GetShapeType() const
return aCustomShape;
}
SdrObject* FuConstructCustomShape::CreateDefaultObject(const sal_uInt16, const ::tools::Rectangle& rRectangle)
SdrObjectUniquePtr FuConstructCustomShape::CreateDefaultObject(const sal_uInt16, const ::tools::Rectangle& rRectangle)
{
SdrObject* pObj = SdrObjFactory::MakeNewObject(
SdrObjectUniquePtr pObj(SdrObjFactory::MakeNewObject(
mpView->getSdrModelFromSdrView(),
mpView->GetCurrentObjInventor(),
mpView->GetCurrentObjIdentifier());
mpView->GetCurrentObjIdentifier()));
if( pObj )
{
......@@ -247,9 +247,9 @@ SdrObject* FuConstructCustomShape::CreateDefaultObject(const sal_uInt16, const :
if ( doConstructOrthogonal() )
ImpForceQuadratic( aRect );
pObj->SetLogicRect( aRect );
SetAttributes( pObj );
SetAttributes( pObj.get() );
SfxItemSet aAttr(mpDoc->GetPool());
SetStyleSheet(aAttr, pObj);
SetStyleSheet(aAttr, pObj.get());
pObj->SetMergedItemSet(aAttr);
}
return pObj;
......
......@@ -711,7 +711,7 @@ void FuConstructRectangle::SetLineEnds(SfxItemSet& rAttr, SdrObject const & rObj
}
}
SdrObject* FuConstructRectangle::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle)
SdrObjectUniquePtr FuConstructRectangle::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle)
{
DBG_ASSERT( (nID != SID_DRAW_FONTWORK) && (nID != SID_DRAW_FONTWORK_VERTICAL ), "FuConstRectangle::CreateDefaultObject can not create Fontwork shapes!" );
......@@ -768,10 +768,10 @@ SdrObject* FuConstructRectangle::CreateDefaultObject(const sal_uInt16 nID, const
// case SID_CONNECTOR_LINES_CIRCLE_END:
// case SID_CONNECTOR_LINES_CIRCLES:
SdrObject* pObj = SdrObjFactory::MakeNewObject(
SdrObjectUniquePtr pObj(SdrObjFactory::MakeNewObject(
mpView->getSdrModelFromSdrView(),
mpView->GetCurrentObjInventor(),
mpView->GetCurrentObjIdentifier());
mpView->GetCurrentObjIdentifier()));
if(pObj)
{
......@@ -803,14 +803,14 @@ SdrObject* FuConstructRectangle::CreateDefaultObject(const sal_uInt16 nID, const
case SID_LINE_ARROW_SQUARE:
case SID_LINE_SQUARE_ARROW:
{
if( dynamic_cast< const SdrPathObj *>( pObj ) != nullptr)
if( auto pPathObj = dynamic_cast<SdrPathObj *>( pObj.get() ) )
{
sal_Int32 nYMiddle((aRect.Top() + aRect.Bottom()) / 2);
::basegfx::B2DPolygon aB2DPolygon;
aB2DPolygon.append(::basegfx::B2DPoint(aStart.X(), nYMiddle));
aB2DPolygon.append(::basegfx::B2DPoint(aEnd.X(), nYMiddle));
static_cast<SdrPathObj*>(pObj)->SetPathPoly(::basegfx::B2DPolyPolygon(aB2DPolygon));
pPathObj->SetPathPoly(::basegfx::B2DPolyPolygon(aB2DPolygon));
}
else
{
......@@ -822,7 +822,7 @@ SdrObject* FuConstructRectangle::CreateDefaultObject(const sal_uInt16 nID, const
case SID_DRAW_MEASURELINE:
{
if( auto pMeasureObj = dynamic_cast< SdrMeasureObj *>( pObj ) )
if( auto pMeasureObj = dynamic_cast< SdrMeasureObj *>( pObj.get() ) )
{
sal_Int32 nYMiddle((aRect.Top() + aRect.Bottom()) / 2);
pMeasureObj->SetPoint(Point(aStart.X(), nYMiddle), 0);
......@@ -865,7 +865,7 @@ SdrObject* FuConstructRectangle::CreateDefaultObject(const sal_uInt16 nID, const
case SID_CONNECTOR_LINES_CIRCLE_END:
case SID_CONNECTOR_LINES_CIRCLES:
{
if( auto pEdgeObj = dynamic_cast< SdrEdgeObj *>( pObj ) )
if( auto pEdgeObj = dynamic_cast< SdrEdgeObj *>( pObj.get() ) )
{
pEdgeObj->SetTailPoint(false, aStart);
pEdgeObj->SetTailPoint(true, aEnd);
......@@ -880,11 +880,11 @@ SdrObject* FuConstructRectangle::CreateDefaultObject(const sal_uInt16 nID, const
case SID_DRAW_CAPTION:
case SID_DRAW_CAPTION_VERTICAL:
{
if( auto pCaptionObj = dynamic_cast< SdrCaptionObj *>( pObj ) )
if( auto pCaptionObj = dynamic_cast< SdrCaptionObj *>( pObj.get() ) )
{
bool bIsVertical(SID_DRAW_CAPTION_VERTICAL == nID);
static_cast<SdrTextObj*>(pObj)->SetVerticalWriting(bIsVertical);
pCaptionObj->SetVerticalWriting(bIsVertical);
if(bIsVertical)
{
......@@ -917,8 +917,8 @@ SdrObject* FuConstructRectangle::CreateDefaultObject(const sal_uInt16 nID, const
}
SfxItemSet aAttr(mpDoc->GetPool());
SetStyleSheet(aAttr, pObj);
SetAttributes(aAttr, pObj);
SetStyleSheet(aAttr, pObj.get());
SetAttributes(aAttr, pObj.get());
SetLineEnds(aAttr, *pObj);
pObj->SetMergedItemSet(aAttr);
}
......
......@@ -134,14 +134,14 @@ void FuConstructUnoControl::Deactivate()
mpWindow->SetPointer( aOldPointer );
}
SdrObject* FuConstructUnoControl::CreateDefaultObject(const sal_uInt16, const ::tools::Rectangle& rRectangle)
SdrObjectUniquePtr FuConstructUnoControl::CreateDefaultObject(const sal_uInt16, const ::tools::Rectangle& rRectangle)
{
// case SID_FM_CREATE_CONTROL:
SdrObject* pObj = SdrObjFactory::MakeNewObject(
SdrObjectUniquePtr pObj(SdrObjFactory::MakeNewObject(
mpView->getSdrModelFromSdrView(),
mpView->GetCurrentObjInventor(),
mpView->GetCurrentObjIdentifier());
mpView->GetCurrentObjIdentifier()));
if(pObj)
{
......
......@@ -1019,7 +1019,7 @@ void FuPoor::ReceiveRequest(SfxRequest& /*rReq*/)
{
}
SdrObject* FuPoor::CreateDefaultObject(const sal_uInt16, const ::tools::Rectangle& )
SdrObjectUniquePtr FuPoor::CreateDefaultObject(const sal_uInt16, const ::tools::Rectangle& )
{
// empty base implementation
return nullptr;
......
......@@ -1304,17 +1304,17 @@ void FuText::DoubleClick(const MouseEvent& )
/** Removed the insertion of default text and putting a new text
object directly into edit mode.
*/
SdrObject* FuText::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle)
SdrObjectUniquePtr FuText::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle)
{
SdrObject* pObj = SdrObjFactory::MakeNewObject(
SdrObjectUniquePtr pObj( SdrObjFactory::MakeNewObject(
mpView->getSdrModelFromSdrView(),
mpView->GetCurrentObjInventor(),
mpView->GetCurrentObjIdentifier(),
nullptr);
nullptr) );
if(pObj)
{
if( auto pText = dynamic_cast< SdrTextObj *>( pObj ) )
if( auto pText = dynamic_cast< SdrTextObj *>( pObj.get() ) )
{
pText->SetLogicRect(rRectangle);
......
......@@ -43,7 +43,7 @@ public:
virtual void Activate() override;
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:
FuConstruct3dObject (
......
......@@ -38,7 +38,7 @@ public:
virtual void Activate() override;
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:
FuConstructArc (
......
......@@ -47,7 +47,7 @@ public:
void SetEditMode(sal_uInt16 nMode);
sal_uInt16 GetEditMode() { return nEditMode; }
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:
FuConstructBezierPolygon (
......
......@@ -45,7 +45,7 @@ public:
void SetAttributes( SdrObject* pObj );
const OUString& GetShapeType() const;
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#
virtual bool doConstructOrthogonal() const override;
......
......@@ -49,7 +49,7 @@ public:
void SetAttributes(SfxItemSet& rAttr, SdrObject* pObj);
void SetLineEnds(SfxItemSet& rAttr, SdrObject const & rObj);
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:
FuConstructRectangle (
......
......@@ -45,7 +45,7 @@ public:
virtual void Activate() override;
virtual void Deactivate() override;
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:
FuConstructUnoControl(
......
......@@ -24,6 +24,7 @@
#include <tools/link.hxx>
#include <tools/gen.hxx>
#include <vcl/vclptr.hxx>
#include <svx/svdobj.hxx>
#include <helper/simplereferencecomponent.hxx>
......@@ -89,7 +90,7 @@ public:
void StartDelayToScrollTimer ();
virtual SdrObject* CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle);
virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle);
/** is called when the current function should be aborted. <p>
This is used when a function gets a KEY_ESCAPE but can also
......
......@@ -55,7 +55,7 @@ public:
void DeleteDefaultText();
SdrTextObj* GetTextObj() { return mxTextObj.get(); }
virtual SdrObject* CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle) override;
virtual SdrObjectUniquePtr CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle) override;
/** is called when the current function should be aborted. <p>
This is used when a function gets a KEY_ESCAPE but can also
......
......@@ -615,12 +615,13 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
if(pPageView)
{
// create the default object
SdrObject* pObj = GetCurrentFunction()->CreateDefaultObject(nSId, aNewObjectRectangle);
SdrObjectUniquePtr pObj = GetCurrentFunction()->CreateDefaultObject(nSId, aNewObjectRectangle);
if(pObj)
{
auto pObjTmp = pObj.get();
// insert into page
GetView()->InsertObjectAtView(pObj, *pPageView);
GetView()->InsertObjectAtView(pObj.release(), *pPageView);
// Now that pFuActual has done what it was created for we
// can switch on the edit mode for callout objects.
......@@ -635,7 +636,7 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
ExecuteList(SID_TEXTEDIT, SfxCallMode::SYNCHRON |
SfxCallMode::RECORD, { &aItem });
// Put text object into edit mode.
GetView()->SdrBeginTextEdit(static_cast<SdrTextObj*>(pObj), pPageView);
GetView()->SdrBeginTextEdit(static_cast<SdrTextObj*>(pObjTmp), pPageView);
break;
}
}
......
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