diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2013-11-25 12:01:57 +0100 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2013-11-28 20:40:38 +0100 |
commit | 6ce9618ef9ebe58bc6f3ced34c465bbeb5df5b23 (patch) | |
tree | 036c9759a3cc515059273b33181cd2290f2d4414 /sc | |
parent | fa0fe19e89ba68a6b02cbdd5eff6bc161024c53d (diff) |
Allow to edit data stream from Edit-> Links... dialog.
Change-Id: Ibb456da55f04c39ddb7b58eb71ca488cf209edb5
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/docshell/datastream.cxx | 40 | ||||
-rw-r--r-- | sc/source/ui/inc/datastream.hxx | 4 | ||||
-rw-r--r-- | sc/source/ui/inc/datastreamdlg.hxx | 6 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/datastreamdlg.cxx | 36 |
4 files changed, 65 insertions, 21 deletions
diff --git a/sc/source/ui/docshell/datastream.cxx b/sc/source/ui/docshell/datastream.cxx index aef6c3b0794b..ff095f5e6090 100644 --- a/sc/source/ui/docshell/datastream.cxx +++ b/sc/source/ui/docshell/datastream.cxx @@ -18,6 +18,7 @@ #include <sfx2/viewfrm.hxx> #include <arealink.hxx> #include <asciiopt.hxx> +#include <datastreamdlg.hxx> #include <dbfunc.hxx> #include <docsh.hxx> #include <documentimport.hxx> @@ -217,21 +218,11 @@ DataStream::DataStream(ScDocShell *pShell, const OUString& rURL, const OUString& , mbRunning(false) , mpLines(0) , mnLinesCount(0) - , mpEndRange(NULL) { mxThread = new datastreams::CallerThread( this ); mxThread->launch(); Decode(rURL, rRange, nLimit, rMove, nSettings); - - maStartRange = maRange; - sal_Int32 nHeight = maRange.aEnd.Row() - maRange.aStart.Row() + 1; - nLimit = nHeight * (nLimit / nHeight); - if (nLimit && maRange.aStart.Row() + nLimit - 1 < MAXROW) - { - mpEndRange.reset( new ScRange(maRange) ); - mpEndRange->Move(0, nLimit - nHeight, 0); - } } DataStream::~DataStream() @@ -271,14 +262,15 @@ OString DataStream::ConsumeLine() } void DataStream::Decode(const OUString& rURL, const OUString& rRange, - const sal_Int32 nLimit, const OUString& rMove, const sal_uInt32 nSettings) + sal_Int32 nLimit, const OUString& rMove, const sal_uInt32 nSettings) { msURL = rURL; msRange = rRange; mnLimit = nLimit; msMove = rMove; mnSettings = nSettings; - maRange.Parse(msRange); + mpEndRange.reset( NULL ); + SvStream *pStream = 0; if (mnSettings & SCRIPT_STREAM) pStream = new SvScriptStream(msURL); @@ -288,8 +280,6 @@ void DataStream::Decode(const OUString& rURL, const OUString& rRange, mxReaderThread->launch(); mbValuesInLine = mnSettings & VALUES_IN_LINE; - if (!mbValuesInLine) - return; if (msMove == "NO_MOVE") meMove = NO_MOVE; @@ -297,6 +287,16 @@ void DataStream::Decode(const OUString& rURL, const OUString& rRange, meMove = RANGE_DOWN; else if (msMove == "MOVE_DOWN") meMove = MOVE_DOWN; + + maRange.Parse(msRange); + maStartRange = maRange; + sal_Int32 nHeight = maRange.aEnd.Row() - maRange.aStart.Row() + 1; + nLimit = nHeight * (nLimit / nHeight); + if (nLimit && maRange.aStart.Row() + nLimit - 1 < MAXROW) + { + mpEndRange.reset( new ScRange(maRange) ); + mpEndRange->Move(0, nLimit - nHeight, 0); + } } void DataStream::Start() @@ -410,8 +410,18 @@ sfx2::SvBaseLink::UpdateResult DataStream::DataChanged( return SUCCESS; } -void DataStream::Edit(Window* , const Link& ) +void DataStream::Edit(Window* pWindow, const Link& ) { + DataStreamDlg aDialog(mpScDocShell, pWindow); + aDialog.Init(msURL, msRange, mnLimit, msMove, mnSettings); + if (aDialog.Execute() == RET_OK) + { + bool bWasRunning = mbRunning; + Stop(); + aDialog.StartStream(this); + if (bWasRunning) + Start(); + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/datastream.hxx b/sc/source/ui/inc/datastream.hxx index b60a988f527e..91dda2e931d5 100644 --- a/sc/source/ui/inc/datastream.hxx +++ b/sc/source/ui/inc/datastream.hxx @@ -31,8 +31,6 @@ typedef std::vector<OString> LinesList; class DataStream : boost::noncopyable, public sfx2::SvBaseLink { OString ConsumeLine(); - void Decode(const OUString& rURL, const OUString& rRange, const sal_Int32 nLimit, - const OUString& rMove, const sal_uInt32 nSettings); void MoveData(); public: @@ -55,6 +53,8 @@ public: const sal_Int32& GetLimit() const { return mnLimit; } const OUString& GetMove() const { return msMove; } const sal_uInt32& GetSettings() const { return mnSettings; } + void Decode(const OUString& rURL, const OUString& rRange, sal_Int32 nLimit, + const OUString& rMove, const sal_uInt32 nSettings); bool ImportData(); void Start(); void Stop(); diff --git a/sc/source/ui/inc/datastreamdlg.hxx b/sc/source/ui/inc/datastreamdlg.hxx index cb469d78600c..5bb05f31df5b 100644 --- a/sc/source/ui/inc/datastreamdlg.hxx +++ b/sc/source/ui/inc/datastreamdlg.hxx @@ -13,6 +13,7 @@ #include <vcl/dialog.hxx> #include <vcl/layout.hxx> +class DataStream; class ScDocShell; class SvtURLBox; @@ -25,6 +26,7 @@ class DataStreamDlg : public ModalDialog RadioButton* m_pRBScriptData; RadioButton* m_pRBValuesInLine; RadioButton* m_pRBAddressValue; + RadioButton* m_pRBDataDown; RadioButton* m_pRBRangeDown; RadioButton* m_pRBNoMove; RadioButton* m_pRBMaxLimit; @@ -43,7 +45,9 @@ class DataStreamDlg : public ModalDialog public: DataStreamDlg(ScDocShell *pDocShell, Window* pParent); ~DataStreamDlg() {} - void StartStream(); + void Init(const OUString& rURL, const OUString& rRange, const sal_Int32 nLimit, + const OUString& rMove, const sal_uInt32 nSettings); + void StartStream(DataStream *pStream = 0); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/miscdlgs/datastreamdlg.cxx b/sc/source/ui/miscdlgs/datastreamdlg.cxx index b2666877e356..e56cc039e544 100644 --- a/sc/source/ui/miscdlgs/datastreamdlg.cxx +++ b/sc/source/ui/miscdlgs/datastreamdlg.cxx @@ -23,6 +23,7 @@ DataStreamDlg::DataStreamDlg(ScDocShell *pDocShell, Window* pParent) get(m_pRBScriptData, "scriptdata"); get(m_pRBValuesInLine, "valuesinline"); get(m_pRBAddressValue, "addressvalue"); + get(m_pRBDataDown, "datadown"); get(m_pRBRangeDown, "rangedown"); get(m_pRBNoMove, "nomove"); get(m_pRBMaxLimit, "maxlimit"); @@ -63,6 +64,7 @@ void DataStreamDlg::UpdateEnable() bool bOk = !m_pCbUrl->GetURL().isEmpty(); if (m_pRBAddressValue->IsChecked()) { + m_pRBNoMove->Check(); m_pVclFrameLimit->Hide(); m_pVclFrameMove->Hide(); m_pVclFrameRange->Hide(); @@ -70,15 +72,35 @@ void DataStreamDlg::UpdateEnable() } else { - m_pVclFrameLimit->Show(true); + m_pVclFrameLimit->Show(); m_pVclFrameMove->Show(); m_pVclFrameRange->Show(); bOk = bOk && !m_pEdRange->GetText().isEmpty(); } m_pBtnOk->Enable(bOk); + setOptimalLayoutSize(); } -void DataStreamDlg::StartStream() +void DataStreamDlg::Init(const OUString& rURL, const OUString& rRange, const sal_Int32 nLimit, + const OUString& rMove, const sal_uInt32 nSettings) +{ + m_pEdLimit->SetText(OUString::number(nLimit)); + m_pCbUrl->SetText(rURL); + if (nSettings & DataStream::SCRIPT_STREAM) + m_pRBScriptData->Check(); + if (!(nSettings & DataStream::VALUES_IN_LINE)) + m_pRBAddressValue->Check(); + m_pEdRange->SetText(rRange); + if (rMove == "NO_MOVE") + m_pRBNoMove->Check(); + else if (rMove == "RANGE_DOWN") + m_pRBRangeDown->Check(); + else if (rMove == "MOVE_DOWN") + m_pRBDataDown->Check(); + UpdateEnable(); +} + +void DataStreamDlg::StartStream(DataStream *pStream) { sal_Int32 nLimit = 0; if (m_pRBMaxLimit->IsChecked()) @@ -89,7 +111,15 @@ void DataStreamDlg::StartStream() nSettings |= DataStream::SCRIPT_STREAM; if (m_pRBValuesInLine->IsChecked()) nSettings |= DataStream::VALUES_IN_LINE; - DataStream *pStream = DataStream::Set( mpDocShell, + if (pStream) + { + pStream->Decode(rURL, m_pEdRange->GetText(), nLimit, + m_pRBNoMove->IsChecked() ? OUString("NO_MOVE") : m_pRBRangeDown->IsChecked() + ? OUString("RANGE_DOWN") : OUString("MOVE_DOWN"), + nSettings); + return; + } + pStream = DataStream::Set( mpDocShell, rURL, m_pEdRange->GetText(), nLimit, |