Let BaseProperties::CreateObjectSpecificItemSet return unique_ptr

Change-Id: Ic734fe2a425ca1c821ba91df17aecac5ef40a000
This commit is contained in:
Stephan Bergmann
2017-06-13 13:48:18 +02:00
parent 8f187d38b1
commit 889ea6a50f
29 changed files with 94 additions and 52 deletions

View File

@@ -40,7 +40,7 @@ namespace sdr
std::unique_ptr<SfxItemSet> mpItemSet;
// create a new itemset
virtual SfxItemSet* CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
virtual std::unique_ptr<SfxItemSet> CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
// test changeability for a single item
virtual bool AllowItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = nullptr) const override;

View File

@@ -20,6 +20,10 @@
#ifndef INCLUDED_SVX_SDR_PROPERTIES_PROPERTIES_HXX
#define INCLUDED_SVX_SDR_PROPERTIES_PROPERTIES_HXX
#include <sal/config.h>
#include <memory>
#include <sal/types.h>
#include <svx/svxdllapi.h>
@@ -53,7 +57,7 @@ namespace sdr
protected:
// create a new object specific itemset with object specific ranges.
virtual SfxItemSet* CreateObjectSpecificItemSet(SfxItemPool& pPool) = 0;
virtual std::unique_ptr<SfxItemSet> CreateObjectSpecificItemSet(SfxItemPool& pPool) = 0;
// internal access to SdrObject
const SdrObject& GetSdrObject() const;

View File

@@ -42,7 +42,7 @@ namespace sdr
SfxStyleSheet* mpStyleSheet;
// create a new itemset
virtual SfxItemSet* CreateObjectSpecificItemSet(SfxItemPool& pPool) override;
virtual std::unique_ptr<SfxItemSet> CreateObjectSpecificItemSet(SfxItemPool& pPool) override;
// Do the ItemChange, may do special handling
virtual void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = nullptr) override;

View File

@@ -31,7 +31,7 @@ namespace sdr
{
protected:
// create a new itemset
virtual SfxItemSet* CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
virtual std::unique_ptr<SfxItemSet> CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
// react on ItemSet changes
virtual void ItemSetChanged(const SfxItemSet& rSet) override;

View File

@@ -31,7 +31,7 @@ namespace sdr
{
protected:
// create a new itemset
virtual SfxItemSet* CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
virtual std::unique_ptr<SfxItemSet> CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
// react on ItemSet changes
virtual void ItemSetChanged(const SfxItemSet& rSet) override;

View File

@@ -31,7 +31,7 @@ namespace sdr
{
protected:
// create a new itemset
virtual SfxItemSet* CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
virtual std::unique_ptr<SfxItemSet> CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
// react on ItemSet changes
virtual void ItemSetChanged(const SfxItemSet& rSet) override;

View File

@@ -34,7 +34,7 @@ namespace sdr
protected:
// create a new itemset
virtual SfxItemSet* CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
virtual std::unique_ptr<SfxItemSet> CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
// test changeability for a single item
virtual bool AllowItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = nullptr) const override;

View File

@@ -31,7 +31,7 @@ namespace sdr
{
protected:
// create a new itemset
virtual SfxItemSet* CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
virtual std::unique_ptr<SfxItemSet> CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
// react on ItemSet changes
virtual void ItemSetChanged(const SfxItemSet& rSet) override;

View File

@@ -38,7 +38,7 @@ namespace sdr
std::unique_ptr<SfxItemSet> mpEmptyItemSet;
// create a new itemset
virtual SfxItemSet* CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
virtual std::unique_ptr<SfxItemSet> CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
// test changeability for a single item
virtual bool AllowItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = nullptr) const override;

View File

@@ -31,7 +31,7 @@ namespace sdr
{
protected:
// create a new itemset
virtual SfxItemSet* CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
virtual std::unique_ptr<SfxItemSet> CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
// react on ItemSet changes
virtual void ItemSetChanged(const SfxItemSet& rSet) override;

View File

@@ -31,7 +31,7 @@ namespace sdr
{
protected:
// create a new itemset
virtual SfxItemSet* CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
virtual std::unique_ptr<SfxItemSet> CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
// test changeability for a single item
virtual bool AllowItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = nullptr) const override;

View File

@@ -31,7 +31,7 @@ namespace sdr
{
protected:
// create a new itemset
virtual SfxItemSet* CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
virtual std::unique_ptr<SfxItemSet> CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
// react on ItemSet changes
virtual void ItemSetChanged(const SfxItemSet& rSet) override;

View File

@@ -31,7 +31,7 @@ namespace sdr
{
protected:
// create a new object specific itemset with object specific ranges.
virtual SfxItemSet* CreateObjectSpecificItemSet(SfxItemPool& pPool) override;
virtual std::unique_ptr<SfxItemSet> CreateObjectSpecificItemSet(SfxItemPool& pPool) override;
// Do the ItemChange, may do special handling
virtual void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = nullptr) override;

View File

@@ -36,7 +36,7 @@ namespace sdr
protected:
// create a new itemset
virtual SfxItemSet* CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
virtual std::unique_ptr<SfxItemSet> CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
// Do the ItemChange, may do special handling
virtual void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = nullptr) override;

View File

@@ -21,6 +21,7 @@
#include <utility>
#include <o3tl/make_unique.hxx>
#include <sdr/properties/attributeproperties.hxx>
#include <sdr/properties/itemsettools.hxx>
#include <tools/debug.hxx>
@@ -112,9 +113,9 @@ namespace sdr
}
// create a new itemset
SfxItemSet* AttributeProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
std::unique_ptr<SfxItemSet> AttributeProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
{
return new SfxItemSet(rPool,
return o3tl::make_unique<SfxItemSet>(rPool,
// ranges from SdrAttrObj
SDRATTR_START, SDRATTR_SHADOW_LAST,
@@ -419,7 +420,7 @@ namespace sdr
pItemSet = pItemSet->GetParent();
}
SfxItemSet* pNewSet = CreateObjectSpecificItemSet(pNewModel->GetItemPool());
auto pNewSet = CreateObjectSpecificItemSet(pNewModel->GetItemPool());
std::vector<const SfxItemSet*>::reverse_iterator riter;
for (riter = aSetList.rbegin(); riter != aSetList.rend(); ++riter)
@@ -455,7 +456,7 @@ namespace sdr
}
}
mpItemSet.reset(pNewSet);
mpItemSet = std::move(pNewSet);
}
}
}

