Kaydet (Commit) b409cdef authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Removed dependency of ScCollection and ScDataObject.

üst 6bae4674
......@@ -29,15 +29,15 @@
#ifndef SC_AREASAVE_HXX
#define SC_AREASAVE_HXX
#include "collect.hxx"
#include "global.hxx"
#include "address.hxx"
#include <boost/ptr_container/ptr_vector.hpp>
class ScDocument;
class ScAreaLink;
class ScAreaLinkSaver : public ScDataObject
class ScAreaLinkSaver
{
private:
::rtl::OUString aFileName;
......@@ -50,9 +50,7 @@ private:
public:
ScAreaLinkSaver( const ScAreaLink& rSource );
ScAreaLinkSaver( const ScAreaLinkSaver& rCopy );
virtual ~ScAreaLinkSaver();
virtual ScDataObject* Clone() const;
~ScAreaLinkSaver();
bool IsEqual( const ScAreaLink& rCompare ) const;
bool IsEqualSource( const ScAreaLink& rCompare ) const;
......@@ -62,22 +60,26 @@ public:
};
class ScAreaLinkSaveCollection : public ScCollection
class ScAreaLinkSaveCollection
{
typedef ::boost::ptr_vector<ScAreaLinkSaver> DataType;
DataType maData;
public:
ScAreaLinkSaveCollection();
ScAreaLinkSaveCollection( const ScAreaLinkSaveCollection& rCopy );
virtual ~ScAreaLinkSaveCollection();
ScAreaLinkSaveCollection( const ScAreaLinkSaveCollection& r );
~ScAreaLinkSaveCollection();
virtual ScDataObject* Clone() const;
ScAreaLinkSaver* operator[](sal_uInt16 nIndex) const {return (ScAreaLinkSaver*)At(nIndex);}
bool IsEqual( const ScDocument* pDoc ) const;
void Restore( ScDocument* pDoc ) const;
// returns NULL if empty
static ScAreaLinkSaveCollection* CreateFromDoc( const ScDocument* pDoc );
const ScAreaLinkSaver* operator[](size_t nIndex) const;
size_t size() const;
void clear();
void push_back(ScAreaLinkSaver* p);
};
......
......@@ -54,7 +54,6 @@ ScAreaLinkSaver::ScAreaLinkSaver( const ScAreaLink& rSource ) :
}
ScAreaLinkSaver::ScAreaLinkSaver( const ScAreaLinkSaver& rCopy ) :
ScDataObject(),
aFileName ( rCopy.aFileName ),
aFilterName ( rCopy.aFilterName ),
aOptions ( rCopy.aOptions ),
......@@ -64,14 +63,7 @@ ScAreaLinkSaver::ScAreaLinkSaver( const ScAreaLinkSaver& rCopy ) :
{
}
ScAreaLinkSaver::~ScAreaLinkSaver()
{
}
ScDataObject* ScAreaLinkSaver::Clone() const
{
return new ScAreaLinkSaver( *this );
}
ScAreaLinkSaver::~ScAreaLinkSaver() {}
bool ScAreaLinkSaver::IsEqualSource( const ScAreaLink& rCompare ) const
{
......@@ -113,25 +105,12 @@ void ScAreaLinkSaver::InsertNewLink( ScDocument* pDoc ) const
}
}
// -----------------------------------------------------------------------
ScAreaLinkSaveCollection::ScAreaLinkSaveCollection()
{
}
ScAreaLinkSaveCollection::ScAreaLinkSaveCollection( const ScAreaLinkSaveCollection& rCopy ) :
ScCollection( rCopy )
{
}
ScAreaLinkSaveCollection::ScAreaLinkSaveCollection() {}
ScAreaLinkSaveCollection::~ScAreaLinkSaveCollection()
{
}
ScAreaLinkSaveCollection::ScAreaLinkSaveCollection( const ScAreaLinkSaveCollection& r ) :
maData(r.maData) {}
ScDataObject* ScAreaLinkSaveCollection::Clone() const
{
return new ScAreaLinkSaveCollection( *this );
}
ScAreaLinkSaveCollection::~ScAreaLinkSaveCollection() {}
bool ScAreaLinkSaveCollection::IsEqual( const ScDocument* pDoc ) const
{
......@@ -141,7 +120,7 @@ bool ScAreaLinkSaveCollection::IsEqual( const ScDocument* pDoc ) const
sfx2::LinkManager* pLinkManager = const_cast<ScDocument*>(pDoc)->GetLinkManager();
if (pLinkManager)
{
sal_uInt16 nPos = 0;
size_t nPos = 0;
const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
sal_uInt16 nLinkCount = rLinks.Count();
for (sal_uInt16 i=0; i<nLinkCount; i++)
......@@ -149,13 +128,13 @@ bool ScAreaLinkSaveCollection::IsEqual( const ScDocument* pDoc ) const
::sfx2::SvBaseLink* pBase = *rLinks[i];
if (pBase->ISA(ScAreaLink))
{
if ( nPos >= GetCount() || !(*this)[nPos]->IsEqual( *(ScAreaLink*)pBase ) )
if ( nPos >= size() || !(*this)[nPos]->IsEqual( *(ScAreaLink*)pBase ) )
return false;
++nPos;
}
}
if ( nPos < GetCount() )
if ( nPos < size() )
return false; // fewer links in the document than in the save collection
}
......@@ -188,10 +167,10 @@ void ScAreaLinkSaveCollection::Restore( ScDocument* pDoc ) const
if (pLinkManager)
{
const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
sal_uInt16 nSaveCount = GetCount();
for (sal_uInt16 nPos=0; nPos<nSaveCount; nPos++)
size_t nSaveCount = size();
for (size_t nPos=0; nPos<nSaveCount; ++nPos)
{
ScAreaLinkSaver* pSaver = (*this)[nPos];
const ScAreaLinkSaver* pSaver = (*this)[nPos];
ScAreaLink* pLink = lcl_FindLink( rLinks, *pSaver );
if ( pLink )
pSaver->WriteToLink( *pLink ); // restore output position
......@@ -219,8 +198,7 @@ ScAreaLinkSaveCollection* ScAreaLinkSaveCollection::CreateFromDoc( const ScDocum
pColl = new ScAreaLinkSaveCollection;
ScAreaLinkSaver* pSaver = new ScAreaLinkSaver( *(ScAreaLink*)pBase );
if (!pColl->Insert(pSaver))
delete pSaver;
pColl->push_back(pSaver);
}
}
}
......@@ -228,4 +206,24 @@ ScAreaLinkSaveCollection* ScAreaLinkSaveCollection::CreateFromDoc( const ScDocum
return pColl;
}
const ScAreaLinkSaver* ScAreaLinkSaveCollection::operator [](size_t nIndex) const
{
return &maData[nIndex];
}
size_t ScAreaLinkSaveCollection::size() const
{
return maData.size();
}
void ScAreaLinkSaveCollection::clear()
{
maData.clear();
}
void ScAreaLinkSaveCollection::push_back(ScAreaLinkSaver* p)
{
maData.push_back(p);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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