Rebased ref, commits from common ancestor: commit 1e5fb1d9504c76e63f5392742368369ae704dcd3 Author: Kohei Yoshida <kohei.yosh...@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..f9686ae 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 ); @@ -375,14 +383,11 @@ void DataStream::StopImport() void DataStream::Refresh() { - SCROW nEndRow = mpEndRange ? mpEndRange->aEnd.Row() : MAXROW; - 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 +482,7 @@ void DataStream::Text2Doc() orcus::csv_parser<CSVHandler> parser(aLine.getStr(), aLine.getLength(), aHdl, aConfig); parser.parse(); - ++mnRepaintCounter; + ++mnLinesSinceRefresh; } #else @@ -536,7 +541,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; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits