[Libreoffice-commits] core.git: Branch 'private/matus/sc-hacks' - sc/source

Matúš Kukan matus.kukan at gmail.com
Tue Nov 12 02:33:50 PST 2013


 sc/source/ui/inc/datastreams.hxx         |   15 ++++++---
 sc/source/ui/miscdlgs/datastreams.cxx    |   48 ++++++++++++++++---------------
 sc/source/ui/miscdlgs/datastreamsdlg.cxx |   14 +++------
 3 files changed, 42 insertions(+), 35 deletions(-)

New commits:
commit 8168849381fb7bcff2d26e4d3310ecefb42445bc
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Tue Nov 12 10:49:18 2013 +0100

    fix the move commit
    
    Change-Id: Id37a27d0a671ce74d66d9cfa09cdafa8bceb9255

diff --git a/sc/source/ui/inc/datastreams.hxx b/sc/source/ui/inc/datastreams.hxx
index ae807df..d3f63b9 100644
--- a/sc/source/ui/inc/datastreams.hxx
+++ b/sc/source/ui/inc/datastreams.hxx
@@ -14,6 +14,7 @@
 
 #include <boost/scoped_ptr.hpp>
 
+namespace { class DataStreamsDlg; }
 class Dialog;
 class ScDocShell;
 class ScDocument;
@@ -24,10 +25,12 @@ namespace datastreams { class CallerThread; }
 
 class DataStreams
 {
+    friend DataStreamsDlg;
+    enum MoveEnum { NO_MOVE, RANGE_DOWN, MOVE_DOWN, MOVE_UP };
     Dialog *mpDialog;
     ScDocShell *mpScDocShell;
     ScDocument *mpScDocument;
-    enum { NO_MOVE, RANGE_DOWN, MOVE_DOWN, MOVE_UP } meMove;
+    MoveEnum meMove;
     bool mbRunning;
     boost::scoped_ptr<ScRange> mpRange;
     boost::scoped_ptr<ScRange> mpStartRange;
@@ -37,14 +40,16 @@ class DataStreams
 
 public:
     DataStreams(ScDocShell *pScDocShell);
-    virtual ~DataStreams();
+    ~DataStreams();
     bool ImportData();
-    void MoveData();
     void ShowDialog(Window *pParent);
+
+private:
+    void MoveData();
+    void Set(const OUString& rUrl, bool bIsScript, const OUString& rRange,
+            sal_Int32 nLimit, MoveEnum eMove);
     void Start();
     void Stop();
-    void Set(const OUString& rUrl, bool bIsScript, const OUString& rRange);
-    void SetMove(sal_Int32 nLimit, bool bMoveRangeDown);
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/datastreams.cxx b/sc/source/ui/miscdlgs/datastreams.cxx
index 61e211d..587fddb 100644
--- a/sc/source/ui/miscdlgs/datastreams.cxx
+++ b/sc/source/ui/miscdlgs/datastreams.cxx
@@ -83,7 +83,8 @@ void DataStreams::Stop()
     mpScDocument->EnableUndo(true);
 }
 
