[Libreoffice-commits] core.git: Branch 'private/kohei/xlsx-import-speedup' - 3 commits - sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Sat Nov 2 01:26:40 CET 2013
sc/source/core/data/documentimport.cxx | 57 +++++++++++++++++++++------------
sc/source/filter/orcus/interface.cxx | 2 -
sc/source/filter/xml/xmlcelli.cxx | 3 -
3 files changed, 37 insertions(+), 25 deletions(-)
New commits:
commit 7db26c533be55fbe2c9ffe8246939ae8aadbad31
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Fri Nov 1 20:23:18 2013 -0400
Use position hints for broadcasters when activating formula cells.
No reason not to do this since we are bulk-registering formula cells.
Change-Id: Ie0356c62a3c4698f5560272cb0c104f84cacde56
diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx
index f52eb38..3b33f46 100644
--- a/sc/source/core/data/documentimport.cxx
+++ b/sc/source/core/data/documentimport.cxx
@@ -19,16 +19,22 @@
#include "stringutil.hxx"
#include "compiler.hxx"
#include "paramisc.hxx"
+#include "listenercontext.hxx"
#include "svl/sharedstringpool.hxx"
struct ScDocumentImportImpl
{
ScDocument& mrDoc;
+ sc::StartListeningContext maListenCxt;
sc::ColumnBlockPositionSet maBlockPosSet;
sal_uInt16 mnDefaultScriptNumeric;
- ScDocumentImportImpl(ScDocument& rDoc) : mrDoc(rDoc), maBlockPosSet(rDoc), mnDefaultScriptNumeric(SC_SCRIPTTYPE_UNKNOWN) {}
+ ScDocumentImportImpl(ScDocument& rDoc) :
+ mrDoc(rDoc),
+ maListenCxt(rDoc),
+ maBlockPosSet(rDoc),
+ mnDefaultScriptNumeric(SC_SCRIPTTYPE_UNKNOWN) {}
};
ScDocumentImport::ScDocumentImport(ScDocument& rDoc) : mpImpl(new ScDocumentImportImpl(rDoc)) {}
@@ -398,13 +404,15 @@ namespace {
class CellStoreInitializer
{
ScDocument& mrDoc;
+ sc::StartListeningContext& mrListenCxt;
sc::CellTextAttrStoreType maAttrs;
sc::CellTextAttrStoreType::iterator miPos;
sal_uInt16 mnScriptNumeric;
public:
- CellStoreInitializer(ScDocument& rDoc, sal_uInt16 nScriptNumeric) :
+ CellStoreInitializer(ScDocument& rDoc, sc::StartListeningContext& rCxt, sal_uInt16 nScriptNumeric) :
mrDoc(rDoc),
+ mrListenCxt(rCxt),
maAttrs(MAXROWCOUNT),
miPos(maAttrs.begin()),
mnScriptNumeric(nScriptNumeric) {}
@@ -429,7 +437,7 @@ public:
for (; it != itEnd; ++it)
{
ScFormulaCell& rFC = **it;
- rFC.StartListeningTo(&mrDoc);
+ rFC.StartListeningTo(mrListenCxt);
}
}
}
@@ -444,7 +452,8 @@ public:
void ScDocumentImport::finalize()
{
- // Populate the text width and script type arrays in all columns.
+ // Populate the text width and script type arrays in all columns. Also
+ // activate all formula cells.
ScDocument::TableContainer::iterator itTab = mpImpl->mrDoc.maTabs.begin(), itTabEnd = mpImpl->mrDoc.maTabs.end();
for (; itTab != itTabEnd; ++itTab)
{
@@ -461,7 +470,7 @@ void ScDocumentImport::finalize()
void ScDocumentImport::initColumn(ScColumn& rCol)
{
- CellStoreInitializer aFunc(mpImpl->mrDoc, mpImpl->mnDefaultScriptNumeric);
+ CellStoreInitializer aFunc(mpImpl->mrDoc, mpImpl->maListenCxt, mpImpl->mnDefaultScriptNumeric);
std::for_each(rCol.maCells.begin(), rCol.maCells.end(), aFunc);
aFunc.swap(rCol.maCellTextAttrs);
rCol.RegroupFormulaCells();
commit 4b040c2f0923808e81dba576c942db744d500078
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Fri Nov 1 20:14:12 2013 -0400
No point using the pimpl pattern here.
The whole class is already hidden in the source file.
Change-Id: Ib6157ae275217a95586735f74beee1700041a679
diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx
index c2b951a..f52eb38 100644
--- a/sc/source/core/data/documentimport.cxx
+++ b/sc/source/core/data/documentimport.cxx
@@ -397,23 +397,17 @@ namespace {
class CellStoreInitializer
{
- struct Impl
- {
- sc::CellTextAttrStoreType maAttrs;
- sc::CellTextAttrStoreType::iterator miPos;
- sal_uInt16 mnScriptNumeric;
-
- Impl(const sal_uInt32 nMaxRowCount, const sal_uInt16 nScriptNumeric)
- : maAttrs(nMaxRowCount), miPos(maAttrs.begin()), mnScriptNumeric(nScriptNumeric)
- {}
- };
-
ScDocument& mrDoc;
- boost::shared_ptr<Impl> mpImpl;
+ sc::CellTextAttrStoreType maAttrs;
+ sc::CellTextAttrStoreType::iterator miPos;
+ sal_uInt16 mnScriptNumeric;
public:
CellStoreInitializer(ScDocument& rDoc, sal_uInt16 nScriptNumeric) :
- mrDoc(rDoc), mpImpl(new Impl(MAXROWCOUNT, nScriptNumeric)) {}
+ mrDoc(rDoc),
+ maAttrs(MAXROWCOUNT),
+ miPos(maAttrs.begin()),
+ mnScriptNumeric(nScriptNumeric) {}
void operator() (const sc::CellStoreType::value_type& node)
{
@@ -423,9 +417,9 @@ public:
// Fill with default values for non-empty cell segments.
sc::CellTextAttr aDefault;
if (node.type == sc::element_type_numeric)
- aDefault.mnScriptType = mpImpl->mnScriptNumeric;
+ aDefault.mnScriptType = mnScriptNumeric;
std::vector<sc::CellTextAttr> aDefaults(node.size, aDefault);
- mpImpl->miPos = mpImpl->maAttrs.set(mpImpl->miPos, node.position, aDefaults.begin(), aDefaults.end());
+ miPos = maAttrs.set(miPos, node.position, aDefaults.begin(), aDefaults.end());
if (node.type == sc::element_type_formula)
{
@@ -442,7 +436,7 @@ public:
void swap(sc::CellTextAttrStoreType& rAttrs)
{
- mpImpl->maAttrs.swap(rAttrs);
+ maAttrs.swap(rAttrs);
}
};
commit 30bf8451129ead432d1c956fd1c225b736e9bca6
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Fri Nov 1 20:09:57 2013 -0400
Have all formula cells start listening at once after the file load.
Rather than doing it individually.
Change-Id: I5ed55947b715bf6d7d61a1f8b751be7fdcf425fb
diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx
index 323ccfb..c2b951a 100644
--- a/sc/source/core/data/documentimport.cxx
+++ b/sc/source/core/data/documentimport.cxx
@@ -395,7 +395,7 @@ void ScDocumentImport::setTableOpCells(const ScRange& rRange, const ScTabOpParam
namespace {
-class CellTextAttrInitializer
+class CellStoreInitializer
{
struct Impl
{
@@ -408,10 +408,12 @@ class CellTextAttrInitializer
{}
};
+ ScDocument& mrDoc;
boost::shared_ptr<Impl> mpImpl;
public:
- CellTextAttrInitializer(sal_uInt16 nScriptNumeric) : mpImpl(new Impl(MAXROWCOUNT, nScriptNumeric)) {}
+ CellStoreInitializer(ScDocument& rDoc, sal_uInt16 nScriptNumeric) :
+ mrDoc(rDoc), mpImpl(new Impl(MAXROWCOUNT, nScriptNumeric)) {}
void operator() (const sc::CellStoreType::value_type& node)
{
@@ -424,6 +426,18 @@ public:
aDefault.mnScriptType = mpImpl->mnScriptNumeric;
std::vector<sc::CellTextAttr> aDefaults(node.size, aDefault);
mpImpl->miPos = mpImpl->maAttrs.set(mpImpl->miPos, node.position, aDefaults.begin(), aDefaults.end());
+
+ if (node.type == sc::element_type_formula)
+ {
+ // Have all formula cells start listening to the document.
+ sc::formula_block::iterator it = sc::formula_block::begin(*node.data);
+ sc::formula_block::iterator itEnd = sc::formula_block::end(*node.data);
+ for (; it != itEnd; ++it)
+ {
+ ScFormulaCell& rFC = **it;
+ rFC.StartListeningTo(&mrDoc);
+ }
+ }
}
void swap(sc::CellTextAttrStoreType& rAttrs)
@@ -453,7 +467,7 @@ void ScDocumentImport::finalize()
void ScDocumentImport::initColumn(ScColumn& rCol)
{
- CellTextAttrInitializer aFunc(mpImpl->mnDefaultScriptNumeric);
+ CellStoreInitializer aFunc(mpImpl->mrDoc, mpImpl->mnDefaultScriptNumeric);
std::for_each(rCol.maCells.begin(), rCol.maCells.end(), aFunc);
aFunc.swap(rCol.maCellTextAttrs);
rCol.RegroupFormulaCells();
diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx
index df2da17..1372d775 100644
--- a/sc/source/filter/orcus/interface.cxx
+++ b/sc/source/filter/orcus/interface.cxx
@@ -364,7 +364,6 @@ void ScOrcusSheet::set_shared_formula(
// For now, orcus doesn't support setting cached result. Mark it for re-calculation.
pCell->SetDirty(true);
- pCell->StartListeningTo(&mrDoc.getDoc());
}
void ScOrcusSheet::set_shared_formula(
@@ -388,7 +387,6 @@ void ScOrcusSheet::set_shared_formula(os::row_t row, os::col_t col, size_t sinde
// For now, orcus doesn't support setting cached result. Mark it for re-calculation.
pCell->SetDirty(true);
- pCell->StartListeningTo(&mrDoc.getDoc());
}
void ScOrcusSheet::set_array_formula(
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 31e5bea9..a3f3a0f0 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -1027,7 +1027,6 @@ void ScXMLTableRowCellContext::SetFormulaCell(ScFormulaCell* pFCell) const
pFCell->SetHybridDouble(fValue);
pFCell->ResetDirty();
}
- pFCell->StartListeningTo(rXMLImport.GetDocument());
}
}
@@ -1075,7 +1074,6 @@ void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos,
SAL_WARN("sc", "matrix cell without matrix");
}
}
- pFCell->StartListeningTo(rXMLImport.GetDocument());
}
}
else //regular text cells
@@ -1437,7 +1435,6 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos )
nMatrixCols, nMatrixRows, pMat, new formula::FormulaDoubleToken(fValue));
pFCell->ResetDirty();
}
- pFCell->StartListeningTo(rXMLImport.GetDocument());
}
}
else
More information about the Libreoffice-commits
mailing list