diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-12-18 23:51:27 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-12-19 15:33:08 -0500 |
commit | a17794d5fa8d6757a1f3caff7d9428720c0a357e (patch) | |
tree | c464d7acc38cf9f5190234b85203d2492d81f938 /sc | |
parent | ec5aea8ceddc6701234c7d9b68160b6998be3633 (diff) |
Switch away from using the sfx2 link manager for data stream.
Change-Id: I05ac5a8151135ace7f4e351cfedab0170c8d9a57
Diffstat (limited to 'sc')
-rw-r--r-- | sc/Library_sc.mk | 1 | ||||
-rw-r--r-- | sc/inc/document.hxx | 5 | ||||
-rw-r--r-- | sc/inc/documentlinkmgr.hxx | 36 | ||||
-rw-r--r-- | sc/source/core/data/documen2.cxx | 14 | ||||
-rw-r--r-- | sc/source/core/data/documen8.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/docshell/datastream.cxx | 88 | ||||
-rw-r--r-- | sc/source/ui/docshell/documentlinkmgr.cxx | 44 | ||||
-rw-r--r-- | sc/source/ui/inc/datastream.hxx | 11 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh2.cxx | 52 |
9 files changed, 131 insertions, 125 deletions
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk index 01a4ab964e5b..8eeab594157f 100644 --- a/sc/Library_sc.mk +++ b/sc/Library_sc.mk @@ -404,6 +404,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\ sc/source/ui/docshell/docsh6 \ sc/source/ui/docshell/docsh7 \ sc/source/ui/docshell/docsh8 \ + sc/source/ui/docshell/documentlinkmgr \ sc/source/ui/docshell/editable \ sc/source/ui/docshell/externalrefmgr \ sc/source/ui/docshell/impex \ diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 74d9cd1a9d71..8d528301fb01 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -70,6 +70,7 @@ class EditTextIterator; struct NoteEntry; struct FormulaGroupContext; class DocumentStreamAccess; +class DocumentLinkManager; } @@ -259,6 +260,7 @@ private: boost::scoped_ptr<svl::SharedStringPool> mpCellStringPool; boost::scoped_ptr<sc::FormulaGroupContext> mpFormulaGroupCxt; + mutable boost::scoped_ptr<sc::DocumentLinkManager> mpDocLinkMgr; SfxUndoManager* mpUndoManager; ScFieldEditEngine* pEditEngine; // uses pEditPool from xPoolHelper @@ -480,6 +482,9 @@ public: SC_DLLPUBLIC sfx2::LinkManager* GetLinkManager() const; + sc::DocumentLinkManager& GetDocLinkManager(); + const sc::DocumentLinkManager& GetDocLinkManager() const; + SC_DLLPUBLIC const ScDocOptions& GetDocOptions() const; SC_DLLPUBLIC void SetDocOptions( const ScDocOptions& rOpt ); SC_DLLPUBLIC const ScViewOptions& GetViewOptions() const; diff --git a/sc/inc/documentlinkmgr.hxx b/sc/inc/documentlinkmgr.hxx new file mode 100644 index 000000000000..ead56985788e --- /dev/null +++ b/sc/inc/documentlinkmgr.hxx @@ -0,0 +1,36 @@ +/* -*- 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/. + */ + +#ifndef SC_DOCUMENTLINKMGR_HXX +#define SC_DOCUMENTLINKMGR_HXX + +#include <boost/noncopyable.hpp> + +namespace sc { + +class DataStream; +struct DocumentLinkManagerImpl; + +class DocumentLinkManager : boost::noncopyable +{ + DocumentLinkManagerImpl* mpImpl; + +public: + DocumentLinkManager(); + + void setDataStream( DataStream* p ); + DataStream* getDataStream(); + const DataStream* getDataStream() const; +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index 2ee3828f30a0..583109677d90 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -95,6 +95,7 @@ #include "refreshtimerprotector.hxx" #include "scopetools.hxx" #include "formulagroup.hxx" +#include "documentlinkmgr.hxx" using namespace com::sun::star; @@ -266,6 +267,19 @@ sfx2::LinkManager* ScDocument::GetLinkManager() const return pLinkManager; } +sc::DocumentLinkManager& ScDocument::GetDocLinkManager() +{ + if (!mpDocLinkMgr) + mpDocLinkMgr.reset(new sc::DocumentLinkManager); + return *mpDocLinkMgr; +} + +const sc::DocumentLinkManager& ScDocument::GetDocLinkManager() const +{ + if (!mpDocLinkMgr) + mpDocLinkMgr.reset(new sc::DocumentLinkManager); + return *mpDocLinkMgr; +} void ScDocument::SetStorageGrammar( formula::FormulaGrammar::Grammar eGram ) { diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx index dfd8a36cc474..47ad10371eef 100644 --- a/sc/source/core/data/documen8.cxx +++ b/sc/source/core/data/documen8.cxx @@ -86,7 +86,6 @@ #include "columniterator.hxx" #include "globalnames.hxx" #include "stringutil.hxx" -#include <datastream.hxx> #include <memory> #include <boost/scoped_ptr.hpp> @@ -1194,7 +1193,7 @@ bool ScDocument::HasAreaLinks() const const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks(); sal_uInt16 nCount = rLinks.size(); for (sal_uInt16 i=0; i<nCount; i++) - if ((*rLinks[i])->ISA(ScAreaLink) || (*rLinks[i])->ISA(sc::DataStream)) + if ((*rLinks[i])->ISA(ScAreaLink)) return true; } @@ -1209,7 +1208,7 @@ void ScDocument::UpdateAreaLinks() for (sal_uInt16 i=0; i<rLinks.size(); i++) { ::sfx2::SvBaseLink* pBase = *rLinks[i]; - if (pBase->ISA(ScAreaLink) || (*rLinks[i])->ISA(sc::DataStream)) + if (pBase->ISA(ScAreaLink)) pBase->Update(); } } diff --git a/sc/source/ui/docshell/datastream.cxx b/sc/source/ui/docshell/datastream.cxx index c506ee407ded..5b1b9dd04832 100644 --- a/sc/source/ui/docshell/datastream.cxx +++ b/sc/source/ui/docshell/datastream.cxx @@ -16,18 +16,14 @@ #include <osl/time.h> #include <rtl/strbuf.hxx> #include <salhelper/thread.hxx> -#include <sfx2/linkmgr.hxx> #include <sfx2/viewfrm.hxx> -#include <arealink.hxx> #include <datastreamdlg.hxx> -#include <dbfunc.hxx> #include <docsh.hxx> -#include <documentimport.hxx> -#include <impex.hxx> #include <rangelst.hxx> #include <tabvwsh.hxx> #include <viewdata.hxx> #include <stringutil.hxx> +#include <documentlinkmgr.hxx> #include <config_orcus.h> @@ -189,46 +185,9 @@ DataStream* DataStream::Set( ScDocShell *pShell, const OUString& rURL, const ScRange& rRange, sal_Int32 nLimit, MoveType eMove, sal_uInt32 nSettings) { - // Each DataStream needs a destination area in order to be exported. - // There can be only one ScAreaLink / DataStream per cell. - // So - if we don't need range (DataStream with mbValuesInLine == false), - // just find a free cell for now. - ScRange aDestArea; - if (rRange.IsValid()) - aDestArea = rRange; - - sfx2::LinkManager* pLinkManager = pShell->GetDocument()->GetLinkManager(); - sal_uInt16 nLinkPos = 0; - while (nLinkPos < pLinkManager->GetLinks().size()) - { - sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[nLinkPos]; - if (!rRange.IsValid()) - { - if ( (pBase->ISA(ScAreaLink) && static_cast<ScAreaLink*> - (&(*pBase))->GetDestArea().aStart == aDestArea.aStart) - || (pBase->ISA(DataStream) && static_cast<DataStream*> - (&(*pBase))->GetRange().aStart == aDestArea.aStart) ) - { - aDestArea.Move(0, 1, 0); - nLinkPos = 0; - continue; - } - else - ++nLinkPos; - } - else if ( (pBase->ISA(ScAreaLink) && static_cast<ScAreaLink*> - (&(*pBase))->GetDestArea().aStart == aDestArea.aStart) - || (pBase->ISA(DataStream) && static_cast<DataStream*> - (&(*pBase))->GetRange().aStart == aDestArea.aStart) ) - { - pLinkManager->Remove( pBase ); - } - else - ++nLinkPos; - } - - DataStream* pLink = new DataStream(pShell, rURL, aDestArea, nLimit, eMove, nSettings); - pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, rURL, NULL, NULL ); + DataStream* pLink = new DataStream(pShell, rURL, rRange, nLimit, eMove, nSettings); + sc::DocumentLinkManager& rMgr = pShell->GetDocument()->GetDocLinkManager(); + rMgr.setDataStream(pLink); return pLink; } @@ -435,12 +394,6 @@ void DataStream::MoveData() } } -IMPL_LINK_NOARG(DataStream, RefreshHdl) -{ - ImportData(); - return 0; -} - #if ENABLE_ORCUS namespace { @@ -573,39 +526,6 @@ bool DataStream::ImportData() return mbRunning; } -sfx2::SvBaseLink::UpdateResult DataStream::DataChanged( - const OUString& , const css::uno::Any& ) -{ - MakeToolbarVisible(); - StopImport(); - bool bStart = true; - if (mnSettings & SCRIPT_STREAM && !mxReaderThread.is() && - officecfg::Office::Common::Security::Scripting::MacroSecurityLevel::get() >= 1) - { - MessageDialog aQBox( NULL, "QueryRunStreamScriptDialog", "modules/scalc/ui/queryrunstreamscriptdialog.ui"); - aQBox.set_primary_text( aQBox.get_primary_text().replaceFirst("%URL", msURL) ); - if (RET_YES != aQBox.Execute()) - bStart = false; - } - if (bStart) - StartImport(); - return SUCCESS; -} - -void DataStream::Edit( Window* pWindow, const Link& ) -{ - DataStreamDlg aDialog(mpDocShell, pWindow); - aDialog.Init(msURL, maStartRange, mnLimit, meMove, mnSettings); - if (aDialog.Execute() == RET_OK) - { - bool bWasRunning = mbRunning; - StopImport(); - aDialog.StartStream(this); - if (bWasRunning) - StartImport(); - } -} - } // namespace sc /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/docshell/documentlinkmgr.cxx b/sc/source/ui/docshell/documentlinkmgr.cxx new file mode 100644 index 000000000000..2b9998f96244 --- /dev/null +++ b/sc/source/ui/docshell/documentlinkmgr.cxx @@ -0,0 +1,44 @@ +/* -*- 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> + +#include <boost/noncopyable.hpp> +#include <boost/scoped_ptr.hpp> + +namespace sc { + +struct DocumentLinkManagerImpl : boost::noncopyable +{ + boost::scoped_ptr<DataStream> mpDataStream; + + DocumentLinkManagerImpl() : mpDataStream(NULL) {} +}; + +DocumentLinkManager::DocumentLinkManager() : mpImpl(new DocumentLinkManagerImpl) {} + +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(); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/datastream.hxx b/sc/source/ui/inc/datastream.hxx index 1cde20e69b9a..935e89547118 100644 --- a/sc/source/ui/inc/datastream.hxx +++ b/sc/source/ui/inc/datastream.hxx @@ -14,14 +14,12 @@ #include <rtl/ref.hxx> #include <rtl/ustring.hxx> -#include <sfx2/lnkbase.hxx> #include <address.hxx> #include <boost/noncopyable.hpp> #include <boost/scoped_ptr.hpp> #include <vector> -#include <rangelst.hxx> #include <documentstreamaccess.hxx> class ScDocShell; @@ -37,12 +35,11 @@ namespace datastreams { typedef std::vector<OString> LinesList; -class DataStream : boost::noncopyable, public sfx2::SvBaseLink +class DataStream : boost::noncopyable { OString ConsumeLine(); void MoveData(); void Text2Doc(); - DECL_LINK( RefreshHdl, void* ); public: enum MoveType { NO_MOVE, RANGE_DOWN, MOVE_DOWN, MOVE_UP }; @@ -58,11 +55,7 @@ public: ScDocShell *pShell, const OUString& rURL, const ScRange& rRange, sal_Int32 nLimit, MoveType eMove, sal_uInt32 nSettings); - virtual ~DataStream(); - // sfx2::SvBaseLink - virtual sfx2::SvBaseLink::UpdateResult DataChanged( - const OUString& , const css::uno::Any& ) SAL_OVERRIDE; - virtual void Edit(Window* , const Link& ) SAL_OVERRIDE; + ~DataStream(); ScRange GetRange() const; const OUString& GetURL() const { return msURL; } diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx index 9cba2015d26f..b55e00cb15ff 100644 --- a/sc/source/ui/view/cellsh2.cxx +++ b/sc/source/ui/view/cellsh2.cxx @@ -20,7 +20,6 @@ #include "scitems.hxx" #include <sfx2/viewfrm.hxx> #include <sfx2/app.hxx> -#include <sfx2/linkmgr.hxx> #include <sfx2/request.hxx> #include <svl/aeitem.hxx> #include <basic/sbxcore.hxx> @@ -62,6 +61,7 @@ #include "datastreamdlg.hxx" #include "queryentry.hxx" #include "markdata.hxx" +#include <documentlinkmgr.hxx> #include <config_orcus.h> @@ -742,36 +742,30 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq ) } break; case SID_DATA_STREAMS: - { - sc::DataStreamDlg aDialog( GetViewData()->GetDocShell(), pTabViewShell->GetDialogParent() ); - if (aDialog.Execute() == RET_OK) - aDialog.StartStream(); - } - break; + { + sc::DataStreamDlg aDialog( GetViewData()->GetDocShell(), pTabViewShell->GetDialogParent() ); + if (aDialog.Execute() == RET_OK) + aDialog.StartStream(); + } + break; case SID_DATA_STREAMS_PLAY: - { - ScDocument *pDoc = GetViewData()->GetDocument(); - if (pDoc->GetLinkManager()) - { - const sfx2::SvBaseLinks& rLinks = pDoc->GetLinkManager()->GetLinks(); - for (size_t i = 0; i < rLinks.size(); i++) - if (sc::DataStream *pStream = dynamic_cast<sc::DataStream*>(&(*(*rLinks[i])))) - pStream->StartImport(); - } - } - break; + { + ScDocument *pDoc = GetViewData()->GetDocument(); + sc::DocumentLinkManager& rMgr = pDoc->GetDocLinkManager(); + sc::DataStream* pStrm = rMgr.getDataStream(); + if (pStrm) + pStrm->StartImport(); + } + break; case SID_DATA_STREAMS_STOP: - { - ScDocument *pDoc = GetViewData()->GetDocument(); - if (pDoc->GetLinkManager()) - { - const sfx2::SvBaseLinks& rLinks = pDoc->GetLinkManager()->GetLinks(); - for (size_t i = 0; i < rLinks.size(); i++) - if (sc::DataStream *pStream = dynamic_cast<sc::DataStream*>(&(*(*rLinks[i])))) - pStream->StopImport(); - } - } - break; + { + ScDocument *pDoc = GetViewData()->GetDocument(); + sc::DocumentLinkManager& rMgr = pDoc->GetDocLinkManager(); + sc::DataStream* pStrm = rMgr.getDataStream(); + if (pStrm) + pStrm->StopImport(); + } + break; case SID_MANAGE_XML_SOURCE: ExecuteXMLSourceDialog(); break; |