summaryrefslogtreecommitdiff
path: root/sc/source/ui/docshell/datastream.cxx
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2013-12-30 15:43:21 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-12-30 19:40:08 -0500
commit226f4f037c8492eca1050b0590169e85e61fb413 (patch)
tree9715785dbe291aaa5ff123d5dc6b399e3a0f7220 /sc/source/ui/docshell/datastream.cxx
parent2d283f2ef291fff5c27fdc55874aaacc94a9453c (diff)
Remove CallerThread and use Timer to do the same, on the main thread.
This makes the UI more responsive in general. Change-Id: I5f8a4fab84a73812af868262cc7daa9d92cb3777
Diffstat (limited to 'sc/source/ui/docshell/datastream.cxx')
-rw-r--r--sc/source/ui/docshell/datastream.cxx52
1 files changed, 14 insertions, 38 deletions
diff --git a/sc/source/ui/docshell/datastream.cxx b/sc/source/ui/docshell/datastream.cxx
index 35665a2d8a14..04605e4dfe72 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: */