2013-12-18 23:51:27 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <documentlinkmgr.hxx>
|
|
|
|
#include <datastream.hxx>
|
2014-01-08 16:29:35 -05:00
|
|
|
#include <sfx2/linkmgr.hxx>
|
2013-12-18 23:51:27 -05:00
|
|
|
|
|
|
|
#include <boost/noncopyable.hpp>
|
|
|
|
#include <boost/scoped_ptr.hpp>
|
|
|
|
|
|
|
|
namespace sc {
|
|
|
|
|
|
|
|
struct DocumentLinkManagerImpl : boost::noncopyable
|
|
|
|
{
|
2014-01-08 16:29:35 -05:00
|
|
|
ScDocument& mrDoc;
|
|
|
|
SfxObjectShell* mpShell;
|
2013-12-18 23:51:27 -05:00
|
|
|
boost::scoped_ptr<DataStream> mpDataStream;
|
2014-01-08 16:29:35 -05:00
|
|
|
boost::scoped_ptr<sfx2::LinkManager> mpLinkManager;
|
2013-12-18 23:51:27 -05:00
|
|
|
|
2014-01-08 16:29:35 -05:00
|
|
|
DocumentLinkManagerImpl( ScDocument& rDoc, SfxObjectShell* pShell ) :
|
|
|
|
mrDoc(rDoc), mpShell(pShell), mpDataStream(NULL), mpLinkManager(NULL) {}
|
|
|
|
|
|
|
|
~DocumentLinkManagerImpl()
|
|
|
|
{
|
|
|
|
// Shared base links
|
|
|
|
if (mpLinkManager)
|
|
|
|
{
|
|
|
|
sfx2::SvLinkSources aTemp = mpLinkManager->GetServers();
|
|
|
|
for (sfx2::SvLinkSources::const_iterator it = aTemp.begin(); it != aTemp.end(); ++it)
|
|
|
|
(*it)->Closed();
|
|
|
|
|
|
|
|
if (!mpLinkManager->GetLinks().empty())
|
|
|
|
mpLinkManager->Remove(0, mpLinkManager->GetLinks().size());
|
|
|
|
}
|
|
|
|
}
|
2013-12-18 23:51:27 -05:00
|
|
|
};
|
|
|
|
|
2014-01-08 16:29:35 -05:00
|
|
|
DocumentLinkManager::DocumentLinkManager( ScDocument& rDoc, SfxObjectShell* pShell ) :
|
|
|
|
mpImpl(new DocumentLinkManagerImpl(rDoc, pShell)) {}
|
2013-12-18 23:51:27 -05:00
|
|
|
|
2014-01-08 16:33:42 -05:00
|
|
|
DocumentLinkManager::~DocumentLinkManager()
|
|
|
|
{
|
|
|
|
delete mpImpl;
|
|
|
|
}
|
|
|
|
|
2013-12-18 23:51:27 -05:00
|
|
|
void DocumentLinkManager::setDataStream( DataStream* p )
|
|
|
|
{
|
|
|
|
mpImpl->mpDataStream.reset(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
DataStream* DocumentLinkManager::getDataStream()
|
|
|
|
{
|
|
|
|
return mpImpl->mpDataStream.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
const DataStream* DocumentLinkManager::getDataStream() const
|
|
|
|
{
|
|
|
|
return mpImpl->mpDataStream.get();
|
|
|
|
}
|
|
|
|
|
2014-01-08 16:29:35 -05:00
|
|
|
sfx2::LinkManager* DocumentLinkManager::getLinkManager( bool bCreate )
|
|
|
|
{
|
|
|
|
if (!mpImpl->mpLinkManager && bCreate && mpImpl->mpShell)
|
|
|
|
mpImpl->mpLinkManager.reset(new sfx2::LinkManager(mpImpl->mpShell));
|
|
|
|
return mpImpl->mpLinkManager.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
const sfx2::LinkManager* DocumentLinkManager::getExistingLinkManager() const
|
|
|
|
{
|
|
|
|
return mpImpl->mpLinkManager.get();
|
|
|
|
}
|
|
|
|
|
2013-12-18 23:51:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|