View File

@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <o3tl/make_unique.hxx>
#include <sdr/properties/captionproperties.hxx>
#include <svl/itemset.hxx>
#include <svl/style.hxx>
@@ -30,9 +33,9 @@ namespace sdr
namespace properties
{
// create a new itemset
SfxItemSet* CaptionProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
std::unique_ptr<SfxItemSet> CaptionProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
{
return new SfxItemSet(rPool,
return o3tl::make_unique<SfxItemSet>(rPool,
// range from SdrAttrObj
SDRATTR_START, SDRATTR_SHADOW_LAST,

View File

@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <o3tl/make_unique.hxx>
#include <sdr/properties/circleproperties.hxx>
#include <svl/itemset.hxx>
#include <svl/style.hxx>
@@ -32,9 +35,9 @@ namespace sdr
namespace properties
{
// create a new itemset
SfxItemSet* CircleProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
std::unique_ptr<SfxItemSet> CircleProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
{
return new SfxItemSet(rPool,
return o3tl::make_unique<SfxItemSet>(rPool,
// range from SdrAttrObj
SDRATTR_START, SDRATTR_SHADOW_LAST,

View File

@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <o3tl/make_unique.hxx>
#include <sdr/properties/connectorproperties.hxx>
#include <svl/itemset.hxx>
#include <svl/style.hxx>
@@ -30,9 +33,9 @@ namespace sdr
namespace properties
{
// create a new itemset
SfxItemSet* ConnectorProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
std::unique_ptr<SfxItemSet> ConnectorProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
{
return new SfxItemSet(rPool,
return o3tl::make_unique<SfxItemSet>(rPool,
// range from SdrAttrObj
SDRATTR_START, SDRATTR_SHADOW_LAST,

View File

@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <o3tl/make_unique.hxx>
#include <sdr/properties/customshapeproperties.hxx>
#include <svl/itemset.hxx>
#include <svl/style.hxx>
@@ -59,9 +62,9 @@ namespace sdr
}
}
SfxItemSet* CustomShapeProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
std::unique_ptr<SfxItemSet> CustomShapeProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
{
return new SfxItemSet(rPool,
return o3tl::make_unique<SfxItemSet>(rPool,
// ranges from SdrAttrObj
SDRATTR_START, SDRATTR_SHADOW_LAST,

View File

@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <o3tl/make_unique.hxx>
#include <svx/sdr/properties/defaultproperties.hxx>
#include <sdr/properties/itemsettools.hxx>
#include <svl/itemset.hxx>
@@ -35,10 +38,10 @@ namespace sdr
{
namespace properties
{
SfxItemSet* DefaultProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
std::unique_ptr<SfxItemSet> DefaultProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
{
// Basic implementation; Basic object has NO attributes
return new SfxItemSet(rPool);
return o3tl::make_unique<SfxItemSet>(rPool);
}
DefaultProperties::DefaultProperties(SdrObject& rObj)
@@ -75,7 +78,7 @@ namespace sdr
{
if(!mpItemSet)
{
const_cast<DefaultProperties*>(this)->mpItemSet.reset(const_cast<DefaultProperties*>(this)->CreateObjectSpecificItemSet(GetSdrObject().GetObjectItemPool()));
const_cast<DefaultProperties*>(this)->mpItemSet = const_cast<DefaultProperties*>(this)->CreateObjectSpecificItemSet(GetSdrObject().GetObjectItemPool());
const_cast<DefaultProperties*>(this)->ForceDefaultAttributes();
}

View File

@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <o3tl/make_unique.hxx>
#include <sdr/properties/e3dproperties.hxx>
#include <svl/itemset.hxx>
#include <svx/svddef.hxx>
@@ -28,9 +31,9 @@ namespace sdr
namespace properties
{
// create a new itemset
SfxItemSet* E3dProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
std::unique_ptr<SfxItemSet> E3dProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
{
return new SfxItemSet(rPool,
return o3tl::make_unique<SfxItemSet>(rPool,
// ranges from SdrAttrObj
SDRATTR_START, SDRATTR_SHADOW_LAST,

View File

@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <o3tl/make_unique.hxx>
#include <sdr/properties/emptyproperties.hxx>
#include <svl/itemset.hxx>
#include <svx/svddef.hxx>
@@ -30,11 +33,11 @@ namespace sdr
namespace properties
{
// create a new itemset
SfxItemSet* EmptyProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
std::unique_ptr<SfxItemSet> EmptyProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
{
// Basic implementation; Basic object has NO attributes
assert(!"EmptyProperties::CreateObjectSpecificItemSet() should never be called");
return new SfxItemSet(rPool);
return o3tl::make_unique<SfxItemSet>(rPool);
}
EmptyProperties::EmptyProperties(SdrObject& rObj)
@@ -52,7 +55,7 @@ namespace sdr
{
if(!mpEmptyItemSet)
{
const_cast<EmptyProperties*>(this)->mpEmptyItemSet.reset(const_cast<EmptyProperties*>(this)->CreateObjectSpecificItemSet(GetSdrObject().GetObjectItemPool()));
const_cast<EmptyProperties*>(this)->mpEmptyItemSet = const_cast<EmptyProperties*>(this)->CreateObjectSpecificItemSet(GetSdrObject().GetObjectItemPool());
}
assert(mpEmptyItemSet);

View File

@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <o3tl/make_unique.hxx>
#include <sdr/properties/graphicproperties.hxx>
#include <svl/itemset.hxx>
#include <svl/style.hxx>
@@ -31,9 +34,9 @@ namespace sdr
namespace properties
{
// create a new itemset
SfxItemSet* GraphicProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
std::unique_ptr<SfxItemSet> GraphicProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
{
return new SfxItemSet(rPool,
return o3tl::make_unique<SfxItemSet>(rPool,
// range from SdrAttrObj
SDRATTR_START, SDRATTR_SHADOW_LAST,

View File

@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <o3tl/make_unique.hxx>
#include <sdr/properties/groupproperties.hxx>
#include <svl/itemset.hxx>
#include <svl/whiter.hxx>
@@ -32,12 +35,12 @@ namespace sdr
namespace properties
{
// create a new itemset
SfxItemSet* GroupProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
std::unique_ptr<SfxItemSet> GroupProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
{
// Groups have in principle no ItemSet. To support methods like
// GetMergedItemSet() the local one is used. Thus, all items in the pool
// may be used and a pool itemset is created.
return new SfxItemSet(rPool);
return o3tl::make_unique<SfxItemSet>(rPool);
}
GroupProperties::GroupProperties(SdrObject& rObj)

View File

@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <o3tl/make_unique.hxx>
#include <sdr/properties/measureproperties.hxx>
#include <svl/itemset.hxx>
#include <svl/style.hxx>
@@ -36,9 +39,9 @@ namespace sdr
namespace properties
{
// create a new itemset
SfxItemSet* MeasureProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
std::unique_ptr<SfxItemSet> MeasureProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
{
return new SfxItemSet(rPool,
return o3tl::make_unique<SfxItemSet>(rPool,
// range from SdrAttrObj
SDRATTR_START, SDRATTR_SHADOW_LAST,

View File

@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <o3tl/make_unique.hxx>
#include <sdr/properties/pageproperties.hxx>
#include <svl/itemset.hxx>
#include <svx/svdobj.hxx>
@@ -29,10 +32,10 @@ namespace sdr
namespace properties
{
// create a new itemset
SfxItemSet* PageProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
std::unique_ptr<SfxItemSet> PageProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
{
// override to legally return a valid ItemSet
return new SfxItemSet(rPool);
return o3tl::make_unique<SfxItemSet>(rPool);
}
PageProperties::PageProperties(SdrObject& rObj)
@@ -60,7 +63,7 @@ namespace sdr
{
if(!mpEmptyItemSet)
{
const_cast<PageProperties*>(this)->mpEmptyItemSet.reset(const_cast<PageProperties*>(this)->CreateObjectSpecificItemSet(GetSdrObject().GetObjectItemPool()));
const_cast<PageProperties*>(this)->mpEmptyItemSet = const_cast<PageProperties*>(this)->CreateObjectSpecificItemSet(GetSdrObject().GetObjectItemPool());
}
DBG_ASSERT(mpEmptyItemSet, "Could not create an SfxItemSet(!)");

View File

@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <o3tl/make_unique.hxx>
#include <sdr/properties/textproperties.hxx>
#include <svl/itemset.hxx>
#include <svl/style.hxx>
@@ -42,9 +45,9 @@ namespace sdr
{
namespace properties
{
SfxItemSet* TextProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
std::unique_ptr<SfxItemSet> TextProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
{
return new SfxItemSet(rPool,
return o3tl::make_unique<SfxItemSet>(rPool,
// range from SdrAttrObj
SDRATTR_START, SDRATTR_SHADOW_LAST,

View File

@@ -29,6 +29,7 @@
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/typeprovider.hxx>
#include <o3tl/any.hxx>
#include <o3tl/make_unique.hxx>
#include <svl/style.hxx>
#include <svl/itemset.hxx>
@@ -150,7 +151,7 @@ namespace sdr
{
protected:
// create a new itemset
SfxItemSet* CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
std::unique_ptr<SfxItemSet> CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
const svx::ITextProvider& getTextProvider() const override;
@@ -177,9 +178,9 @@ namespace sdr
};
// create a new itemset
SfxItemSet* CellProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
std::unique_ptr<SfxItemSet> CellProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
{
return new SfxItemSet(rPool,
return o3tl::make_unique<SfxItemSet>(rPool,
// range from SdrAttrObj
SDRATTR_START, SDRATTR_SHADOW_LAST,

View File

@@ -22,7 +22,7 @@
#include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/container/XIndexAccess.hpp>
#include <o3tl/make_unique.hxx>
#include <vcl/canvastools.hxx>
#include <com/sun/star/style/XStyle.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
@@ -86,7 +86,7 @@ class TableProperties : public TextProperties
{
protected:
// create a new itemset
SfxItemSet* CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
std::unique_ptr<SfxItemSet> CreateObjectSpecificItemSet(SfxItemPool& rPool) override;
public:
// basic constructor
@@ -125,9 +125,9 @@ void TableProperties::ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNe
}
// create a new itemset
SfxItemSet* TableProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
std::unique_ptr<SfxItemSet> TableProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
{
return new SfxItemSet(rPool,
return o3tl::make_unique<SfxItemSet>(rPool,
// range from SdrAttrObj
SDRATTR_START, SDRATTR_SHADOW_LAST,