[Libreoffice-commits] core.git: Branch 'private/kohei/calc-data-stream' - sc/inc sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Tue Dec 17 18:51:20 PST 2013


 sc/inc/documentstreamaccess.hxx              |    1 +
 sc/source/core/data/documentstreamaccess.cxx |   21 +++++++++++++++++++++
 sc/source/ui/docshell/datastream.cxx         |   14 ++++++++++----
 3 files changed, 32 insertions(+), 4 deletions(-)

New commits:
commit e6bb2672d64e759e0ca782fffa0af9156733c9e6
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Dec 17 21:51:43 2013 -0500

    Detect numbers which are to be inserted as numeric cells.
    
    Also, disable automatic scrolling.
    
    Change-Id: I2f3facfd91b9b4e3f86b9685a546a094180bf1ee

diff --git a/sc/inc/documentstreamaccess.hxx b/sc/inc/documentstreamaccess.hxx
index 74f8914..9fa2d78 100644
--- a/sc/inc/documentstreamaccess.hxx
+++ b/sc/inc/documentstreamaccess.hxx
@@ -33,6 +33,7 @@ class DocumentStreamAccess
 public:
     DocumentStreamAccess( ScDocument& rDoc );
 
+    void setNumericCell( const ScAddress& rPos, double fVal );
     void setStringCell( const ScAddress& rPos, const OUString& rStr );
 
     /**
diff --git a/sc/source/core/data/documentstreamaccess.cxx b/sc/source/core/data/documentstreamaccess.cxx
index 81ca160..bf3efe3 100644
--- a/sc/source/core/data/documentstreamaccess.cxx
+++ b/sc/source/core/data/documentstreamaccess.cxx
@@ -31,6 +31,27 @@ struct DocumentStreamAccessImpl
 DocumentStreamAccess::DocumentStreamAccess( ScDocument& rDoc ) :
     mpImpl(new DocumentStreamAccessImpl(rDoc)) {}
 
+void DocumentStreamAccess::setNumericCell( const ScAddress& rPos, double fVal )
+{
+    ScTable* pTab = mpImpl->mrDoc.FetchTable(rPos.Tab());
+    if (!pTab)
+        return;
+
+    ColumnBlockPosition* pBlockPos =
+        mpImpl->maBlockPosSet.getBlockPosition(rPos.Tab(), rPos.Col());
+
+    if (!pBlockPos)
+        return;
+
+    // Set the numeric value.
+    CellStoreType& rCells = pTab->aCol[rPos.Col()].maCells;
+    pBlockPos->miCellPos = rCells.set(pBlockPos->miCellPos, rPos.Row(), fVal);
+
+    // Be sure to set the corresponding text attribute to the default value.
+    CellTextAttrStoreType& rAttrs = pTab->aCol[rPos.Col()].maCellTextAttrs;
+    pBlockPos->miCellTextAttrPos = rAttrs.set(pBlockPos->miCellTextAttrPos, rPos.Row(), CellTextAttr());
+}
+
 void DocumentStreamAccess::setStringCell( const ScAddress& rPos, const OUString& rStr )
 {
     ScTable* pTab = mpImpl->mrDoc.FetchTable(rPos.Tab());
diff --git a/sc/source/ui/docshell/datastream.cxx b/sc/source/ui/docshell/datastream.cxx
index a798b84..af60412e 100644
--- a/sc/source/ui/docshell/datastream.cxx
+++ b/sc/source/ui/docshell/datastream.cxx
@@ -27,6 +27,7 @@
 #include <rangelst.hxx>
 #include <tabvwsh.hxx>
 #include <viewdata.hxx>
+#include <stringutil.hxx>
 
 #include <config_orcus.h>
 
@@ -438,7 +439,12 @@ public:
     {
         if (maPos.Col() <= mnEndCol)
         {
-            mrDoc.setStringCell(maPos, OUString(p, n, RTL_TEXTENCODING_UTF8));
+            OUString aStr(p, n, RTL_TEXTENCODING_UTF8);
+            double fVal;
+            if (ScStringUtil::parseSimpleNumber(aStr, '.', ',', fVal))
+                mrDoc.setNumericCell(maPos, fVal);
+            else
+                mrDoc.setStringCell(maPos, aStr);
         }
         maPos.IncCol();
     }
@@ -511,11 +517,11 @@ bool DataStream::ImportData()
     if (meMove == RANGE_DOWN)
     {
         ++mnCurRow;
-        mpDocShell->GetViewData()->GetView()->AlignToCursor(
-                maStartRange.aStart.Col(), mnCurRow, SC_FOLLOW_JUMP);
+//      mpDocShell->GetViewData()->GetView()->AlignToCursor(
+//              maStartRange.aStart.Col(), mnCurRow, SC_FOLLOW_JUMP);
     }
 
-    if (mnRepaintCounter > 100)
+    if (mnRepaintCounter > 200)
         Repaint();
 
     return mbRunning;


More information about the Libreoffice-commits mailing list