Kaydet (Commit) f482c9fd authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Michael Stahl

Convert local variable from Container to std::vector and std::set

Change-Id: I0b15939e1d04a3a2a5f8a4e2df8f0826903a8811
üst f23f1418
...@@ -231,7 +231,7 @@ void SdrTextObj::ImpSetTextStyleSheetListeners() ...@@ -231,7 +231,7 @@ void SdrTextObj::ImpSetTextStyleSheetListeners()
SfxStyleSheetBasePool* pStylePool=pModel!=NULL ? pModel->GetStyleSheetPool() : NULL; SfxStyleSheetBasePool* pStylePool=pModel!=NULL ? pModel->GetStyleSheetPool() : NULL;
if (pStylePool!=NULL) if (pStylePool!=NULL)
{ {
Container aStyles(1024,64,64); std::vector<XubString*> aStyleNames;
OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject(); OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject();
if (pOutlinerParaObject!=NULL) if (pOutlinerParaObject!=NULL)
{ {
...@@ -256,28 +256,28 @@ void SdrTextObj::ImpSetTextStyleSheetListeners() ...@@ -256,28 +256,28 @@ void SdrTextObj::ImpSetTextStyleSheetListeners()
aStyleName += aFam; aStyleName += aFam;
sal_Bool bFnd(sal_False); sal_Bool bFnd(sal_False);
sal_uInt32 nNum(aStyles.Count()); sal_uInt32 nNum(aStyleNames.size());
while(!bFnd && nNum > 0) while(!bFnd && nNum > 0)
{ {
// we don't want duplicate stylesheets // we don't want duplicate stylesheets
nNum--; nNum--;
bFnd = (aStyleName.Equals(*(XubString*)aStyles.GetObject(nNum))); bFnd = aStyleName.Equals(*aStyleNames[nNum]);
} }
if(!bFnd) if(!bFnd)
{ {
aStyles.Insert(new XubString(aStyleName), CONTAINER_APPEND); aStyleNames.push_back(new XubString(aStyleName));
} }
} }
} }
} }
// now replace the strings in the container by StyleSheet* // now convert the strings in the vector from names to StyleSheet*
sal_uIntPtr nNum=aStyles.Count(); std::set<SfxStyleSheet*> aStyleSheets;
while (nNum>0) { while (!aStyleNames.empty()) {
nNum--; XubString* pName=aStyleNames.back();
XubString* pName=(XubString*)aStyles.GetObject(nNum); aStyleNames.pop_back();
String aFam = pName->Copy(0, pName->Len() - 6); String aFam = pName->Copy(0, pName->Len() - 6);
...@@ -291,28 +291,24 @@ void SdrTextObj::ImpSetTextStyleSheetListeners() ...@@ -291,28 +291,24 @@ void SdrTextObj::ImpSetTextStyleSheetListeners()
SfxStyleSheet* pStyle=PTR_CAST(SfxStyleSheet,pStyleBase); SfxStyleSheet* pStyle=PTR_CAST(SfxStyleSheet,pStyleBase);
delete pName; delete pName;
if (pStyle!=NULL && pStyle!=GetStyleSheet()) { if (pStyle!=NULL && pStyle!=GetStyleSheet()) {
aStyles.Replace(pStyle,nNum); aStyleSheets.insert(pStyle);
} else {
aStyles.Remove(nNum);
} }
} }
// now remove all superfluous stylesheets // now remove all superfluous stylesheets
nNum=GetBroadcasterCount(); sal_uIntPtr nNum=GetBroadcasterCount();
while (nNum>0) { while (nNum>0) {
nNum--; nNum--;
SfxBroadcaster* pBroadcast=GetBroadcasterJOE((sal_uInt16)nNum); SfxBroadcaster* pBroadcast=GetBroadcasterJOE((sal_uInt16)nNum);
SfxStyleSheet* pStyle=PTR_CAST(SfxStyleSheet,pBroadcast); SfxStyleSheet* pStyle=PTR_CAST(SfxStyleSheet,pBroadcast);
if (pStyle!=NULL && pStyle!=GetStyleSheet()) { // special case for stylesheet of the object if (pStyle!=NULL && pStyle!=GetStyleSheet()) { // special case for stylesheet of the object
if (aStyles.GetPos(pStyle)==CONTAINER_ENTRY_NOTFOUND) { if (aStyleSheets.find(pStyle)==aStyleSheets.end()) {
EndListening(*pStyle); EndListening(*pStyle);
} }
} }
} }
// and finally, merge all stylesheets that are contained in aStyles with previous broadcasters // and finally, merge all stylesheets that are contained in aStyles with previous broadcasters
nNum=aStyles.Count(); for(std::set<SfxStyleSheet*>::const_iterator it = aStyleSheets.begin(); it != aStyleSheets.end(); ++it) {
while (nNum>0) { SfxStyleSheet* pStyle=*it;
nNum--;
SfxStyleSheet* pStyle=(SfxStyleSheet*)aStyles.GetObject(nNum);
// let StartListening see for itself if there's already a listener registered // let StartListening see for itself if there's already a listener registered
StartListening(*pStyle,sal_True); StartListening(*pStyle,sal_True);
} }
......
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