diff options
author | Noel Grandin <noel@peralex.com> | 2012-08-14 15:03:14 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-08-16 15:14:57 +0200 |
commit | 7758eaf702849691dcf24472d864ee7ff6d02345 (patch) | |
tree | 508c82198240f2b8d746702ac73fc0acca624b10 | |
parent | c8a68356b4c8f8f45405da8e76baeb38a930941f (diff) |
Convert SdrUShortCont from Container to std::set
Change-Id: Ic7e929d4f20cd737eb15dacdb5718b6c79c80aaf
-rw-r--r-- | sd/source/ui/animations/motionpathtag.cxx | 16 | ||||
-rw-r--r-- | svx/inc/svx/svdmark.hxx | 106 | ||||
-rw-r--r-- | svx/source/svdraw/svddrgmt.cxx | 22 | ||||
-rw-r--r-- | svx/source/svdraw/svdglev.cxx | 34 | ||||
-rw-r--r-- | svx/source/svdraw/svdmark.cxx | 90 | ||||
-rw-r--r-- | svx/source/svdraw/svdmrkv.cxx | 12 | ||||
-rw-r--r-- | svx/source/svdraw/svdmrkv1.cxx | 94 | ||||
-rw-r--r-- | svx/source/svdraw/svdpoev.cxx | 44 |
8 files changed, 109 insertions, 309 deletions
diff --git a/sd/source/ui/animations/motionpathtag.cxx b/sd/source/ui/animations/motionpathtag.cxx index e1c6e1e13458..e48460e48ce7 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 4b68fed64e1f..429570b99475 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 76361c1ed991..8c7762ffcf24 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 0d9c0c75deca..0935381db98e 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 0e03069a89c1..66627e5c071c 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 f0f8f9d2ab4d..2f16e1d1ec97 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 7094f8e8f828..7ffeec00ea08 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 862795296d5d..c94e13e708b7 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)) |