summaryrefslogtreecommitdiff
path: root/sc/source/filter/oox/formulabuffer.cxx
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2013-11-14 12:14:12 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-11-14 23:53:51 -0500
commit6a4b377c1a5794efee4cbdc93289bc9ce5ead730 (patch)
tree447207ebbd116cf4ebbe2b20c40cdc863951f276 /sc/source/filter/oox/formulabuffer.cxx
parentae79b40f725ac28f8940bc9d97fd137088c20a22 (diff)
Do everything on main thread when the thread count is 1.
This helps debugging / profiling easier. Change-Id: I7834585bf2aa5d5f550bd218b9845ec964b06655
Diffstat (limited to 'sc/source/filter/oox/formulabuffer.cxx')
-rw-r--r--sc/source/filter/oox/formulabuffer.cxx87
1 files changed, 50 insertions, 37 deletions
diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx
index 343c5455a2e0..7472d3d78255 100644
--- a/sc/source/filter/oox/formulabuffer.cxx
+++ b/sc/source/filter/oox/formulabuffer.cxx
@@ -269,6 +269,25 @@ void applyCellFormulaValues(
}
}
+void processSheetFormulaCells(
+ ScDocumentImport& rDoc, FormulaBuffer::SheetItem& rItem, SvNumberFormatter& rFormatter )
+{
+ if (rItem.mpSharedFormulaEntries && rItem.mpSharedFormulaIDs)
+ applySharedFormulas(rDoc, rFormatter, *rItem.mpSharedFormulaEntries, *rItem.mpSharedFormulaIDs);
+
+ if (rItem.mpCellFormulas)
+ {
+ CachedTokenArray aCache(rDoc.getDoc());
+ applyCellFormulas(rDoc, aCache, rFormatter, *rItem.mpCellFormulas);
+ }
+
+ if (rItem.mpArrayFormulas)
+ applyArrayFormulas(rDoc, rFormatter, *rItem.mpArrayFormulas);
+
+ if (rItem.mpCellFormulaValues)
+ applyCellFormulaValues(rDoc, *rItem.mpCellFormulaValues);
+}
+
class WorkerThread : public salhelper::Thread
{
ScDocumentImport& mrDoc;
@@ -288,20 +307,7 @@ public:
protected:
virtual void execute()
{
- if (mrItem.mpSharedFormulaEntries && mrItem.mpSharedFormulaIDs)
- applySharedFormulas(mrDoc, *mpFormatter, *mrItem.mpSharedFormulaEntries, *mrItem.mpSharedFormulaIDs);
-
- if (mrItem.mpCellFormulas)
- {
- CachedTokenArray aCache(mrDoc.getDoc());
- applyCellFormulas(mrDoc, aCache, *mpFormatter, *mrItem.mpCellFormulas);
- }
-
- if (mrItem.mpArrayFormulas)
- applyArrayFormulas(mrDoc, *mpFormatter, *mrItem.mpArrayFormulas);
-
- if (mrItem.mpCellFormulaValues)
- applyCellFormulaValues(mrDoc, *mrItem.mpCellFormulaValues);
+ processSheetFormulaCells(mrDoc, mrItem, *mpFormatter);
}
};
@@ -345,36 +351,43 @@ void FormulaBuffer::finalizeImport()
for (SCTAB nTab = 0; nTab < nTabCount; ++nTab)
aSheetItems.push_back(getSheetItem(nTab));
- typedef rtl::Reference<WorkerThread> WorkerThreadRef;
- std::vector<WorkerThreadRef> aThreads;
- aThreads.reserve(nThreadCount);
-
std::vector<SheetItem>::iterator it = aSheetItems.begin(), itEnd = aSheetItems.end();
- // TODO: Right now we are spawning multiple threads all at once and block
- // on them all at once. Any more clever thread management would require
- // use of condition variables which our own osl thread framework seems to
- // lack.
- while (it != itEnd)
+ if (nThreadCount == 1)
+ {
+ for (; it != itEnd; ++it)
+ processSheetFormulaCells(rDoc, *it, *rDoc.getDoc().GetFormatTable());
+ }
+ else
{
- for (size_t i = 0; i < nThreadCount; ++i)
+ typedef rtl::Reference<WorkerThread> WorkerThreadRef;
+ std::vector<WorkerThreadRef> aThreads;
+ aThreads.reserve(nThreadCount);
+ // TODO: Right now we are spawning multiple threads all at once and block
+ // on them all at once. Any more clever thread management would require
+ // use of condition variables which our own osl thread framework seems to
+ // lack.
+ while (it != itEnd)
{
- if (it == itEnd)
- break;
+ for (size_t i = 0; i < nThreadCount; ++i)
+ {
+ if (it == itEnd)
+ break;
- WorkerThreadRef xThread(new WorkerThread(rDoc, *it, rDoc.getDoc().CreateFormatTable()));
- ++it;
- aThreads.push_back(xThread);
- xThread->launch();
- }
+ WorkerThreadRef xThread(new WorkerThread(rDoc, *it, rDoc.getDoc().CreateFormatTable()));
+ ++it;
+ aThreads.push_back(xThread);
+ xThread->launch();
+ }
- for (size_t i = 0, n = aThreads.size(); i < n; ++i)
- {
- if (aThreads[i].is())
- aThreads[i]->join();
- }
+ for (size_t i = 0, n = aThreads.size(); i < n; ++i)
+ {
+ if (aThreads[i].is())
+ aThreads[i]->join();
+ }
- aThreads.clear();
+ aThreads.clear();
+ }
}
rDoc.getDoc().SetAutoNameCache(NULL);