summaryrefslogtreecommitdiff
path: root/sc/source/ui/miscdlgs/datastreamsdlg.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/ui/miscdlgs/datastreamsdlg.cxx')
-rw-r--r--sc/source/ui/miscdlgs/datastreamsdlg.cxx123
1 files changed, 123 insertions, 0 deletions
diff --git a/sc/source/ui/miscdlgs/datastreamsdlg.cxx b/sc/source/ui/miscdlgs/datastreamsdlg.cxx
new file mode 100644
index 000000000000..b2f5d275bd80
--- /dev/null
+++ b/sc/source/ui/miscdlgs/datastreamsdlg.cxx
@@ -0,0 +1,123 @@
+/* -*- 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 <datastreams.hxx>
+
+namespace {
+
+class DataStreamsDlg : public ModalDialog
+{
+ DataStreams *mpDataStreams;
+
+ SvtURLBox* m_pCbUrl;
+ PushButton* m_pBtnBrowse;
+ PushButton* m_pBtnStop;
+ RadioButton* m_pRBDirectData;
+ RadioButton* m_pRBScriptData;
+ RadioButton* m_pRBDataDown;
+ RadioButton* m_pRBRangeDown;
+ RadioButton* m_pRBNoMove;
+ RadioButton* m_pRBMaxLimit;
+ RadioButton* m_pRBUnlimited;
+ Edit* m_pEdRange;
+ Edit* m_pEdLimit;
+ OKButton* m_pBtnOk;
+
+ DECL_LINK(UpdateHdl, void *);
+ DECL_LINK(BrowseHdl, void *);
+ DECL_LINK(StopHdl, 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_pBtnStop, "stop");
+ get(m_pRBDirectData, "directdata");
+ get(m_pRBScriptData, "scriptdata");
+ get(m_pRBDataDown, "datadown");
+ get(m_pRBRangeDown, "rangedown");
+ get(m_pRBNoMove, "nomove");
+ get(m_pRBMaxLimit, "maxlimit");
+ get(m_pRBUnlimited, "unlimited");
+ get(m_pEdRange, "range");
+ get(m_pEdLimit, "limit");
+ get(m_pBtnOk, "ok");
+
+ m_pCbUrl->SetSelectHdl( LINK( this, DataStreamsDlg, UpdateHdl ) );
+ m_pEdRange->SetModifyHdl( LINK( this, DataStreamsDlg, UpdateHdl ) );
+ m_pBtnBrowse->SetClickHdl( LINK( this, DataStreamsDlg, BrowseHdl ) );
+ m_pBtnStop->SetClickHdl( LINK( this, DataStreamsDlg, StopHdl ) );
+ UpdateEnable();
+}
+
+void DataStreamsDlg::Start()
+{
+ bool bIsScript = m_pRBScriptData->IsChecked();
+ sal_Int32 nLimit = 0;
+ if (m_pRBMaxLimit->IsChecked())
+ nLimit = m_pEdLimit->GetText().toInt32();
+ mpDataStreams->Set(m_pCbUrl->GetText(), bIsScript, 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, StopHdl)
+{
+ mpDataStreams->Stop();
+ return 0;
+}
+
+IMPL_LINK_NOARG(DataStreamsDlg, UpdateHdl)
+{
+ UpdateEnable();
+ return 0;
+}
+
+void DataStreamsDlg::UpdateEnable()
+{
+ bool bOk = !m_pEdRange->GetText().isEmpty();
+ bOk = bOk && !m_pCbUrl->GetURL().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: */