summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@collabora.com>2013-11-21 15:23:09 +0100
committerMatúš Kukan <matus.kukan@collabora.com>2013-12-02 11:13:42 +0100
commit8f8013abc9182ce940d8c1aa359d62215f82f9cc (patch)
treea2d46a9389bd014a14acf13d9b81c0d50b673168 /sc
parent9623ae14ab8b1e0381ebae7b9c1d07235ae85c91 (diff)
Rework data streams to be more like file links (ScAreaLink).
By inheriting from sfx2::SvBaseLink and storing in sfx2::LinkManager we can have more data streams and see / remove them in Edit -> Links... dialog. Also rename to DataStream to avoid confusion. Change-Id: I9c3b89020324af7be082f9e6e1cd479aeb72fe81
Diffstat (limited to 'sc')
-rw-r--r--sc/Library_sc.mk4
-rw-r--r--sc/source/ui/docshell/datastream.cxx (renamed from sc/source/ui/miscdlgs/datastreams.cxx)155
-rw-r--r--sc/source/ui/inc/cellsh.hxx3
-rw-r--r--sc/source/ui/inc/datastream.hxx (renamed from sc/source/ui/inc/datastreams.hxx)24
-rw-r--r--sc/source/ui/inc/datastreamdlg.hxx49
-rw-r--r--sc/source/ui/miscdlgs/datastreamdlg.cxx98
-rw-r--r--sc/source/ui/miscdlgs/datastreamsdlg.cxx135
-rw-r--r--sc/source/ui/view/cellsh.cxx2
-rw-r--r--sc/source/ui/view/cellsh2.cxx36
-rw-r--r--sc/uiconfig/scalc/ui/datastreams.ui2
10 files changed, 285 insertions, 223 deletions
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index aa7099c8ab63..fe2ddf89580e 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -385,6 +385,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/ui/dialogs/searchresults \
sc/source/ui/docshell/arealink \
sc/source/ui/docshell/autostyl \
+ sc/source/ui/docshell/datastream \
sc/source/ui/docshell/dbdocfun \
sc/source/ui/docshell/dbdocimp \
sc/source/ui/docshell/docfunc \
@@ -443,8 +444,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/ui/miscdlgs/autofmt \
sc/source/ui/miscdlgs/conflictsdlg \
sc/source/ui/miscdlgs/crnrdlg \
- sc/source/ui/miscdlgs/datastreams \
- sc/source/ui/miscdlgs/datastreamsdlg \
+ sc/source/ui/miscdlgs/datastreamdlg \
sc/source/ui/miscdlgs/highred \
sc/source/ui/miscdlgs/optsolver \
sc/source/ui/miscdlgs/protectiondlg \
diff --git a/sc/source/ui/miscdlgs/datastreams.cxx b/sc/source/ui/docshell/datastream.cxx
index 59d3b39d6099..d58c72c29b51 100644
--- a/sc/source/ui/miscdlgs/datastreams.cxx
+++ b/sc/source/ui/docshell/datastream.cxx
@@ -7,13 +7,14 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include <datastreams.hxx>
+#include <datastream.hxx>
#include <com/sun/star/frame/XLayoutManager.hpp>
#include <com/sun/star/ui/XUIElement.hpp>
#include <osl/conditn.hxx>
#include <rtl/strbuf.hxx>
#include <salhelper/thread.hxx>
+#include <sfx2/linkmgr.hxx>
#include <sfx2/viewfrm.hxx>
#include <asciiopt.hxx>
#include <dbfunc.hxx>
@@ -30,14 +31,14 @@ namespace datastreams {
class CallerThread : public salhelper::Thread
{
- DataStreams *mpDataStreams;
+ DataStream *mpDataStream;
public:
osl::Condition maStart;
bool mbTerminate;
- CallerThread(DataStreams *pData):
+ CallerThread(DataStream *pData):
Thread("CallerThread")
- ,mpDataStreams(pData)
+ ,mpDataStream(pData)
,mbTerminate(false)
{}
@@ -53,7 +54,7 @@ private:
maStart.wait();
maStart.reset();
if (!mbTerminate)
- while (mpDataStreams->ImportData())
+ while (mpDataStream->ImportData())
wait(aTime);
};
}
@@ -137,19 +138,68 @@ private:
}
-DataStreams::DataStreams(ScDocShell *pScDocShell):
- mpScDocShell(pScDocShell)
+static void lcl_MakeToolbarVisible(SfxViewFrame *pViewFrame)
+{
+ css::uno::Reference< css::frame::XFrame > xFrame =
+ pViewFrame->GetFrame().GetFrameInterface();
+ if (!xFrame.is())
+ return;
+
+ css::uno::Reference< css::beans::XPropertySet > xPropSet(xFrame, css::uno::UNO_QUERY);
+ if (!xPropSet.is())
+ return;
+
+ css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
+ xPropSet->getPropertyValue("LayoutManager") >>= xLayoutManager;
+ if (!xLayoutManager.is())
+ return;
+
+ const OUString sResourceURL( "private:resource/toolbar/datastreams" );
+ css::uno::Reference< css::ui::XUIElement > xUIElement = xLayoutManager->getElement(sResourceURL);
+ if (!xUIElement.is())
+ {
+ xLayoutManager->createElement( sResourceURL );
+ xLayoutManager->showElement( sResourceURL );
+ }
+}
+
+void DataStream::Set(ScDocShell *pShell, const OUString& rURL, const OUString& rRange, sal_Int32 nLimit, const OUString& rMove)
+{
+ sfx2::SvBaseLink *pLink = 0;
+ pLink = new DataStream( pShell, rURL, rRange, nLimit, rMove );
+ sfx2::LinkManager* pLinkManager = pShell->GetDocument()->GetLinkManager();
+ pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, rURL, NULL, NULL );
+
+ lcl_MakeToolbarVisible(pShell->GetViewData()->GetViewShell()->GetViewFrame());
+}
+
+DataStream::DataStream(ScDocShell *pShell, const OUString& rURL,
+ const OUString& rRange, sal_Int32 nLimit, const OUString& rMove)
+ : mpScDocShell(pShell)
, mpScDocument(mpScDocShell->GetDocument())
, meMove(NO_MOVE)
, mbRunning(false)
, mpLines(0)
, mnLinesCount(0)
+ , mpRange(new ScRange())
+ , mpEndRange(NULL)
{
mxThread = new datastreams::CallerThread( this );
mxThread->launch();
+
+ Decode(rURL, rRange, rMove);
+
+ mpStartRange.reset( new ScRange(*mpRange.get()) );
+ sal_Int32 nHeight = mpRange->aEnd.Row() - mpRange->aStart.Row() + 1;
+ nLimit = nHeight * (nLimit / nHeight);
+ if (nLimit && mpRange->aStart.Row() + nLimit - 1 < MAXROW)
+ {
+ mpEndRange.reset( new ScRange(*mpRange) );
+ mpEndRange->Move(0, nLimit - nHeight, 0);
+ }
}
-DataStreams::~DataStreams()
+DataStream::~DataStream()
{
if (mbRunning)
Stop();
@@ -160,7 +210,7 @@ DataStreams::~DataStreams()
mxReaderThread->endThread();
}
-OString DataStreams::ConsumeLine()
+OString DataStream::ConsumeLine()
{
if (!mpLines || mnLinesCount >= mpLines->size())
{
@@ -183,7 +233,32 @@ OString DataStreams::ConsumeLine()
return mpLines->at(mnLinesCount++);
}
-void DataStreams::Start()
+void DataStream::Decode( const OUString& rURL, const OUString& rRange, const OUString& rMove)
+{
+ sal_Int32 nIndex = rURL.indexOf(sfx2::cTokenSeparator);
+ SvStream *pStream = 0;
+ if (nIndex != -1)
+ pStream = new SvScriptStream(rURL.copy(0, nIndex));
+ else
+ pStream = new SvFileStream(rURL, STREAM_READ);
+ mxReaderThread = new datastreams::ReaderThread( pStream );
+ mxReaderThread->launch();
+
+ mbValuesInLine = !rRange.isEmpty();
+ if (!mbValuesInLine)
+ return;
+
+ mpRange->Parse(rRange, mpScDocument);
+
+ if (rMove == "NO_MOVE")
+ meMove = NO_MOVE;
+ else if (rMove == "RANGE_DOWN")
+ meMove = RANGE_DOWN;
+ else if (rMove == "MOVE_DOWN")
+ meMove = MOVE_DOWN;
+}
+
+void DataStream::Start()
{
if (mbRunning)
return;
@@ -191,30 +266,9 @@ void DataStreams::Start()
mpScDocument->EnableUndo(false);
mbRunning = true;
mxThread->maStart.set();
- css::uno::Reference< css::frame::XFrame > xFrame =
- mpScDocShell->GetViewData()->GetViewShell()->GetViewFrame()->GetFrame().GetFrameInterface();
- if (!xFrame.is())
- return;
-
- css::uno::Reference< css::beans::XPropertySet > xPropSet(xFrame, css::uno::UNO_QUERY);
- if (!xPropSet.is())
- return;
-
- css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
- xPropSet->getPropertyValue("LayoutManager") >>= xLayoutManager;
- if (!xLayoutManager.is())
- return;
-
- const OUString sResourceURL( "private:resource/toolbar/datastreams" );
- css::uno::Reference< css::ui::XUIElement > xUIElement = xLayoutManager->getElement(sResourceURL);
- if (!xUIElement.is())
- {
- xLayoutManager->createElement( sResourceURL );
- xLayoutManager->showElement( sResourceURL );
- }
}
-void DataStreams::Stop()
+void DataStream::Stop()
{
if (!mbRunning)
return;
@@ -222,36 +276,7 @@ void DataStreams::Stop()
mpScDocument->EnableUndo(mbIsUndoEnabled);
}
-void DataStreams::Set(SvStream *pStream, bool bValuesInLine,
- const OUString& rRange, sal_Int32 nLimit, MoveEnum eMove)
-{
- if (mxReaderThread.is())
- mxReaderThread->endThread();
- mxReaderThread = new datastreams::ReaderThread( pStream );
- mxReaderThread->launch();
-
- mpEndRange.reset( NULL );
- mpRange.reset ( new ScRange() );
- mbValuesInLine = bValuesInLine;
- if (!mbValuesInLine)
- {
- meMove = NO_MOVE;
- return;
- }
-
- mpRange->Parse(rRange, mpScDocument);
- mpStartRange.reset( new ScRange(*mpRange.get()) );
- meMove = eMove;
- sal_Int32 nHeight = mpRange->aEnd.Row() - mpRange->aStart.Row() + 1;
- nLimit = nHeight * (nLimit / nHeight);
- if (nLimit && mpRange->aStart.Row() + nLimit - 1 < MAXROW)
- {
- mpEndRange.reset( new ScRange(*mpRange) );
- mpEndRange->Move(0, nLimit - nHeight, 0);
- }
-}
-
-void DataStreams::MoveData()
+void DataStream::MoveData()
{
switch (meMove)
{
@@ -273,7 +298,7 @@ void DataStreams::MoveData()
}
}
-bool DataStreams::ImportData()
+bool DataStream::ImportData()
{
SolarMutexGuard aGuard;
MoveData();
@@ -336,4 +361,8 @@ bool DataStreams::ImportData()
return mbRunning;
}
+void DataStream::Edit(Window* , const Link& )
+{
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/cellsh.hxx b/sc/source/ui/inc/cellsh.hxx
index d7be8ac993d7..b44eb9f25904 100644
--- a/sc/source/ui/inc/cellsh.hxx
+++ b/sc/source/ui/inc/cellsh.hxx
@@ -33,19 +33,16 @@ class SvxClipboardFmtItem;
class TransferableDataHelper;
class TransferableClipboardListener;
class AbstractScLinkedAreaDlg;
-class DataStreams;
struct CellShell_Impl
{
TransferableClipboardListener* m_pClipEvtLstnr;
AbstractScLinkedAreaDlg* m_pLinkedDlg;
- DataStreams* m_pDataStreams;
SfxRequest* m_pRequest;
CellShell_Impl() :
m_pClipEvtLstnr( NULL ),
m_pLinkedDlg( NULL ),
- m_pDataStreams( NULL ),
m_pRequest( NULL ) {}
};
diff --git a/sc/source/ui/inc/datastreams.hxx b/sc/source/ui/inc/datastream.hxx
index 93d157483b23..12d784f4a269 100644
--- a/sc/source/ui/inc/datastreams.hxx
+++ b/sc/source/ui/inc/datastream.hxx
@@ -11,6 +11,7 @@
#include <rtl/ref.hxx>
#include <rtl/ustring.hxx>
+#include <sfx2/lnkbase.hxx>
#include <boost/noncopyable.hpp>
#include <boost/scoped_ptr.hpp>
@@ -23,23 +24,28 @@ namespace datastreams {
class ScDocShell;
class ScDocument;
class ScRange;
-class SvStream;
class Window;
typedef std::vector<OString> LinesList;
-class DataStreams : boost::noncopyable
+class DataStream : boost::noncopyable, public sfx2::SvBaseLink
{
+ OString ConsumeLine();
+ void Decode(const OUString& rURL, const OUString& rRange, const OUString& rMove);
+ void MoveData();
+
public:
enum MoveEnum { NO_MOVE, RANGE_DOWN, MOVE_DOWN, MOVE_UP };
- DataStreams(ScDocShell *pScDocShell);
- ~DataStreams();
- OString ConsumeLine();
+
+ static void Set(ScDocShell *pShell, const OUString& rURL,
+ const OUString& rRange, sal_Int32 nLimit, const OUString& rMove);
+
+ DataStream(ScDocShell *pShell, const OUString& rURL,
+ const OUString& rRange, sal_Int32 nLimit, const OUString& rMove);
+ virtual ~DataStream();
+ virtual void Edit(Window* , const Link& ) SAL_OVERRIDE;
+
bool ImportData();
- void MoveData();
- void Set(SvStream *pStream, bool bValuesInLine,
- const OUString& rRange, sal_Int32 nLimit, MoveEnum eMove);
- void ShowDialog(Window *pParent);
void Start();
void Stop();
diff --git a/sc/source/ui/inc/datastreamdlg.hxx b/sc/source/ui/inc/datastreamdlg.hxx
new file mode 100644
index 000000000000..cb469d78600c
--- /dev/null
+++ b/sc/source/ui/inc/datastreamdlg.hxx
@@ -0,0 +1,49 @@
+/* -*- 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 <sal/config.h>
+
+#include <rtl/ref.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/layout.hxx>
+
+class ScDocShell;
+class SvtURLBox;
+
+class DataStreamDlg : public ModalDialog
+{
+ ScDocShell *mpDocShell;
+
+ SvtURLBox* m_pCbUrl;
+ PushButton* m_pBtnBrowse;
+ RadioButton* m_pRBScriptData;
+ RadioButton* m_pRBValuesInLine;
+ RadioButton* m_pRBAddressValue;
+ RadioButton* m_pRBRangeDown;
+ RadioButton* m_pRBNoMove;
+ RadioButton* m_pRBMaxLimit;
+ Edit* m_pEdRange;
+ Edit* m_pEdLimit;
+ OKButton* m_pBtnOk;
+ VclFrame* m_pVclFrameLimit;
+ VclFrame* m_pVclFrameMove;
+ VclFrame* m_pVclFrameRange;
+
+ DECL_LINK(UpdateHdl, void *);
+ DECL_LINK(BrowseHdl, void *);
+
+ void UpdateEnable();
+
+public:
+ DataStreamDlg(ScDocShell *pDocShell, Window* pParent);
+ ~DataStreamDlg() {}
+ void StartStream();
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/datastreamdlg.cxx b/sc/source/ui/miscdlgs/datastreamdlg.cxx
new file mode 100644
index 000000000000..cd2d2c4f5666
--- /dev/null
+++ b/sc/source/ui/miscdlgs/datastreamdlg.cxx
@@ -0,0 +1,98 @@
+/* -*- 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 <datastreamdlg.hxx>
+
+#include <sfx2/filedlghelper.hxx>
+#include <sfx2/linkmgr.hxx>
+#include <svtools/inettbc.hxx>
+#include <vcl/layout.hxx>
+#include <datastream.hxx>
+
+DataStreamDlg::DataStreamDlg(ScDocShell *pDocShell, Window* pParent)
+ : ModalDialog(pParent, "DataStreamDialog", "modules/scalc/ui/datastreams.ui")
+ , mpDocShell(pDocShell)
+{
+ get(m_pCbUrl, "url");
+ get(m_pBtnBrowse, "browse");
+ get(m_pRBScriptData, "scriptdata");
+ get(m_pRBValuesInLine, "valuesinline");
+ get(m_pRBAddressValue, "addressvalue");
+ get(m_pRBRangeDown, "rangedown");
+ get(m_pRBNoMove, "nomove");
+ get(m_pRBMaxLimit, "maxlimit");
+ get(m_pEdRange, "range");
+ get(m_pEdLimit, "limit");
+ get(m_pBtnOk, "ok");
+ get(m_pVclFrameLimit, "framelimit");
+ get(m_pVclFrameMove, "framemove");
+ get(m_pVclFrameRange, "framerange");
+
+ m_pCbUrl->SetSelectHdl( LINK( this, DataStreamDlg, UpdateHdl ) );
+ m_pRBAddressValue->SetClickHdl( LINK( this, DataStreamDlg, UpdateHdl ) );
+ m_pRBValuesInLine->SetClickHdl( LINK( this, DataStreamDlg, UpdateHdl ) );
+ m_pEdRange->SetModifyHdl( LINK( this, DataStreamDlg, UpdateHdl ) );
+ m_pBtnBrowse->SetClickHdl( LINK( this, DataStreamDlg, BrowseHdl ) );
+ UpdateEnable();
+}
+
+IMPL_LINK_NOARG(DataStreamDlg, BrowseHdl)
+{
+ sfx2::FileDialogHelper aFileDialog(0, 0);
+ if ( aFileDialog.Execute() != ERRCODE_NONE )
+ return 0;
+
+ m_pCbUrl->SetText( aFileDialog.GetPath() );
+ UpdateEnable();
+ return 0;
+}
+
+IMPL_LINK_NOARG(DataStreamDlg, UpdateHdl)
+{
+ UpdateEnable();
+ return 0;
+}
+
+void DataStreamDlg::UpdateEnable()
+{
+ bool bOk = !m_pCbUrl->GetURL().isEmpty();
+ if (m_pRBAddressValue->IsChecked())
+ {
+ m_pVclFrameLimit->Hide();
+ m_pVclFrameMove->Hide();
+ m_pVclFrameRange->Hide();
+ }
+ else
+ {
+ m_pVclFrameLimit->Show(true);
+ m_pVclFrameMove->Show();
+ m_pVclFrameRange->Show();
+ bOk = bOk && !m_pEdRange->GetText().isEmpty();
+ }
+ m_pBtnOk->Enable(bOk);
+}
+
+void DataStreamDlg::StartStream()
+{
+ sal_Int32 nLimit = 0;
+ if (m_pRBMaxLimit->IsChecked())
+ nLimit = m_pEdLimit->GetText().toInt32();
+ OUString rURL = m_pCbUrl->GetText();
+ if (m_pRBScriptData->IsChecked())
+ rURL += OUString(sfx2::cTokenSeparator);
+ DataStream::Set( mpDocShell,
+ rURL,
+ m_pEdRange->GetText(),
+ nLimit,
+ m_pRBNoMove->IsChecked() ? OUString("NO_MOVE") : m_pRBRangeDown->IsChecked()
+ ? OUString("RANGE_DOWN") : OUString("MOVE_DOWN")
+ );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/datastreamsdlg.cxx b/sc/source/ui/miscdlgs/datastreamsdlg.cxx
deleted file mode 100644
index bacb67aeedd6..000000000000
--- a/sc/source/ui/miscdlgs/datastreamsdlg.cxx
+++ /dev/null
@@ -1,135 +0,0 @@
-/* -*- 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 <sfx2/filedlghelper.hxx>
-#include <svtools/inettbc.hxx>
-#include <vcl/dialog.hxx>
-#include <vcl/layout.hxx>
-#include <datastreams.hxx>
-
-namespace {
-
-class DataStreamsDlg : public ModalDialog
-{
- DataStreams *mpDataStreams;
-
- SvtURLBox* m_pCbUrl;
- PushButton* m_pBtnBrowse;
- RadioButton* m_pRBScriptData;
- RadioButton* m_pRBValuesInLine;
- RadioButton* m_pRBAddressValue;
- RadioButton* m_pRBRangeDown;
- RadioButton* m_pRBNoMove;
- RadioButton* m_pRBMaxLimit;
- Edit* m_pEdRange;
- Edit* m_pEdLimit;
- OKButton* m_pBtnOk;
- VclFrame* m_pVclFrameLimit;
- VclFrame* m_pVclFrameMove;
- VclFrame* m_pVclFrameRange;
-
- DECL_LINK(UpdateHdl, void *);
- DECL_LINK(BrowseHdl, void *);
-
- void UpdateEnable();
-
-public:
- DataStreamsDlg(DataStreams *pDataStreams, Window* pParent);
- ~DataStreamsDlg() {}
- void Start();
-};
-
-DataStreamsDlg::DataStreamsDlg(DataStreams *pDataStreams, Window* pParent)
- : ModalDialog(pParent, "DataStreamsDialog", "modules/scalc/ui/datastreams.ui")
- , mpDataStreams(pDataStreams)
-{
- get(m_pCbUrl, "url");
- get(m_pBtnBrowse, "browse");
- get(m_pRBScriptData, "scriptdata");
- get(m_pRBValuesInLine, "valuesinline");
- get(m_pRBAddressValue, "addressvalue");
- get(m_pRBRangeDown, "rangedown");
- get(m_pRBNoMove, "nomove");
- get(m_pRBMaxLimit, "maxlimit");
- get(m_pEdRange, "range");
- get(m_pEdLimit, "limit");
- get(m_pBtnOk, "ok");
- get(m_pVclFrameLimit, "framelimit");
- get(m_pVclFrameMove, "framemove");
- get(m_pVclFrameRange, "framerange");
-
- m_pCbUrl->SetSelectHdl( LINK( this, DataStreamsDlg, UpdateHdl ) );
- m_pRBAddressValue->SetClickHdl( LINK( this, DataStreamsDlg, UpdateHdl ) );
- m_pRBValuesInLine->SetClickHdl( LINK( this, DataStreamsDlg, UpdateHdl ) );
- m_pEdRange->SetModifyHdl( LINK( this, DataStreamsDlg, UpdateHdl ) );
- m_pBtnBrowse->SetClickHdl( LINK( this, DataStreamsDlg, BrowseHdl ) );
- UpdateEnable();
-}
-
-void DataStreamsDlg::Start()
-{
- sal_Int32 nLimit = 0;
- if (m_pRBMaxLimit->IsChecked())
- nLimit = m_pEdLimit->GetText().toInt32();
- mpDataStreams->Set(
- (m_pRBScriptData->IsChecked() ?
- dynamic_cast<SvStream*>( new SvScriptStream(m_pCbUrl->GetText()) ) :
- dynamic_cast<SvStream*>( new SvFileStream(m_pCbUrl->GetText(), STREAM_READ) )),
- m_pRBValuesInLine->IsChecked(),
- m_pEdRange->GetText(), nLimit, (m_pRBNoMove->IsChecked() ? DataStreams::NO_MOVE :
- m_pRBRangeDown->IsChecked() ? DataStreams::RANGE_DOWN : DataStreams::MOVE_DOWN) );
- mpDataStreams->Start();
-}
-
-IMPL_LINK_NOARG(DataStreamsDlg, BrowseHdl)
-{
- sfx2::FileDialogHelper aFileDialog(0, 0);
- if ( aFileDialog.Execute() != ERRCODE_NONE )
- return 0;
-
- m_pCbUrl->SetText( aFileDialog.GetPath() );
- UpdateEnable();
- return 0;
-}
-
-IMPL_LINK_NOARG(DataStreamsDlg, UpdateHdl)
-{
- UpdateEnable();
- return 0;
-}
-
-void DataStreamsDlg::UpdateEnable()
-{
- bool bOk = !m_pCbUrl->GetURL().isEmpty();
- if (m_pRBAddressValue->IsChecked())
- {
- m_pVclFrameLimit->Hide();
- m_pVclFrameMove->Hide();
- m_pVclFrameRange->Hide();
- }
- else
- {
- m_pVclFrameLimit->Show(true);
- m_pVclFrameMove->Show();
- m_pVclFrameRange->Show();
- bOk = bOk && !m_pEdRange->GetText().isEmpty();
- }
- m_pBtnOk->Enable(bOk);
-}
-
-}
-
-void DataStreams::ShowDialog(Window *pParent)
-{
- DataStreamsDlg aDialog(this, pParent);
- if (aDialog.Execute() == RET_OK)
- aDialog.Start();
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx
index ec69f05a0c3a..cf9d13b8c313 100644
--- a/sc/source/ui/view/cellsh.cxx
+++ b/sc/source/ui/view/cellsh.cxx
@@ -55,7 +55,6 @@
#include "postit.hxx"
#include "cliputil.hxx"
#include "clipparam.hxx"
-#include "datastreams.hxx"
#include "markdata.hxx"
//------------------------------------------------------------------
@@ -99,7 +98,6 @@ ScCellShell::~ScCellShell()
}
delete pImpl->m_pLinkedDlg;
- delete pImpl->m_pDataStreams;
delete pImpl->m_pRequest;
delete pImpl;
}
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index 4450bd9437f7..aceb41cea89b 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -20,6 +20,7 @@
#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>
@@ -56,7 +57,8 @@
#include "scabstdlg.hxx"
#include "impex.hxx"
#include "asciiopt.hxx"
-#include "datastreams.hxx"
+#include "datastream.hxx"
+#include "datastreamdlg.hxx"
#include "queryentry.hxx"
#include "markdata.hxx"
@@ -734,17 +736,35 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
}
break;
case SID_DATA_STREAMS:
- if (!pImpl->m_pDataStreams)
- pImpl->m_pDataStreams = new DataStreams(GetViewData()->GetDocShell());
- pImpl->m_pDataStreams->ShowDialog( pTabViewShell->GetDialogParent() );
+ {
+ DataStreamDlg aDialog( GetViewData()->GetDocShell(), pTabViewShell->GetDialogParent() );
+ if (aDialog.Execute() == RET_OK)
+ aDialog.StartStream();
+ }
break;
case SID_DATA_STREAMS_PLAY:
- if (pImpl->m_pDataStreams)
- pImpl->m_pDataStreams->Start();
+ {
+ ScDocument *pDoc = GetViewData()->GetDocument();
+ if (pDoc->GetLinkManager())
+ {
+ const sfx2::SvBaseLinks& rLinks = pDoc->GetLinkManager()->GetLinks();
+ for (size_t i = 0; i < rLinks.size(); i++)
+ if (DataStream *pStream = dynamic_cast<DataStream*>(&(*(*rLinks[i]))))
+ pStream->Start();
+ }
+ }
break;
case SID_DATA_STREAMS_STOP:
- if (pImpl->m_pDataStreams)
- pImpl->m_pDataStreams->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 (DataStream *pStream = dynamic_cast<DataStream*>(&(*(*rLinks[i]))))
+ pStream->Stop();
+ }
+ }
break;
case SID_MANAGE_XML_SOURCE:
ExecuteXMLSourceDialog();
diff --git a/sc/uiconfig/scalc/ui/datastreams.ui b/sc/uiconfig/scalc/ui/datastreams.ui
index 853840aa1fd9..fc2dcea68a90 100644
--- a/sc/uiconfig/scalc/ui/datastreams.ui
+++ b/sc/uiconfig/scalc/ui/datastreams.ui
@@ -2,7 +2,7 @@
<interface>
<!-- interface-requires gtk+ 3.0 -->
<!-- interface-requires LibreOffice 1.0 -->
- <object class="GtkDialog" id="DataStreamsDialog">
+ <object class="GtkDialog" id="DataStreamDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes">Live Data Streams</property>