summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@collabora.com>2013-11-25 12:01:57 +0100
committerMatúš Kukan <matus.kukan@collabora.com>2013-12-02 11:13:43 +0100
commitb5b18e81fb58eae5fcb92d76f2c487c766978453 (patch)
tree20dd356bde44f2a5772c9c9130eccbcbd347d334
parent97fa39975f592cb2d46db95b9a323ff753497fbd (diff)
Allow to edit data stream from Edit-> Links... dialog.
Change-Id: Ibb456da55f04c39ddb7b58eb71ca488cf209edb5
-rw-r--r--sc/source/ui/docshell/datastream.cxx40
-rw-r--r--sc/source/ui/inc/datastream.hxx4
-rw-r--r--sc/source/ui/inc/datastreamdlg.hxx6
-rw-r--r--sc/source/ui/miscdlgs/datastreamdlg.cxx36
4 files changed, 65 insertions, 21 deletions
diff --git a/sc/source/ui/docshell/datastream.cxx b/sc/source/ui/docshell/datastream.cxx
index 7f309e0eb068..514cefdfb0ac 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 64d56136cfdb..3b0f745b7cc7 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 9ade70b0ed62..7b3e151f37f6 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,