[Libreoffice-commits] core.git: include/svx svx/source
Takeshi Abe
tabe at fixedpoint.jp
Wed Sep 13 14:14:22 UTC 2017
include/svx/svdhlpln.hxx | 23 ++++++++++-------------
svx/source/svdraw/svdhlpln.cxx | 8 ++------
2 files changed, 12 insertions(+), 19 deletions(-)
New commits:
commit 84b8e14ad30bc3bfbd52b38fe5472a6d85e4f41a
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date: Wed Sep 13 18:34:58 2017 +0900
svx: Simplify SdrHelpLineList with std::unique_ptr
This also kills no longer used SdrHelpLineList::GetObject().
Change-Id: I6e08e44214657c536717e96693c89104d7118cfd
Reviewed-on: https://gerrit.libreoffice.org/42234
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Michael Stahl <mstahl at redhat.com>
diff --git a/include/svx/svdhlpln.hxx b/include/svx/svdhlpln.hxx
index 86890979f91d..ede56f82d279 100644
--- a/include/svx/svdhlpln.hxx
+++ b/include/svx/svdhlpln.hxx
@@ -26,6 +26,7 @@
#include <vcl/pointr.hxx>
#include <svx/svxdllapi.h>
+#include <memory>
class OutputDevice;
@@ -58,34 +59,30 @@ public:
#define SDRHELPLINE_NOTFOUND 0xFFFF
class SVX_DLLPUBLIC SdrHelpLineList {
- std::vector<SdrHelpLine*> aList;
-protected:
- SdrHelpLine* GetObject(sal_uInt16 i) const { return aList[i]; }
+ std::vector<std::unique_ptr<SdrHelpLine>> aList;
+
public:
- SdrHelpLineList(): aList() {}
- SdrHelpLineList(const SdrHelpLineList& rSrcList): aList() { *this=rSrcList; }
- ~SdrHelpLineList() { Clear(); }
+ SdrHelpLineList() {}
+ SdrHelpLineList(const SdrHelpLineList& rSrcList) { *this=rSrcList; }
void Clear();
SdrHelpLineList& operator=(const SdrHelpLineList& rSrcList);
bool operator==(const SdrHelpLineList& rCmp) const;
bool operator!=(const SdrHelpLineList& rCmp) const { return !operator==(rCmp); }
sal_uInt16 GetCount() const { return sal_uInt16(aList.size()); }
- void Insert(const SdrHelpLine& rHL) { aList.push_back(new SdrHelpLine(rHL)); }
+ void Insert(const SdrHelpLine& rHL) { aList.emplace_back(new SdrHelpLine(rHL)); }
void Insert(const SdrHelpLine& rHL, sal_uInt16 nPos)
{
if(nPos==0xFFFF)
- aList.push_back(new SdrHelpLine(rHL));
+ aList.emplace_back(new SdrHelpLine(rHL));
else
- aList.insert(aList.begin() + nPos, new SdrHelpLine(rHL));
+ aList.emplace(aList.begin() + nPos, new SdrHelpLine(rHL));
}
void Delete(sal_uInt16 nPos)
{
- SdrHelpLine* p = aList[nPos];
- delete p;
aList.erase(aList.begin() + nPos);
}
- SdrHelpLine& operator[](sal_uInt16 nPos) { return *GetObject(nPos); }
- const SdrHelpLine& operator[](sal_uInt16 nPos) const { return *GetObject(nPos); }
+ SdrHelpLine& operator[](sal_uInt16 nPos) { return *aList[nPos]; }
+ const SdrHelpLine& operator[](sal_uInt16 nPos) const { return *aList[nPos]; }
sal_uInt16 HitTest(const Point& rPnt, sal_uInt16 nTolLog, const OutputDevice& rOut) const;
};
diff --git a/svx/source/svdraw/svdhlpln.cxx b/svx/source/svdraw/svdhlpln.cxx
index 622ae221b78d..a1260d51dd95 100644
--- a/svx/source/svdraw/svdhlpln.cxx
+++ b/svx/source/svdraw/svdhlpln.cxx
@@ -75,10 +75,6 @@ tools::Rectangle SdrHelpLine::GetBoundRect(const OutputDevice& rOut) const
void SdrHelpLineList::Clear()
{
- sal_uInt16 nCount=GetCount();
- for (sal_uInt16 i=0; i<nCount; i++) {
- delete GetObject(i);
- }
aList.clear();
}
@@ -99,7 +95,7 @@ bool SdrHelpLineList::operator==(const SdrHelpLineList& rSrcList) const
if (nCount==rSrcList.GetCount()) {
bEqual = true;
for (sal_uInt16 i=0; i<nCount && bEqual; i++) {
- if (*GetObject(i)!=*rSrcList.GetObject(i)) {
+ if (*aList[i]!=*rSrcList.aList[i]) {
bEqual = false;
}
}
@@ -112,7 +108,7 @@ sal_uInt16 SdrHelpLineList::HitTest(const Point& rPnt, sal_uInt16 nTolLog, const
sal_uInt16 nCount=GetCount();
for (sal_uInt16 i=nCount; i>0;) {
i--;
- if (GetObject(i)->IsHit(rPnt,nTolLog,rOut)) return i;
+ if (aList[i]->IsHit(rPnt,nTolLog,rOut)) return i;
}
return SDRHELPLINE_NOTFOUND;
}
More information about the Libreoffice-commits
mailing list