[Libreoffice-commits] core.git: sw/source

Stephan Bergmann sbergman at redhat.com
Wed Jun 14 15:48:42 UTC 2017


 sw/source/core/inc/unoport.hxx     |    2 +-
 sw/source/core/unocore/unoport.cxx |   11 +++++------
 2 files changed, 6 insertions(+), 7 deletions(-)

New commits:
commit 7ac68fc033f0df2399105735e43417ea0c689c18
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Jun 14 17:48:12 2017 +0200

    Use unique_ptr for SwXTextPortion::GetPropertyValue param
    
    Change-Id: Ib20981fa47220d3122807a1f567d9f2fb54f5e76

diff --git a/sw/source/core/inc/unoport.hxx b/sw/source/core/inc/unoport.hxx
index ad16fbd3f5af..b8603a30a155 100644
--- a/sw/source/core/inc/unoport.hxx
+++ b/sw/source/core/inc/unoport.hxx
@@ -137,7 +137,7 @@ protected:
         const css::uno::Sequence< OUString >& aPropertyNames );
 
     void GetPropertyValue( css::uno::Any &rVal,
-                const SfxItemPropertySimpleEntry& rEntry, SwUnoCursor *pUnoCursor, SfxItemSet *&pSet );
+                const SfxItemPropertySimpleEntry& rEntry, SwUnoCursor *pUnoCursor, std::unique_ptr<SfxItemSet> &pSet );
 
     /// @throws css::uno::RuntimeException
     css::uno::Sequence<css::beans::GetDirectPropertyTolerantResult> SAL_CALL GetPropertyValuesTolerant_Impl(
diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx
index 916150b1b73e..b9769d58f91b 100644
--- a/sw/source/core/unocore/unoport.cxx
+++ b/sw/source/core/unocore/unoport.cxx
@@ -20,6 +20,7 @@
 #include <unoport.hxx>
 
 #include <cmdid.h>
+#include <o3tl/make_unique.hxx>
 #include <osl/mutex.hxx>
 #include <cppuhelper/exc_hlp.hxx>
 #include <cppuhelper/interfacecontainer.h>
@@ -218,7 +219,7 @@ void SwXTextPortion::GetPropertyValue(
         uno::Any &rVal,
         const SfxItemPropertySimpleEntry& rEntry,
         SwUnoCursor *pUnoCursor,
-        SfxItemSet *&pSet )
+        std::unique_ptr<SfxItemSet> &pSet )
 {
     OSL_ENSURE( pUnoCursor, "UNO cursor missing" );
     if (!pUnoCursor)
@@ -360,7 +361,7 @@ void SwXTextPortion::GetPropertyValue(
                 {
                     if(!pSet)
                     {
-                        pSet = new SfxItemSet(pUnoCursor->GetDoc()->GetAttrPool(),
+                        pSet = o3tl::make_unique<SfxItemSet>(pUnoCursor->GetDoc()->GetAttrPool(),
                             RES_CHRATR_BEGIN, RES_FRMATR_END - 1,
                             RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER,
                             RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER,
@@ -383,7 +384,7 @@ uno::Sequence< uno::Any > SAL_CALL SwXTextPortion::GetPropertyValues_Impl(
     SwUnoCursor& rUnoCursor = GetCursor();
 
     {
-        SfxItemSet *pSet = nullptr;
+        std::unique_ptr<SfxItemSet> pSet;
         // get starting point for the look-up, either the provided one or else
         // from the beginning of the map
         const SfxItemPropertyMap& rMap = m_pPropSet->getPropertyMap();
@@ -397,7 +398,6 @@ uno::Sequence< uno::Any > SAL_CALL SwXTextPortion::GetPropertyValues_Impl(
             else
                 throw beans::UnknownPropertyException( "Unknown property: " + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
         }
-        delete pSet;
     }
     return aValues;
 }
@@ -589,7 +589,7 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXTextPortion:
         sal_Int32 nProps = rPropertyNames.getLength();
         const OUString *pProp = rPropertyNames.getConstArray();
 
-        SfxItemSet *pSet = nullptr;
+        std::unique_ptr<SfxItemSet> pSet;
 
         const SfxItemPropertyMap& rPropMap = m_pPropSet->getPropertyMap();
 
@@ -657,7 +657,6 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXTextPortion:
                 aResult.Result = beans::TolerantPropertySetResultType::WRAPPED_TARGET;
             }
         }
-        delete pSet;
     }
     catch (const uno::RuntimeException&)
     {


More information about the Libreoffice-commits mailing list