Kaydet (Commit) c050300a authored tarafından Ivan Timofeev's avatar Ivan Timofeev

remove SdrObjRefList, use vector directly

also prevent using operator[] on empty vector

Change-Id: I0582ab1c7fd04a0bc6d717d8ca51670c3e5ef1c9
üst 9bb30a4a
...@@ -219,7 +219,7 @@ sal_uIntPtr ImpSdrGDIMetaFileImport::DoImport(const GDIMetaFile& rMtf, ...@@ -219,7 +219,7 @@ sal_uIntPtr ImpSdrGDIMetaFileImport::DoImport(const GDIMetaFile& rMtf,
// MapMode scaling // MapMode scaling
MapScaling(); MapScaling();
// scale objects to predetermined rectangle // scale objects to predetermined rectangle
sal_uIntPtr nAnz=aTmpList.GetObjCount(); size_t nAnz=aTmpList.size();
// To calculate the progress meter, we use GetActionSize()*3. // To calculate the progress meter, we use GetActionSize()*3.
// However, aTmpList has a lower entry count limit than GetActionSize(), // However, aTmpList has a lower entry count limit than GetActionSize(),
...@@ -238,9 +238,9 @@ sal_uIntPtr ImpSdrGDIMetaFileImport::DoImport(const GDIMetaFile& rMtf, ...@@ -238,9 +238,9 @@ sal_uIntPtr ImpSdrGDIMetaFileImport::DoImport(const GDIMetaFile& rMtf,
// insert all objects cached in aTmpList now into rOL from nInsPos // insert all objects cached in aTmpList now into rOL from nInsPos
if (nInsPos>rOL.GetObjCount()) nInsPos=rOL.GetObjCount(); if (nInsPos>rOL.GetObjCount()) nInsPos=rOL.GetObjCount();
SdrInsertReason aReason(SDRREASON_VIEWCALL); 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); rOL.NbcInsertObject(pObj,nInsPos,&aReason);
nInsPos++; nInsPos++;
...@@ -264,7 +264,7 @@ sal_uIntPtr ImpSdrGDIMetaFileImport::DoImport(const GDIMetaFile& rMtf, ...@@ -264,7 +264,7 @@ sal_uIntPtr ImpSdrGDIMetaFileImport::DoImport(const GDIMetaFile& rMtf,
pProgrInfo->ReportError(); pProgrInfo->ReportError();
} }
return aTmpList.GetObjCount(); return aTmpList.size();
} }
void ImpSdrGDIMetaFileImport::SetAttributes(SdrObject* pObj, bool bForceTextAttr) void ImpSdrGDIMetaFileImport::SetAttributes(SdrObject* pObj, bool bForceTextAttr)
...@@ -427,7 +427,7 @@ void ImpSdrGDIMetaFileImport::InsertObj( SdrObject* pObj, sal_Bool bScale ) ...@@ -427,7 +427,7 @@ void ImpSdrGDIMetaFileImport::InsertObj( SdrObject* pObj, sal_Bool bScale )
} }
else else
{ {
aTmpList.InsertObject( pObj ); aTmpList.push_back( pObj );
if ( HAS_BASE( SdrPathObj, pObj ) ) if ( HAS_BASE( SdrPathObj, pObj ) )
{ {
bool bClosed=pObj->IsClosedObj(); bool bClosed=pObj->IsClosedObj();
...@@ -563,9 +563,9 @@ bool ImpSdrGDIMetaFileImport::CheckLastLineMerge(const basegfx::B2DPolygon& rSrc ...@@ -563,9 +563,9 @@ bool ImpSdrGDIMetaFileImport::CheckLastLineMerge(const basegfx::B2DPolygon& rSrc
} }
// #i73407# reformulation to use new B2DPolygon classes // #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); SdrPathObj* pLastPoly = PTR_CAST(SdrPathObj, pTmpObj);
if(pLastPoly) if(pLastPoly)
...@@ -629,9 +629,9 @@ bool ImpSdrGDIMetaFileImport::CheckLastLineMerge(const basegfx::B2DPolygon& rSrc ...@@ -629,9 +629,9 @@ bool ImpSdrGDIMetaFileImport::CheckLastLineMerge(const basegfx::B2DPolygon& rSrc
bool ImpSdrGDIMetaFileImport::CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon & rPolyPolygon) bool ImpSdrGDIMetaFileImport::CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon & rPolyPolygon)
{ {
// #i73407# reformulation to use new B2DPolygon classes // #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); SdrPathObj* pLastPoly = PTR_CAST(SdrPathObj, pTmpObj);
if(pLastPoly) if(pLastPoly)
...@@ -929,7 +929,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaMapModeAction& rAct) ...@@ -929,7 +929,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaMapModeAction& rAct)
void ImpSdrGDIMetaFileImport::MapScaling() void ImpSdrGDIMetaFileImport::MapScaling()
{ {
sal_uInt32 i, nAnz = aTmpList.GetObjCount(); size_t i, nAnz = aTmpList.size();
const MapMode& rMap = aVD.GetMapMode(); const MapMode& rMap = aVD.GetMapMode();
Point aMapOrg( rMap.GetOrigin() ); Point aMapOrg( rMap.GetOrigin() );
sal_Bool bMov2 = aMapOrg.X() != 0 || aMapOrg.Y() != 0; sal_Bool bMov2 = aMapOrg.X() != 0 || aMapOrg.Y() != 0;
...@@ -937,7 +937,7 @@ void ImpSdrGDIMetaFileImport::MapScaling() ...@@ -937,7 +937,7 @@ void ImpSdrGDIMetaFileImport::MapScaling()
{ {
for ( i = nMapScalingOfs; i < nAnz; i++ ) for ( i = nMapScalingOfs; i < nAnz; i++ )
{ {
SdrObject* pObj = aTmpList.GetObj(i); SdrObject* pObj = aTmpList[i];
if ( bMov2 ) if ( bMov2 )
pObj->NbcMove( Size( aMapOrg.X(), aMapOrg.Y() ) ); pObj->NbcMove( Size( aMapOrg.X(), aMapOrg.Y() ) );
} }
......
...@@ -45,34 +45,6 @@ class SdrPage; ...@@ -45,34 +45,6 @@ class SdrPage;
class SdrObject; class SdrObject;
class SvdProgressInfo; 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 // Helper Class ImpSdrGDIMetaFileImport
//************************************************************ //************************************************************
...@@ -80,10 +52,10 @@ public: ...@@ -80,10 +52,10 @@ public:
class ImpSdrGDIMetaFileImport class ImpSdrGDIMetaFileImport
{ {
protected: protected:
SdrObjRefList aTmpList; std::vector<SdrObject*> aTmpList;
VirtualDevice aVD; VirtualDevice aVD;
Rectangle aScaleRect; 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* pLineAttr;
SfxItemSet* pFillAttr; SfxItemSet* pFillAttr;
SfxItemSet* pTextAttr; SfxItemSet* pTextAttr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment