[Libreoffice-commits] core.git: Branch 'private/kohei/calc-data-stream' - sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Wed Dec 18 11:55:36 PST 2013
sc/source/ui/docshell/datastream.cxx | 23 +++++++++++++++++------
sc/source/ui/inc/datastream.hxx | 3 ++-
2 files changed, 19 insertions(+), 7 deletions(-)
New commits:
commit 8d181be07c62f0b762bed05b0517d9841de4c761
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Wed Dec 18 14:55:17 2013 -0500
Fine-tune our refresh policy during streaming.
Change-Id: I9eff0bc0e4087261e2283a55211c8a9daf2a8b24
diff --git a/sc/source/ui/docshell/datastream.cxx b/sc/source/ui/docshell/datastream.cxx
index cbf8957..db5f34a 100644
--- a/sc/source/ui/docshell/datastream.cxx
+++ b/sc/source/ui/docshell/datastream.cxx
@@ -13,12 +13,12 @@
#include <com/sun/star/ui/XUIElement.hpp>
#include <officecfg/Office/Common.hxx>
#include <osl/conditn.hxx>
+#include <osl/time.h>
#include <rtl/strbuf.hxx>
#include <salhelper/thread.hxx>
#include <sfx2/linkmgr.hxx>
#include <sfx2/viewfrm.hxx>
#include <arealink.hxx>
-#include <asciiopt.hxx>
#include <datastreamdlg.hxx>
#include <dbfunc.hxx>
#include <docsh.hxx>
@@ -42,6 +42,13 @@
namespace sc {
+inline double getNow()
+{
+ TimeValue now;
+ osl_getSystemTime(&now);
+ return static_cast<double>(now.Seconds) + static_cast<double>(now.Nanosec) / 1000000000.0;
+}
+
namespace datastreams {
class CallerThread : public salhelper::Thread
@@ -246,7 +253,8 @@ DataStream::DataStream(ScDocShell *pShell, const OUString& rURL, const ScRange&
mbRunning(false),
mpLines(0),
mnLinesCount(0),
- mnRepaintCounter(0),
+ mnLinesSinceRefresh(0),
+ mfLastRefreshTime(0.0),
mnCurRow(0)
{
mxThread = new datastreams::CallerThread( this );
@@ -379,10 +387,11 @@ void DataStream::Refresh()
ScRange aRange(maStartRange.aStart);
aRange.aEnd = ScAddress(maStartRange.aEnd.Col(), nEndRow, maStartRange.aStart.Tab());
- mnRepaintCounter = 0;
-
// Hard recalc will repaint the grid area.
mpDocShell->DoHardRecalc(true);
+
+ mfLastRefreshTime = getNow();
+ mnLinesSinceRefresh = 0;
}
void DataStream::MoveData()
@@ -477,7 +486,7 @@ void DataStream::Text2Doc()
orcus::csv_parser<CSVHandler> parser(aLine.getStr(), aLine.getLength(), aHdl, aConfig);
parser.parse();
- ++mnRepaintCounter;
+ ++mnLinesSinceRefresh;
}
#else
@@ -536,7 +545,9 @@ bool DataStream::ImportData()
// maStartRange.aStart.Col(), mnCurRow, SC_FOLLOW_JUMP);
}
- if (mnRepaintCounter > 200)
+ if (getNow() - mfLastRefreshTime > 0.1 && mnLinesSinceRefresh > 200)
+ // Refresh no more frequently than every 0.1 second, and wait until at
+ // least we have processed 200 lines.
Refresh();
return mbRunning;
diff --git a/sc/source/ui/inc/datastream.hxx b/sc/source/ui/inc/datastream.hxx
index 86be03b..a593aad 100644
--- a/sc/source/ui/inc/datastream.hxx
+++ b/sc/source/ui/inc/datastream.hxx
@@ -93,7 +93,8 @@ private:
bool mbValuesInLine;
LinesList* mpLines;
size_t mnLinesCount;
- size_t mnRepaintCounter;
+ size_t mnLinesSinceRefresh;
+ double mfLastRefreshTime;
SCROW mnCurRow;
ScRange maStartRange;
boost::scoped_ptr<ScRange> mpEndRange;
More information about the Libreoffice-commits
mailing list