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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Jan 16 10:55:02 UTC 2019


 include/svx/ctredlin.hxx               |    6 +++---
 sc/source/ui/miscdlgs/acredlin.cxx     |   24 +++++++++++-------------
 sc/source/ui/miscdlgs/conflictsdlg.cxx |   10 +++++-----
 svx/source/dialog/ctredlin.cxx         |   12 ++++++------
 sw/source/uibase/misc/redlndlg.cxx     |    8 ++++----
 5 files changed, 29 insertions(+), 31 deletions(-)

New commits:
commit 3c93d34caa79c37c41eab1d3212a7ff1cdf53d34
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Jan 15 08:04:49 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Jan 16 11:54:38 2019 +0100

    pass RedlinData around by unique_ptr
    
    Change-Id: Ibe709e64b89e5e036e741203a14242f27df8c637
    Reviewed-on: https://gerrit.libreoffice.org/66416
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/svx/ctredlin.hxx b/include/svx/ctredlin.hxx
index 78eaed2ff4f2..e83b9eec7e0c 100644
--- a/include/svx/ctredlin.hxx
+++ b/include/svx/ctredlin.hxx
@@ -166,14 +166,14 @@ public:
 
         The rStr contains the entire redline entry; the columns are delimited by '\t'.
     */
-    SvTreeListEntry* InsertEntry(const OUString &rStr, RedlinData *pUserData,
+    SvTreeListEntry* InsertEntry(const OUString &rStr, std::unique_ptr<RedlinData> pUserData,
                                  SvTreeListEntry* pParent = nullptr, sal_uLong nPos = TREELIST_APPEND);
 
     /** Insert a redline entry.
 
         The rStr contains the entire redline entry; the columns are delimited by '\t'.
     */
-    SvTreeListEntry* InsertEntry(const OUString &rStr, RedlinData *pUserData, const Color&,
+    SvTreeListEntry* InsertEntry(const OUString &rStr, std::unique_ptr<RedlinData> pUserData, const Color&,
                                  SvTreeListEntry* pParent, sal_uLong nPos = TREELIST_APPEND);
 
     /** Insert a redline entry.
@@ -181,7 +181,7 @@ public:
         rRedlineType contains the image for this redline entry (plus for insertion, minus for deletion etc.).
         rStr contains the rest of the redline entry; the columns are delimited by '\t'.
     */
-    SvTreeListEntry* InsertEntry(const Image &rRedlineType, const OUString &rStr, RedlinData *pUserData,
+    SvTreeListEntry* InsertEntry(const Image &rRedlineType, const OUString &rStr, std::unique_ptr<RedlinData> pUserData,
                                  SvTreeListEntry* pParent, sal_uLong nPos = TREELIST_APPEND);
 
     virtual SvTreeListEntry* CreateEntry() const override;
diff --git a/sc/source/ui/miscdlgs/acredlin.cxx b/sc/source/ui/miscdlgs/acredlin.cxx
index 05d1ab0b22d3..ad4d2ba5e61c 100644
--- a/sc/source/ui/miscdlgs/acredlin.cxx
+++ b/sc/source/ui/miscdlgs/acredlin.cxx
@@ -370,7 +370,7 @@ SvTreeListEntry* ScAcceptChgDlg::AppendChangeAction(
     OUStringBuffer aBuf;
     OUString aDesc;
 
-    ScRedlinData* pNewData=new ScRedlinData;
+    std::unique_ptr<ScRedlinData> pNewData(new ScRedlinData);
     pNewData->pData=const_cast<ScChangeAction *>(pScChangeAction);
     pNewData->nActionNo=pScChangeAction->GetActionNumber();
     pNewData->bIsAcceptable=pScChangeAction->IsClickable();
@@ -474,12 +474,12 @@ SvTreeListEntry* ScAcceptChgDlg::AppendChangeAction(
     if(!bFlag&& bUseColor&& pParent==nullptr)
     {
         pEntry = pTheView->InsertEntry(
-            aBuf.makeStringAndClear() ,pNewData, COL_LIGHTBLUE, pParent, TREELIST_APPEND);
+            aBuf.makeStringAndClear(), std::move(pNewData), COL_LIGHTBLUE, pParent, TREELIST_APPEND);
     }
     else if(bFlag&& bUseColor&& pParent!=nullptr)
     {
         pEntry = pTheView->InsertEntry(
-            aBuf.makeStringAndClear(), pNewData, COL_GREEN, pParent, TREELIST_APPEND);
+            aBuf.makeStringAndClear(), std::move(pNewData), COL_GREEN, pParent, TREELIST_APPEND);
         SvTreeListEntry* pExpEntry=pParent;
 
         while(pExpEntry!=nullptr && !pTheView->IsExpanded(pExpEntry))
@@ -494,7 +494,7 @@ SvTreeListEntry* ScAcceptChgDlg::AppendChangeAction(
     else
     {
         pEntry = pTheView->InsertEntry(
-            aBuf.makeStringAndClear(), pNewData, pParent, TREELIST_APPEND);
+            aBuf.makeStringAndClear(), std::move(pNewData), pParent, TREELIST_APPEND);
     }
     return pEntry;
 }
@@ -545,7 +545,7 @@ SvTreeListEntry* ScAcceptChgDlg::AppendFilteredAction(
         OUString aString;
         OUString aDesc;
 
-        ScRedlinData* pNewData=new ScRedlinData;
+        std::unique_ptr<ScRedlinData> pNewData(new ScRedlinData);
         pNewData->pData=const_cast<ScChangeAction *>(pScChangeAction);
         pNewData->nActionNo=pScChangeAction->GetActionNumber();
         pNewData->bIsAcceptable=pScChangeAction->IsClickable();
@@ -614,10 +614,8 @@ SvTreeListEntry* ScAcceptChgDlg::AppendFilteredAction(
         if (pTheView->IsValidComment(aComment))
         {
             aString+=aComment;
-            pEntry=pTheView->InsertEntry(aString,pNewData,pParent,TREELIST_APPEND);
+            pEntry=pTheView->InsertEntry(aString,std::move(pNewData),pParent,TREELIST_APPEND);
         }
-        else
-            delete pNewData;
     }
     return pEntry;
 }
@@ -718,7 +716,7 @@ SvTreeListEntry* ScAcceptChgDlg::InsertChangeActionContent(const ScChangeActionC
 
     aString += aComment;
 
-    ScRedlinData* pNewData=new ScRedlinData;
+    std::unique_ptr<ScRedlinData> pNewData(new ScRedlinData);
     pNewData->nInfo=nSpecial;
     pNewData->pData=const_cast<ScChangeActionContent *>(pScChangeAction);
     pNewData->nActionNo=pScChangeAction->GetActionNumber();
@@ -733,10 +731,10 @@ SvTreeListEntry* ScAcceptChgDlg::InsertChangeActionContent(const ScChangeActionC
     if (pTheView->IsValidComment(aComment) && bFlag)
     {
         bHasFilterEntry=true;
-        pEntry=pTheView->InsertEntry(aString,pNewData,pParent);
+        pEntry=pTheView->InsertEntry(aString,std::move(pNewData),pParent);
     }
     else
-        pEntry=pTheView->InsertEntry(aString,pNewData,COL_LIGHTBLUE,pParent);
+        pEntry=pTheView->InsertEntry(aString,std::move(pNewData),COL_LIGHTBLUE,pParent);
     return pEntry;
 }
 
@@ -818,14 +816,14 @@ void ScAcceptChgDlg::UpdateView()
     if(nAcceptCount>0)
     {
         pParent=pTheView->InsertEntry(
-            aStrAllAccepted, static_cast< RedlinData * >(nullptr),
+            aStrAllAccepted, std::unique_ptr<RedlinData>(),
             static_cast< SvTreeListEntry * >(nullptr));
         pParent->EnableChildrenOnDemand();
     }
     if(nRejectCount>0)
     {
         pParent=pTheView->InsertEntry(
-            aStrAllRejected, static_cast< RedlinData * >(nullptr),
+            aStrAllRejected, std::unique_ptr<RedlinData>(),
             static_cast< SvTreeListEntry * >(nullptr));
         pParent->EnableChildrenOnDemand();
     }
diff --git a/sc/source/ui/miscdlgs/conflictsdlg.cxx b/sc/source/ui/miscdlgs/conflictsdlg.cxx
index 759f711a399a..bd62d7d24fd6 100644
--- a/sc/source/ui/miscdlgs/conflictsdlg.cxx
+++ b/sc/source/ui/miscdlgs/conflictsdlg.cxx
@@ -631,9 +631,9 @@ void ScConflictsDlg::UpdateView()
     {
         if (rConflictEntry.meConflictAction == SC_CONFLICT_ACTION_NONE)
         {
-            RedlinData* pRootUserData = new RedlinData();
+            std::unique_ptr<RedlinData> pRootUserData(new RedlinData());
             pRootUserData->pData = static_cast<void*>(&rConflictEntry);
-            SvTreeListEntry* pRootEntry = m_pLbConflicts->InsertEntry( GetConflictString( rConflictEntry ), pRootUserData );
+            SvTreeListEntry* pRootEntry = m_pLbConflicts->InsertEntry( GetConflictString( rConflictEntry ), std::move(pRootUserData) );
 
             for ( auto& aSharedAction : rConflictEntry.maSharedActions )
             {
@@ -651,7 +651,7 @@ void ScConflictsDlg::UpdateView()
                     }
 
                     OUString aString( GetActionString( pAction, mpSharedDoc ) );
-                    m_pLbConflicts->InsertEntry( aString, static_cast< RedlinData* >( nullptr ), pRootEntry );
+                    m_pLbConflicts->InsertEntry( aString, std::unique_ptr<RedlinData>(), pRootEntry );
                 }
             }
 
@@ -671,9 +671,9 @@ void ScConflictsDlg::UpdateView()
                     }
 
                     OUString aString( GetActionString( pAction, mpOwnDoc ) );
-                    RedlinData* pUserData = new RedlinData();
+                    std::unique_ptr<RedlinData> pUserData(new RedlinData());
                     pUserData->pData = static_cast< void* >( pAction );
-                    m_pLbConflicts->InsertEntry( aString, pUserData, pRootEntry );
+                    m_pLbConflicts->InsertEntry( aString, std::move(pUserData), pRootEntry );
                 }
             }
 
diff --git a/svx/source/dialog/ctredlin.cxx b/svx/source/dialog/ctredlin.cxx
index 6a77f75efdba..188d7bc582e3 100644
--- a/svx/source/dialog/ctredlin.cxx
+++ b/svx/source/dialog/ctredlin.cxx
@@ -289,15 +289,15 @@ bool SvxRedlinTable::IsValidComment(const OUString &rCommentStr)
 }
 
 SvTreeListEntry* SvxRedlinTable::InsertEntry(const OUString& rStr,
-        RedlinData *pUserData, SvTreeListEntry* pParent, sal_uLong nPos)
+        std::unique_ptr<RedlinData> pUserData, SvTreeListEntry* pParent, sal_uLong nPos)
 {
     const Color aColor = (pUserData && pUserData->bDisabled) ? COL_GRAY : GetTextColor();
 
-    return InsertEntry(rStr, pUserData, aColor, pParent, nPos);
+    return InsertEntry(rStr, std::move(pUserData), aColor, pParent, nPos);
 }
 
 SvTreeListEntry* SvxRedlinTable::InsertEntry(const OUString& rStr,
-        RedlinData *pUserData, const Color& rColor, SvTreeListEntry* pParent, sal_uLong nPos)
+        std::unique_ptr<RedlinData> pUserData, const Color& rColor, SvTreeListEntry* pParent, sal_uLong nPos)
 {
     maEntryColor = rColor;
     maEntryImage = Image();
@@ -306,17 +306,17 @@ SvTreeListEntry* SvxRedlinTable::InsertEntry(const OUString& rStr,
     const OUString aFirstStr(rStr.getToken(0, '\t', nIndex));
     maEntryString = nIndex > 0 ? rStr.copy(nIndex) : OUString();
 
-    return SvSimpleTable::InsertEntry(aFirstStr, pParent, false, nPos, pUserData);
+    return SvSimpleTable::InsertEntry(aFirstStr, pParent, false, nPos, pUserData.release());
 }
 
 SvTreeListEntry* SvxRedlinTable::InsertEntry(const Image &rRedlineType, const OUString& rStr,
-        RedlinData *pUserData, SvTreeListEntry* pParent, sal_uLong nPos)
+        std::unique_ptr<RedlinData> pUserData, SvTreeListEntry* pParent, sal_uLong nPos)
 {
     maEntryColor = (pUserData && pUserData->bDisabled) ? COL_GRAY : GetTextColor();
     maEntryImage = rRedlineType;
     maEntryString = rStr;
 
-    return SvSimpleTable::InsertEntry(OUString(), pParent, false, nPos, pUserData);
+    return SvSimpleTable::InsertEntry(OUString(), pParent, false, nPos, pUserData.release());
 }
 
 SvTreeListEntry* SvxRedlinTable::CreateEntry() const
