[Libreoffice-commits] core.git: Branch 'private/kohei/calc-data-stream' - sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Wed Dec 18 22:19:41 PST 2013
sc/source/filter/xml/xmlexprt.cxx | 12 --------
sc/source/ui/docshell/datastream.cxx | 46 +++++++++++++-------------------
sc/source/ui/inc/datastream.hxx | 4 +-
sc/source/ui/inc/datastreamdlg.hxx | 7 ++--
sc/source/ui/miscdlgs/datastreamdlg.cxx | 40 +++++++++++++--------------
sc/source/ui/view/cellsh2.cxx | 6 ++++
6 files changed, 50 insertions(+), 65 deletions(-)
New commits:
commit 7d7ba40bea62f6ba6ccd91230a58f03f141ecdf8
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Thu Dec 19 01:20:13 2013 -0500
Initialize data stream dialog properly.
Change-Id: I86d4cfe946de896951d5eca2317f6d515113b249
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 51f2175..74c20da 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -836,18 +836,6 @@ void ScXMLExport::GetAreaLinks( ScMyAreaLinksContainer& rAreaLinks )
aAreaLink.nRefresh = pLink->GetTimeout();
rAreaLinks.AddNewAreaLink( aAreaLink );
}
- sc::DataStream *pStream = dynamic_cast<sc::DataStream*>(&(*(*rLinks[i])));
- if (pStream)
- {
- ScMyAreaLink aAreaLink;
- ScUnoConversion::FillApiRange( aAreaLink.aDestRange, pStream->GetRange() );
- aAreaLink.sSourceStr = pStream->GetMove();
- aAreaLink.sFilter = OUString::number(pStream->GetLimit());
- aAreaLink.sFilterOptions = "DataStream";
- aAreaLink.sURL = pStream->GetURL();
- aAreaLink.nRefresh = pStream->GetSettings();
- rAreaLinks.AddNewAreaLink( aAreaLink );
- }
}
}
rAreaLinks.Sort();
diff --git a/sc/source/ui/docshell/datastream.cxx b/sc/source/ui/docshell/datastream.cxx
index 5b1b9dd..a68d338 100644
--- a/sc/source/ui/docshell/datastream.cxx
+++ b/sc/source/ui/docshell/datastream.cxx
@@ -264,27 +264,13 @@ OString DataStream::ConsumeLine()
ScRange DataStream::GetRange() const
{
ScRange aRange = maStartRange;
- if (mpEndRange)
- aRange.aEnd = mpEndRange->aEnd;
+ aRange.aEnd = maEndRange.aEnd;
return aRange;
}
-OUString DataStream::GetMove() const
+DataStream::MoveType DataStream::GetMove() const
{
- switch (meMove)
- {
- case MOVE_DOWN:
- return OUString("MOVE_DOWN");
- case MOVE_UP:
- return OUString("MOVE_UP");
- case NO_MOVE:
- return OUString("NO_MOVE");
- case RANGE_DOWN:
- return OUString("RANGE_DOWN");
- default:
- ;
- }
- return OUString();
+ return meMove;
}
void DataStream::Decode(const OUString& rURL, const ScRange& rRange,
@@ -294,7 +280,6 @@ void DataStream::Decode(const OUString& rURL, const ScRange& rRange,
mnLimit = nLimit;
meMove = eMove;
mnSettings = nSettings;
- mpEndRange.reset( NULL );
mbValuesInLine = mnSettings & VALUES_IN_LINE;
@@ -306,11 +291,21 @@ void DataStream::Decode(const OUString& rURL, const ScRange& rRange,
aRange.aEnd.SetRow(aRange.aStart.Row());
maStartRange = aRange;
- if (nLimit && aRange.aStart.Row() + nLimit - 1 < MAXROW)
+ maEndRange = aRange;
+ if (nLimit == 0)
+ {
+ // Unlimited
+ maEndRange.aStart.SetRow(MAXROW);
+ }
+ else if (nLimit > 0)
{
- mpEndRange.reset(new ScRange(aRange));
- mpEndRange->Move(0, nLimit-1, 0);
+ // Limited.
+ maEndRange.aStart.IncRow(nLimit-1);
+ if (maEndRange.aStart.Row() > MAXROW)
+ maEndRange.aStart.SetRow(MAXROW);
}
+
+ maEndRange.aEnd.SetRow(maEndRange.aStart.Row());
}
void DataStream::StartImport()
@@ -359,14 +354,11 @@ void DataStream::Refresh()
void DataStream::MoveData()
{
- if (!mpEndRange)
- return;
-
switch (meMove)
{
case RANGE_DOWN:
{
- if (mnCurRow == mpEndRange->aStart.Row())
+ if (mnCurRow == maEndRange.aStart.Row())
meMove = MOVE_UP;
}
break;
@@ -375,7 +367,7 @@ void DataStream::MoveData()
// Remove the top row and shift the remaining rows upward. Then
// insert a new row at the end row position.
ScRange aRange = maStartRange;
- aRange.aEnd = mpEndRange->aEnd;
+ aRange.aEnd = maEndRange.aEnd;
maDocAccess.shiftRangeUp(aRange);
}
break;
@@ -384,7 +376,7 @@ void DataStream::MoveData()
// Remove the end row and shift the remaining rows downward by
// inserting a new row at the top row.
ScRange aRange = maStartRange;
- aRange.aEnd = mpEndRange->aEnd;
+ aRange.aEnd = maEndRange.aEnd;
maDocAccess.shiftRangeDown(aRange);
}
break;
diff --git a/sc/source/ui/inc/datastream.hxx b/sc/source/ui/inc/datastream.hxx
index 935e895..b7cd712 100644
--- a/sc/source/ui/inc/datastream.hxx
+++ b/sc/source/ui/inc/datastream.hxx
@@ -60,7 +60,7 @@ public:
ScRange GetRange() const;
const OUString& GetURL() const { return msURL; }
const sal_Int32& GetLimit() const { return mnLimit; }
- OUString GetMove() const;
+ MoveType GetMove() const;
const sal_uInt32& GetSettings() const { return mnSettings; }
void Decode(
@@ -93,7 +93,7 @@ private:
double mfLastRefreshTime;
SCROW mnCurRow;
ScRange maStartRange;
- boost::scoped_ptr<ScRange> mpEndRange;
+ ScRange maEndRange;
rtl::Reference<datastreams::CallerThread> mxThread;
rtl::Reference<datastreams::ReaderThread> mxReaderThread;
};
diff --git a/sc/source/ui/inc/datastreamdlg.hxx b/sc/source/ui/inc/datastreamdlg.hxx
index c7cff94..851afef 100644
--- a/sc/source/ui/inc/datastreamdlg.hxx
+++ b/sc/source/ui/inc/datastreamdlg.hxx
@@ -36,6 +36,7 @@ class DataStreamDlg : public ModalDialog
RadioButton* m_pRBRangeDown;
RadioButton* m_pRBNoMove;
RadioButton* m_pRBMaxLimit;
+ RadioButton* m_pRBUnlimited;
Edit* m_pEdRange;
Edit* m_pEdLimit;
OKButton* m_pBtnOk;
@@ -51,11 +52,9 @@ class DataStreamDlg : public ModalDialog
public:
DataStreamDlg(ScDocShell *pDocShell, Window* pParent);
- void Init(
- const OUString& rURL, const ScRange& rRange, const sal_Int32 nLimit,
- DataStream::MoveType eMove, const sal_uInt32 nSettings);
+ void Init( const DataStream& rStrm );
- void StartStream(DataStream *pStream = 0);
+ void StartStream();
};
}
diff --git a/sc/source/ui/miscdlgs/datastreamdlg.cxx b/sc/source/ui/miscdlgs/datastreamdlg.cxx
index fbd1389..17b9e6e 100644
--- a/sc/source/ui/miscdlgs/datastreamdlg.cxx
+++ b/sc/source/ui/miscdlgs/datastreamdlg.cxx
@@ -32,6 +32,7 @@ DataStreamDlg::DataStreamDlg(ScDocShell *pDocShell, Window* pParent)
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");
@@ -114,20 +115,26 @@ ScRange DataStreamDlg::GetStartRange()
return aRange;
}
-void DataStreamDlg::Init(
- const OUString& rURL, const ScRange& rRange, const sal_Int32 nLimit,
- DataStream::MoveType eMove, const sal_uInt32 nSettings)
+void DataStreamDlg::Init( const DataStream& rStrm )
{
- 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();
-
- OUString aStr = rRange.Format(SCA_VALID);
+ m_pCbUrl->SetText(rStrm.GetURL());
+
+ ScRange aRange = rStrm.GetRange();
+ ScRange aTopRange = aRange;
+ aTopRange.aEnd.SetRow(aTopRange.aStart.Row());
+ OUString aStr = aTopRange.Format(SCA_VALID);
m_pEdRange->SetText(aStr);
+ SCROW nRows = aRange.aEnd.Row() - aRange.aStart.Row() + 1;
+
+ if (nRows == MAXROWCOUNT)
+ m_pRBUnlimited->Check();
+ else
+ {
+ m_pRBMaxLimit->Check();
+ m_pEdLimit->SetText(OUString::number(nRows));
+ }
+ DataStream::MoveType eMove = rStrm.GetMove();
switch (eMove)
{
case DataStream::MOVE_DOWN:
@@ -146,7 +153,7 @@ void DataStreamDlg::Init(
UpdateEnable();
}
-void DataStreamDlg::StartStream(DataStream *pStream)
+void DataStreamDlg::StartStream()
{
ScRange aStartRange = GetStartRange();
if (!aStartRange.IsValid())
@@ -166,14 +173,7 @@ void DataStreamDlg::StartStream(DataStream *pStream)
DataStream::MoveType eMove =
m_pRBRangeDown->IsChecked() ? DataStream::RANGE_DOWN : DataStream::MOVE_DOWN;
- if (pStream)
- {
- pStream->Decode(rURL, aStartRange, nLimit, eMove, nSettings);
- pStream->SetRefreshOnEmptyLine(m_pCBRefreshOnEmpty->IsChecked());
- return;
- }
-
- pStream = DataStream::Set(mpDocShell, rURL, aStartRange, nLimit, eMove, nSettings);
+ DataStream* pStream = DataStream::Set(mpDocShell, rURL, aStartRange, nLimit, eMove, nSettings);
pStream->SetRefreshOnEmptyLine(m_pCBRefreshOnEmpty->IsChecked());
DataStream::MakeToolbarVisible();
pStream->StartImport();
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index 1c7e89c..4cea560 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -739,6 +739,12 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
case SID_DATA_STREAMS:
{
sc::DataStreamDlg aDialog( GetViewData()->GetDocShell(), pTabViewShell->GetDialogParent() );
+ ScDocument *pDoc = GetViewData()->GetDocument();
+ sc::DocumentLinkManager& rMgr = pDoc->GetDocLinkManager();
+ sc::DataStream* pStrm = rMgr.getDataStream();
+ if (pStrm)
+ aDialog.Init(*pStrm);
+
if (aDialog.Execute() == RET_OK)
aDialog.StartStream();
}
More information about the Libreoffice-commits
mailing list