summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-06-06 14:53:38 +0200
committerMichael Stahl <mstahl@redhat.com>2012-06-08 22:52:31 +0200
commit306fe606587153fe619f99bb06e1b4d402cb26f7 (patch)
tree0a14a7309b6fd152a25a921871de07b2e64322c3
parent2186e7cbb03be308c1b02fae881e5e64d3afc36e (diff)
Convert SV_DECL_PTRARR( SvLinkSources) to std::set
Used a std::set because the code was enforcing uniqueness. Change-Id: Ie9243ed17b1165b6a371d0ff2f1a856186697ba3
-rw-r--r--sc/source/core/data/documen2.cxx5
-rw-r--r--sfx2/inc/sfx2/linkmgr.hxx8
-rw-r--r--sfx2/source/appl/linkmgr2.cxx9
-rw-r--r--sw/source/core/doc/docnew.cxx6
-rw-r--r--sw/source/core/doc/swserv.cxx9
5 files changed, 17 insertions, 20 deletions
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 9125e8a16fd9..21d673d5dda6 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -377,8 +377,9 @@ ScDocument::~ScDocument()
if ( GetLinkManager() )
{
// BaseLinks freigeben
- for ( sal_uInt16 n = pLinkManager->GetServers().Count(); n; )
- pLinkManager->GetServers()[ --n ]->Closed();
+ ::sfx2::SvLinkSources aTemp(pLinkManager->GetServers());
+ for( ::sfx2::SvLinkSources::const_iterator it = aTemp.begin(); it != aTemp.end(); ++it )
+ (*it)->Closed();
if ( pLinkManager->GetLinks().Count() )
pLinkManager->Remove( 0, pLinkManager->GetLinks().Count() );
diff --git a/sfx2/inc/sfx2/linkmgr.hxx b/sfx2/inc/sfx2/linkmgr.hxx
index 544c782f6918..f9fd7d577ee4 100644
--- a/sfx2/inc/sfx2/linkmgr.hxx
+++ b/sfx2/inc/sfx2/linkmgr.hxx
@@ -35,6 +35,7 @@
#include <svl/svarray.hxx>
#include <vector>
+#include <set>
class SfxObjectShell;
class Graphic;
@@ -59,8 +60,7 @@ class SvBaseLinkRef;
typedef SvBaseLinkRef* SvBaseLinkRefPtr;
SV_DECL_PTRARR( SvBaseLinks, SvBaseLinkRefPtr, 1 )
-typedef SvLinkSource* SvLinkSourcePtr;
-SV_DECL_PTRARR( SvLinkSources, SvLinkSourcePtr, 1 )
+typedef std::set<SvLinkSource*> SvLinkSources;
class SFX2_DLLPUBLIC LinkManager
{
@@ -162,9 +162,7 @@ public:
const SvLinkSources& GetServers() const { return aServerTbl; }
// Link register/delete
sal_Bool InsertServer( SvLinkSource* rObj );
- void RemoveServer( SvLinkSource* rObj );
- void RemoveServer( sal_uInt16 nPos, sal_uInt16 nCnt = 1 )
- { aServerTbl.Remove( nPos, nCnt ); }
+ void RemoveServer( SvLinkSource* rObj );
// A transfer is aborted, so cancel all download media
// (for the time beeing this is only of interest for the FileLinks!)
diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx
index daec440c0c5a..663e98e89168 100644
--- a/sfx2/source/appl/linkmgr2.cxx
+++ b/sfx2/source/appl/linkmgr2.cxx
@@ -387,19 +387,16 @@ SvLinkSourceRef LinkManager::CreateObj( SvBaseLink * pLink )
sal_Bool LinkManager::InsertServer( SvLinkSource* pObj )
{
// no duplicate inserts
- if( !pObj || USHRT_MAX != aServerTbl.GetPos( pObj ) )
+ if( !pObj )
return sal_False;
- aServerTbl.Insert( pObj, aServerTbl.Count() );
- return sal_True;
+ return aServerTbl.insert( pObj ).second;
}
void LinkManager::RemoveServer( SvLinkSource* pObj )
{
- sal_uInt16 nPos = aServerTbl.GetPos( pObj );
- if( USHRT_MAX != nPos )
- aServerTbl.Remove( nPos, 1 );
+ aServerTbl.erase( pObj );
}
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 3ed8f0aae473..2d3e7c15a75c 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -511,8 +511,10 @@ SwDoc::~SwDoc()
// Release the BaseLinks
{
- for( sal_uInt16 n = pLinkMgr->GetServers().Count(); n; )
- pLinkMgr->GetServers()[ --n ]->Closed();
+ ::sfx2::SvLinkSources aTemp(pLinkMgr->GetServers());
+ for( ::sfx2::SvLinkSources::const_iterator it = aTemp.begin();
+ it != aTemp.end(); ++it )
+ (*it)->Closed();
if( pLinkMgr->GetLinks().Count() )
pLinkMgr->Remove( 0, pLinkMgr->GetLinks().Count() );
diff --git a/sw/source/core/doc/swserv.cxx b/sw/source/core/doc/swserv.cxx
index 1445b2761c9a..167a607fc9ea 100644
--- a/sw/source/core/doc/swserv.cxx
+++ b/sw/source/core/doc/swserv.cxx
@@ -327,9 +327,10 @@ SwDataChanged::~SwDataChanged()
{
const ::sfx2::SvLinkSources& rServers = pDoc->GetLinkManager().GetServers();
- for( sal_uInt16 nCnt = rServers.Count(); nCnt; )
+ ::sfx2::SvLinkSources aTemp(rServers);
+ for( ::sfx2::SvLinkSources::const_iterator it = aTemp.begin(); it != aTemp.end(); ++it )
{
- ::sfx2::SvLinkSourceRef refObj( rServers[ --nCnt ] );
+ ::sfx2::SvLinkSourceRef refObj( *it );
// Any one else interested in the Object?
if( refObj->HasDataLinks() && refObj->ISA( SwServerObject ))
{
@@ -344,9 +345,7 @@ SwDataChanged::~SwDataChanged()
if( !refObj->HasDataLinks() )
{
// Then remove from the list
- // Object is not destroyed, if it still is there!
- if( nCnt < rServers.Count() && &refObj == rServers[ nCnt ] )
- pDoc->GetLinkManager().RemoveServer( nCnt, 1 );
+ pDoc->GetLinkManager().RemoveServer( *it );
}
}
}