[Libreoffice-commits] core.git: Branch 'private/kohei/calc-data-stream' - 2 commits - sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Mon Dec 30 12:43:00 PST 2013
sc/source/ui/docshell/datastream.cxx | 55 ++++++++++-------------------------
sc/source/ui/inc/datastream.hxx | 7 +++-
2 files changed, 22 insertions(+), 40 deletions(-)
New commits:
commit b4b0c48b9252e3899e00be9778bad8913a496e2c
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Mon Dec 30 15:43:21 2013 -0500
Remove CallerThread and use Timer to do the same, on the main thread.
This makes the UI more responsive in general.
Change-Id: I5f8a4fab84a73812af868262cc7daa9d92cb3777
diff --git a/sc/source/ui/docshell/datastream.cxx b/sc/source/ui/docshell/datastream.cxx
index 35665a2..04605e4 100644
--- a/sc/source/ui/docshell/datastream.cxx
+++ b/sc/source/ui/docshell/datastream.cxx
@@ -111,37 +111,6 @@ public:
namespace datastreams {
-class CallerThread : public salhelper::Thread
-{
- DataStream *mpDataStream;
-public:
- osl::Condition maStart;
- bool mbTerminate;
-
- CallerThread(DataStream *pData):
- Thread("CallerThread")
- ,mpDataStream(pData)
- ,mbTerminate(false)
- {}
-
-private:
- virtual void execute()
- {
- while (!mbTerminate)
- {
- // wait for a small amount of time, so that
- // painting methods have a chance to be called.
- // And also to make UI more responsive.
- TimeValue const aTime = {0, 1000};
- maStart.wait();
- maStart.reset();
- if (!mbTerminate)
- while (mpDataStream->ImportData())
- wait(aTime);
- };
- }
-};
-
void emptyLineQueue( std::queue<DataStream::LinesType*>& rQueue )
{
while (!rQueue.empty())
@@ -371,8 +340,8 @@ DataStream::DataStream(ScDocShell *pShell, const OUString& rURL, const ScRange&
mfLastRefreshTime(0.0),
mnCurRow(0)
{
- mxThread = new datastreams::CallerThread( this );
- mxThread->launch();
+ maImportTimer.SetTimeout(0);
+ maImportTimer.SetTimeoutHdl( LINK(this, DataStream, ImportTimerHdl) );
Decode(rURL, rRange, nLimit, eMove, nSettings);
}
@@ -381,9 +350,7 @@ DataStream::~DataStream()
{
if (mbRunning)
StopImport();
- mxThread->mbTerminate = true;
- mxThread->maStart.set();
- mxThread->join();
+
if (mxReaderThread.is())
{
mxReaderThread->endThread();
@@ -487,7 +454,8 @@ void DataStream::StartImport()
}
mbRunning = true;
maDocAccess.reset();
- mxThread->maStart.set();
+
+ maImportTimer.Start();
}
void DataStream::StopImport()
@@ -497,6 +465,7 @@ void DataStream::StopImport()
mbRunning = false;
Refresh();
+ maImportTimer.Stop();
}
void DataStream::SetRefreshOnEmptyLine( bool bVal )
@@ -618,7 +587,6 @@ void DataStream::Text2Doc() {}
bool DataStream::ImportData()
{
- SolarMutexGuard aGuard;
if (!mbValuesInLine)
// We no longer support this mode. To be deleted later.
return false;
@@ -630,6 +598,14 @@ bool DataStream::ImportData()
return mbRunning;
}
+IMPL_LINK_NOARG(DataStream, ImportTimerHdl)
+{
+ if (ImportData())
+ maImportTimer.Start();
+
+ return 0;
+}
+
} // namespace sc
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/datastream.hxx b/sc/source/ui/inc/datastream.hxx
index 5af2dc7..5600a09 100644
--- a/sc/source/ui/inc/datastream.hxx
+++ b/sc/source/ui/inc/datastream.hxx
@@ -14,6 +14,7 @@
#include <rtl/ref.hxx>
#include <rtl/ustring.hxx>
+#include <vcl/timer.hxx>
#include <address.hxx>
#include <boost/noncopyable.hpp>
@@ -102,6 +103,8 @@ private:
void Text2Doc();
void Refresh();
+ DECL_LINK( ImportTimerHdl, void* );
+
private:
ScDocShell* mpDocShell;
ScDocument* mpDoc;
@@ -121,7 +124,9 @@ private:
SCROW mnCurRow;
ScRange maStartRange;
ScRange maEndRange;
- rtl::Reference<datastreams::CallerThread> mxThread;
+
+ Timer maImportTimer;
+
rtl::Reference<datastreams::ReaderThread> mxReaderThread;
};
commit 4fd4e494d0305e496a890f928b7602211ca4eb73
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Mon Dec 30 14:31:30 2013 -0500
This part requires orcus library presence.
Change-Id: I6bfba9872deb7318721ce4d73795ef7569a24e89
diff --git a/sc/source/ui/docshell/datastream.cxx b/sc/source/ui/docshell/datastream.cxx
index a21cba4..35665a2 100644
--- a/sc/source/ui/docshell/datastream.cxx
+++ b/sc/source/ui/docshell/datastream.cxx
@@ -269,10 +269,11 @@ private:
DataStream::Line& rLine = (*pLines)[i];
rLine.maCells.clear();
mpStream->ReadLine(rLine.maLine);
-
+#if ENABLE_ORCUS
CSVHandler aHdl(rLine, mnColCount);
orcus::csv_parser<CSVHandler> parser(rLine.maLine.getStr(), rLine.maLine.getLength(), aHdl, maConfig);
parser.parse();
+#endif
}
aGuard.reset(); // lock
More information about the Libreoffice-commits
mailing list