diff options
author | Ivan Timofeev <timofeev.i.s@gmail.com> | 2012-08-30 23:19:17 +0400 |
---|---|---|
committer | Ivan Timofeev <timofeev.i.s@gmail.com> | 2012-08-31 08:35:18 +0400 |
commit | c050300a72f80ab838bd10f0cedd355048a2aaa5 (patch) | |
tree | f76f73fc49a3a70329a58f1d83e8d1b723634baf /svx | |
parent | Shortcuts in menu in Basic IDE for Undo/Redo (diff) | |
download | core-c050300a72f80ab838bd10f0cedd355048a2aaa5.tar.gz core-c050300a72f80ab838bd10f0cedd355048a2aaa5.zip |
remove SdrObjRefList, use vector directly
also prevent using operator[] on empty vector
Change-Id: I0582ab1c7fd04a0bc6d717d8ca51670c3e5ef1c9
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/svdraw/svdfmtf.cxx | 22 | ||||
-rw-r--r-- | svx/source/svdraw/svdfmtf.hxx | 32 |
2 files changed, 13 insertions, 41 deletions
diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx index 7287db0a0198..b8c007ea97fb 100644 --- a/svx/source/svdraw/svdfmtf.cxx +++ b/svx/source/svdraw/svdfmtf.cxx @@ -219,7 +219,7 @@ sal_uIntPtr ImpSdrGDIMetaFileImport::DoImport(const GDIMetaFile& rMtf, // MapMode scaling MapScaling(); // scale objects to predetermined rectangle - sal_uIntPtr nAnz=aTmpList.GetObjCount(); + size_t nAnz=aTmpList.size(); // To calculate the progress meter, we use GetActionSize()*3. // However, aTmpList has a lower entry count limit than GetActionSize(), @@ -238,9 +238,9 @@ sal_uIntPtr ImpSdrGDIMetaFileImport::DoImport(const GDIMetaFile& rMtf, // insert all objects cached in aTmpList now into rOL from nInsPos if (nInsPos>rOL.GetObjCount()) nInsPos=rOL.GetObjCount(); SdrInsertReason aReason(SDRREASON_VIEWCALL); - for (sal_uIntPtr i=0; i<nAnz; i++) + for (size_t i=0; i<nAnz; i++) { - SdrObject* pObj=aTmpList.GetObj(i); + SdrObject* pObj=aTmpList[i]; rOL.NbcInsertObject(pObj,nInsPos,&aReason); nInsPos++; @@ -264,7 +264,7 @@ sal_uIntPtr ImpSdrGDIMetaFileImport::DoImport(const GDIMetaFile& rMtf, pProgrInfo->ReportError(); } - return aTmpList.GetObjCount(); + return aTmpList.size(); } void ImpSdrGDIMetaFileImport::SetAttributes(SdrObject* pObj, bool bForceTextAttr) @@ -427,7 +427,7 @@ void ImpSdrGDIMetaFileImport::InsertObj( SdrObject* pObj, sal_Bool bScale ) } else { - aTmpList.InsertObject( pObj ); + aTmpList.push_back( pObj ); if ( HAS_BASE( SdrPathObj, pObj ) ) { bool bClosed=pObj->IsClosedObj(); @@ -563,9 +563,9 @@ bool ImpSdrGDIMetaFileImport::CheckLastLineMerge(const basegfx::B2DPolygon& rSrc } // #i73407# reformulation to use new B2DPolygon classes - if(bLastObjWasLine && (aOldLineColor == aVD.GetLineColor()) && rSrcPoly.count()) + if(bLastObjWasLine && (aOldLineColor == aVD.GetLineColor()) && rSrcPoly.count() && !aTmpList.empty()) { - SdrObject* pTmpObj = aTmpList.GetObj(aTmpList.GetObjCount() - 1); + SdrObject* pTmpObj = aTmpList.back(); SdrPathObj* pLastPoly = PTR_CAST(SdrPathObj, pTmpObj); if(pLastPoly) @@ -629,9 +629,9 @@ bool ImpSdrGDIMetaFileImport::CheckLastLineMerge(const basegfx::B2DPolygon& rSrc bool ImpSdrGDIMetaFileImport::CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon & rPolyPolygon) { // #i73407# reformulation to use new B2DPolygon classes - if(bLastObjWasPolyWithoutLine) + if(bLastObjWasPolyWithoutLine && !aTmpList.empty()) { - SdrObject* pTmpObj = aTmpList.GetObj(aTmpList.GetObjCount() - 1); + SdrObject* pTmpObj = aTmpList.back(); SdrPathObj* pLastPoly = PTR_CAST(SdrPathObj, pTmpObj); if(pLastPoly) @@ -929,7 +929,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaMapModeAction& rAct) void ImpSdrGDIMetaFileImport::MapScaling() { - sal_uInt32 i, nAnz = aTmpList.GetObjCount(); + size_t i, nAnz = aTmpList.size(); const MapMode& rMap = aVD.GetMapMode(); Point aMapOrg( rMap.GetOrigin() ); sal_Bool bMov2 = aMapOrg.X() != 0 || aMapOrg.Y() != 0; @@ -937,7 +937,7 @@ void ImpSdrGDIMetaFileImport::MapScaling() { for ( i = nMapScalingOfs; i < nAnz; i++ ) { - SdrObject* pObj = aTmpList.GetObj(i); + SdrObject* pObj = aTmpList[i]; if ( bMov2 ) pObj->NbcMove( Size( aMapOrg.X(), aMapOrg.Y() ) ); } diff --git a/svx/source/svdraw/svdfmtf.hxx b/svx/source/svdraw/svdfmtf.hxx index ceead0de48b0..f0fc89ec4f09 100644 --- a/svx/source/svdraw/svdfmtf.hxx +++ b/svx/source/svdraw/svdfmtf.hxx @@ -46,44 +46,16 @@ class SdrObject; class SvdProgressInfo; //************************************************************ -// Helper Class SdrObjRefList -//************************************************************ - -class SdrObjRefList -{ - std::vector<SdrObject*> aList; -public: - - SdrObjRefList() - : aList() - {} - - void Clear() { aList.clear(); } - sal_uLong GetObjCount() const { return aList.size(); } - SdrObject* GetObj(sal_uLong nNum) const { return aList[nNum]; } - SdrObject* operator[](sal_uLong nNum) const { return aList[nNum]; } - void InsertObject(SdrObject* pObj) { aList.push_back(pObj); } - void InsertObject(SdrObject* pObj, sal_uLong nPos) - { - if(nPos==CONTAINER_APPEND) - aList.push_back(pObj); - else - aList.insert(aList.begin() + nPos, pObj); - } - void RemoveObject(sal_uLong nPos) { aList.erase(aList.begin()+nPos); } -}; - -//************************************************************ // Helper Class ImpSdrGDIMetaFileImport //************************************************************ class ImpSdrGDIMetaFileImport { protected: - SdrObjRefList aTmpList; + std::vector<SdrObject*> aTmpList; VirtualDevice aVD; Rectangle aScaleRect; - sal_uLong nMapScalingOfs; // from here on, not edited with MapScaling + size_t nMapScalingOfs; // from here on, not edited with MapScaling SfxItemSet* pLineAttr; SfxItemSet* pFillAttr; SfxItemSet* pTextAttr; |