From 260cbd3d3c86cd306129f3db290fed8b993b2909 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Fri, 9 Sep 2016 10:02:22 +0200 Subject: use std::unique_ptr Change-Id: I21572ac8afb1c514ff78b1e23c7fb9259f0b01fb --- xmloff/source/chart/MultiPropertySetHandler.hxx | 30 +++++++++---------------- 1 file changed, 11 insertions(+), 19 deletions(-) (limited to 'xmloff') 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 + +#include #include #include #include @@ -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 void Add (const OUString & sName, T& rValue) { - aPropertyList[sName] = new PropertyWrapper (sName, rValue); + aPropertyList[sName] = o3tl::make_unique>(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, 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&) -- cgit v1.2.3