[Libreoffice-commits] core.git: xmloff/inc xmloff/source

Noel Grandin noel.grandin at collabora.co.uk
Thu Jan 25 06:24:55 UTC 2018


 xmloff/inc/txtflde.hxx         |    7 ++++---
 xmloff/source/text/txtflde.cxx |   12 ++++--------
 2 files changed, 8 insertions(+), 11 deletions(-)

New commits:
commit cae452a167b78d8dc164059db8a9fbe1eb3d521d
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Jan 17 17:09:14 2018 +0200

    loplugin:useuniqueptr in XMLTextFieldExport
    
    Change-Id: I2b3e1ec5454bc3486fb41b010091adc549500daf
    Reviewed-on: https://gerrit.libreoffice.org/48512
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/xmloff/inc/txtflde.hxx b/xmloff/inc/txtflde.hxx
index 5f7fd452f988..34c867017762 100644
--- a/xmloff/inc/txtflde.hxx
+++ b/xmloff/inc/txtflde.hxx
@@ -32,6 +32,7 @@
 
 #include <map>
 #include <set>
+#include <memory>
 
 
 class SvXMLExport;
@@ -151,9 +152,9 @@ class XMLTextFieldExport final
     SvXMLExport& rExport;
 
     /// store used text field master names (NULL means: don't collect)
-    ::std::map<
+    std::unique_ptr< ::std::map<
             css::uno::Reference< css::text::XText >,
-            ::std::set< OUString > > *
+            ::std::set< OUString > > >
         pUsedMasters;
 
 public:
@@ -481,7 +482,7 @@ private:
     const OUString sPropertyTooltip;
     const OUString sPropertyTextRange;
 
-    XMLPropertyState* pCombinedCharactersPropertyState;
+    std::unique_ptr<XMLPropertyState> pCombinedCharactersPropertyState;
 
 };
 
diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx
index 946b5f847df3..c2d52cf48421 100644
--- a/xmloff/source/text/txtflde.cxx
+++ b/xmloff/source/text/txtflde.cxx
@@ -274,7 +274,6 @@ inline Sequence<OUString> const GetStringSequenceProperty(
 XMLTextFieldExport::XMLTextFieldExport( SvXMLExport& rExp,
                                         XMLPropertyState* pCombinedCharState)
     : rExport(rExp),
-      pUsedMasters(nullptr),
       sServicePrefix("com.sun.star.text.textfield."),
       sFieldMasterPrefix("com.sun.star.text.FieldMaster."),
       sPresentationServicePrefix("com.sun.star.presentation.TextField."),
@@ -352,8 +351,6 @@ XMLTextFieldExport::XMLTextFieldExport( SvXMLExport& rExp,
 
 XMLTextFieldExport::~XMLTextFieldExport()
 {
-    delete pCombinedCharactersPropertyState;
-    delete pUsedMasters;
 }
 
 /// get the field ID (as in FieldIDEnum) from XTextField
@@ -882,7 +879,7 @@ void XMLTextFieldExport::ExportFieldAutoStyle(
         // export text style with the addition of the combined characters
         DBG_ASSERT(nullptr != pCombinedCharactersPropertyState,
                    "need proper PropertyState for combined characters");
-        const XMLPropertyState *aStates[] = { pCombinedCharactersPropertyState, nullptr };
+        const XMLPropertyState *aStates[] = { pCombinedCharactersPropertyState.get(), nullptr };
         GetExport().GetTextParagraphExport()->Add(
             XML_STYLE_FAMILY_TEXT_TEXT, xRangePropSet,
             aStates);
@@ -969,7 +966,7 @@ void XMLTextFieldExport::ExportField(
 
     // special treatment for combined characters field, because it is
     // exported as a style
-    const XMLPropertyState* aStates[] = { pCombinedCharactersPropertyState, nullptr };
+    const XMLPropertyState* aStates[] = { pCombinedCharactersPropertyState.get(), nullptr };
     const XMLPropertyState **pStates =
                 FIELD_ID_COMBINED_CHARACTERS == nToken
                     ? aStates
@@ -2189,12 +2186,11 @@ void XMLTextFieldExport::ExportFieldDeclarations(
 void XMLTextFieldExport::SetExportOnlyUsedFieldDeclarations(
     bool bExportOnlyUsed)
 {
-    delete pUsedMasters;
-    pUsedMasters = nullptr;
+    pUsedMasters.reset();
 
     // create used masters set (if none is used)
     if (bExportOnlyUsed)
-        pUsedMasters = new map<Reference<XText>, set<OUString> > ;
+        pUsedMasters.reset( new map<Reference<XText>, set<OUString> > );
 }
 
 void XMLTextFieldExport::ExportElement(enum XMLTokenEnum eElementName,


More information about the Libreoffice-commits mailing list