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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Aug 24 13:57:23 UTC 2018


 sc/inc/fielduno.hxx              |    4 ++--
 sc/source/ui/unoobj/cellsuno.cxx |    2 +-
 sc/source/ui/unoobj/fielduno.cxx |   12 ++++++------
 sc/source/ui/unoobj/servuno.cxx  |    1 +
 sc/source/ui/unoobj/textuno.cxx  |    2 +-
 5 files changed, 11 insertions(+), 10 deletions(-)

New commits:
commit b5ee452d403b0c94cc0d7548117e9c96d1d45c67
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Aug 24 13:31:37 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Aug 24 15:56:56 2018 +0200

    loplugin:useuniqueptr in ScEditFieldObj
    
    consequently fixing potential leak in InitDoc
    
    Change-Id: I50885f32d2465b41ede5dcf6653d7d8d30a3aeba
    Reviewed-on: https://gerrit.libreoffice.org/59557
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/inc/fielduno.hxx b/sc/inc/fielduno.hxx
index 7bc542aacfb3..85e641e326e5 100644
--- a/sc/inc/fielduno.hxx
+++ b/sc/inc/fielduno.hxx
@@ -204,7 +204,7 @@ public:
 
     ScEditFieldObj(
         const css::uno::Reference<css::text::XTextRange>& rContent,
-        ScEditSource* pEditSrc, sal_Int32 eType, const ESelection& rSel);
+        std::unique_ptr<ScEditSource> pEditSrc, sal_Int32 eType, const ESelection& rSel);
     virtual ~ScEditFieldObj() override;
 
     sal_Int32 GetFieldType() const { return meType;}
@@ -213,7 +213,7 @@ public:
     SvxFieldItem CreateFieldItem();
     void InitDoc(
         const css::uno::Reference<css::text::XTextRange>& rContent,
-        ScEditSource* pEditSrc, const ESelection& rSel);
+        std::unique_ptr<ScEditSource> pEditSrc, const ESelection& rSel);
 
                             // XTextField
     virtual OUString SAL_CALL getPresentation( sal_Bool bShowCommand ) override;
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 1d951628466c..8346be3d8c88 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -6250,7 +6250,7 @@ void SAL_CALL ScCellObj::insertTextContent( const uno::Reference<text::XTextRang
             aSelection.nEndPos = aSelection.nStartPos + 1;
             uno::Reference<text::XTextRange> xParent(this);
             pCellField->InitDoc(
-                xParent, new ScCellEditSource(pDocSh, aCellPos), aSelection);
+                xParent, o3tl::make_unique<ScCellEditSource>(pDocSh, aCellPos), aSelection);
 
             //  for bAbsorb=FALSE, the new selection must be behind the inserted content
             //  (the xml filter relies on this)
diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx
index c75f351b9641..f6d33ce284aa 100644
--- a/sc/source/ui/unoobj/fielduno.cxx
+++ b/sc/source/ui/unoobj/fielduno.cxx
@@ -336,7 +336,7 @@ uno::Reference<text::XTextField> ScCellFieldsObj::GetObjectByIndex_Impl(sal_Int3
 
     sal_Int32 eType = pData->GetClassId();
     uno::Reference<text::XTextField> xRet(
-        new ScEditFieldObj(mxContent, new ScCellEditSource(pDocShell, aCellPos), eType, aSelection));
+        new ScEditFieldObj(mxContent, o3tl::make_unique<ScCellEditSource>(pDocShell, aCellPos), eType, aSelection));
     return xRet;
 }
 
@@ -493,7 +493,7 @@ uno::Reference<text::XTextField> ScHeaderFieldsObj::GetObjectByIndex_Impl(sal_In
 
     sal_Int32 eRealType = pData->GetClassId();
     uno::Reference<text::XTextField> xRet(
-        new ScEditFieldObj(xTextRange, new ScHeaderFooterEditSource(mrData), eRealType, aSelection));
+        new ScEditFieldObj(xTextRange, o3tl::make_unique<ScHeaderFooterEditSource>(mrData), eRealType, aSelection));
     return xRet;
 }
 
@@ -1061,10 +1061,10 @@ void ScEditFieldObj::setPropertyValueSheet(const OUString& rName, const uno::Any
 
 ScEditFieldObj::ScEditFieldObj(
     const uno::Reference<text::XTextRange>& rContent,
-    ScEditSource* pEditSrc, sal_Int32 eType, const ESelection& rSel) :
+    std::unique_ptr<ScEditSource> pEditSrc, sal_Int32 eType, const ESelection& rSel) :
     OComponentHelper(getMutex()),
     pPropSet(nullptr),
-    mpEditSource(pEditSrc),
+    mpEditSource(std::move(pEditSrc)),
     aSelection(rSel),
     meType(eType), mpData(nullptr), mpContent(rContent), mnNumFormat(0), mbIsDate(false), mbIsFixed(false)
 {
@@ -1093,7 +1093,7 @@ ScEditFieldObj::ScEditFieldObj(
 }
 
 void ScEditFieldObj::InitDoc(
-    const uno::Reference<text::XTextRange>& rContent, ScEditSource* pEditSrc, const ESelection& rSel)
+    const uno::Reference<text::XTextRange>& rContent, std::unique_ptr<ScEditSource> pEditSrc, const ESelection& rSel)
 {
     if (!mpEditSource)
     {
@@ -1101,7 +1101,7 @@ void ScEditFieldObj::InitDoc(
         mpData.reset();
 
         aSelection = rSel;
-        mpEditSource.reset( pEditSrc );
+        mpEditSource = std::move( pEditSrc );
     }
 }
 
diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx
index 37186b02be7c..9bcc3e593298 100644
--- a/sc/source/ui/unoobj/servuno.cxx
+++ b/sc/source/ui/unoobj/servuno.cxx
@@ -28,6 +28,7 @@
 #include <com/sun/star/container/XNameAccess.hpp>
 #include <com/sun/star/text/textfield/Type.hpp>
 
+#include <editsrc.hxx>
 #include <servuno.hxx>
 #include <unonames.hxx>
 #include <appluno.hxx>
diff --git a/sc/source/ui/unoobj/textuno.cxx b/sc/source/ui/unoobj/textuno.cxx
index eedb082d83ab..726ed85c508e 100644
--- a/sc/source/ui/unoobj/textuno.cxx
+++ b/sc/source/ui/unoobj/textuno.cxx
@@ -447,7 +447,7 @@ void SAL_CALL ScHeaderFooterTextObj::insertTextContent(
                 break;
             }
 
-            pHeaderField->InitDoc(xTextRange, new ScHeaderFooterEditSource(aTextData), aSelection);
+            pHeaderField->InitDoc(xTextRange, o3tl::make_unique<ScHeaderFooterEditSource>(aTextData), aSelection);
 
             //  for bAbsorb=FALSE, the new selection must be behind the inserted content
             //  (the xml filter relies on this)


More information about the Libreoffice-commits mailing list