-void DataStreams::Set(const OUString& rUrl, bool bIsScript, const OUString& rRange)
+void DataStreams::Set(const OUString& rUrl, bool bIsScript,
+        const OUString& rRange, sal_Int32 nLimit, MoveEnum eMove)
 {
     mpRange.reset ( new ScRange() );
     mpRange->Parse(rRange, mpScDocument);
@@ -92,12 +93,9 @@ void DataStreams::Set(const OUString& rUrl, bool bIsScript, const OUString& rRan
         mpStream.reset( new SvScriptStream(rUrl) );
     else
         mpStream.reset( new SvFileStream(rUrl, STREAM_READ) );
-}
 
-void DataStreams::SetMove(sal_Int32 nLimit, bool bMoveRangeDown)
-{
     mpEndRange.reset( NULL );
-    meMove = bMoveRangeDown ? RANGE_DOWN : MOVE_DOWN;
+    meMove = eMove;
     sal_Int32 nHeight = mpRange->aEnd.Row() - mpRange->aStart.Row() + 1;
     nLimit = nHeight * (nLimit / nHeight);
     if (nLimit && mpRange->aStart.Row() + nLimit - 1 < MAXROW)
@@ -109,22 +107,23 @@ void DataStreams::SetMove(sal_Int32 nLimit, bool bMoveRangeDown)
 
 void DataStreams::MoveData()
 {
-    if (meMove == MOVE_DOWN)
-    {
-        if (mpEndRange.get())
-            mpScDocument->DeleteRow(*mpEndRange.get());
-        mpScDocument->InsertRow(*mpRange.get());
-    }
-    else if (meMove == RANGE_DOWN)
-    {
-        mpRange->Move(0, mpRange->aEnd.Row() - mpRange->aStart.Row() + 1, 0);
-        if (mpRange->aStart == mpEndRange->aStart)
-            meMove = MOVE_UP;
-    }
-    else if (meMove == MOVE_UP)
+    switch (meMove)
     {
-        mpScDocument->DeleteRow(*mpStartRange.get());
-        mpScDocument->InsertRow(*mpEndRange.get());
+        case RANGE_DOWN:
+            if (mpRange->aStart == mpEndRange->aStart)
+                meMove = MOVE_UP;
+            break;
+        case MOVE_UP:
+            mpScDocument->DeleteRow(*mpStartRange.get());
+            mpScDocument->InsertRow(*mpEndRange.get());
+            break;
+        case MOVE_DOWN:
+            if (mpEndRange.get())
+                mpScDocument->DeleteRow(*mpEndRange.get());
+            mpScDocument->InsertRow(*mpRange.get());
+            break;
+        case NO_MOVE:
+            break;
     }
 }
 
@@ -147,6 +146,7 @@ bool DataStreams::ImportData()
         aBuf.append('\n');
     }
     SolarMutexGuard aGuard;
+    MoveData();
     SvMemoryStream aMemoryStream((void *)aBuf.getStr(), aBuf.getLength(), STREAM_READ);
     ScImportExport aImport(mpScDocument, *mpRange.get());
     ScAsciiOptions aOptions;
@@ -158,8 +158,12 @@ bool DataStreams::ImportData()
     if (meMove == NO_MOVE)
         return mbRunning;
 
-    MoveData();
-    mpScDocShell->GetViewData()->GetView()->AlignToCursor(mpRange->aStart.Col(), mpRange->aStart.Row(), SC_FOLLOW_JUMP);
+    if (meMove == RANGE_DOWN)
+    {
+        mpRange->Move(0, mpRange->aEnd.Row() - mpRange->aStart.Row() + 1, 0);
+        mpScDocShell->GetViewData()->GetView()->AlignToCursor(
+                mpRange->aStart.Col(), mpRange->aStart.Row(), SC_FOLLOW_JUMP);
+    }
     SCROW aEndRow = mpEndRange.get() ? mpEndRange->aEnd.Row() : MAXROW;
     mpScDocShell->PostPaint( ScRange( mpStartRange->aStart, ScAddress( mpRange->aEnd.Col(),
                     aEndRow, mpRange->aStart.Tab()) ), PAINT_GRID );
diff --git a/sc/source/ui/miscdlgs/datastreamsdlg.cxx b/sc/source/ui/miscdlgs/datastreamsdlg.cxx
index 8f8afe1..d99af8b 100644
--- a/sc/source/ui/miscdlgs/datastreamsdlg.cxx
+++ b/sc/source/ui/miscdlgs/datastreamsdlg.cxx
@@ -90,14 +90,12 @@ IMPL_LINK_NOARG(DataStreamsDlg, BrowseHdl)
 IMPL_LINK_NOARG(DataStreamsDlg, StartHdl)
 {
     bool bIsScript = m_pRBScriptData->IsChecked();
-    mpDataStreams->Set(m_pCbUrl->GetText(), bIsScript, m_pEdRange->GetText());
-    if (!m_pRBNoMove->IsChecked())
-    {
-        sal_Int32 nLimit = 0;
-        if (m_pRBMaxLimit->IsChecked())
-            nLimit = m_pEdLimit->GetText().toInt32();
-        mpDataStreams->SetMove(nLimit, m_pRBRangeDown->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();
     UpdateEnable();
     return 0;


More information about the Libreoffice-commits mailing list