summaryrefslogtreecommitdiff
path: root/sc/source/ui
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2013-12-18 23:51:27 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-12-19 15:33:08 -0500
commita17794d5fa8d6757a1f3caff7d9428720c0a357e (patch)
treec464d7acc38cf9f5190234b85203d2492d81f938 /sc/source/ui
parentec5aea8ceddc6701234c7d9b68160b6998be3633 (diff)
Switch away from using the sfx2 link manager for data stream.
Change-Id: I05ac5a8151135ace7f4e351cfedab0170c8d9a57
Diffstat (limited to 'sc/source/ui')
-rw-r--r--sc/source/ui/docshell/datastream.cxx88
-rw-r--r--sc/source/ui/docshell/documentlinkmgr.cxx44
-rw-r--r--sc/source/ui/inc/datastream.hxx11
-rw-r--r--sc/source/ui/view/cellsh2.cxx52
4 files changed, 73 insertions, 122 deletions
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;