Kaydet (Commit) 84b8e14a authored tarafından Takeshi Abe's avatar Takeshi Abe Kaydeden (comit) Michael Stahl

svx: Simplify SdrHelpLineList with std::unique_ptr

This also kills no longer used SdrHelpLineList::GetObject().

Change-Id: I6e08e44214657c536717e96693c89104d7118cfd
Reviewed-on: https://gerrit.libreoffice.org/42234Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMichael Stahl <mstahl@redhat.com>
üst 1f582e38
......@@ -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;
};
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment