[Libreoffice-commits] .: 16 commits - reportdesign/source sd/source svx/inc svx/source
Michael Stahl
mst at kemper.freedesktop.org
Thu Aug 16 06:17:18 PDT 2012
reportdesign/source/ui/report/dlgedfunc.cxx | 4
sd/source/ui/animations/motionpathtag.cxx | 16 +-
svx/inc/svdibrow.hxx | 5
svx/inc/svx/sdrpagewindow.hxx | 1
svx/inc/svx/svddrag.hxx | 11 -
svx/inc/svx/svdetc.hxx | 50 +------
svx/inc/svx/svdglob.hxx | 2
svx/inc/svx/svdglue.hxx | 19 +-
svx/inc/svx/svdhdl.hxx | 11 -
svx/inc/svx/svdhlpln.hxx | 34 +++--
svx/inc/svx/svdlayer.hxx | 35 ++++-
svx/inc/svx/svdmark.hxx | 117 +-----------------
svx/source/svdraw/svddrag.cxx | 19 +-
svx/source/svdraw/svddrgmt.cxx | 22 +--
svx/source/svdraw/svdetc.cxx | 91 +++-----------
svx/source/svdraw/svdfmtf.hxx | 1
svx/source/svdraw/svdglev.cxx | 34 +++--
svx/source/svdraw/svdglue.cxx | 4
svx/source/svdraw/svdhdl.cxx | 94 ++++++--------
svx/source/svdraw/svdhlpln.cxx | 2
svx/source/svdraw/svdibrow.cxx | 30 ++--
svx/source/svdraw/svdlayer.cxx | 37 +++--
svx/source/svdraw/svdmark.cxx | 179 ++++++----------------------
svx/source/svdraw/svdmrkv.cxx | 12 -
svx/source/svdraw/svdmrkv1.cxx | 94 +++++---------
svx/source/svdraw/svdoole2.cxx | 4
svx/source/svdraw/svdpoev.cxx | 44 +++---
27 files changed, 359 insertions(+), 613 deletions(-)
New commits:
commit 81b5ecc5a68cd15497301e6b10b462673f93655f
Author: Noel Grandin <noel at peralex.com>
Date: Wed Aug 15 11:30:54 2012 +0200
Convert aLayer field in SdrLayerAdmin class from Container to std::vector
Change-Id: I884f8e76d0bc7b2eb9f99434809fa824409446e4
diff --git a/svx/inc/svx/svdlayer.hxx b/svx/inc/svx/svdlayer.hxx
index aac75c9..f0b468b 100644
--- a/svx/inc/svx/svdlayer.hxx
+++ b/svx/inc/svx/svdlayer.hxx
@@ -35,6 +35,7 @@
#include <svx/svdsob.hxx>
#include <svx/svdtypes.hxx> // fuer typedef SdrLayerID
#include "svx/svxdllapi.h"
+#include <algorithm>
class SdrModel;
@@ -84,7 +85,7 @@ friend class SdrModel;
friend class SdrPage;
protected:
- Container aLayer;
+ std::vector<SdrLayer*> aLayer;
Container aLSets;
SdrLayerAdmin* pParent; // Der Admin der Seite kennt den Admin des Docs
SdrModel* pModel; // zum Broadcasten
@@ -107,20 +108,42 @@ public:
void SetParent(SdrLayerAdmin* pNewParent) { pParent=pNewParent; }
void SetModel(SdrModel* pNewModel);
SdrModel* GetModel() const { return pModel; }
- void InsertLayer(SdrLayer* pLayer, sal_uInt16 nPos=0xFFFF) { aLayer.Insert(pLayer,nPos); pLayer->SetModel(pModel); Broadcast(); }
+ void InsertLayer(SdrLayer* pLayer)
+ {
+ aLayer.push_back(pLayer);
+ pLayer->SetModel(pModel);
+ Broadcast();
+ }
+ void InsertLayer(SdrLayer* pLayer, sal_uInt16 nPos)
+ {
+ if(nPos==0xFFFF)
+ aLayer.push_back(pLayer);
+ else
+ aLayer.insert(aLayer.begin() + nPos, pLayer);
+ pLayer->SetModel(pModel);
+ Broadcast();
+ }
SdrLayer* RemoveLayer(sal_uInt16 nPos);
// Alle Layer loeschen
void ClearLayer();
// Neuer Layer wird angelegt und eingefuegt
SdrLayer* NewLayer(const String& rName, sal_uInt16 nPos=0xFFFF);
- void DeleteLayer(SdrLayer* pLayer) { aLayer.Remove(pLayer); delete pLayer; Broadcast(); }
+ void DeleteLayer(SdrLayer* pLayer)
+ {
+ std::vector<SdrLayer*>::iterator it = std::find(aLayer.begin(), aLayer.end(), pLayer);
+ if( it == aLayer.end() )
+ return;
+ aLayer.erase(it);
+ delete pLayer;
+ Broadcast();
+ }
// Neuer Layer, Name wird aus der Resource geholt
SdrLayer* NewStandardLayer(sal_uInt16 nPos=0xFFFF);
// Iterieren ueber alle Layer
- sal_uInt16 GetLayerCount() const { return sal_uInt16(aLayer.Count()); }
- SdrLayer* GetLayer(sal_uInt16 i) { return (SdrLayer*)(aLayer.GetObject(i)); }
- const SdrLayer* GetLayer(sal_uInt16 i) const { return (SdrLayer*)(aLayer.GetObject(i)); }
+ sal_uInt16 GetLayerCount() const { return sal_uInt16(aLayer.size()); }
+ SdrLayer* GetLayer(sal_uInt16 i) { return aLayer[i]; }
+ const SdrLayer* GetLayer(sal_uInt16 i) const { return aLayer[i]; }
sal_uInt16 GetLayerPos(SdrLayer* pLayer) const;
diff --git a/svx/source/svdraw/svdlayer.cxx b/svx/source/svdraw/svdlayer.cxx
index f946fc0..4b02822 100644
--- a/svx/source/svdraw/svdlayer.cxx
+++ b/svx/source/svdraw/svdlayer.cxx
@@ -159,7 +159,7 @@ bool SdrLayer::operator==(const SdrLayer& rCmpLayer) const
////////////////////////////////////////////////////////////////////////////////////////////////////
SdrLayerAdmin::SdrLayerAdmin(SdrLayerAdmin* pNewParent):
- aLayer(1024,16,16),
+ aLayer(),
aLSets(1024,16,16),
pModel(NULL)
{
@@ -168,7 +168,7 @@ SdrLayerAdmin::SdrLayerAdmin(SdrLayerAdmin* pNewParent):
}
SdrLayerAdmin::SdrLayerAdmin(const SdrLayerAdmin& rSrcLayerAdmin):
- aLayer(1024,16,16),
+ aLayer(),
aLSets(1024,16,16),
pParent(NULL),
pModel(NULL)
@@ -184,13 +184,9 @@ SdrLayerAdmin::~SdrLayerAdmin()
void SdrLayerAdmin::ClearLayer()
{
- SdrLayer* pL;
- pL=(SdrLayer*)aLayer.First();
- while (pL!=NULL) {
- delete pL;
- pL=(SdrLayer*)aLayer.Next();
- }
- aLayer.Clear();
+ for( std::vector<SdrLayer*>::const_iterator it = aLayer.begin(); it != aLayer.end(); ++it )
+ delete *it;
+ aLayer.clear();
}
const SdrLayerAdmin& SdrLayerAdmin::operator=(const SdrLayerAdmin& rSrcLayerAdmin)
@@ -200,7 +196,7 @@ const SdrLayerAdmin& SdrLayerAdmin::operator=(const SdrLayerAdmin& rSrcLayerAdmi
sal_uInt16 i;
sal_uInt16 nAnz=rSrcLayerAdmin.GetLayerCount();
for (i=0; i<nAnz; i++) {
- aLayer.Insert(new SdrLayer(*rSrcLayerAdmin.GetLayer(i)),CONTAINER_APPEND);
+ aLayer.push_back(new SdrLayer(*rSrcLayerAdmin.GetLayer(i)));
}
return *this;
}
@@ -208,7 +204,7 @@ const SdrLayerAdmin& SdrLayerAdmin::operator=(const SdrLayerAdmin& rSrcLayerAdmi
bool SdrLayerAdmin::operator==(const SdrLayerAdmin& rCmpLayerAdmin) const
{
if (pParent!=rCmpLayerAdmin.pParent ||
- aLayer.Count()!=rCmpLayerAdmin.aLayer.Count() ||
+ aLayer.size()!=rCmpLayerAdmin.aLayer.size() ||
aLSets.Count()!=rCmpLayerAdmin.aLSets.Count()) return sal_False;
bool bOk = true;
sal_uInt16 nAnz=GetLayerCount();
@@ -243,7 +239,8 @@ void SdrLayerAdmin::Broadcast() const
SdrLayer* SdrLayerAdmin::RemoveLayer(sal_uInt16 nPos)
{
- SdrLayer* pRetLayer=(SdrLayer*)(aLayer.Remove(nPos));
+ SdrLayer* pRetLayer=aLayer[nPos];
+ aLayer.erase(aLayer.begin()+nPos);
Broadcast();
return pRetLayer;
}
@@ -253,7 +250,10 @@ SdrLayer* SdrLayerAdmin::NewLayer(const XubString& rName, sal_uInt16 nPos)
SdrLayerID nID=GetUniqueLayerID();
SdrLayer* pLay=new SdrLayer(nID,rName);
pLay->SetModel(pModel);
- aLayer.Insert(pLay,nPos);
+ if(nPos==0xFFFF)
+ aLayer.push_back(pLay);
+ else
+ aLayer.insert(aLayer.begin() + nPos, pLay);
Broadcast();
return pLay;
}
@@ -264,7 +264,10 @@ SdrLayer* SdrLayerAdmin::NewStandardLayer(sal_uInt16 nPos)
SdrLayer* pLay=new SdrLayer(nID,String());
pLay->SetStandardLayer();
pLay->SetModel(pModel);
- aLayer.Insert(pLay,nPos);
+ if(nPos==0xFFFF)
+ aLayer.push_back(pLay);
+ else
+ aLayer.insert(aLayer.begin() + nPos, pLay);
Broadcast();
return pLay;
}
@@ -273,9 +276,11 @@ sal_uInt16 SdrLayerAdmin::GetLayerPos(SdrLayer* pLayer) const
{
sal_uIntPtr nRet=SDRLAYER_NOTFOUND;
if (pLayer!=NULL) {
- nRet=aLayer.GetPos(pLayer);
- if (nRet==CONTAINER_ENTRY_NOTFOUND) {
+ std::vector<SdrLayer*>::const_iterator it = std::find(aLayer.begin(), aLayer.end(), pLayer);
+ if (it==aLayer.end()) {
nRet=SDRLAYER_NOTFOUND;
+ } else {
+ nRet=it - aLayer.begin();
}
}
return sal_uInt16(nRet);
commit 87e31cb51b277513d28eff5236f308f2941126b4
Author: Noel Grandin <noel at peralex.com>
Date: Wed Aug 15 11:12:18 2012 +0200
Convert aList field in SdrHelpLineList class from Container to std::vector
Change-Id: Ie91548bfad1cd60d8926cb5cc729a07f539590a1
diff --git a/svx/inc/svx/svdhlpln.hxx b/svx/inc/svx/svdhlpln.hxx
index 33b0a8c..51dc1c9 100644
--- a/svx/inc/svx/svdhlpln.hxx
+++ b/svx/inc/svx/svdhlpln.hxx
@@ -34,7 +34,6 @@
#include <tools/gen.hxx>
#include <vcl/pointr.hxx>
-#include <tools/contnr.hxx>
#include "svx/svxdllapi.h"
class OutputDevice;
@@ -73,21 +72,38 @@ public:
#define SDRHELPLINE_NOTFOUND 0xFFFF
class SVX_DLLPUBLIC SdrHelpLineList {
- Container aList;
+ std::vector<SdrHelpLine*> aList;
protected:
- SdrHelpLine* GetObject(sal_uInt16 i) const { return (SdrHelpLine*)(aList.GetObject(i)); }
+ SdrHelpLine* GetObject(sal_uInt16 i) const { return aList[i]; }
public:
- SdrHelpLineList(): aList(1024,4,4) {}
- SdrHelpLineList(const SdrHelpLineList& rSrcList): aList(1024,4,4) { *this=rSrcList; }
+ SdrHelpLineList(): aList() {}
+ SdrHelpLineList(const SdrHelpLineList& rSrcList): aList() { *this=rSrcList; }
~SdrHelpLineList() { Clear(); }
void Clear();
void 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.Count()); }
- void Insert(const SdrHelpLine& rHL, sal_uInt16 nPos=0xFFFF) { aList.Insert(new SdrHelpLine(rHL),nPos); }
- void Delete(sal_uInt16 nPos) { delete (SdrHelpLine*)aList.Remove(nPos); } // #i24900#
- void Move(sal_uInt16 nPos, sal_uInt16 nNewPos) { aList.Insert(aList.Remove(nPos),nNewPos); }
+ 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, sal_uInt16 nPos)
+ {
+ if(nPos==0xFFFF)
+ aList.push_back(new SdrHelpLine(rHL));
+ else
+ aList.insert(aList.begin() + nPos, new SdrHelpLine(rHL));
+ }
+ void Delete(sal_uInt16 nPos)
+ {
+ SdrHelpLine* p = aList[nPos];
+ delete p;
+ aList.erase(aList.begin() + nPos);
+ }
+ void Move(sal_uInt16 nPos, sal_uInt16 nNewPos)
+ {
+ SdrHelpLine* p = aList[nPos];
+ aList.erase(aList.begin() + nPos);
+ aList.insert(aList.begin() + nNewPos, p);
+ }
SdrHelpLine& operator[](sal_uInt16 nPos) { return *GetObject(nPos); }
const SdrHelpLine& operator[](sal_uInt16 nPos) const { return *GetObject(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 7b44b46..70508e0 100644
--- a/svx/source/svdraw/svdhlpln.cxx
+++ b/svx/source/svdraw/svdhlpln.cxx
@@ -89,7 +89,7 @@ void SdrHelpLineList::Clear()
for (sal_uInt16 i=0; i<nAnz; i++) {
delete GetObject(i);
}
- aList.Clear();
+ aList.clear();
}
void SdrHelpLineList::operator=(const SdrHelpLineList& rSrcList)
commit a6f60d546ac61bfd9db7fad06138512cde4acb5a
Author: Noel Grandin <noel at peralex.com>
Date: Wed Aug 15 10:49:33 2012 +0200
Convert aList in SdrGluePointList class from Container to std::vector
Change-Id: I401b01d5d1072262d0bd2b85298751c9180004d3
diff --git a/svx/inc/svx/svdglue.hxx b/svx/inc/svx/svdglue.hxx
index c6a58eb..43fce9f 100644
--- a/svx/inc/svx/svdglue.hxx
+++ b/svx/inc/svx/svdglue.hxx
@@ -34,9 +34,9 @@ class OutputDevice;
class SvStream;
class SdrObject;
-#include <tools/contnr.hxx>
#include <tools/gen.hxx>
#include "svx/svxdllapi.h"
+#include <vector>
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -116,20 +116,25 @@ public:
#define SDRGLUEPOINT_NOTFOUND 0xFFFF
class SVX_DLLPUBLIC SdrGluePointList {
- Container aList;
+ std::vector<SdrGluePoint*> aList;
protected:
- SdrGluePoint* GetObject(sal_uInt16 i) const { return (SdrGluePoint*)(aList.GetObject(i)); }
+ SdrGluePoint* GetObject(sal_uInt16 i) const { return aList[i]; }
public:
- SdrGluePointList(): aList(1024,4,4) {}
- SdrGluePointList(const SdrGluePointList& rSrcList): aList(1024,4,4) { *this=rSrcList; }
+ SdrGluePointList(): aList() {}
+ SdrGluePointList(const SdrGluePointList& rSrcList): aList() { *this=rSrcList; }
~SdrGluePointList() { Clear(); }
void Clear();
void operator=(const SdrGluePointList& rSrcList);
- sal_uInt16 GetCount() const { return sal_uInt16(aList.Count()); }
+ sal_uInt16 GetCount() const { return sal_uInt16(aList.size()); }
// Beim Insert wird dem Objekt (also dem GluePoint) automatisch eine Id zugewiesen.
// ReturnCode ist der Index des neuen GluePoints in der Liste
sal_uInt16 Insert(const SdrGluePoint& rGP);
- void Delete(sal_uInt16 nPos) { delete (SdrGluePoint*)aList.Remove(nPos); }
+ void Delete(sal_uInt16 nPos)
+ {
+ SdrGluePoint* p = aList[nPos];
+ aList.erase(aList.begin()+nPos);
+ delete p;
+ }
SdrGluePoint& operator[](sal_uInt16 nPos) { return *GetObject(nPos); }
const SdrGluePoint& operator[](sal_uInt16 nPos) const { return *GetObject(nPos); }
sal_uInt16 FindGluePoint(sal_uInt16 nId) const;
diff --git a/svx/source/svdraw/svdfmtf.hxx b/svx/source/svdraw/svdfmtf.hxx
index 96e12cb..85bebfb 100644
--- a/svx/source/svdraw/svdfmtf.hxx
+++ b/svx/source/svdraw/svdfmtf.hxx
@@ -29,6 +29,7 @@
#ifndef _SVDFMTF_HXX
#define _SVDFMTF_HXX
+#include <tools/contnr.hxx>
#include <vcl/metaact.hxx>
#include <vcl/virdev.hxx>
#include <svx/svdobj.hxx>
diff --git a/svx/source/svdraw/svdglue.cxx b/svx/source/svdraw/svdglue.cxx
index 1490d37..911879d 100644
--- a/svx/source/svdraw/svdglue.cxx
+++ b/svx/source/svdraw/svdglue.cxx
@@ -277,7 +277,7 @@ void SdrGluePointList::Clear()
for (sal_uInt16 i=0; i<nAnz; i++) {
delete GetObject(i);
}
- aList.Clear();
+ aList.clear();
}
void SdrGluePointList::operator=(const SdrGluePointList& rSrcList)
@@ -320,7 +320,7 @@ sal_uInt16 SdrGluePointList::Insert(const SdrGluePoint& rGP)
}
pGP->SetId(nId);
}
- aList.Insert(pGP,nInsPos);
+ aList.insert(aList.begin()+nInsPos, pGP);
return nInsPos;
}
commit deb266708f4d3ab3c64c33e93c96f19479da7d95
Author: Noel Grandin <noel at peralex.com>
Date: Wed Aug 15 10:25:16 2012 +0200
Remove unnecessary include
Change-Id: Ie3cf56fd23b516b80dc39ceb92d4535c6583f97b
diff --git a/svx/inc/svx/svdglob.hxx b/svx/inc/svx/svdglob.hxx
index 2f72782..1f8b9a1 100644
--- a/svx/inc/svx/svdglob.hxx
+++ b/svx/inc/svx/svdglob.hxx
@@ -20,8 +20,6 @@
#ifndef _SVDGLOB_HXX
#define _SVDGLOB_HXX
-#include <tools/contnr.hxx>
-
#include <tools/resid.hxx>
#include <tools/string.hxx>
commit d36d6cf72c37f03a5283b527ed2af9350fffec17
Author: Noel Grandin <noel at peralex.com>
Date: Wed Aug 15 10:21:04 2012 +0200
Remove unnecessary include
Change-Id: I27c4b22987d2a54eb71f5636eb72ba2e635ac6d8
diff --git a/svx/inc/svx/sdrpagewindow.hxx b/svx/inc/svx/sdrpagewindow.hxx
index b4e0d01..bb96b8d 100644
--- a/svx/inc/svx/sdrpagewindow.hxx
+++ b/svx/inc/svx/sdrpagewindow.hxx
@@ -36,7 +36,6 @@
#include <cppuhelper/implbase4.hxx>
#include <svx/sdr/overlay/overlaymanager.hxx>
#include <svx/svdtypes.hxx> // for SdrLayerID
-#include <tools/contnr.hxx>
#include <svx/sdrpagewindow.hxx>
#include "svx/svxdllapi.h"
commit bd00fd98c66e3a19aeea30a4ecef0873da54d5bf
Author: Michael Stahl <mstahl at redhat.com>
Date: Thu Aug 16 14:45:26 2012 +0200
_SdrItemBrowserControl::SetAttributes: fix previous commit:
Since the element is no longer removed in the loop the same element is
deleted over and over; also the erase should be from nEntryNum to end.
Change-Id: I5767d5e453b5b9b05fe1869ab8915f23c30aab14
diff --git a/svx/source/svdraw/svdibrow.cxx b/svx/source/svdraw/svdibrow.cxx
index f76e423..ecc11a9 100644
--- a/svx/source/svdraw/svdibrow.cxx
+++ b/svx/source/svdraw/svdibrow.cxx
@@ -1043,11 +1043,11 @@ void _SdrItemBrowserControl::SetAttributes(const SfxItemSet* pSet, const SfxItem
} // while
if (aList.size()>nEntryNum) { // maybe still too many entries
- sal_uIntPtr nTooMuch=aList.size()-nEntryNum;
- for (sal_uIntPtr nNum=0; nNum<nTooMuch; nNum++) {
- delete ImpGetEntry(nEntryNum);
+ size_t const nTooMuch = aList.size() - nEntryNum;
+ for (size_t n = nEntryNum; n < aList.size(); ++n) {
+ delete aList[n];
}
- aList.erase(aList.begin(), aList.begin() + nTooMuch);
+ aList.erase(aList.begin() + nEntryNum, aList.end());
RowRemoved(nEntryNum,nTooMuch);
}
} else {
commit 3c4fd9de6270948a3f215ae7da23d7f30c1d76da
Author: Noel Grandin <noel at peralex.com>
Date: Wed Aug 15 10:09:20 2012 +0200
Convert aList in class _SdrItemBrowserControl from Container to std::vector
Change-Id: I9a64f26e57b9ceb35100364c2e875e2f07a4be65
diff --git a/svx/inc/svdibrow.hxx b/svx/inc/svdibrow.hxx
index a71227e..8a8e868 100644
--- a/svx/inc/svdibrow.hxx
+++ b/svx/inc/svdibrow.hxx
@@ -29,7 +29,6 @@
#ifndef _SVDIBROW_HXX
#define _SVDIBROW_HXX
-#include <tools/contnr.hxx>
#include <svtools/brwbox.hxx>
#include <vcl/edit.hxx>
#include <vcl/floatwin.hxx>
@@ -41,7 +40,7 @@ class BrowserMouseEvent;
class _SdrItemBrowserControl: public BrowseBox
{
friend class ImpItemEdit;
- Container aList;
+ std::vector<ImpItemListRow*> aList;
long nAktPaintRow;
Edit* pEditControl;
XubString aWNamMerk;
@@ -61,7 +60,7 @@ private:
#if _SOLAR__PRIVATE
void ImpCtor();
void ImpSetEntry(const ImpItemListRow& rEntry, sal_uIntPtr nEntryNum);
- ImpItemListRow* ImpGetEntry(sal_uIntPtr nPos) const { return (ImpItemListRow*)aList.GetObject(nPos); }
+ ImpItemListRow* ImpGetEntry(sal_uIntPtr nPos) const { return aList[nPos]; }
void ImpSaveWhich();
void ImpRestoreWhich();
#endif // __PRIVATE
diff --git a/svx/source/svdraw/svdibrow.cxx b/svx/source/svdraw/svdibrow.cxx
index 21cef82..f76e423 100644
--- a/svx/source/svdraw/svdibrow.cxx
+++ b/svx/source/svdraw/svdibrow.cxx
@@ -219,7 +219,7 @@ void ImpItemEdit::KeyInput(const KeyEvent& rKEvt)
_SdrItemBrowserControl::_SdrItemBrowserControl(Window* pParent, WinBits nBits):
BrowseBox(pParent,nBits,MYBROWSEMODE),
- aList(1024,16,16)
+ aList()
{
ImpCtor();
}
@@ -290,17 +290,17 @@ void _SdrItemBrowserControl::ImpCtor()
void _SdrItemBrowserControl::Clear()
{
- sal_uIntPtr nAnz=aList.Count();
+ sal_uIntPtr nAnz=aList.size();
for (sal_uIntPtr nNum=0; nNum<nAnz; nNum++) {
delete ImpGetEntry(nNum);
}
- aList.Clear();
+ aList.clear();
BrowseBox::Clear();
}
long _SdrItemBrowserControl::GetRowCount() const
{
- return aList.Count();
+ return aList.size();
}
sal_Bool _SdrItemBrowserControl::SeekRow(long nRow)
@@ -312,7 +312,7 @@ sal_Bool _SdrItemBrowserControl::SeekRow(long nRow)
String _SdrItemBrowserControl::GetCellText(long _nRow, sal_uInt16 _nColId) const
{
String sRet;
- if ( _nRow >= 0 && _nRow < (sal_Int32)aList.Count() )
+ if ( _nRow >= 0 && _nRow < (sal_Int32)aList.size() )
{
ImpItemListRow* pEntry = ImpGetEntry(_nRow);
if ( pEntry )
@@ -354,7 +354,7 @@ String _SdrItemBrowserControl::GetCellText(long _nRow, sal_uInt16 _nColId) const
void _SdrItemBrowserControl::PaintField(OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColumnId) const
{
- if (nAktPaintRow<0 || (sal_uIntPtr)nAktPaintRow>=aList.Count()) {
+ if (nAktPaintRow<0 || (sal_uIntPtr)nAktPaintRow>=aList.size()) {
return;
}
Rectangle aR(rRect);
@@ -383,7 +383,7 @@ sal_uIntPtr _SdrItemBrowserControl::GetCurrentPos() const
sal_uIntPtr nRet=CONTAINER_ENTRY_NOTFOUND;
if (GetSelectRowCount()==1) {
long nPos=((BrowseBox*)this)->FirstSelectedRow();
- if (nPos>=0 && (sal_uIntPtr)nPos<aList.Count()) {
+ if (nPos>=0 && (sal_uIntPtr)nPos<aList.size()) {
nRet=(sal_uIntPtr)nPos;
}
}
@@ -470,7 +470,7 @@ void _SdrItemBrowserControl::ImpSaveWhich()
nLastWhich=nWh;
nLastWhichOfs=nPos-nTop;
if (nTop<0) nTop=0;
- if (nBtm>=(long)aList.Count()) nBtm=aList.Count()-1;
+ if (nBtm>=(long)aList.size()) nBtm=aList.size()-1;
nLastWhichOben=ImpGetEntry(nTop)->nWhichId;
nLastWhichUnten=ImpGetEntry(nBtm)->nWhichId;
}
@@ -480,7 +480,7 @@ void _SdrItemBrowserControl::ImpRestoreWhich()
{
if (nLastWhich!=0) {
bool bFnd = false;
- sal_uIntPtr nAnz=aList.Count();
+ sal_uIntPtr nAnz=aList.size();
sal_uIntPtr nNum;
for (nNum=0; nNum<nAnz && !bFnd; nNum++) {
ImpItemListRow* pEntry=ImpGetEntry(nNum);
@@ -573,7 +573,7 @@ void _SdrItemBrowserControl::ImpSetEntry(const ImpItemListRow& rEntry, sal_uIntP
{
ImpItemListRow* pAktEntry=ImpGetEntry(nEntryNum);
if (pAktEntry==NULL) {
- aList.Insert(new ImpItemListRow(rEntry),CONTAINER_APPEND);
+ aList.push_back(new ImpItemListRow(rEntry));
RowInserted(nEntryNum);
} else if (*pAktEntry!=rEntry) {
bool bStateDiff=rEntry.eState!=pAktEntry->eState;
@@ -1042,12 +1042,12 @@ void _SdrItemBrowserControl::SetAttributes(const SfxItemSet* pSet, const SfxItem
nWhich=aIter.NextWhich();
} // while
- if (aList.Count()>nEntryNum) { // maybe still too many entries
- sal_uIntPtr nTooMuch=aList.Count()-nEntryNum;
+ if (aList.size()>nEntryNum) { // maybe still too many entries
+ sal_uIntPtr nTooMuch=aList.size()-nEntryNum;
for (sal_uIntPtr nNum=0; nNum<nTooMuch; nNum++) {
delete ImpGetEntry(nEntryNum);
- aList.Remove(nEntryNum);
}
+ aList.erase(aList.begin(), aList.begin() + nTooMuch);
RowRemoved(nEntryNum,nTooMuch);
}
} else {
commit 0ed685f8ff352a5b1ec8604a9e943547f9ca7ef3
Author: Noel Grandin <noel at peralex.com>
Date: Wed Aug 15 09:39:52 2012 +0200
Remove unused class ContainerSorter
Change-Id: Iba5a8c370a6b097ac0de3911c6a76e6a86d4ac6b
diff --git a/svx/inc/svx/svdetc.hxx b/svx/inc/svx/svdetc.hxx
index 1ac93a3..dc5760b 100644
--- a/svx/inc/svx/svdetc.hxx
+++ b/svx/inc/svx/svdetc.hxx
@@ -30,7 +30,6 @@
#define _SVDETC_HXX
#include <tools/string.hxx>
-#include <tools/contnr.hxx>
#include <vcl/outdev.hxx>
#include <tools/shl.hxx>
@@ -119,25 +118,6 @@ class SfxItemSet;
// Bei XFILL_NONE gibt's sal_False und rCol bleibt unveraendert.
SVX_DLLPUBLIC bool GetDraftFillColor(const SfxItemSet& rSet, Color& rCol);
-class ContainerSorter {
-protected:
- Container& rCont;
-private:
- void ImpSubSort(long nL, long nR) const;
-public:
- ContainerSorter(Container& rNewCont): rCont(rNewCont) {}
- void DoSort(sal_uIntPtr a=0, sal_uIntPtr b=0xFFFFFFFF) const;
-
- // Compare() has to return:
- // -1 if *pElem1<*pElem2
- // 0 if *pElem1=*pElem2
- // +1 if *pElem1>*pElem2
- virtual int Compare(const void* pElem1, const void* pElem2) const=0;
-
-protected:
- ~ContainerSorter() {}
-};
-
////////////////////////////////////////////////////////////////////////////////////////////////////
// Ein ItemSet auf Outliner- bzw. EditEngine-Items durchsuchen
diff --git a/svx/source/svdraw/svdetc.cxx b/svx/source/svdraw/svdetc.cxx
index 776f526..54d9ae6 100644
--- a/svx/source/svdraw/svdetc.cxx
+++ b/svx/source/svdraw/svdetc.cxx
@@ -235,39 +235,6 @@ IMPL_LINK(OLEObjCache, UnloadCheckHdl, AutoTimer*, /*pTim*/)
return 0;
}
-void ContainerSorter::DoSort(sal_uIntPtr a, sal_uIntPtr b) const
-{
- sal_uIntPtr nAnz=rCont.Count();
- if (b>nAnz) b=nAnz;
- if (b>0) b--;
- if (a<b) ImpSubSort(a,b);
-}
-
-void ContainerSorter::ImpSubSort(long nL, long nR) const
-{
- long i,j;
- const void* pX;
- void* pI;
- void* pJ;
- i=nL;
- j=nR;
- pX=rCont.GetObject((nL+nR)/2);
- do {
- pI=rCont.Seek(i);
- while (pI!=pX && Compare(pI,pX)<0) { i++; pI=rCont.Next(); }
- pJ=rCont.Seek(j);
- while (pJ!=pX && Compare(pX,pJ)<0) { j--; pJ=rCont.Prev(); }
- if (i<=j) {
- rCont.Replace(pJ,i);
- rCont.Replace(pI,j);
- i++;
- j--;
- }
- } while (i<=j);
- if (nL<j) ImpSubSort(nL,j);
- if (i<nR) ImpSubSort(i,nR);
-}
-
////////////////////////////////////////////////////////////////////////////////////////////////////
void SdrLinkList::Clear()
commit 7d5922ca8f04604aba57708ee20fb4cdeaea2e44
Author: Noel Grandin <noel at peralex.com>
Date: Wed Aug 15 08:28:22 2012 +0200
Convert aList in SdrHdlList class from Container to std::deque
Change-Id: I54c60fefe2e808b5e6251286a72537e5a88bf566
diff --git a/svx/inc/svx/svdhdl.hxx b/svx/inc/svx/svdhdl.hxx
index 0744c35..3a44b92 100644
--- a/svx/inc/svx/svdhdl.hxx
+++ b/svx/inc/svx/svdhdl.hxx
@@ -32,7 +32,6 @@
#include <tools/gen.hxx>
#include <vcl/pointr.hxx>
-#include <tools/contnr.hxx>
#include <svl/solar.hrc>
@@ -449,15 +448,15 @@ class SVX_DLLPUBLIC SdrHdlList
protected:
sal_uIntPtr mnFocusIndex;
SdrMarkView* pView;
- Container aList;
- sal_uInt16 nHdlSize;
+ std::deque<SdrHdl*> aList;
+ sal_uInt16 nHdlSize;
unsigned bRotateShear : 1;
unsigned bDistortShear : 1;
unsigned bMoveOutside : 1; // Handles nach aussen ruecken (fuer TextEdit)
private:
- SVX_DLLPRIVATE SdrHdlList(const SdrHdlList&): aList(1024,64,64) {}
+ SVX_DLLPRIVATE SdrHdlList(const SdrHdlList&): aList() {}
SVX_DLLPRIVATE void operator=(const SdrHdlList&) {}
SVX_DLLPRIVATE sal_Bool operator==(const SdrHdlList&) const { return sal_False; }
SVX_DLLPRIVATE sal_Bool operator!=(const SdrHdlList&) const { return sal_False; }
@@ -480,8 +479,8 @@ public:
// 2.Level PageView (Pointer)
// 3.Level Position (x+y)
void Sort();
- sal_uIntPtr GetHdlCount() const { return aList.Count(); }
- SdrHdl* GetHdl(sal_uIntPtr nNum) const { return (SdrHdl*)(aList.GetObject(nNum)); }
+ sal_uIntPtr GetHdlCount() const { return aList.size(); }
+ SdrHdl* GetHdl(sal_uIntPtr nNum) const { return aList[nNum]; }
sal_uIntPtr GetHdlNum(const SdrHdl* pHdl) const;
void SetHdlSize(sal_uInt16 nSiz);
sal_uInt16 GetHdlSize() const { return nHdlSize; }
diff --git a/svx/source/svdraw/svdhdl.cxx b/svx/source/svdraw/svdhdl.cxx
index 62c3aae..7931db8 100644
--- a/svx/source/svdraw/svdhdl.cxx
+++ b/svx/source/svdraw/svdhdl.cxx
@@ -1666,17 +1666,10 @@ void ImpTextframeHdl::CreateB2dIAObject()
////////////////////////////////////////////////////////////////////////////////////////////////////
-class ImpSdrHdlListSorter: public ContainerSorter {
-public:
- ImpSdrHdlListSorter(Container& rNewCont): ContainerSorter(rNewCont) {}
- virtual ~ImpSdrHdlListSorter() {}
- virtual int Compare(const void* pElem1, const void* pElem2) const;
-};
-
-int ImpSdrHdlListSorter::Compare(const void* pElem1, const void* pElem2) const
+static bool ImpSdrHdlListSorter(SdrHdl* const& lhs, SdrHdl* const& rhs)
{
- SdrHdlKind eKind1=((SdrHdl*)pElem1)->GetKind();
- SdrHdlKind eKind2=((SdrHdl*)pElem2)->GetKind();
+ SdrHdlKind eKind1=lhs->GetKind();
+ SdrHdlKind eKind2=rhs->GetKind();
// Level 1: first normal handles, then Glue, then User, then Plus handles, then reference point handles
unsigned n1=1;
unsigned n2=1;
@@ -1691,44 +1684,44 @@ int ImpSdrHdlListSorter::Compare(const void* pElem1, const void* pElem2) const
else if (eKind2==HDL_USER) n2=3;
else if (eKind2==HDL_SMARTTAG) n2=0;
}
- if (((SdrHdl*)pElem1)->IsPlusHdl()) n1=4;
- if (((SdrHdl*)pElem2)->IsPlusHdl()) n2=4;
+ if (lhs->IsPlusHdl()) n1=4;
+ if (rhs->IsPlusHdl()) n2=4;
if (n1==n2)
{
// Level 2: PageView (Pointer)
- SdrPageView* pPV1=((SdrHdl*)pElem1)->GetPageView();
- SdrPageView* pPV2=((SdrHdl*)pElem2)->GetPageView();
+ SdrPageView* pPV1=lhs->GetPageView();
+ SdrPageView* pPV2=rhs->GetPageView();
if (pPV1==pPV2)
{
// Level 3: Position (x+y)
- SdrObject* pObj1=((SdrHdl*)pElem1)->GetObj();
- SdrObject* pObj2=((SdrHdl*)pElem2)->GetObj();
+ SdrObject* pObj1=lhs->GetObj();
+ SdrObject* pObj2=rhs->GetObj();
if (pObj1==pObj2)
{
- sal_uInt32 nNum1=((SdrHdl*)pElem1)->GetObjHdlNum();
- sal_uInt32 nNum2=((SdrHdl*)pElem2)->GetObjHdlNum();
+ sal_uInt32 nNum1=lhs->GetObjHdlNum();
+ sal_uInt32 nNum2=rhs->GetObjHdlNum();
if (nNum1==nNum2)
{
if (eKind1==eKind2)
- return (long)pElem1<(long)pElem2 ? -1 : 1; // Hack, to always get to the same sorting
- return (sal_uInt16)eKind1<(sal_uInt16)eKind2 ? -1 : 1;
+ return (long)lhs<(long)rhs; // Hack, to always get to the same sorting
+ return (sal_uInt16)eKind1<(sal_uInt16)eKind2;
}
else
- return nNum1<nNum2 ? -1 : 1;
+ return nNum1<nNum2;
}
else
{
- return (long)pObj1<(long)pObj2 ? -1 : 1;
+ return (long)pObj1<(long)pObj2;
}
}
else
{
- return (long)pPV1<(long)pPV2 ? -1 : 1;
+ return (long)pPV1<(long)pPV2;
}
}
else
{
- return n1<n2 ? -1 : 1;
+ return n1<n2;
}
}
@@ -1828,7 +1821,7 @@ void SdrHdlList::TravelFocusHdl(sal_Bool bForward)
if(mnFocusIndex != CONTAINER_ENTRY_NOTFOUND && mnFocusIndex >= GetHdlCount())
mnFocusIndex = CONTAINER_ENTRY_NOTFOUND;
- if(aList.Count())
+ if(!aList.empty())
{
// take care of old handle
const sal_uIntPtr nOldHdlNum(mnFocusIndex);
@@ -1842,24 +1835,24 @@ void SdrHdlList::TravelFocusHdl(sal_Bool bForward)
}
// allocate pointer array for sorted handle list
- ImplHdlAndIndex* pHdlAndIndex = new ImplHdlAndIndex[aList.Count()];
+ ImplHdlAndIndex* pHdlAndIndex = new ImplHdlAndIndex[aList.size()];
// build sorted handle list
sal_uInt32 a;
- for( a = 0; a < aList.Count(); a++)
+ for( a = 0; a < aList.size(); a++)
{
- pHdlAndIndex[a].mpHdl = (SdrHdl*)aList.GetObject(a);
+ pHdlAndIndex[a].mpHdl = aList[a];
pHdlAndIndex[a].mnIndex = a;
}
- qsort(pHdlAndIndex, aList.Count(), sizeof(ImplHdlAndIndex), ImplSortHdlFunc);
+ qsort(pHdlAndIndex, aList.size(), sizeof(ImplHdlAndIndex), ImplSortHdlFunc);
// look for old num in sorted array
sal_uIntPtr nOldHdl(nOldHdlNum);
if(nOldHdlNum != CONTAINER_ENTRY_NOTFOUND)
{
- for(a = 0; a < aList.Count(); a++)
+ for(a = 0; a < aList.size(); a++)
{
if(pHdlAndIndex[a].mpHdl == pOld)
{
@@ -1877,7 +1870,7 @@ void SdrHdlList::TravelFocusHdl(sal_Bool bForward)
{
if(nOldHdl != CONTAINER_ENTRY_NOTFOUND)
{
- if(nOldHdl == aList.Count() - 1)
+ if(nOldHdl == aList.size() - 1)
{
// end forward run
nNewHdl = CONTAINER_ENTRY_NOTFOUND;
@@ -1899,7 +1892,7 @@ void SdrHdlList::TravelFocusHdl(sal_Bool bForward)
if(nOldHdl == CONTAINER_ENTRY_NOTFOUND)
{
// start backward run at last entry
- nNewHdl = aList.Count() - 1;
+ nNewHdl = aList.size() - 1;
}
else
@@ -1925,9 +1918,9 @@ void SdrHdlList::TravelFocusHdl(sal_Bool bForward)
{
SdrHdl* pNew = pHdlAndIndex[nNewHdl].mpHdl;
- for(a = 0; a < aList.Count(); a++)
+ for(a = 0; a < aList.size(); a++)
{
- if((SdrHdl*)aList.GetObject(a) == pNew)
+ if(aList[a] == pNew)
{
nNewHdlNum = a;
break;
@@ -2006,7 +1999,7 @@ void SdrHdlList::ResetFocusHdl()
SdrHdlList::SdrHdlList(SdrMarkView* pV)
: mnFocusIndex(CONTAINER_ENTRY_NOTFOUND),
pView(pV),
- aList(1024,32,32)
+ aList()
{
nHdlSize = 3;
bRotateShear = sal_False;
@@ -2063,28 +2056,24 @@ void SdrHdlList::SetDistortShear(sal_Bool bOn)
SdrHdl* SdrHdlList::RemoveHdl(sal_uIntPtr nNum)
{
- SdrHdl* pRetval = (SdrHdl*)aList.Remove(nNum);
+ SdrHdl* pRetval = aList[nNum];
+ aList.erase(aList.begin() + nNum);
return pRetval;
}
void SdrHdlList::RemoveAllByKind(SdrHdlKind eKind)
{
- SdrHdl* p = static_cast<SdrHdl*>(aList.Last());
- while (p)
+ for(std::deque<SdrHdl*>::iterator it = aList.begin(); it != aList.end(); )
{
+ SdrHdl* p = *it;
if (p->GetKind() == eKind)
{
- // If removing an item doesn't invalidate the current position,
- // then perhaps it's safe to keep calling Prev here. But then I'm
- // too lazy to find out & this Container needs to be replaced by
- // STL anyways... :-P
- aList.Remove(p);
+ it = aList.erase( it );
delete p;
- p = static_cast<SdrHdl*>(aList.Last()); // start from the back again.
}
else
- p = static_cast<SdrHdl*>(aList.Prev());
+ ++it;
}
}
@@ -2095,7 +2084,7 @@ void SdrHdlList::Clear()
SdrHdl* pHdl=GetHdl(i);
delete pHdl;
}
- aList.Clear();
+ aList.clear();
bRotateShear=sal_False;
bDistortShear=sal_False;
@@ -2106,8 +2095,7 @@ void SdrHdlList::Sort()
// remember currently focused handle
SdrHdl* pPrev = GetFocusHdl();
- ImpSdrHdlListSorter aSort(aList);
- aSort.DoSort();
+ std::sort( aList.begin(), aList.end(), ImpSdrHdlListSorter );
// get now and compare
SdrHdl* pNow = GetFocusHdl();
@@ -2131,8 +2119,10 @@ sal_uIntPtr SdrHdlList::GetHdlNum(const SdrHdl* pHdl) const
{
if (pHdl==NULL)
return CONTAINER_ENTRY_NOTFOUND;
- sal_uIntPtr nPos=aList.GetPos(pHdl);
- return nPos;
+ std::deque<SdrHdl*>::const_iterator it = std::find( aList.begin(), aList.end(), pHdl);
+ if( it == aList.end() )
+ return CONTAINER_ENTRY_NOTFOUND;
+ return it - aList.begin();
}
void SdrHdlList::AddHdl(SdrHdl* pHdl, sal_Bool bAtBegin)
@@ -2141,11 +2131,11 @@ void SdrHdlList::AddHdl(SdrHdl* pHdl, sal_Bool bAtBegin)
{
if (bAtBegin)
{
- aList.Insert(pHdl,sal_uIntPtr(0));
+ aList.push_front(pHdl);
}
else
{
- aList.Insert(pHdl,CONTAINER_APPEND);
+ aList.push_back(pHdl);
}
pHdl->SetHdlList(this);
}
commit aa11e7bae89fe691f914abb27d1c4a03d27a7ee5
Author: Noel Grandin <noel at peralex.com>
Date: Tue Aug 14 16:31:53 2012 +0200
Convert maList in SdrMarkList from Container to std::vector
Change-Id: I1e975805a82dcf273cde8a9deba4a7e31dbd72b2
diff --git a/svx/inc/svx/svdmark.hxx b/svx/inc/svx/svdmark.hxx
index 429570b..c29ce81 100644
--- a/svx/inc/svx/svdmark.hxx
+++ b/svx/inc/svx/svdmark.hxx
@@ -31,7 +31,6 @@
#include <vector>
-#include <tools/contnr.hxx>
#include <tools/string.hxx>
#include "svx/svxdllapi.h"
#include <svx/sdrobjectuser.hxx>
@@ -177,7 +176,7 @@ public:
class SVX_DLLPUBLIC SdrMarkList
{
protected:
- Container maList;
+ std::vector<SdrMark*> maList;
String maMarkName;
String maPointName;
@@ -197,7 +196,7 @@ private:
public:
SdrMarkList()
- : maList(1024, 64, 64),
+ : maList(),
mbPointNameOk(sal_False),
mbGluePointNameOk(sal_False),
mbNameOk(sal_False),
@@ -206,7 +205,7 @@ public:
}
SdrMarkList(const SdrMarkList& rLst)
- : maList(1024, 64, 64)
+ : maList()
{
*this = rLst;
}
@@ -225,12 +224,12 @@ public:
sal_uLong GetMarkCount() const
{
- return maList.Count();
+ return maList.size();
}
SdrMark* GetMark(sal_uLong nNum) const
{
- return (SdrMark*)(maList.GetObject(nNum));
+ return maList[nNum];
}
sal_uLong FindObject(const SdrObject* pObj) const;
diff --git a/svx/source/svdraw/svdmark.cxx b/svx/source/svdraw/svdmark.cxx
index 66627e5..b99cff9 100644
--- a/svx/source/svdraw/svdmark.cxx
+++ b/svx/source/svdraw/svdmark.cxx
@@ -229,22 +229,10 @@ sal_Bool SdrMark::operator==(const SdrMark& rMark) const
////////////////////////////////////////////////////////////////////////////////////////////////////
-class ImpSdrMarkListSorter: public ContainerSorter
+static bool ImpSdrMarkListSorter(SdrMark* const& lhs, SdrMark* const& rhs)
{
-public:
- ImpSdrMarkListSorter(Container& rNewCont)
- : ContainerSorter(rNewCont)
- {}
-
- virtual ~ImpSdrMarkListSorter() {}
-
- virtual int Compare(const void* pElem1, const void* pElem2) const;
-};
-
-int ImpSdrMarkListSorter::Compare(const void* pElem1, const void* pElem2) const
-{
- SdrObject* pObj1 = ((SdrMark*)pElem1)->GetMarkedSdrObj();
- SdrObject* pObj2 = ((SdrMark*)pElem2)->GetMarkedSdrObj();
+ SdrObject* pObj1 = lhs->GetMarkedSdrObj();
+ SdrObject* pObj2 = rhs->GetMarkedSdrObj();
SdrObjList* pOL1 = (pObj1) ? pObj1->GetObjList() : 0L;
SdrObjList* pOL2 = (pObj2) ? pObj2->GetObjList() : 0L;
@@ -256,11 +244,11 @@ int ImpSdrMarkListSorter::Compare(const void* pElem1, const void* pElem2) const
sal_uInt32 nObjOrd1((pObj1) ? pObj1->GetNavigationPosition() : 0);
sal_uInt32 nObjOrd2((pObj2) ? pObj2->GetNavigationPosition() : 0);
- return (nObjOrd1 < nObjOrd2 ? -1 : 1);
+ return nObjOrd1 < nObjOrd2;
}
else
{
- return ((long)pOL1 < (long)pOL2) ? -1 : 1;
+ return (long)pOL1 < (long)pOL2;
}
}
@@ -279,37 +267,37 @@ void SdrMarkList::ImpForceSort()
if(!mbSorted)
{
mbSorted = sal_True;
- sal_uLong nAnz = maList.Count();
+ sal_uLong nAnz = maList.size();
// remove invalid
if(nAnz > 0 )
{
- SdrMark* pAkt = (SdrMark*)maList.First();
- while( pAkt )
+ for(std::vector<SdrMark*>::iterator it = maList.begin(); it != maList.end(); )
{
+ SdrMark* pAkt = *it;
if(pAkt->GetMarkedSdrObj() == 0)
{
- maList.Remove();
+ it = maList.erase( it );
delete pAkt;
}
- pAkt= (SdrMark*)maList.Next();
+ else
+ ++it;
}
- nAnz = maList.Count();
+ nAnz = maList.size();
}
if(nAnz > 1)
{
- ImpSdrMarkListSorter aSort(maList);
- aSort.DoSort();
+ std::sort(maList.begin(), maList.end(), ImpSdrMarkListSorter);
// remove duplicates
- if(maList.Count() > 1)
+ if(maList.size() > 1)
{
- SdrMark* pAkt = (SdrMark*)maList.Last();
- SdrMark* pCmp = (SdrMark*)maList.Prev();
-
- while(pCmp)
+ SdrMark* pAkt = maList.back();
+ int i = maList.size() - 2;
+ while(i)
{
+ SdrMark* pCmp = maList[i];
if(pAkt->GetMarkedSdrObj() == pCmp->GetMarkedSdrObj() && pAkt->GetMarkedSdrObj())
{
// Con1/Con2 Merging
@@ -320,7 +308,7 @@ void SdrMarkList::ImpForceSort()
pAkt->SetCon2(sal_True);
// delete pCmp
- maList.Remove();
+ maList.erase(maList.begin() + i);
delete pCmp;
}
@@ -329,7 +317,7 @@ void SdrMarkList::ImpForceSort()
pAkt = pCmp;
}
- pCmp = (SdrMark*)maList.Prev();
+ --i;
}
}
}
@@ -344,7 +332,7 @@ void SdrMarkList::Clear()
delete pMark;
}
- maList.Clear();
+ maList.clear();
SetNameDirty();
}
@@ -356,7 +344,7 @@ void SdrMarkList::operator=(const SdrMarkList& rLst)
{
SdrMark* pMark = rLst.GetMark(i);
SdrMark* pNeuMark = new SdrMark(*pMark);
- maList.Insert(pNeuMark, CONTAINER_APPEND);
+ maList.push_back(pNeuMark);
}
maMarkName = rLst.maMarkName;
@@ -379,11 +367,11 @@ sal_uLong SdrMarkList::FindObject(const SdrObject* pObj) const
// is not inserted in a object list.
// Since this may be by purpose and necessary somewhere else i decided that it is
// less dangerous to change this method then changing SdrObject::GetOrdNum().
- if(pObj && maList.Count())
+ if(pObj && !maList.empty())
{
- for(sal_uLong a(0L); a < maList.Count(); a++)
+ for(sal_uLong a(0L); a < maList.size(); a++)
{
- if(((SdrMark*)(maList.GetObject(a)))->GetMarkedSdrObj() == pObj)
+ if(maList[a]->GetMarkedSdrObj() == pObj)
{
return a;
}
@@ -396,14 +384,14 @@ sal_uLong SdrMarkList::FindObject(const SdrObject* pObj) const
void SdrMarkList::InsertEntry(const SdrMark& rMark, sal_Bool bChkSort)
{
SetNameDirty();
- sal_uLong nAnz(maList.Count());
+ sal_uLong nAnz(maList.size());
if(!bChkSort || !mbSorted || nAnz == 0)
{
if(!bChkSort)
mbSorted = sal_False;
- maList.Insert(new SdrMark(rMark), CONTAINER_APPEND);
+ maList.push_back(new SdrMark(rMark));
}
else
{
@@ -424,7 +412,7 @@ void SdrMarkList::InsertEntry(const SdrMark& rMark, sal_Bool bChkSort)
else
{
SdrMark* pKopie = new SdrMark(rMark);
- maList.Insert(pKopie, CONTAINER_APPEND);
+ maList.push_back(pKopie);
// now check if the sort is ok
const SdrObjList* pLastOL = pLastObj!=0L ? pLastObj->GetObjList() : 0L;
@@ -459,7 +447,7 @@ void SdrMarkList::DeleteMark(sal_uLong nNum)
if(pMark)
{
- maList.Remove(nNum);
+ maList.erase(maList.begin() + nNum);
delete pMark;
SetNameDirty();
}
@@ -475,14 +463,14 @@ void SdrMarkList::ReplaceMark(const SdrMark& rNewMark, sal_uLong nNum)
delete pMark;
SetNameDirty();
SdrMark* pKopie = new SdrMark(rNewMark);
- maList.Replace(pKopie, nNum);
+ maList[nNum] = pKopie;
mbSorted = sal_False;
}
}
void SdrMarkList::Merge(const SdrMarkList& rSrcList, sal_Bool bReverse)
{
- sal_uLong nAnz(rSrcList.maList.Count());
+ sal_uLong nAnz(rSrcList.maList.size());
if(rSrcList.mbSorted)
{
@@ -494,7 +482,7 @@ void SdrMarkList::Merge(const SdrMarkList& rSrcList, sal_Bool bReverse)
{
for(sal_uLong i(0L); i < nAnz; i++)
{
- SdrMark* pM = (SdrMark*)(rSrcList.maList.GetObject(i));
+ SdrMark* pM = rSrcList.maList[i];
InsertEntry(*pM);
}
}
@@ -503,7 +491,7 @@ void SdrMarkList::Merge(const SdrMarkList& rSrcList, sal_Bool bReverse)
for(sal_uLong i(nAnz); i > 0;)
{
i--;
- SdrMark* pM = (SdrMark*)(rSrcList.maList.GetObject(i));
+ SdrMark* pM = rSrcList.maList[i];
InsertEntry(*pM);
}
}
@@ -513,18 +501,19 @@ sal_Bool SdrMarkList::DeletePageView(const SdrPageView& rPV)
{
sal_Bool bChgd(sal_False);
- for(sal_uLong i(GetMarkCount()); i > 0; )
+ for(std::vector<SdrMark*>::iterator it = maList.begin(); it != maList.end(); )
{
- i--;
- SdrMark* pMark = GetMark(i);
+ SdrMark* pMark = *it;
if(pMark->GetPageView()==&rPV)
{
- maList.Remove(i);
+ it = maList.erase(it);
delete pMark;
SetNameDirty();
bChgd = sal_True;
}
+ else
+ ++it;
}
return bChgd;
@@ -546,7 +535,7 @@ sal_Bool SdrMarkList::InsertPageView(const SdrPageView& rPV)
if(bDoIt)
{
SdrMark* pM = new SdrMark(pObj, (SdrPageView*)&rPV);
- maList.Insert(pM, CONTAINER_APPEND);
+ maList.push_back(pM);
SetNameDirty();
bChgd = sal_True;
}
commit 7758eaf702849691dcf24472d864ee7ff6d02345
Author: Noel Grandin <noel at peralex.com>
Date: Tue Aug 14 15:03:14 2012 +0200
Convert SdrUShortCont from Container to std::set
Change-Id: Ic7e929d4f20cd737eb15dacdb5718b6c79c80aaf
diff --git a/sd/source/ui/animations/motionpathtag.cxx b/sd/source/ui/animations/motionpathtag.cxx
index e1c6e1e..e48460e 100644
--- a/sd/source/ui/animations/motionpathtag.cxx
+++ b/sd/source/ui/animations/motionpathtag.cxx
@@ -846,7 +846,7 @@ sal_uLong MotionPathTag::GetMarkedPointCount() const
if( mpMark )
{
const SdrUShortCont* pPts=mpMark->GetMarkedPoints();
- return pPts ? pPts->GetCount() : 0;
+ return pPts ? pPts->size() : 0;
}
else
{
@@ -864,11 +864,9 @@ sal_Bool MotionPathTag::MarkPoint(SdrHdl& rHdl, sal_Bool bUnmark )
SmartHdl* pSmartHdl = dynamic_cast< SmartHdl* >( &rHdl );
if( pSmartHdl && pSmartHdl->getTag().get() == this )
{
- SdrUShortCont* pPts=mpMark->ForceMarkedPoints();
- pPts->ForceSort();
+ mpMark->ForceMarkedPoints();
if (mrView.MarkPointHelper(&rHdl,mpMark,bUnmark))
{
- pPts->ForceSort();
mrView.MarkListHasChanged();
bRet=sal_True;
}
@@ -1002,7 +1000,7 @@ void MotionPathTag::addCustomHandles( SdrHdlList& rHandlerList )
rHandlerList.AddHdl( pSmartHdl );
- const bool bSelected= pMrkPnts && pMrkPnts->Exist(sal::static_int_cast< sal_uInt16 >(nHandle));
+ const bool bSelected= pMrkPnts && pMrkPnts->find( sal_uInt16(nHandle) ) != pMrkPnts->end();
pSmartHdl->SetSelected(bSelected);
if( mrView.IsPlusHandlesAlwaysVisible() || bSelected )
@@ -1102,7 +1100,7 @@ void MotionPathTag::deselect()
SdrUShortCont* pPts = mpMark->GetMarkedPoints();
if( pPts )
- pPts->Clear();
+ pPts->clear();
}
selectionChanged();
@@ -1131,7 +1129,7 @@ void MotionPathTag::DeleteMarkedPoints()
if( pPts )
{
PolyPolygonEditor aEditor( mpPathObj->GetPathPoly(), mpPathObj->IsClosed() );
- if( aEditor.DeletePoints( pPts->getContainer() ) )
+ if( aEditor.DeletePoints( *pPts ) )
{
if( aEditor.GetPolyPolygon().count() )
{
@@ -1186,7 +1184,7 @@ void MotionPathTag::SetMarkedSegmentsKind(SdrPathSegmentKind eKind)
if(pPts)
{
PolyPolygonEditor aEditor( mpPathObj->GetPathPoly(), mpPathObj->IsClosed() );
- if(aEditor.SetSegmentsKind( eKind, pPts->getContainer()) )
+ if(aEditor.SetSegmentsKind( eKind, *pPts ) )
{
mpPathObj->SetPathPoly(aEditor.GetPolyPolygon());
mrView.MarkListHasChanged();
@@ -1239,7 +1237,7 @@ void MotionPathTag::SetMarkedPointsSmooth(SdrPathSmoothKind eKind)
if(pPts)
{
PolyPolygonEditor aEditor( mpPathObj->GetPathPoly(), mpPathObj->IsClosed() );
- if(aEditor.SetPointsSmooth( eFlags, pPts->getContainer() ) )
+ if(aEditor.SetPointsSmooth( eFlags, *pPts ) )
{
mpPathObj->SetPathPoly(aEditor.GetPolyPolygon());
mrView.MarkListHasChanged();
diff --git a/svx/inc/svx/svdmark.hxx b/svx/inc/svx/svdmark.hxx
index 4b68fed..429570b 100644
--- a/svx/inc/svx/svdmark.hxx
+++ b/svx/inc/svx/svdmark.hxx
@@ -45,106 +45,8 @@ class SdrObject;
class SdrPageView;
// Ein Container fuer USHORTs (im Prinzip ein dynamisches Array)
-class SVX_DLLPUBLIC SdrUShortCont
-{
- Container maArray;
- sal_Bool mbSorted;
-
-private:
- void CheckSort(sal_uLong nPos);
-
-public:
- SdrUShortCont(sal_uInt16 nBlock, sal_uInt16 nInit, sal_uInt16 nResize)
- : maArray(nBlock, nInit, nResize),
- mbSorted(sal_True)
- {}
-
- SdrUShortCont(const SdrUShortCont& rCont)
- : maArray(rCont.maArray),
- mbSorted(rCont.mbSorted)
- {}
-
- /** helper to migrate to stl containers */
- std::set< sal_uInt16 > getContainer();
-
- SdrUShortCont& operator=(const SdrUShortCont& rCont)
- {
- maArray = rCont.maArray;
- mbSorted = rCont.mbSorted;
- return *this;
- }
-
- sal_Bool operator==(const SdrUShortCont& rCont) const
- {
- return maArray == rCont.maArray;
- }
+class SVX_DLLPUBLIC SdrUShortCont : public std::set<sal_uInt16> {};
- sal_Bool operator!=(const SdrUShortCont& rCont) const
- {
- return maArray != rCont.maArray;
- }
-
- void Clear()
- {
- maArray.Clear();
- mbSorted = sal_True;
- }
-
- void Sort() const;
-
- void ForceSort() const
- {
- if(!mbSorted)
- {
- Sort();
- }
- }
-
- void Insert(sal_uInt16 nElem, sal_uLong nPos = CONTAINER_APPEND)
- {
- maArray.Insert((void*)sal_uLong(nElem),nPos);
-
- if(mbSorted)
- {
- CheckSort(nPos);
- }
- }
-
- void Remove(sal_uLong nPos)
- {
- maArray.Remove(nPos);
- }
-
- void Replace(sal_uInt16 nElem, sal_uLong nPos)
- {
- maArray.Replace((void*)sal_uLong(nElem), nPos);
-
- if(mbSorted)
- {
- CheckSort(nPos);
- }
- }
-
- sal_uInt16 GetObject(sal_uLong nPos) const
- {
- return sal_uInt16(sal_uIntPtr(maArray.GetObject(nPos)));
- }
-
- sal_uLong GetPos(sal_uInt16 nElem) const
- {
- return maArray.GetPos((void*)(sal_uLong)nElem);
- }
-
- sal_uLong GetCount() const
- {
- return maArray.Count();
- }
-
- sal_Bool Exist(sal_uInt16 nElem) const
- {
- return (CONTAINER_ENTRY_NOTFOUND != maArray.GetPos((void*)(sal_uLong)nElem));
- }
-};
// Alles was eine View ueber ein markiertes Objekt wissen muss
class SVX_DLLPUBLIC SdrMark : public sdr::ObjectUser
@@ -250,7 +152,7 @@ public:
SdrUShortCont* ForceMarkedPoints()
{
if(!mpPoints)
- mpPoints = new SdrUShortCont(1024, 32, 32);
+ mpPoints = new SdrUShortCont;
return mpPoints;
}
@@ -258,7 +160,7 @@ public:
SdrUShortCont* ForceMarkedLines()
{
if(!mpLines)
- mpLines = new SdrUShortCont(1024, 32, 32);
+ mpLines = new SdrUShortCont;
return mpLines;
}
@@ -266,7 +168,7 @@ public:
SdrUShortCont* ForceMarkedGluePoints()
{
if(!mpGluePoints)
- mpGluePoints = new SdrUShortCont(1024, 32, 32);
+ mpGluePoints = new SdrUShortCont;
return mpGluePoints;
}
diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx
index 76361c1..8c7762f 100644
--- a/svx/source/svdraw/svddrgmt.cxx
+++ b/svx/source/svdraw/svddrgmt.cxx
@@ -459,7 +459,7 @@ void SdrDragMethod::createSdrDragEntries_PointDrag()
{
const SdrUShortCont* pPts = pM->GetMarkedPoints();
- if(pPts && pPts->GetCount())
+ if(pPts && !pPts->empty())
{
const SdrObject* pObj = pM->GetMarkedSdrObj();
const SdrPathObj* pPath = dynamic_cast< const SdrPathObj* >(pObj);
@@ -470,12 +470,10 @@ void SdrDragMethod::createSdrDragEntries_PointDrag()
if(aPathXPP.count())
{
- const sal_uInt32 nPtAnz(pPts->GetCount());
-
- for(sal_uInt32 nPtNum(0); nPtNum < nPtAnz; nPtNum++)
+ for(SdrUShortCont::const_iterator it = pPts->begin(); it != pPts->end(); ++it)
{
sal_uInt32 nPolyNum, nPointNum;
- const sal_uInt16 nObjPt(pPts->GetObject(nPtNum));
+ const sal_uInt16 nObjPt = *it;
if(sdr::PolyPolygonEditor::GetRelativePolyPoint(aPathXPP, nObjPt, nPolyNum, nPointNum))
{
@@ -507,18 +505,16 @@ void SdrDragMethod::createSdrDragEntries_GlueDrag()
{
const SdrUShortCont* pPts = pM->GetMarkedGluePoints();
- if(pPts && pPts->GetCount())
+ if(pPts && !pPts->empty())
{
const SdrObject* pObj = pM->GetMarkedSdrObj();
const SdrGluePointList* pGPL = pObj->GetGluePointList();
if(pGPL)
{
- const sal_uInt32 nPtAnz(pPts->GetCount());
-
- for(sal_uInt32 nPtNum(0); nPtNum < nPtAnz; nPtNum++)
+ for(SdrUShortCont::const_iterator it = pPts->begin(); it != pPts->end(); ++it)
{
- const sal_uInt16 nObjPt(pPts->GetObject(nPtNum));
+ const sal_uInt16 nObjPt = *it;
const sal_uInt16 nGlueNum(pGPL->FindGluePoint(nObjPt));
if(SDRGLUEPOINT_NOTFOUND != nGlueNum)
@@ -1575,7 +1571,7 @@ void SdrDragMove::MoveSdrDrag(const Point& rNoSnapPnt_)
{
const SdrMark* pM=rML.GetMark(nMarkNum);
const SdrUShortCont* pPts=pM->GetMarkedGluePoints();
- sal_uLong nPtAnz=pPts==NULL ? 0 : pPts->GetCount();
+ sal_uLong nPtAnz=pPts==NULL ? 0 : pPts->size();
if (nPtAnz!=0)
{
@@ -1583,9 +1579,9 @@ void SdrDragMove::MoveSdrDrag(const Point& rNoSnapPnt_)
const SdrGluePointList* pGPL=pObj->GetGluePointList();
Rectangle aBound(pObj->GetCurrentBoundRect());
- for (sal_uLong nPtNum=0; nPtNum<nPtAnz; nPtNum++)
+ for (SdrUShortCont::const_iterator it = pPts->begin(); it != pPts->end(); ++it)
{
- sal_uInt16 nId=pPts->GetObject(nPtNum);
+ sal_uInt16 nId = *it;
sal_uInt16 nGlueNum=pGPL->FindGluePoint(nId);
if (nGlueNum!=SDRGLUEPOINT_NOTFOUND)
diff --git a/svx/source/svdraw/svdglev.cxx b/svx/source/svdraw/svdglev.cxx
index 0d9c0c7..0935381 100644
--- a/svx/source/svdraw/svdglev.cxx
+++ b/svx/source/svdraw/svdglev.cxx
@@ -63,7 +63,7 @@ void SdrGlueEditView::ImpDoMarkedGluePoints(PGlueDoFunc pDoFunc, sal_Bool bConst
SdrMark* pM=GetSdrMarkByIndex(nm);
SdrObject* pObj=pM->GetMarkedSdrObj();
const SdrUShortCont* pPts=pM->GetMarkedGluePoints();
- sal_uIntPtr nPtAnz=pPts==NULL ? 0 : pPts->GetCount();
+ sal_uIntPtr nPtAnz=pPts==NULL ? 0 : pPts->size();
if (nPtAnz!=0) {
SdrGluePointList* pGPL=NULL;
if (bConst) {
@@ -77,9 +77,9 @@ void SdrGlueEditView::ImpDoMarkedGluePoints(PGlueDoFunc pDoFunc, sal_Bool bConst
if(!bConst && IsUndoEnabled() )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
- for (sal_uIntPtr nPtNum=0; nPtNum<nPtAnz; nPtNum++)
+ for(SdrUShortCont::const_iterator it = pPts->begin(); it != pPts->end(); ++it)
{
- sal_uInt16 nPtId=pPts->GetObject(nPtNum);
+ sal_uInt16 nPtId=*it;
sal_uInt16 nGlueIdx=pGPL->FindGluePoint(nPtId);
if (nGlueIdx!=SDRGLUEPOINT_NOTFOUND)
{
@@ -244,7 +244,7 @@ void SdrGlueEditView::DeleteMarkedGluePoints()
SdrMark* pM=GetSdrMarkByIndex(nm);
SdrObject* pObj=pM->GetMarkedSdrObj();
const SdrUShortCont* pPts=pM->GetMarkedGluePoints();
- sal_uIntPtr nPtAnz=pPts==NULL ? 0 : pPts->GetCount();
+ sal_uIntPtr nPtAnz=pPts==NULL ? 0 : pPts->size();
if (nPtAnz!=0)
{
SdrGluePointList* pGPL=pObj->ForceGluePointList();
@@ -253,9 +253,9 @@ void SdrGlueEditView::DeleteMarkedGluePoints()
if( bUndo )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
- for (sal_uIntPtr nPtNum=0; nPtNum<nPtAnz; nPtNum++)
+ for(SdrUShortCont::const_iterator it = pPts->begin(); it != pPts->end(); ++it)
{
- sal_uInt16 nPtId=pPts->GetObject(nPtNum);
+ sal_uInt16 nPtId=*it;
sal_uInt16 nGlueIdx=pGPL->FindGluePoint(nPtId);
if (nGlueIdx!=SDRGLUEPOINT_NOTFOUND)
{
@@ -290,24 +290,31 @@ void SdrGlueEditView::ImpCopyMarkedGluePoints()
SdrObject* pObj=pM->GetMarkedSdrObj();
SdrUShortCont* pPts=pM->GetMarkedGluePoints();
SdrGluePointList* pGPL=pObj->ForceGluePointList();
- sal_uIntPtr nPtAnz=pPts==NULL ? 0 : pPts->GetCount();
+ sal_uIntPtr nPtAnz=pPts==NULL ? 0 : pPts->size();
if (nPtAnz!=0 && pGPL!=NULL)
{
if( bUndo )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
- for (sal_uIntPtr nPtNum=0; nPtNum<nPtAnz; nPtNum++)
+ SdrUShortCont aIdsToErase;
+ SdrUShortCont aIdsToInsert;
+ for(SdrUShortCont::const_iterator it = pPts->begin(); it != pPts->end(); ++it)
{
- sal_uInt16 nPtId=pPts->GetObject(nPtNum);
+ sal_uInt16 nPtId=*it;
sal_uInt16 nGlueIdx=pGPL->FindGluePoint(nPtId);
if (nGlueIdx!=SDRGLUEPOINT_NOTFOUND)
{
SdrGluePoint aNewGP((*pGPL)[nGlueIdx]); // clone GluePoint
sal_uInt16 nNewIdx=pGPL->Insert(aNewGP); // and insert it
sal_uInt16 nNewId=(*pGPL)[nNewIdx].GetId(); // retrieve ID of new GluePoints
- pPts->Replace(nNewId,nPtNum); // select it (instead of the old one)
+ aIdsToErase.insert(nPtId); // select it (instead of the old one)
+ aIdsToInsert.insert(nNewId);
}
}
+ for(SdrUShortCont::const_iterator it = aIdsToErase.begin(); it != aIdsToErase.end(); ++it)
+ pPts->erase(*it);
+ pPts->insert(aIdsToInsert.begin(), aIdsToInsert.end());
+
}
}
if( bUndo )
@@ -326,7 +333,7 @@ void SdrGlueEditView::ImpTransformMarkedGluePoints(PGlueTrFunc pTrFunc, const vo
SdrMark* pM=GetSdrMarkByIndex(nm);
SdrObject* pObj=pM->GetMarkedSdrObj();
const SdrUShortCont* pPts=pM->GetMarkedGluePoints();
- sal_uIntPtr nPtAnz=pPts==NULL ? 0 : pPts->GetCount();
+ sal_uIntPtr nPtAnz=pPts==NULL ? 0 : pPts->size();
if (nPtAnz!=0) {
SdrGluePointList* pGPL=pObj->ForceGluePointList();
if (pGPL!=NULL)
@@ -334,8 +341,9 @@ void SdrGlueEditView::ImpTransformMarkedGluePoints(PGlueTrFunc pTrFunc, const vo
if( IsUndoEnabled() )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
- for (sal_uIntPtr nPtNum=0; nPtNum<nPtAnz; nPtNum++) {
- sal_uInt16 nPtId=pPts->GetObject(nPtNum);
+ for(SdrUShortCont::const_iterator it = pPts->begin(); it != pPts->end(); ++it)
+ {
+ sal_uInt16 nPtId=*it;
sal_uInt16 nGlueIdx=pGPL->FindGluePoint(nPtId);
if (nGlueIdx!=SDRGLUEPOINT_NOTFOUND) {
SdrGluePoint& rGP=(*pGPL)[nGlueIdx];
diff --git a/svx/source/svdraw/svdmark.cxx b/svx/source/svdraw/svdmark.cxx
index 0e03069..66627e5 100644
--- a/svx/source/svdraw/svdmark.cxx
+++ b/svx/source/svdraw/svdmark.cxx
@@ -47,92 +47,6 @@
#include <svl/brdcst.hxx>
#include <svx/svdoedge.hxx>
-////////////////////////////////////////////////////////////////////////////////////////////////////
-
-class ImpSdrUShortContSorter: public ContainerSorter
-{
-public:
- ImpSdrUShortContSorter(Container& rNewCont)
- : ContainerSorter(rNewCont)
- {}
-
- virtual ~ImpSdrUShortContSorter() {}
-
- virtual int Compare(const void* pElem1, const void* pElem2) const;
-};
-
-int ImpSdrUShortContSorter::Compare(const void* pElem1, const void* pElem2) const
-{
- sal_uInt16 n1((sal_uInt16)((sal_uIntPtr)pElem1));
- sal_uInt16 n2((sal_uInt16)((sal_uIntPtr)pElem2));
-
- return ((n1 < n2) ? (-1) : (n1 > n2) ? (1) : (0));
-}
-
-void SdrUShortCont::Sort() const
-{
- ImpSdrUShortContSorter aSort(*((Container*)(&maArray)));
- aSort.DoSort();
- ((SdrUShortCont*)this)->mbSorted = sal_True;
-
- sal_uLong nNum(GetCount());
-
- if(nNum > 1)
- {
- nNum--;
- sal_uInt16 nVal0 = GetObject(nNum);
-
- while(nNum > 0)
- {
- nNum--;
- sal_uInt16 nVal1 = GetObject(nNum);
-
- if(nVal1 == nVal0)
- {
- ((SdrUShortCont*)this)->Remove(nNum);
- }
-
- nVal0 = nVal1;
- }
- }
-}
-
-void SdrUShortCont::CheckSort(sal_uLong nPos)
-{
- sal_uLong nAnz(maArray.Count());
-
- if(nPos > nAnz)
- nPos = nAnz;
-
- sal_uInt16 nAktVal = GetObject(nPos);
-
- if(nPos > 0)
- {
- sal_uInt16 nPrevVal = GetObject(nPos - 1);
-
- if(nPrevVal >= nAktVal)
- mbSorted = sal_False;
- }
-
- if(nPos < nAnz - 1)
- {
- sal_uInt16 nNextVal = GetObject(nPos + 1);
-
- if(nNextVal <= nAktVal)
- mbSorted = sal_False;
- }
-}
-
-std::set< sal_uInt16 > SdrUShortCont::getContainer()
-{
- std::set< sal_uInt16 > aSet;
-
- sal_uInt32 nAnz = maArray.Count();
- while(nAnz)
- aSet.insert( GetObject(--nAnz) );
-
- return aSet;
-}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -718,7 +632,7 @@ const XubString& SdrMarkList::GetPointMarkDescription(sal_Bool bGlue) const
{
const SdrMark* pMark = GetMark(nMarkNum);
const SdrUShortCont* pPts = bGlue ? pMark->GetMarkedGluePoints() : pMark->GetMarkedPoints();
- sal_uLong nAnz(pPts ? pPts->GetCount() : 0);
+ sal_uLong nAnz(pPts ? pPts->size() : 0);
if(nAnz)
{
@@ -782,7 +696,7 @@ const XubString& SdrMarkList::GetPointMarkDescription(sal_Bool bGlue) const
const SdrMark* pMark2 = GetMark(i);
const SdrUShortCont* pPts = bGlue ? pMark2->GetMarkedGluePoints() : pMark2->GetMarkedPoints();
- if(pPts && pPts->GetCount() && pMark2->GetMarkedSdrObj())
+ if(pPts && !pPts->empty() && pMark2->GetMarkedSdrObj())
{
pMark2->GetMarkedSdrObj()->TakeObjNamePlural(aStr1);
bEq = aNam.Equals(aStr1);
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index f0f8f9d..2f16e1d 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -709,7 +709,8 @@ void SdrMarkView::SetMarkHandles()
pHdl->SetObjHdlNum(sal_uInt16(i-nSiz0));
if (bPoly)
{
- sal_Bool bSelected=pMrkPnts!=NULL && pMrkPnts->Exist(sal_uInt16(i-nSiz0));
+ sal_Bool bSelected=pMrkPnts!=NULL
+ && pMrkPnts->find( sal_uInt16(i-nSiz0) ) != pMrkPnts->end();
pHdl->SetSelected(bSelected);
if (bPlusHdlAlways || bSelected)
{
@@ -743,10 +744,9 @@ void SdrMarkView::SetMarkHandles()
const SdrGluePointList* pGPL=pObj->GetGluePointList();
if (pGPL!=NULL)
{
- sal_uInt16 nAnz=(sal_uInt16)pMrkGlue->GetCount();
- for (sal_uInt16 nNum=0; nNum<nAnz; nNum++)
+ for(SdrUShortCont::const_iterator it = pMrkGlue->begin(); it != pMrkGlue->end(); ++it)
{
- sal_uInt16 nId=pMrkGlue->GetObject(nNum);
+ sal_uInt16 nId=*it;
//nNum changed to nNumGP because already used in for loop
sal_uInt16 nNumGP=pGPL->FindGluePoint(nId);
if (nNumGP!=SDRGLUEPOINT_NOTFOUND)
@@ -1147,8 +1147,8 @@ void SdrMarkView::CheckMarked()
{
if (!IsGluePointEditMode()) { // selected glue points only in GlueEditMode
SdrUShortCont* pPts=pM->GetMarkedGluePoints();
- if (pPts!=NULL && pPts->GetCount()!=0) {
- pPts->Clear();
+ if (pPts!=NULL) {
+ pPts->clear();
}
}
}
diff --git a/svx/source/svdraw/svdmrkv1.cxx b/svx/source/svdraw/svdmrkv1.cxx
index 7094f8e..7ffeec0 100644
--- a/svx/source/svdraw/svdmrkv1.cxx
+++ b/svx/source/svdraw/svdmrkv1.cxx
@@ -85,7 +85,7 @@ sal_Bool SdrMarkView::HasMarkedPoints() const
for (sal_uIntPtr nMarkNum=0; nMarkNum<nMarkAnz && !bRet; nMarkNum++) {
const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
const SdrUShortCont* pPts=pM->GetMarkedPoints();
- bRet=pPts!=NULL && pPts->GetCount()!=0;
+ bRet=pPts!=NULL && !pPts->empty();
}
}
}
@@ -102,7 +102,7 @@ sal_uIntPtr SdrMarkView::GetMarkedPointCount() const
for (sal_uIntPtr nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++) {
const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
const SdrUShortCont* pPts=pM->GetMarkedPoints();
- if (pPts!=NULL) nAnz+=pPts->GetCount();
+ if (pPts!=NULL) nAnz+=pPts->size();
}
}
}
@@ -142,14 +142,14 @@ sal_Bool SdrMarkView::ImpMarkPoint(SdrHdl* pHdl, SdrMark* pMark, sal_Bool bUnmar
SdrUShortCont* pPts=pMark->ForceMarkedPoints();
if (!bUnmark)
{
- pPts->Insert((sal_uInt16)nHdlNum);
+ pPts->insert((sal_uInt16)nHdlNum);
}
else
{
- sal_uIntPtr nBla=pPts->GetPos((sal_uInt16)nHdlNum);
- if (nBla!=CONTAINER_ENTRY_NOTFOUND)
+ SdrUShortCont::const_iterator it = pPts->find( (sal_uInt16)nHdlNum );
+ if (it != pPts->end())
{
- pPts->Remove(nBla);
+ pPts->erase(it);
}
else
{
@@ -206,10 +206,8 @@ sal_Bool SdrMarkView::MarkPoint(SdrHdl& rHdl, sal_Bool bUnmark)
sal_uIntPtr nMarkNum=TryToFindMarkedObject(pObj);
if (nMarkNum!=CONTAINER_ENTRY_NOTFOUND) {
SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
- SdrUShortCont* pPts=pM->ForceMarkedPoints();
- pPts->ForceSort();
+ pM->ForceMarkedPoints();
if (ImpMarkPoint(&rHdl,pM,bUnmark)) {
- pPts->ForceSort();
MarkListHasChanged();
bRet=sal_True;
}
@@ -236,17 +234,12 @@ sal_Bool SdrMarkView::MarkPoints(const Rectangle* pRect, sal_Bool bUnmark)
const SdrObject* pObj=pHdl->GetObj();
const SdrPageView* pPV=pHdl->GetPageView();
if (pObj!=pObj0 || pPV!=pPV0 || pM==NULL) { // This section is for optimization,
- if (pM!=NULL) {
- SdrUShortCont* pPts=pM->GetMarkedPoints();
- if (pPts!=NULL) pPts->ForceSort();
- }
sal_uIntPtr nMarkNum=TryToFindMarkedObject(pObj); // so ImpMarkPoint() doesn't always
if (nMarkNum!=CONTAINER_ENTRY_NOTFOUND) { // have to search the object in the MarkList.
pM=GetSdrMarkByIndex(nMarkNum);
pObj0=pObj;
pPV0=pPV;
- SdrUShortCont* pPts=pM->ForceMarkedPoints();
- pPts->ForceSort();
+ pM->ForceMarkedPoints();
} else {
#ifdef DBG_UTIL
if (pObj->IsInserted()) {
@@ -262,10 +255,6 @@ sal_Bool SdrMarkView::MarkPoints(const Rectangle* pRect, sal_Bool bUnmark)
}
}
}
- if (pM!=NULL) { // Clean up the last selected MarkEntry, if necessary
- SdrUShortCont* pPts=pM->GetMarkedPoints();
- if (pPts!=NULL) pPts->ForceSort();
- }
if (bChgd) {
MarkListHasChanged();
}
@@ -350,28 +339,20 @@ void SdrMarkView::UndirtyMrkPnt() const
// Remove invalid selected points, that is, all
// entries above the number of points in the object.
sal_uInt32 nMax(pObj->GetPointCount());
- sal_uInt32 nPtNum(0xffffffff);
- pPts->ForceSort();
-
- for (sal_uInt32 nIndex(pPts->GetCount()); nIndex > 0L && nPtNum >= nMax;)
+ SdrUShortCont::const_iterator it = pPts->lower_bound(nMax);
+ if( it != pPts->end() )
{
- nIndex--;
- nPtNum = pPts->GetObject(nIndex);
-
- if(nPtNum >= nMax)
- {
- pPts->Remove(nIndex);
- bChg = sal_True;
- }
+ pPts->erase(it, pPts->end() );
+ bChg = sal_True;
}
}
else
{
OSL_FAIL("SdrMarkView::UndirtyMrkPnt(): Selected points on an object that is not a PolyObj!");
- if(pPts && pPts->GetCount())
+ if(pPts && !pPts->empty())
{
- pPts->Clear();
+ pPts->clear();
bChg = sal_True;
}
}
@@ -385,18 +366,19 @@ void SdrMarkView::UndirtyMrkPnt() const
// Remove invalid selected glue points, that is, all entries
// (IDs) that aren't contained in the GluePointList of the
// object
- pPts->ForceSort();
- for (sal_uIntPtr nIndex=pPts->GetCount(); nIndex>0;) {
- nIndex--;
- sal_uInt16 nId=pPts->GetObject(nIndex);
+ for(SdrUShortCont::const_iterator it = pPts->begin(); it != pPts->end(); )
+ {
+ sal_uInt16 nId=*it;
if (pGPL->FindGluePoint(nId)==SDRGLUEPOINT_NOTFOUND) {
- pPts->Remove(nIndex);
+ it = pPts->erase(it);
bChg=sal_True;
}
+ else
+ ++it;
}
} else {
- if (pPts!=NULL && pPts->GetCount()!=0) {
- pPts->Clear(); // object doesn't have any glue points (any more)
+ if (pPts!=NULL && !pPts->empty()) {
+ pPts->clear(); // object doesn't have any glue points (any more)
bChg=sal_True;
}
}
@@ -443,7 +425,7 @@ sal_Bool SdrMarkView::HasMarkedGluePoints() const
for (sal_uIntPtr nMarkNum=0; nMarkNum<nMarkAnz && !bRet; nMarkNum++) {
const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
const SdrUShortCont* pPts=pM->GetMarkedGluePoints();
- bRet=pPts!=NULL && pPts->GetCount()!=0;
+ bRet=pPts!=NULL && !pPts->empty();
}
return bRet;
}
@@ -461,8 +443,8 @@ sal_Bool SdrMarkView::MarkGluePoints(const Rectangle* pRect, sal_Bool bUnmark)
const SdrGluePointList* pGPL=pObj->GetGluePointList();
SdrUShortCont* pPts=pM->GetMarkedGluePoints();
if (bUnmark && pRect==NULL) { // UnmarkAll
- if (pPts!=NULL && pPts->GetCount()!=0) {
- pPts->Clear();
+ if (pPts!=NULL && !pPts->empty()) {
+ pPts->clear();
bChgd=sal_True;
}
} else {
@@ -476,16 +458,16 @@ sal_Bool SdrMarkView::MarkGluePoints(const Rectangle* pRect, sal_Bool bUnmark)
{
Point aPos(rGP.GetAbsolutePos(*pObj));
if (pRect==NULL || pRect->IsInside(aPos)) {
- if (pPts==NULL) pPts=pM->ForceMarkedGluePoints();
- else pPts->ForceSort();
- sal_uIntPtr nPos=pPts->GetPos(rGP.GetId());
- if (!bUnmark && nPos==CONTAINER_ENTRY_NOTFOUND) {
+ if (pPts==NULL)
+ pPts=pM->ForceMarkedGluePoints();
+ bool bContains = pPts->find( rGP.GetId() ) != pPts->end();
+ if (!bUnmark && !bContains) {
bChgd=sal_True;
- pPts->Insert(rGP.GetId());
+ pPts->insert(rGP.GetId());
}
- if (bUnmark && nPos!=CONTAINER_ENTRY_NOTFOUND) {
+ if (bUnmark && bContains) {
bChgd=sal_True;
- pPts->Remove(nPos);
+ pPts->erase(rGP.GetId());
}
}
}
@@ -558,14 +540,14 @@ sal_Bool SdrMarkView::MarkGluePoint(const SdrObject* pObj, sal_uInt16 nId, const
SdrMark* pM=GetSdrMarkByIndex(nMarkPos);
SdrUShortCont* pPts=bUnmark ? pM->GetMarkedGluePoints() : pM->ForceMarkedGluePoints();
if (pPts!=NULL) {
- sal_uIntPtr nPointPos=pPts->GetPos(nId);
- if (!bUnmark && nPointPos==CONTAINER_ENTRY_NOTFOUND) {
+ bool bContains = pPts->find( nId ) != pPts->end();
+ if (!bUnmark && !bContains) {
bChgd=sal_True;
- pPts->Insert(nId);
+ pPts->insert(nId);
}
- if (bUnmark && nPointPos!=CONTAINER_ENTRY_NOTFOUND) {
+ if (bUnmark && bContains) {
bChgd=sal_True;
- pPts->Remove(nPointPos);
+ pPts->erase(nId);
}
}
} else {
@@ -588,7 +570,7 @@ sal_Bool SdrMarkView::IsGluePointMarked(const SdrObject* pObj, sal_uInt16 nId) c
const SdrMark* pM=GetSdrMarkByIndex(nPos);
const SdrUShortCont* pPts=pM->GetMarkedGluePoints();
if (pPts!=NULL) {
- bRet=pPts->Exist(nId);
+ bRet = pPts->find( nId ) != pPts->end();
}
}
return bRet;
diff --git a/svx/source/svdraw/svdpoev.cxx b/svx/source/svdraw/svdpoev.cxx
index 8627952..c94e13e 100644
--- a/svx/source/svdraw/svdpoev.cxx
+++ b/svx/source/svdraw/svdpoev.cxx
@@ -99,7 +99,7 @@ void SdrPolyEditView::CheckPolyPossibilitiesHelper( SdrMark* pM, bool& b1stSmoot
if(pPath && pPts)
{
- const sal_uInt32 nMarkedPntAnz(pPts->GetCount());
+ const sal_uInt32 nMarkedPntAnz(pPts->size());
if(nMarkedPntAnz)
{
@@ -111,9 +111,9 @@ void SdrPolyEditView::CheckPolyPossibilitiesHelper( SdrMark* pM, bool& b1stSmoot
bSetMarkedSegmentsKindPossible = true;
}
- for(sal_uInt32 nMarkedPntNum(0L); nMarkedPntNum < nMarkedPntAnz; nMarkedPntNum++)
+ for(SdrUShortCont::const_iterator it = pPts->begin(); it != pPts->end(); ++it)
{
- sal_uInt32 nNum(pPts->GetObject(nMarkedPntNum));
+ sal_uInt32 nNum(*it);
sal_uInt32 nPolyNum, nPntNum;
if(PolyPolygonEditor::GetRelativePolyPoint(pPath->GetPathPoly(), nNum, nPolyNum, nPntNum))
@@ -225,7 +225,7 @@ void SdrPolyEditView::SetMarkedPointsSmooth(SdrPathSmoothKind eKind)
if(pPts && pPath)
{
PolyPolygonEditor aEditor( pPath->GetPathPoly(), pPath->IsClosed() );
- if(aEditor.SetPointsSmooth( eFlags, pPts->getContainer() ) )
+ if(aEditor.SetPointsSmooth( eFlags, *pPts ) )
{
if( bUndo )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPath));
@@ -260,7 +260,7 @@ void SdrPolyEditView::SetMarkedSegmentsKind(SdrPathSegmentKind eKind)
if(pPts && pPath)
{
PolyPolygonEditor aEditor( pPath->GetPathPoly(), pPath->IsClosed() );
- if(aEditor.SetSegmentsKind( eKind, pPts->getContainer()) )
+ if(aEditor.SetSegmentsKind( eKind, *pPts ) )
{
if( bUndo )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPath));
@@ -327,8 +327,8 @@ void SdrPolyEditView::DeleteMarkedPoints()
if( pPath && pPts )
{
- PolyPolygonEditor aEditor( pPath ->GetPathPoly(), pPath->IsClosed() );
- if( aEditor.DeletePoints( pPts->getContainer() ) )
+ PolyPolygonEditor aEditor( pPath->GetPathPoly(), pPath->IsClosed() );
+ if( aEditor.DeletePoints( *pPts ) )
{
if( aEditor.GetPolyPolygon().count() )
{
@@ -378,18 +378,15 @@ void SdrPolyEditView::RipUpAtMarkedPoints()
if(pPts && pObj)
{
- pPts->ForceSort();
if( bUndo )
AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
sal_Bool bKorregFlag(sal_False);
- sal_uInt32 nMarkPtsAnz(pPts->GetCount());
sal_uInt32 nMax(pObj->GetHdlCount());
- for(sal_uInt32 i(nMarkPtsAnz); i > 0L;)
+ for(SdrUShortCont::const_reverse_iterator it = pPts->rbegin(); it != pPts->rend(); ++it)
{
- i--;
sal_uInt32 nNewPt0Idx(0L);
- SdrObject* pNeuObj = pObj->RipPoint(pPts->GetObject(i), nNewPt0Idx);
+ SdrObject* pNeuObj = pObj->RipPoint(*it, nNewPt0Idx);
if(pNeuObj)
{
@@ -408,9 +405,10 @@ void SdrPolyEditView::RipUpAtMarkedPoints()
{
bKorregFlag = sal_True;
- for(sal_uInt32 nBla(0L); nBla < nMarkPtsAnz; nBla++)
+ SdrUShortCont aReplaceSet;
+ for(SdrUShortCont::const_iterator it2 = pPts->begin(); it2 != pPts->end(); ++it2)
{
- sal_uInt32 nPntNum(pPts->GetObject(nBla));
+ sal_uInt32 nPntNum(*it2);
nPntNum += nNewPt0Idx;
if(nPntNum >= nMax)
@@ -418,10 +416,11 @@ void SdrPolyEditView::RipUpAtMarkedPoints()
nPntNum -= nMax;
}
- pPts->Replace((sal_uInt16)nPntNum, nBla);
+ aReplaceSet.insert( (sal_uInt16)nPntNum );
}
+ pPts->swap(aReplaceSet);
- i = nMarkPtsAnz;
+ it = pPts->rbegin();
}
}
}
@@ -449,7 +448,7 @@ bool SdrPolyEditView::IsRipUpAtMarkedPointsPossible() const
{
const SdrUShortCont* pSelectedPoints = pMark->GetMarkedPoints();
- if(pSelectedPoints && pSelectedPoints->GetCount())
+ if(pSelectedPoints && !pSelectedPoints->empty())
{
const basegfx::B2DPolyPolygon& rPathPolyPolygon = pMarkedPathObject->GetPathPoly();
@@ -464,9 +463,10 @@ bool SdrPolyEditView::IsRipUpAtMarkedPointsPossible() const
{
bRetval = pMarkedPathObject->IsClosedObj(); // #i76617#
- for(sal_uInt32 b(0); !bRetval && b < pSelectedPoints->GetCount(); b++)
+ for(SdrUShortCont::const_iterator it = pSelectedPoints->begin();
+ !bRetval && it != pSelectedPoints->end(); ++it)
{
- const sal_uInt16 nMarkedPointNum(pSelectedPoints->GetObject(b));
+ const sal_uInt16 nMarkedPointNum(*it);
bRetval = (nMarkedPointNum > 0 && nMarkedPointNum < nPointCount - 1);
}
@@ -597,7 +597,7 @@ void SdrPolyEditView::ImpTransformMarkedPoints(PPolyTrFunc pTrFunc, const void*
SdrMark* pM=GetSdrMarkByIndex(nm);
SdrObject* pObj=pM->GetMarkedSdrObj();
const SdrUShortCont* pPts=pM->GetMarkedPoints();
- sal_uIntPtr nPtAnz=pPts==NULL ? 0 : pPts->GetCount();
+ sal_uIntPtr nPtAnz=pPts==NULL ? 0 : pPts->size();
SdrPathObj* pPath=PTR_CAST(SdrPathObj,pObj);
if (nPtAnz!=0 && pPath!=NULL)
{
@@ -606,9 +606,9 @@ void SdrPolyEditView::ImpTransformMarkedPoints(PPolyTrFunc pTrFunc, const void*
basegfx::B2DPolyPolygon aXPP(pPath->GetPathPoly());
- for(sal_uInt32 nPtNum(0L); nPtNum < nPtAnz; nPtNum++)
+ for(SdrUShortCont::const_iterator it = pPts->begin(); it != pPts->end(); ++it)
{
- sal_uInt32 nPt(pPts->GetObject(nPtNum));
+ sal_uInt32 nPt = *it;
sal_uInt32 nPolyNum, nPointNum;
if(PolyPolygonEditor::GetRelativePolyPoint(aXPP, nPt, nPolyNum, nPointNum))
commit c8a68356b4c8f8f45405da8e76baeb38a930941f
Author: Noel Grandin <noel at peralex.com>
Date: Tue Aug 14 14:49:53 2012 +0200
Remove unused class ImpUShortContainerSorter
Change-Id: I3d7a5c252c29654db7c37965af365380090f7eb6
diff --git a/svx/source/svdraw/svdetc.cxx b/svx/source/svdraw/svdetc.cxx
index fb3a188..776f526 100644
--- a/svx/source/svdraw/svdetc.cxx
+++ b/svx/source/svdraw/svdetc.cxx
@@ -270,22 +270,6 @@ void ContainerSorter::ImpSubSort(long nL, long nR) const
////////////////////////////////////////////////////////////////////////////////////////////////////
-class ImpUShortContainerSorter: public ContainerSorter {
-public:
- ImpUShortContainerSorter(Container& rNewCont): ContainerSorter(rNewCont) {}
- virtual ~ImpUShortContainerSorter() {}
- virtual int Compare(const void* pElem1, const void* pElem2) const;
-};
-
-int ImpUShortContainerSorter::Compare(const void* pElem1, const void* pElem2) const
-{
- sal_uInt16 n1=sal_uInt16(sal_uIntPtr(pElem1));
- sal_uInt16 n2=sal_uInt16(sal_uIntPtr(pElem2));
- return n1<n2 ? -1 : n1>n2 ? 1 : 0;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-
void SdrLinkList::Clear()
{
unsigned nAnz=GetLinkCount();
commit 02d23c2c6696b440f1ec033d8bee39744c2bb2ad
Author: Noel Grandin <noel at peralex.com>
Date: Tue Aug 14 11:31:08 2012 +0200
Remove unused class UShortCont
Change-Id: I4b716aca20b2e7e328b9f6cb9e9c980fd0e7a87f
diff --git a/svx/inc/svx/svdetc.hxx b/svx/inc/svx/svdetc.hxx
index 85690ef..1ac93a3 100644
--- a/svx/inc/svx/svdetc.hxx
+++ b/svx/inc/svx/svdetc.hxx
@@ -119,20 +119,6 @@ class SfxItemSet;
// Bei XFILL_NONE gibt's sal_False und rCol bleibt unveraendert.
SVX_DLLPUBLIC bool GetDraftFillColor(const SfxItemSet& rSet, Color& rCol);
-// Ein Container fuer USHORTs (im Prinzip ein dynamisches Array)
-class UShortCont {
- Container aArr;
-public:
- UShortCont(sal_uInt16 nBlock, sal_uInt16 nInit, sal_uInt16 nResize): aArr(nBlock,nInit,nResize) {}
- void Clear() { aArr.Clear(); }
- void Insert(sal_uInt16 nElem, sal_uIntPtr nPos=CONTAINER_APPEND) { aArr.Insert((void*)sal_uIntPtr(nElem),nPos); }
- void Remove(sal_uIntPtr nPos) { aArr.Remove(nPos); }
- void Replace(sal_uInt16 nElem, sal_uIntPtr nPos) { aArr.Replace((void*)sal_uIntPtr(nElem),nPos); }
- sal_uInt16 GetObject(sal_uIntPtr nPos) const { return sal_uInt16(sal_uIntPtr(aArr.GetObject(nPos))); }
- sal_uIntPtr GetPos(sal_uInt16 nElem) const { return aArr.GetPos((void*)(sal_uIntPtr)nElem); }
- sal_uIntPtr GetCount() const { return aArr.Count(); }
-};
-
class ContainerSorter {
protected:
Container& rCont;
commit 62035e55b4128a5bf391c45160e0be5347fa23ae
Author: Noel Grandin <noel at peralex.com>
Date: Tue Aug 14 11:01:38 2012 +0200
Convert aList field in SdrLinkList class from Container to std::vector
Change-Id: Idf07339186827fb57ded1586108f1a4a49069f42
diff --git a/svx/inc/svx/svdetc.hxx b/svx/inc/svx/svdetc.hxx
index b2408f3..85690ef 100644
--- a/svx/inc/svx/svdetc.hxx
+++ b/svx/inc/svx/svdetc.hxx
@@ -219,16 +219,16 @@ public:
class SdrLinkList
{
- Container aList;
+ std::vector<Link*> aList;
protected:
unsigned FindEntry(const Link& rLink) const;
public:
- SdrLinkList(): aList(1024,4,4) {}
- ~SdrLinkList() { Clear(); }
+ SdrLinkList(): aList() {}
+ ~SdrLinkList() { Clear(); }
SVX_DLLPUBLIC void Clear();
- unsigned GetLinkCount() const { return (unsigned)aList.Count(); }
- Link& GetLink(unsigned nNum) { return *((Link*)(aList.GetObject(nNum))); }
- const Link& GetLink(unsigned nNum) const { return *((Link*)(aList.GetObject(nNum))); }
+ unsigned GetLinkCount() const { return (unsigned)aList.size(); }
+ Link& GetLink(unsigned nNum) { return *aList[nNum]; }
+ const Link& GetLink(unsigned nNum) const { return *aList[nNum]; }
void InsertLink(const Link& rLink, unsigned nPos=0xFFFF);
void RemoveLink(const Link& rLink);
bool HasLink(const Link& rLink) const { return FindEntry(rLink)!=0xFFFF; }
diff --git a/svx/source/svdraw/svdetc.cxx b/svx/source/svdraw/svdetc.cxx
index e43b55b..fb3a188 100644
--- a/svx/source/svdraw/svdetc.cxx
+++ b/svx/source/svdraw/svdetc.cxx
@@ -290,9 +290,9 @@ void SdrLinkList::Clear()
{
unsigned nAnz=GetLinkCount();
for (unsigned i=0; i<nAnz; i++) {
- delete (Link*)aList.GetObject(i);
+ delete aList[i];
}
- aList.Clear();
+ aList.clear();
}
unsigned SdrLinkList::FindEntry(const Link& rLink) const
@@ -309,7 +309,10 @@ void SdrLinkList::InsertLink(const Link& rLink, unsigned nPos)
unsigned nFnd=FindEntry(rLink);
if (nFnd==0xFFFF) {
if (rLink.IsSet()) {
- aList.Insert(new Link(rLink),nPos);
+ if(nPos==0xFFFF)
+ aList.push_back(new Link(rLink));
+ else
+ aList.insert(aList.begin() + nPos, new Link(rLink));
} else {
OSL_FAIL("SdrLinkList::InsertLink(): Tried to insert a link that was not set already.");
}
@@ -322,7 +325,8 @@ void SdrLinkList::RemoveLink(const Link& rLink)
{
unsigned nFnd=FindEntry(rLink);
if (nFnd!=0xFFFF) {
- Link* pLink=(Link*)aList.Remove(nFnd);
+ Link* pLink = aList[nFnd];
+ aList.erase( aList.begin() + nFnd );
delete pLink;
} else {
OSL_FAIL("SdrLinkList::RemoveLink(): Link not found.");
commit 028b34d93be5b794a195df518741ed67f9afdc09
Author: Noel Grandin <noel at peralex.com>
Date: Tue Aug 14 14:47:34 2012 +0200
Convert OLEObjCache class from Container to std::vector
Change-Id: Id1cbbfb2b8436a28647a528db3ae7ed46d32da83
diff --git a/reportdesign/source/ui/report/dlgedfunc.cxx b/reportdesign/source/ui/report/dlgedfunc.cxx
index cc87208..b99f2e3 100644
--- a/reportdesign/source/ui/report/dlgedfunc.cxx
+++ b/reportdesign/source/ui/report/dlgedfunc.cxx
@@ -442,10 +442,10 @@ void DlgEdFunc::deactivateOle(bool _bSelect)
{
OLEObjCache& rObjCache = GetSdrGlobalData().GetOLEObjCache();
OReportController& rController = m_pParent->getSectionWindow()->getViewsWindow()->getView()->getReportView()->getController();
- const sal_uLong nCount = rObjCache.Count();
+ const sal_uLong nCount = rObjCache.size();
for(sal_uLong i = 0 ; i< nCount;++i)
{
- SdrOle2Obj* pObj = reinterpret_cast<SdrOle2Obj*>(rObjCache.GetObject(i));
+ SdrOle2Obj* pObj = rObjCache[i];
if ( m_pParent->getPage() == pObj->GetPage() )
{
uno::Reference< embed::XEmbeddedObject > xObj = pObj->GetObjRef();
diff --git a/svx/inc/svx/svdetc.hxx b/svx/inc/svx/svdetc.hxx
index 68b89c8..b2408f3 100644
--- a/svx/inc/svx/svdetc.hxx
+++ b/svx/inc/svx/svdetc.hxx
@@ -241,9 +241,9 @@ SdrLinkList& ImpGetUserMakeObjUserDataHdl();
class SdrOle2Obj;
class AutoTimer;
-class OLEObjCache : public Container
+class OLEObjCache : public std::vector<SdrOle2Obj*>
{
- sal_uIntPtr nSize;
+ sal_uIntPtr nSize;
AutoTimer* pTimer;
void UnloadOnDemand();
diff --git a/svx/source/svdraw/svdetc.cxx b/svx/source/svdraw/svdetc.cxx
index 7cab83d..e43b55b 100644
--- a/svx/source/svdraw/svdetc.cxx
+++ b/svx/source/svdraw/svdetc.cxx
@@ -103,7 +103,7 @@ const LocaleDataWrapper* SdrGlobalData::GetLocaleData()
////////////////////////////////////////////////////////////////////////////////////////////////////
OLEObjCache::OLEObjCache()
-: Container( 0 )
+: std::vector<SdrOle2Obj*>()
{
nSize = officecfg::Office::Common::Cache::DrawingEngine::OLE_Objects::get();
pTimer = new AutoTimer();
@@ -124,15 +124,15 @@ OLEObjCache::~OLEObjCache()
void OLEObjCache::UnloadOnDemand()
{
- if ( nSize < Count() )
+ if ( nSize < size() )
{
// more objects than configured cache size try to remove objects
// of course not the freshly inserted one at nIndex=0
- sal_uIntPtr nCount2 = Count();
+ sal_uIntPtr nCount2 = size();
sal_uIntPtr nIndex = nCount2-1;
while( nIndex && nCount2 > nSize )
{
- SdrOle2Obj* pUnloadObj = (SdrOle2Obj*) GetObject(nIndex--);
+ SdrOle2Obj* pUnloadObj = (*this)[nIndex--];
if ( pUnloadObj )
{
try
@@ -148,9 +148,9 @@ void OLEObjCache::UnloadOnDemand()
uno::Reference< frame::XModel > xUnloadModel( xUnloadObj->getComponent(), uno::UNO_QUERY );
if ( xUnloadModel.is() )
{
- for ( sal_uIntPtr nCheckInd = 0; nCheckInd < Count(); nCheckInd++ )
+ for ( sal_uIntPtr nCheckInd = 0; nCheckInd < size(); nCheckInd++ )
{
- SdrOle2Obj* pCacheObj = (SdrOle2Obj*) GetObject(nCheckInd);
+ SdrOle2Obj* pCacheObj = (*this)[nCheckInd];
if ( pCacheObj && pCacheObj != pUnloadObj )
{
uno::Reference< frame::XModel > xParentModel = pCacheObj->GetParentXModel();
@@ -174,22 +174,24 @@ void OLEObjCache::UnloadOnDemand()
void OLEObjCache::InsertObj(SdrOle2Obj* pObj)
{
- if ( Count() )
+ if ( !empty() )
{
- SdrOle2Obj* pExistingObj = (SdrOle2Obj*)GetObject( 0 );
+ SdrOle2Obj* pExistingObj = front();
if ( pObj == pExistingObj )
// the object is already on the top, nothing has to be changed
return;
}
// get the old position of the object to know whether it is already in container
- sal_uIntPtr nOldPos = GetPos( pObj );
+ iterator it = std::find( begin(), end(), pObj );
+ bool bFound = it != end();
+ if( it != end() )
+ erase( it );
// insert object into first position
- Remove( nOldPos );
- Insert(pObj, (sal_uIntPtr) 0L);
+ insert(begin(), pObj);
- if ( nOldPos == CONTAINER_ENTRY_NOTFOUND )
+ if ( !bFound )
{
// a new object was inserted, recalculate the cache
UnloadOnDemand();
@@ -198,7 +200,9 @@ void OLEObjCache::InsertObj(SdrOle2Obj* pObj)
void OLEObjCache::RemoveObj(SdrOle2Obj* pObj)
{
- Remove(pObj);
+ iterator it = std::find( begin(), end(), pObj );
+ if( it != end() )
+ erase( it );
}
sal_Bool OLEObjCache::UnloadObj(SdrOle2Obj* pObj)
diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx
index 8c111dc..9c5c8f8 100644
--- a/svx/source/svdraw/svdoole2.cxx
+++ b/svx/source/svdraw/svdoole2.cxx
@@ -391,10 +391,10 @@ void SAL_CALL SdrLightEmbeddedClient_Impl::activatingUI()
xParentFrame->setActiveFrame( xOwnFrame );
OLEObjCache& rObjCache = GetSdrGlobalData().GetOLEObjCache();
- const sal_uIntPtr nCount = rObjCache.Count();
+ const sal_uIntPtr nCount = rObjCache.size();
for(sal_Int32 i = nCount-1 ; i >= 0;--i)
{
- SdrOle2Obj* pObj = reinterpret_cast<SdrOle2Obj*>(rObjCache.GetObject(i));
+ SdrOle2Obj* pObj = rObjCache[i];
if ( pObj != mpObj )
{
// only deactivate ole objects which belongs to the same frame
commit 0aafccd61ee557ab35c3b0ead22f90a633ef80b8
Author: Noel Grandin <noel at peralex.com>
Date: Tue Aug 14 10:41:24 2012 +0200
Convert aPnts field in SdrDragStat class from Container to std::vector
Change-Id: Ia9f5f902c9ebeee6d123dc5c8ee6641bef2239e9
diff --git a/svx/inc/svx/svddrag.hxx b/svx/inc/svx/svddrag.hxx
index abce2ab..682785c 100644
--- a/svx/inc/svx/svddrag.hxx
+++ b/svx/inc/svx/svddrag.hxx
@@ -30,7 +30,6 @@
#define _SVDDRAG_HXX
-#include <tools/contnr.hxx>
#include <tools/gen.hxx>
#include <tools/fract.hxx>
#include "svx/svxdllapi.h"
@@ -54,7 +53,7 @@ protected:
SdrHdl* pHdl; // Der Handle an dem der User zottelt
SdrView* pView;
SdrPageView* pPageView;
- Container aPnts; // Alle bisherigen Punkte: [0]=Start, [Count()-2]=Prev
+ std::vector<Point*> aPnts; // Alle bisherigen Punkte: [0]=Start, [Count()-2]=Prev
Point aRef1; // Referenzpunkt: Resize-Fixpunkt, (Drehachse,
Point aRef2; // Spiegelachse, ...)
Point aPos0; // Position beim letzten Event
@@ -99,19 +98,19 @@ protected:
protected:
void Clear(bool bLeaveOne);
- Point& Pnt(sal_uIntPtr nNum) { return *((Point*)aPnts.GetObject(nNum)); }
+ Point& Pnt(sal_uIntPtr nNum) { return *aPnts[nNum]; }
//public:
SdrDragStatUserData* pUser; // Userdata
public:
- SdrDragStat(): aPnts(1024,16,16) { pUser=NULL; Reset(); }
+ SdrDragStat(): aPnts() { pUser=NULL; Reset(); }
~SdrDragStat() { Clear(sal_False); }
void Reset();
SdrView* GetView() const { return pView; }
void SetView(SdrView* pV) { pView=pV; }
SdrPageView* GetPageView() const { return pPageView; }
void SetPageView(SdrPageView* pPV) { pPageView=pPV; }
- const Point& GetPoint(sal_uIntPtr nNum) const { return *((Point*)aPnts.GetObject(nNum)); }
- sal_uIntPtr GetPointAnz() const { return aPnts.Count(); }
+ const Point& GetPoint(sal_uIntPtr nNum) const { return *aPnts[nNum]; }
+ sal_uIntPtr GetPointAnz() const { return aPnts.size(); }
const Point& GetStart() const { return GetPoint(0); }
Point& Start() { return Pnt(0); }
const Point& GetPrev() const { return GetPoint(GetPointAnz()-(GetPointAnz()>=2 ? 2:1)); }
diff --git a/svx/source/svdraw/svddrag.cxx b/svx/source/svdraw/svddrag.cxx
index 478e8c3..6fb2bb1 100644
--- a/svx/source/svdraw/svddrag.cxx
+++ b/svx/source/svdraw/svddrag.cxx
@@ -31,16 +31,15 @@
void SdrDragStat::Clear(bool bLeaveOne)
{
- void* pP=aPnts.First();
- while (pP!=NULL) {
- delete (Point*)pP;
- pP=aPnts.Next();
+ while (!aPnts.empty()) {
+ delete aPnts.back();
+ aPnts.pop_back();
}
if (pUser!=NULL) delete pUser;
pUser=NULL;
- aPnts.Clear();
+ aPnts.clear();
if (bLeaveOne) {
- aPnts.Insert(new Point,CONTAINER_APPEND);
+ aPnts.push_back(new Point);
}
}
@@ -87,15 +86,15 @@ void SdrDragStat::NextPoint(bool bSaveReal)
{
Point aPnt(GetNow());
if (bSaveReal) aPnt=aRealNow;
- aPnts.Insert(new Point(KorregPos(GetRealNow(),aPnt)),CONTAINER_APPEND);
+ aPnts.push_back(new Point(KorregPos(GetRealNow(),aPnt)));
Prev()=aPnt;
}
void SdrDragStat::PrevPoint()
{
- if (aPnts.Count()>=2) { // one has to remain at all times
- Point* pPnt=(Point*)(aPnts.GetObject(aPnts.Count()-2));
- aPnts.Remove(aPnts.Count()-2);
+ if (aPnts.size()>=2) { // one has to remain at all times
+ Point* pPnt=aPnts[aPnts.size()-2];
+ aPnts.erase(aPnts.begin()+aPnts.size()-2);
delete pPnt;
Now()=KorregPos(GetRealNow(),GetPrev());
}
More information about the Libreoffice-commits
mailing list