[Libreoffice-commits] core.git: 2 commits - include/sfx2 include/svx sfx2/source svx/source
Noel Grandin
noel.grandin at collabora.co.uk
Thu May 3 12:25:06 UTC 2018
include/sfx2/tabdlg.hxx | 1
include/svx/svdmark.hxx | 3 +-
sfx2/source/dialog/tabdlg.cxx | 3 --
svx/source/svdraw/svdmark.cxx | 45 ++++++++++++++----------------------------
4 files changed, 17 insertions(+), 35 deletions(-)
New commits:
commit ab17afd9beeb2a2cef3e7b67a6acd2581d78b823
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Wed May 2 10:16:19 2018 +0200
loplugin:useuniqueptr in SdrMarkList
Change-Id: I36e7af3b1b74a78103c079da58ae1a820b164720
Reviewed-on: https://gerrit.libreoffice.org/53753
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/svx/svdmark.hxx b/include/svx/svdmark.hxx
index 071f1ce568cb..4b901f6ab2ad 100644
--- a/include/svx/svdmark.hxx
+++ b/include/svx/svdmark.hxx
@@ -25,6 +25,7 @@
#include <svx/sdrobjectuser.hxx>
#include <tools/solar.h>
+#include <memory>
#include <set>
#include <vector>
@@ -134,7 +135,7 @@ public:
class SVX_DLLPUBLIC SdrMarkList final
{
- std::vector<SdrMark*> maList;
+ std::vector<std::unique_ptr<SdrMark>> maList;
OUString maMarkName;
OUString maPointName;
diff --git a/svx/source/svdraw/svdmark.cxx b/svx/source/svdraw/svdmark.cxx
index da4f03051999..00901afc309e 100644
--- a/svx/source/svdraw/svdmark.cxx
+++ b/svx/source/svdraw/svdmark.cxx
@@ -119,7 +119,7 @@ SdrMark& SdrMark::operator=(const SdrMark& rMark)
return *this;
}
-static bool ImpSdrMarkListSorter(SdrMark* const& lhs, SdrMark* const& rhs)
+static bool ImpSdrMarkListSorter(std::unique_ptr<SdrMark> const& lhs, std::unique_ptr<SdrMark> const& rhs)
{
SdrObject* pObj1 = lhs->GetMarkedSdrObj();
SdrObject* pObj2 = rhs->GetMarkedSdrObj();
@@ -161,13 +161,11 @@ void SdrMarkList::ImpForceSort()
// remove invalid
if(nCount > 0 )
{
- for(std::vector<SdrMark*>::iterator it = maList.begin(); it != maList.end(); )
+ for(auto it = maList.begin(); it != maList.end(); )
{
- SdrMark* pCurrent = *it;
- if(pCurrent->GetMarkedSdrObj() == nullptr)
+ if(it->get()->GetMarkedSdrObj() == nullptr)
{
it = maList.erase( it );
- delete pCurrent;
}
else
++it;
@@ -182,11 +180,11 @@ void SdrMarkList::ImpForceSort()
// remove duplicates
if(maList.size() > 1)
{
- SdrMark* pCurrent = maList.back();
+ SdrMark* pCurrent = maList.back().get();
for (size_t count = maList.size() - 1; count; --count)
{
size_t i = count - 1;
- SdrMark* pCmp = maList[i];
+ SdrMark* pCmp = maList[i].get();
assert(pCurrent->GetMarkedSdrObj());
if(pCurrent->GetMarkedSdrObj() == pCmp->GetMarkedSdrObj())
{
@@ -199,8 +197,6 @@ void SdrMarkList::ImpForceSort()
// delete pCmp
maList.erase(maList.begin() + i);
-
- delete pCmp;
}
else
{
@@ -214,10 +210,6 @@ void SdrMarkList::ImpForceSort()
void SdrMarkList::Clear()
{
- for (auto const& elem : maList)
- {
- delete elem;
- }
maList.clear();
mbSorted = true; //we're empty, so can be considered sorted
SetNameDirty();
@@ -230,8 +222,7 @@ SdrMarkList& SdrMarkList::operator=(const SdrMarkList& rLst)
for(size_t i = 0; i < rLst.GetMarkCount(); ++i)
{
SdrMark* pMark = rLst.GetMark(i);
- SdrMark* pNewMark = new SdrMark(*pMark);
- maList.push_back(pNewMark);
+ maList.emplace_back(new SdrMark(*pMark));
}
maMarkName = rLst.maMarkName;
@@ -245,7 +236,7 @@ SdrMarkList& SdrMarkList::operator=(const SdrMarkList& rLst)
SdrMark* SdrMarkList::GetMark(size_t nNum) const
{
- return (nNum < maList.size()) ? maList[nNum] : nullptr;
+ return (nNum < maList.size()) ? maList[nNum].get() : nullptr;
}
size_t SdrMarkList::FindObject(const SdrObject* pObj) const
@@ -283,7 +274,7 @@ void SdrMarkList::InsertEntry(const SdrMark& rMark, bool bChkSort)
if(!bChkSort)
mbSorted = false;
- maList.push_back(new SdrMark(rMark));
+ maList.emplace_back(new SdrMark(rMark));
}
else
{
@@ -303,8 +294,7 @@ void SdrMarkList::InsertEntry(const SdrMark& rMark, bool bChkSort)
}
else
{
- SdrMark* pCopy = new SdrMark(rMark);
- maList.push_back(pCopy);
+ maList.emplace_back(new SdrMark(rMark));
// now check if the sort is ok
const SdrObjList* pLastOL = pLastObj!=nullptr ? pLastObj->getParentOfSdrObject() : nullptr;
@@ -338,7 +328,6 @@ void SdrMarkList::DeleteMark(size_t nNum)
if(pMark)
{
maList.erase(maList.begin() + nNum);
- delete pMark;
if (maList.empty())
mbSorted = true; //we're empty, so can be considered sorted
SetNameDirty();
@@ -352,10 +341,8 @@ void SdrMarkList::ReplaceMark(const SdrMark& rNewMark, size_t nNum)
if(pMark)
{
- delete pMark;
SetNameDirty();
- SdrMark* pCopy = new SdrMark(rNewMark);
- maList[nNum] = pCopy;
+ maList[nNum].reset(new SdrMark(rNewMark));
mbSorted = false;
}
}
@@ -374,7 +361,7 @@ void SdrMarkList::Merge(const SdrMarkList& rSrcList, bool bReverse)
{
for(size_t i = 0; i < nCount; ++i)
{
- SdrMark* pM = rSrcList.maList[i];
+ SdrMark* pM = rSrcList.maList[i].get();
InsertEntry(*pM);
}
}
@@ -383,7 +370,7 @@ void SdrMarkList::Merge(const SdrMarkList& rSrcList, bool bReverse)
for(size_t i = nCount; i > 0;)
{
--i;
- SdrMark* pM = rSrcList.maList[i];
+ SdrMark* pM = rSrcList.maList[i].get();
InsertEntry(*pM);
}
}
@@ -393,14 +380,13 @@ bool SdrMarkList::DeletePageView(const SdrPageView& rPV)
{
bool bChgd(false);
- for(std::vector<SdrMark*>::iterator it = maList.begin(); it != maList.end(); )
+ for(auto it = maList.begin(); it != maList.end(); )
{
- SdrMark* pMark = *it;
+ SdrMark* pMark = it->get();
if(pMark->GetPageView()==&rPV)
{
it = maList.erase(it);
- delete pMark;
SetNameDirty();
bChgd = true;
}
@@ -425,8 +411,7 @@ bool SdrMarkList::InsertPageView(const SdrPageView& rPV)
if(bDoIt)
{
- SdrMark* pM = new SdrMark(pObj, const_cast<SdrPageView*>(&rPV));
- maList.push_back(pM);
+ maList.emplace_back(new SdrMark(pObj, const_cast<SdrPageView*>(&rPV)));
SetNameDirty();
bChgd = true;
}
commit 12fe762438d761d8cf32f264a0e1c2d57b65aeb8
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Thu May 3 09:58:58 2018 +0200
m_bStandardPushed is dead
Change-Id: Ibea072af1c6f6de968535807dadf89866123ba44
Reviewed-on: https://gerrit.libreoffice.org/53775
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/sfx2/tabdlg.hxx b/include/sfx2/tabdlg.hxx
index e4df01acbc9a..9317380174a3 100644
--- a/include/sfx2/tabdlg.hxx
+++ b/include/sfx2/tabdlg.hxx
@@ -245,7 +245,6 @@ private:
std::unique_ptr<SfxItemSet> m_pOutSet;
std::unique_ptr< TabDlg_Impl > m_pImpl;
sal_uInt16* m_pRanges;
- bool m_bStandardPushed;
DECL_DLLPRIVATE_LINK(ActivatePageHdl, const OString&, void);
DECL_DLLPRIVATE_LINK(DeactivatePageHdl, const OString&, bool);
diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx
index 9e6e9155cd9a..ec2c9befddda 100644
--- a/sfx2/source/dialog/tabdlg.cxx
+++ b/sfx2/source/dialog/tabdlg.cxx
@@ -1470,7 +1470,6 @@ SfxTabDialogController::SfxTabDialogController
, m_pSet(pItemSet ? new SfxItemSet(*pItemSet) : nullptr)
, m_pOutSet(nullptr)
, m_pRanges(nullptr)
- , m_bStandardPushed(false)
, m_pExampleSet(nullptr)
{
Init_Impl(bEditFmt);
@@ -1889,8 +1888,6 @@ short SfxTabDialogController::Ok()
if ( m_pOutSet && m_pOutSet->Count() > 0 )
bModified = true;
- if (m_bStandardPushed)
- bModified = true;
return bModified ? RET_OK : RET_CANCEL;
}
More information about the Libreoffice-commits
mailing list