diff options
author | David Tardon <dtardon@redhat.com> | 2016-09-09 10:02:22 +0200 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2016-09-09 12:14:04 +0200 |
commit | 260cbd3d3c86cd306129f3db290fed8b993b2909 (patch) | |
tree | 27b4516dcd8b8e82e1807b7de8ec6c21fb97dcae /xmloff | |
parent | e5981249db34db2367bae2a2f3e7e8d9f8bd09a0 (diff) |
use std::unique_ptr
Change-Id: I21572ac8afb1c514ff78b1e23c7fb9259f0b01fb
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/chart/MultiPropertySetHandler.hxx | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/xmloff/source/chart/MultiPropertySetHandler.hxx b/xmloff/source/chart/MultiPropertySetHandler.hxx index e263790d5158..7996bfa1e3ee 100644 --- a/xmloff/source/chart/MultiPropertySetHandler.hxx +++ b/xmloff/source/chart/MultiPropertySetHandler.hxx @@ -20,6 +20,9 @@ #ifndef INCLUDED_XMLOFF_SOURCE_CHART_MULTIPROPERTYSETHANDLER_HXX #define INCLUDED_XMLOFF_SOURCE_CHART_MULTIPROPERTYSETHANDLER_HXX +#include <memory> + +#include <o3tl/make_unique.hxx> #include <rtl/ustring.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XMultiPropertySet.hpp> @@ -123,7 +126,6 @@ public: */ explicit MultiPropertySetHandler (css::uno::Reference< css::uno::XInterface> const & xObject); - ~MultiPropertySetHandler(); /** @descr Add a property to handle. The type given implicitly by the reference to a variable is used to create an instance of the PropertyWrapper template class. @@ -133,7 +135,7 @@ public: */ template<class T> void Add (const OUString & sName, T& rValue) { - aPropertyList[sName] = new PropertyWrapper<T> (sName, rValue); + aPropertyList[sName] = o3tl::make_unique<PropertyWrapper<T>>(sName, rValue); } /** @descr Try to get the values for all properties added with the Add @@ -168,7 +170,7 @@ private: PropertyWrapper. It uses OUStringComparison for sorting the property names. */ - ::std::map< OUString, PropertyWrapperBase*, OUStringComparison> aPropertyList; + ::std::map< OUString, std::unique_ptr<PropertyWrapperBase>, OUStringComparison> aPropertyList; /// The object from which to get the property values. css::uno::Reference< css::uno::XInterface> mxObject; @@ -180,19 +182,11 @@ MultiPropertySetHandler::MultiPropertySetHandler (css::uno::Reference< { } -MultiPropertySetHandler::~MultiPropertySetHandler() -{ - ::std::map< OUString, PropertyWrapperBase*, OUStringComparison>::iterator I; - for (I=aPropertyList.begin(); I!=aPropertyList.end(); ++I) - delete I->second; -} - bool MultiPropertySetHandler::GetProperties() { - ::std::map< OUString, PropertyWrapperBase*, OUStringComparison>::iterator I; css::uno::Sequence< OUString> aNameList (aPropertyList.size()); - int i; - for (I=aPropertyList.begin(),i=0; I!=aPropertyList.end(); ++I) + int i = 0; + for (auto I=aPropertyList.begin(); I!=aPropertyList.end(); ++I) aNameList[i++] = I->second->msName; if ( ! MultiGet(aNameList)) if ( ! SingleGet(aNameList)) @@ -208,11 +202,10 @@ bool MultiPropertySetHandler::MultiGet (const css::uno::Sequence< if (xMultiSet.is()) try { - ::std::map< OUString, PropertyWrapperBase*, OUStringComparison>::iterator I; - int i; + int i = 0; css::uno::Sequence< css::uno::Any> aValueList = xMultiSet->getPropertyValues (rNameList); - for (I=aPropertyList.begin(),i=0; I!=aPropertyList.end(); ++I) + for (auto I=aPropertyList.begin(); I!=aPropertyList.end(); ++I) I->second->SetValue (aValueList[i++]); } catch (const css::beans::UnknownPropertyException&) @@ -233,9 +226,8 @@ bool MultiPropertySetHandler::SingleGet (const css::uno::Sequence< if (xSingleSet.is()) try { - ::std::map< OUString, PropertyWrapperBase*, OUStringComparison>::iterator I; - int i; - for (I=aPropertyList.begin(),i=0; I!=aPropertyList.end(); ++I) + int i = 0; + for (auto I=aPropertyList.begin(); I!=aPropertyList.end(); ++I) I->second->SetValue (xSingleSet->getPropertyValue (rNameList[i++])); } catch (const css::beans::UnknownPropertyException&) |