[Libreoffice-commits] core.git: Branch 'private/kohei/calc-data-stream' - sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Tue Dec 17 19:38:22 PST 2013
sc/source/filter/xml/xmlcelli.cxx | 20 ++++++----
sc/source/ui/docshell/datastream.cxx | 62 +++++++++++++++++++++-----------
sc/source/ui/inc/datastream.hxx | 22 +++++++----
sc/source/ui/inc/datastreamdlg.hxx | 6 +--
sc/source/ui/miscdlgs/datastreamdlg.cxx | 45 ++++++++++++-----------
5 files changed, 97 insertions(+), 58 deletions(-)
New commits:
commit 4df058058a72d73ad032ef31fedb766c0ce03458
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Tue Dec 17 22:38:37 2013 -0500
Pass enum values around rather than OUString ones.
Ditto with the range type.
Change-Id: Iab37d50b6d58d76c60872f49f13d77ff0c918974
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 1223d3c5..b1d0de3 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -1005,13 +1005,19 @@ void ScXMLTableRowCellContext::SetCellRangeSource( const ScAddress& rPosition )
SvtMiscOptions aMiscOptions;
if (aMiscOptions.IsExperimentalMode() && pCellRangeSource->sFilterOptions == "DataStream")
{
- sc::DataStream::Set( dynamic_cast<ScDocShell*>(pDoc->GetDocumentShell())
- , pCellRangeSource->sURL // rURL
- , sRangeStr // rRange
- , sFilterName.toInt32() // nLimit
- , sSourceStr // rMove
- , pCellRangeSource->nRefresh // nSettings
- );
+ ScRange aRange;
+ sal_uInt16 nRes = aRange.Parse(sRangeStr, pDoc);
+ if ((nRes & SCA_VALID) == SCA_VALID)
+ {
+ sc::DataStream::MoveType eMove = sc::DataStream::ToMoveType(sSourceStr);
+ sc::DataStream::Set( dynamic_cast<ScDocShell*>(pDoc->GetDocumentShell())
+ , pCellRangeSource->sURL // rURL
+ , aRange
+ , sFilterName.toInt32() // nLimit
+ , eMove
+ , pCellRangeSource->nRefresh // nSettings
+ );
+ }
return;
}
ScAreaLink* pLink = new ScAreaLink( pDoc->GetDocumentShell(), pCellRangeSource->sURL,
diff --git a/sc/source/ui/docshell/datastream.cxx b/sc/source/ui/docshell/datastream.cxx
index af60412e..1bb9cd6 100644
--- a/sc/source/ui/docshell/datastream.cxx
+++ b/sc/source/ui/docshell/datastream.cxx
@@ -178,25 +178,24 @@ void DataStream::MakeToolbarVisible()
}
}
-DataStream* DataStream::Set(ScDocShell *pShell, const OUString& rURL, const OUString& rRange,
- sal_Int32 nLimit, const OUString& rMove, sal_uInt32 nSettings)
+DataStream* DataStream::Set(
+ ScDocShell *pShell, const OUString& rURL, const ScRange& rRange,
+ sal_Int32 nLimit, MoveType eMove, sal_uInt32 nSettings)
{
// Each DataStream needs a destination area in order to be exported.
// There can be only one ScAreaLink / DataStream per cell.
// So - if we don't need range (DataStream with mbValuesInLine == false),
// just find a free cell for now.
ScRange aDestArea;
- sal_uInt16 nRes = aDestArea.Parse(rRange, pShell->GetDocument());
- if ((nRes & SCA_VALID) != SCA_VALID)
- // Invalid range string.
- return NULL;
+ if (rRange.IsValid())
+ aDestArea = rRange;
sfx2::LinkManager* pLinkManager = pShell->GetDocument()->GetLinkManager();
sal_uInt16 nLinkPos = 0;
while (nLinkPos < pLinkManager->GetLinks().size())
{
sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[nLinkPos];
- if (rRange.isEmpty())
+ if (!rRange.IsValid())
{
if ( (pBase->ISA(ScAreaLink) && static_cast<ScAreaLink*>
(&(*pBase))->GetDestArea().aStart == aDestArea.aStart)
@@ -221,13 +220,25 @@ DataStream* DataStream::Set(ScDocShell *pShell, const OUString& rURL, const OUSt
++nLinkPos;
}
- DataStream* pLink = new DataStream(pShell, rURL, aDestArea, nLimit, rMove, nSettings);
+ DataStream* pLink = new DataStream(pShell, rURL, aDestArea, nLimit, eMove, nSettings);
pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, rURL, NULL, NULL );
return pLink;
}
+DataStream::MoveType DataStream::ToMoveType( const OUString& rMoveStr )
+{
+ if (rMoveStr == "RANGE_DOWN")
+ return RANGE_DOWN;
+ if (rMoveStr == "MOVE_DOWN")
+ return MOVE_DOWN;
+ if (rMoveStr == "MOVE_UP")
+ return MOVE_UP;
+
+ return NO_MOVE; // default
+}
+
DataStream::DataStream(ScDocShell *pShell, const OUString& rURL, const ScRange& rRange,
- sal_Int32 nLimit, const OUString& rMove, sal_uInt32 nSettings) :
+ sal_Int32 nLimit, MoveType eMove, sal_uInt32 nSettings) :
mpDocShell(pShell),
mpDoc(mpDocShell->GetDocument()),
maDocAccess(*mpDoc),
@@ -241,7 +252,7 @@ DataStream::DataStream(ScDocShell *pShell, const OUString& rURL, const ScRange&
mxThread = new datastreams::CallerThread( this );
mxThread->launch();
- Decode(rURL, rRange, nLimit, rMove, nSettings);
+ Decode(rURL, rRange, nLimit, eMove, nSettings);
}
DataStream::~DataStream()
@@ -289,24 +300,35 @@ ScRange DataStream::GetRange() const
return aRange;
}
+OUString 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();
+}
+
void DataStream::Decode(const OUString& rURL, const ScRange& rRange,
- sal_Int32 nLimit, const OUString& rMove, const sal_uInt32 nSettings)
+ sal_Int32 nLimit, MoveType eMove, const sal_uInt32 nSettings)
{
msURL = rURL;
mnLimit = nLimit;
- msMove = rMove;
+ meMove = eMove;
mnSettings = nSettings;
mpEndRange.reset( NULL );
mbValuesInLine = mnSettings & VALUES_IN_LINE;
- if (msMove == "NO_MOVE")
- meMove = NO_MOVE;
- else if (msMove == "RANGE_DOWN")
- meMove = RANGE_DOWN;
- else if (msMove == "MOVE_DOWN")
- meMove = MOVE_DOWN;
-
mnCurRow = rRange.aStart.Row();
ScRange aRange = rRange;
@@ -549,7 +571,7 @@ sfx2::SvBaseLink::UpdateResult DataStream::DataChanged(
void DataStream::Edit( Window* pWindow, const Link& )
{
DataStreamDlg aDialog(mpDocShell, pWindow);
- aDialog.Init(msURL, maStartRange, mnLimit, msMove, mnSettings);
+ aDialog.Init(msURL, maStartRange, mnLimit, meMove, mnSettings);
if (aDialog.Execute() == RET_OK)
{
bool bWasRunning = mbRunning;
diff --git a/sc/source/ui/inc/datastream.hxx b/sc/source/ui/inc/datastream.hxx
index 5f20bf4..494a73e 100644
--- a/sc/source/ui/inc/datastream.hxx
+++ b/sc/source/ui/inc/datastream.hxx
@@ -7,6 +7,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#ifndef SC_DATASTREAM_HXX
+#define SC_DATASTREAM_HXX
+
#include <sal/config.h>
#include <rtl/ref.hxx>
@@ -42,16 +45,18 @@ class DataStream : boost::noncopyable, public sfx2::SvBaseLink
DECL_LINK( RefreshHdl, void* );
public:
- enum MoveEnum { NO_MOVE, RANGE_DOWN, MOVE_DOWN, MOVE_UP };
+ enum MoveType { NO_MOVE, RANGE_DOWN, MOVE_DOWN, MOVE_UP };
enum { SCRIPT_STREAM = 1, VALUES_IN_LINE = 2 };
static void MakeToolbarVisible();
- static DataStream* Set(ScDocShell *pShell, const OUString& rURL, const OUString& rRange,
- sal_Int32 nLimit, const OUString& rMove, sal_uInt32 nSettings);
+ static DataStream* Set(ScDocShell *pShell, const OUString& rURL, const ScRange& rRange,
+ sal_Int32 nLimit, MoveType eMove, sal_uInt32 nSettings);
+
+ static MoveType ToMoveType( const OUString& rMoveStr );
DataStream(
ScDocShell *pShell, const OUString& rURL, const ScRange& rRange,
- sal_Int32 nLimit, const OUString& rMove, sal_uInt32 nSettings);
+ sal_Int32 nLimit, MoveType eMove, sal_uInt32 nSettings);
virtual ~DataStream();
// sfx2::SvBaseLink
@@ -62,12 +67,12 @@ public:
ScRange GetRange() const;
const OUString& GetURL() const { return msURL; }
const sal_Int32& GetLimit() const { return mnLimit; }
- const OUString& GetMove() const { return msMove; }
+ OUString GetMove() const;
const sal_uInt32& GetSettings() const { return mnSettings; }
void Decode(
const OUString& rURL, const ScRange& rRange, sal_Int32 nLimit,
- const OUString& rMove, const sal_uInt32 nSettings);
+ MoveType eMove, const sal_uInt32 nSettings);
bool ImportData();
void StartImport();
@@ -82,10 +87,9 @@ private:
ScDocument* mpDoc;
DocumentStreamAccess maDocAccess;
OUString msURL;
- OUString msMove;
sal_Int32 mnLimit;
sal_uInt32 mnSettings;
- MoveEnum meMove;
+ MoveType meMove;
bool mbRunning;
bool mbValuesInLine;
LinesList* mpLines;
@@ -101,4 +105,6 @@ private:
}
+#endif
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/datastreamdlg.hxx b/sc/source/ui/inc/datastreamdlg.hxx
index e3308f8..d817743 100644
--- a/sc/source/ui/inc/datastreamdlg.hxx
+++ b/sc/source/ui/inc/datastreamdlg.hxx
@@ -13,14 +13,14 @@
#include <vcl/dialog.hxx>
#include <vcl/layout.hxx>
+#include <datastream.hxx>
+
class ScDocShell;
class SvtURLBox;
class ScRange;
namespace sc {
-class DataStream;
-
class DataStreamDlg : public ModalDialog
{
ScDocShell *mpDocShell;
@@ -51,7 +51,7 @@ public:
void Init(
const OUString& rURL, const ScRange& rRange, const sal_Int32 nLimit,
- const OUString& rMove, const sal_uInt32 nSettings);
+ DataStream::MoveType eMove, const sal_uInt32 nSettings);
void StartStream(DataStream *pStream = 0);
};
diff --git a/sc/source/ui/miscdlgs/datastreamdlg.cxx b/sc/source/ui/miscdlgs/datastreamdlg.cxx
index 06980b9..bc1bf3d 100644
--- a/sc/source/ui/miscdlgs/datastreamdlg.cxx
+++ b/sc/source/ui/miscdlgs/datastreamdlg.cxx
@@ -12,7 +12,6 @@
#include <sfx2/filedlghelper.hxx>
#include <svtools/inettbc.hxx>
#include <vcl/layout.hxx>
-#include <datastream.hxx>
#include <address.hxx>
#include <docsh.hxx>
@@ -111,7 +110,7 @@ ScRange DataStreamDlg::GetStartRange()
void DataStreamDlg::Init(
const OUString& rURL, const ScRange& rRange, const sal_Int32 nLimit,
- const OUString& rMove, const sal_uInt32 nSettings)
+ DataStream::MoveType eMove, const sal_uInt32 nSettings)
{
m_pEdLimit->SetText(OUString::number(nLimit));
m_pCbUrl->SetText(rURL);
@@ -123,12 +122,22 @@ void DataStreamDlg::Init(
OUString aStr = rRange.Format(SCA_VALID);
m_pEdRange->SetText(aStr);
- if (rMove == "NO_MOVE")
- m_pRBNoMove->Check();
- else if (rMove == "RANGE_DOWN")
- m_pRBRangeDown->Check();
- else if (rMove == "MOVE_DOWN")
- m_pRBDataDown->Check();
+ switch (eMove)
+ {
+ case DataStream::MOVE_DOWN:
+ m_pRBDataDown->Check();
+ break;
+ case DataStream::NO_MOVE:
+ m_pRBNoMove->Check();
+ break;
+ case DataStream::RANGE_DOWN:
+ m_pRBRangeDown->Check();
+ break;
+ case DataStream::MOVE_UP:
+ default:
+ ;
+ }
+
UpdateEnable();
}
@@ -148,22 +157,18 @@ void DataStreamDlg::StartStream(DataStream *pStream)
nSettings |= DataStream::SCRIPT_STREAM;
if (m_pRBValuesInLine->IsChecked())
nSettings |= DataStream::VALUES_IN_LINE;
+
+ DataStream::MoveType eMove =
+ m_pRBNoMove->IsChecked() ? DataStream::NO_MOVE : m_pRBRangeDown->IsChecked()
+ ? DataStream::RANGE_DOWN : DataStream::MOVE_DOWN;
+
if (pStream)
{
- pStream->Decode(rURL, aStartRange, nLimit,
- m_pRBNoMove->IsChecked() ? OUString("NO_MOVE") : m_pRBRangeDown->IsChecked()
- ? OUString("RANGE_DOWN") : OUString("MOVE_DOWN"),
- nSettings);
+ pStream->Decode(rURL, aStartRange, nLimit, eMove, nSettings);
return;
}
- pStream = DataStream::Set( mpDocShell,
- rURL,
- m_pEdRange->GetText(),
- nLimit,
- m_pRBNoMove->IsChecked() ? OUString("NO_MOVE") : m_pRBRangeDown->IsChecked()
- ? OUString("RANGE_DOWN") : OUString("MOVE_DOWN")
- , nSettings
- );
+
+ pStream = DataStream::Set(mpDocShell, rURL, aStartRange, nLimit, eMove, nSettings);
DataStream::MakeToolbarVisible();
pStream->StartImport();
}
More information about the Libreoffice-commits
mailing list