diff --git a/sw/source/uibase/misc/redlndlg.cxx b/sw/source/uibase/misc/redlndlg.cxx
index 135cd7b49658..321869fff38a 100644
--- a/sw/source/uibase/misc/redlndlg.cxx
+++ b/sw/source/uibase/misc/redlndlg.cxx
@@ -601,13 +601,13 @@ void SwRedlineAcceptDlg::InsertChildren(SwRedlineDataParent *pParent, const SwRa
 
         if (bValidChild)
         {
-            RedlinData *pData = new RedlinData;
+            std::unique_ptr<RedlinData> pData(new RedlinData);
             pData->pData = pRedlineChild;
             pData->bDisabled = true;
             sChild = GetRedlineText(rRedln, pData->aDateTime, nStack);
 
             SvTreeListEntry* pChild = m_pTable->InsertEntry(GetActionImage(rRedln, nStack),
-                    sChild, pData, pParent->pTLBParent);
+                    sChild, std::move(pData), pParent->pTLBParent);
 
             pRedlineChild->pTLBChild = pChild;
             if (!bValidParent)
@@ -748,12 +748,12 @@ void SwRedlineAcceptDlg::InsertParents(SwRedlineTable::size_type nStart, SwRedli
         m_RedlineParents.insert(m_RedlineParents.begin() + i,
                 std::unique_ptr<SwRedlineDataParent>(pRedlineParent));
 
-        RedlinData *pData = new RedlinData;
+        std::unique_ptr<RedlinData> pData(new RedlinData);
         pData->pData = pRedlineParent;
         pData->bDisabled = false;
 
         sParent = GetRedlineText(rRedln, pData->aDateTime);
-        pParent = m_pTable->InsertEntry(GetActionImage(rRedln), sParent, pData, nullptr, i);
+        pParent = m_pTable->InsertEntry(GetActionImage(rRedln), sParent, std::move(pData), nullptr, i);
         if( pCurrRedline == &rRedln )
         {
             m_pTable->SetCurEntry( pParent );


More information about the Libreoffice-commits mailing list