summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-06-11 16:05:21 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-06-20 11:16:34 +0200
commitcebcb879c169171f9c1306999e3843d081f4c2ce (patch)
tree74d46ecb1dc86062c94eb8cbba71b997123482b0
parentd79b0d8648067055616de6f8913e5dbbac5311f4 (diff)
loplugin:useuniqueptr in PropertyControl
Change-Id: I6b648f26f3946da27585a70f18406e92d9de80c2 Reviewed-on: https://gerrit.libreoffice.org/56107 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sd/source/ui/animations/CustomAnimationDialog.cxx31
-rw-r--r--sd/source/ui/animations/CustomAnimationDialog.hxx8
-rw-r--r--sd/source/ui/animations/CustomAnimationPane.cxx5
3 files changed, 21 insertions, 23 deletions
diff --git a/sd/source/ui/animations/CustomAnimationDialog.cxx b/sd/source/ui/animations/CustomAnimationDialog.cxx
index 95f23249006f..224bf1223bc1 100644
--- a/sd/source/ui/animations/CustomAnimationDialog.cxx
+++ b/sd/source/ui/animations/CustomAnimationDialog.cxx
@@ -2285,18 +2285,15 @@ PropertyControl::~PropertyControl()
void PropertyControl::dispose()
{
- delete mpSubControl;
+ mpSubControl.reset();
ListBox::dispose();
}
-void PropertyControl::setSubControl( PropertySubControl* pSubControl )
+void PropertyControl::setSubControl( std::unique_ptr<PropertySubControl> pSubControl )
{
- if( mpSubControl && mpSubControl != pSubControl )
- delete mpSubControl;
+ mpSubControl = std::move(pSubControl);
- mpSubControl = pSubControl;
-
- Control* pControl = pSubControl ? pSubControl->getControl() : nullptr;
+ Control* pControl = mpSubControl ? mpSubControl->getControl() : nullptr;
if( pControl )
{
@@ -2323,15 +2320,15 @@ PropertySubControl::~PropertySubControl()
{
}
-PropertySubControl* PropertySubControl::create( sal_Int32 nType, vcl::Window* pParent, const Any& rValue, const OUString& rPresetId, const Link<LinkParamNone*,void>& rModifyHdl )
+std::unique_ptr<PropertySubControl> PropertySubControl::create( sal_Int32 nType, vcl::Window* pParent, const Any& rValue, const OUString& rPresetId, const Link<LinkParamNone*,void>& rModifyHdl )
{
- PropertySubControl* pSubControl = nullptr;
+ std::unique_ptr<PropertySubControl> pSubControl;
switch( nType )
{
case nPropertyTypeDirection:
case nPropertyTypeSpokes:
case nPropertyTypeZoom:
- pSubControl = new PresetPropertyBox( nType, pParent, rValue, rPresetId, rModifyHdl );
+ pSubControl.reset( new PresetPropertyBox( nType, pParent, rValue, rPresetId, rModifyHdl ) );
break;
case nPropertyTypeColor:
@@ -2339,31 +2336,31 @@ PropertySubControl* PropertySubControl::create( sal_Int32 nType, vcl::Window* pP
case nPropertyTypeFirstColor:
case nPropertyTypeCharColor:
case nPropertyTypeLineColor:
- pSubControl = new ColorPropertyBox( nType, pParent, rValue, rModifyHdl );
+ pSubControl.reset( new ColorPropertyBox( nType, pParent, rValue, rModifyHdl ) );
break;
case nPropertyTypeFont:
- pSubControl = new FontPropertyBox( nType, pParent, rValue, rModifyHdl );
+ pSubControl.reset( new FontPropertyBox( nType, pParent, rValue, rModifyHdl ) );
break;
case nPropertyTypeCharHeight:
- pSubControl = new CharHeightPropertyBox( nType, pParent, rValue, rModifyHdl );
+ pSubControl.reset( new CharHeightPropertyBox( nType, pParent, rValue, rModifyHdl ) );
break;
case nPropertyTypeRotate:
- pSubControl = new RotationPropertyBox( nType, pParent, rValue, rModifyHdl );
+ pSubControl.reset( new RotationPropertyBox( nType, pParent, rValue, rModifyHdl ) );
break;
case nPropertyTypeTransparency:
- pSubControl = new TransparencyPropertyBox( nType, pParent, rValue, rModifyHdl );
+ pSubControl.reset( new TransparencyPropertyBox( nType, pParent, rValue, rModifyHdl ) );
break;
case nPropertyTypeScale:
- pSubControl = new ScalePropertyBox( nType, pParent, rValue, rModifyHdl );
+ pSubControl.reset( new ScalePropertyBox( nType, pParent, rValue, rModifyHdl ) );
break;
case nPropertyTypeCharDecoration:
- pSubControl = new FontStylePropertyBox( nType, pParent, rValue, rModifyHdl );
+ pSubControl.reset( new FontStylePropertyBox( nType, pParent, rValue, rModifyHdl ) );
break;
}
diff --git a/sd/source/ui/animations/CustomAnimationDialog.hxx b/sd/source/ui/animations/CustomAnimationDialog.hxx
index 4d0c685dabb1..2ad30fb2bcb1 100644
--- a/sd/source/ui/animations/CustomAnimationDialog.hxx
+++ b/sd/source/ui/animations/CustomAnimationDialog.hxx
@@ -105,7 +105,7 @@ public:
virtual Control* getControl() = 0;
- static PropertySubControl*
+ static std::unique_ptr<PropertySubControl>
create( sal_Int32 nType,
vcl::Window* pParent,
const css::uno::Any& rValue,
@@ -125,13 +125,13 @@ public:
virtual ~PropertyControl() override;
virtual void dispose() override;
- void setSubControl( PropertySubControl* pSubControl );
- PropertySubControl* getSubControl() const { return mpSubControl; }
+ void setSubControl( std::unique_ptr<PropertySubControl> pSubControl );
+ PropertySubControl* getSubControl() const { return mpSubControl.get(); }
virtual void Resize() override;
private:
- PropertySubControl* mpSubControl;
+ std::unique_ptr<PropertySubControl> mpSubControl;
};
class CustomAnimationDurationTabPage;
diff --git a/sd/source/ui/animations/CustomAnimationPane.cxx b/sd/source/ui/animations/CustomAnimationPane.cxx
index cca48273915f..4f57fe860884 100644
--- a/sd/source/ui/animations/CustomAnimationPane.cxx
+++ b/sd/source/ui/animations/CustomAnimationPane.cxx
@@ -590,8 +590,9 @@ void CustomAnimationPane::updateControls()
pSubControl = mpLBProperty->getSubControl();
if( !pSubControl || (pSubControl->getControlType() != mnPropertyType) )
{
- pSubControl = PropertySubControl::create( mnPropertyType, mpPlaceholderBox, aValue, pEffect->getPresetId(), LINK( this, CustomAnimationPane, implPropertyHdl ) );
- mpLBProperty->setSubControl( pSubControl );
+ auto pNewControl = PropertySubControl::create( mnPropertyType, mpPlaceholderBox, aValue, pEffect->getPresetId(), LINK( this, CustomAnimationPane, implPropertyHdl ) );
+ pSubControl = pNewControl.get();
+ mpLBProperty->setSubControl( std::move(pNewControl) );
}
else
{