[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - sc/inc sc/source
Eike Rathke
erack at redhat.com
Tue Apr 19 12:18:29 UTC 2016
sc/inc/columnset.hxx | 2 ++
sc/inc/document.hxx | 2 ++
sc/inc/listenercontext.hxx | 4 ++++
sc/source/core/data/columnset.cxx | 10 ++++++++++
sc/source/core/data/document.cxx | 12 ++++++++----
sc/source/core/data/document10.cxx | 10 ++++++++++
sc/source/core/data/listenercontext.cxx | 10 ++++++++++
sc/source/core/data/table2.cxx | 19 +++++++++++++++++--
8 files changed, 63 insertions(+), 6 deletions(-)
New commits:
commit 23acddd6e478eceff770846f0c0aabaa4c265016
Author: Eike Rathke <erack at redhat.com>
Date: Tue Apr 19 11:03:15 2016 +0200
call StartNeededListeners() only on affected columns, tdf#99322 follow-up
Iterating over the entire document is an unnecessary performancce
penalty if the set of affected columns is already known.
(cherry picked from commit 35abb3aacb4072171e8c580e1306e3c44e368646)
Conflicts:
sc/inc/document.hxx
sc: fix loplugin:passstuffbyref
(cherry picked from commit 7218011f134250a2ad3e03ff28d5665265c50605)
const as const can, tdf#99322 follow-up
(cherry picked from commit 2efd20c7a18fe5e864509c75443883ccf35bc3a4)
6716817b0ca439b63cc7b49eb7a611c2c15a9b00
8c9714e6c6b15fbb1068b79d2efae48927a1fa77
Change-Id: I84598066f878ca4615d6a5e1d6c70ebaa686e446
Reviewed-on: https://gerrit.libreoffice.org/24242
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/sc/inc/columnset.hxx b/sc/inc/columnset.hxx
index 3ee8fba..ddf08ba 100644
--- a/sc/inc/columnset.hxx
+++ b/sc/inc/columnset.hxx
@@ -30,6 +30,8 @@ class ColumnSet
public:
void set(SCTAB nTab, SCCOL nCol);
void getColumns(SCTAB nTab, std::vector<SCCOL>& rCols) const;
+ bool hasTab( SCTAB nTab ) const;
+ bool empty() const;
};
}
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 5fbd432..4cb2de4 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -80,6 +80,7 @@ struct SortUndoParam;
struct ReorderParam;
class FormulaGroupAreaListener;
class IconSetBitmapMap;
+class ColumnSet;
}
@@ -1959,6 +1960,7 @@ public:
void SetHardRecalcState( HardRecalcState eVal ) { eHardRecalcState = eVal; }
void StartAllListeners();
void StartNeededListeners();
+ void StartNeededListeners( const std::shared_ptr<const sc::ColumnSet>& rpColSet );
void StartAllListeners( const ScRange& rRange );
void SetForcedFormulas( bool bVal ) { bHasForcedFormulas = bVal; }
diff --git a/sc/inc/listenercontext.hxx b/sc/inc/listenercontext.hxx
index 0ecbd8b..491db5d 100644
--- a/sc/inc/listenercontext.hxx
+++ b/sc/inc/listenercontext.hxx
@@ -23,14 +23,18 @@ namespace sc {
struct ColumnBlockPosition;
class ColumnBlockPositionSet;
+class ColumnSet;
class StartListeningContext : boost::noncopyable
{
ScDocument& mrDoc;
std::shared_ptr<ColumnBlockPositionSet> mpSet;
+ std::shared_ptr<const ColumnSet> mpColSet;
public:
StartListeningContext(ScDocument& rDoc);
StartListeningContext(ScDocument& rDoc, const std::shared_ptr<ColumnBlockPositionSet>& pSet);
+ void setColumnSet( const std::shared_ptr<const ColumnSet>& pColSet );
+ const std::shared_ptr<const ColumnSet>& getColumnSet() const;
ScDocument& getDoc() { return mrDoc;}
ColumnBlockPosition* getBlockPosition(SCTAB nTab, SCCOL nCol);
diff --git a/sc/source/core/data/columnset.cxx b/sc/source/core/data/columnset.cxx
index 84935e5..1af1371 100644
--- a/sc/source/core/data/columnset.cxx
+++ b/sc/source/core/data/columnset.cxx
@@ -52,6 +52,16 @@ void ColumnSet::getColumns(SCTAB nTab, std::vector<SCCOL>& rCols) const
rCols.swap(aCols);
}
+bool ColumnSet::hasTab(SCTAB nTab) const
+{
+ return maTabs.find(nTab) != maTabs.end();
+}
+
+bool ColumnSet::empty() const
+{
+ return maTabs.empty();
+}
+
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 843de15..ca63d82 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -2598,10 +2598,14 @@ void ScDocument::CopyBlockFromClip(
// For URM_MOVE group listeners may have been removed,
// re-establish them.
- /* TODO: actually only those in
- * sc::RefUpdateContext::maRegroupCols are affected,
- * come up with a start listeners that takes such. */
- StartNeededListeners();
+ if (!aRefCxt.maRegroupCols.empty())
+ {
+ /* TODO: holding the ColumnSet in a shared_ptr at
+ * RefUpdateContext would eliminate the need of
+ * copying it here. */
+ std::shared_ptr<const sc::ColumnSet> pColSet( new sc::ColumnSet( aRefCxt.maRegroupCols));
+ StartNeededListeners( pColSet);
+ }
SetInsertingFromOtherDoc( bOldInserting);
}
diff --git a/sc/source/core/data/document10.cxx b/sc/source/core/data/document10.cxx
index d3303ed..8e1a54b 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -396,6 +396,11 @@ class StartNeededListenersHandler : std::unary_function<ScTable*, void>
std::shared_ptr<sc::StartListeningContext> mpCxt;
public:
explicit StartNeededListenersHandler( ScDocument& rDoc ) : mpCxt(new sc::StartListeningContext(rDoc)) {}
+ explicit StartNeededListenersHandler( ScDocument& rDoc, const std::shared_ptr<const sc::ColumnSet>& rpColSet ) :
+ mpCxt(new sc::StartListeningContext(rDoc))
+ {
+ mpCxt->setColumnSet( rpColSet);
+ }
void operator() (ScTable* p)
{
@@ -411,6 +416,11 @@ void ScDocument::StartNeededListeners()
std::for_each(maTabs.begin(), maTabs.end(), StartNeededListenersHandler(*this));
}
+void ScDocument::StartNeededListeners( const std::shared_ptr<const sc::ColumnSet>& rpColSet )
+{
+ std::for_each(maTabs.begin(), maTabs.end(), StartNeededListenersHandler(*this, rpColSet));
+}
+
void ScDocument::StartAllListeners( const ScRange& rRange )
{
std::shared_ptr<sc::ColumnBlockPositionSet> pPosSet(new sc::ColumnBlockPositionSet(*this));
diff --git a/sc/source/core/data/listenercontext.cxx b/sc/source/core/data/listenercontext.cxx
index 75010007..ad5e314 100644
--- a/sc/source/core/data/listenercontext.cxx
+++ b/sc/source/core/data/listenercontext.cxx
@@ -20,6 +20,16 @@ StartListeningContext::StartListeningContext(
ScDocument& rDoc, const std::shared_ptr<ColumnBlockPositionSet>& pSet) :
mrDoc(rDoc), mpSet(pSet) {}
+void StartListeningContext::setColumnSet( const std::shared_ptr<const ColumnSet>& rpColSet )
+{
+ mpColSet = rpColSet;
+}
+
+const std::shared_ptr<const ColumnSet>& StartListeningContext::getColumnSet() const
+{
+ return mpColSet;
+}
+
ColumnBlockPosition* StartListeningContext::getBlockPosition(SCTAB nTab, SCCOL nCol)
{
return mpSet->getBlockPosition(nTab, nCol);
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 24fde8a..453ba0a 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -53,6 +53,7 @@
#include "columnspanset.hxx"
#include <rowheightcontext.hxx>
#include <refhint.hxx>
+#include "listenercontext.hxx"
#include "scitems.hxx"
#include <editeng/boxitem.hxx>
@@ -1033,8 +1034,22 @@ const ScColumn* ScTable::FetchColumn( SCCOL nCol ) const
void ScTable::StartListeners( sc::StartListeningContext& rCxt, bool bAll )
{
- for (SCCOL i=0; i<=MAXCOL; i++)
- aCol[i].StartListeners(rCxt, bAll);
+ std::shared_ptr<const sc::ColumnSet> pColSet = rCxt.getColumnSet();
+ if (!pColSet)
+ {
+ for (SCCOL i=0; i<=MAXCOL; i++)
+ aCol[i].StartListeners(rCxt, bAll);
+ }
+ else if (pColSet->hasTab( nTab))
+ {
+ std::vector<SCCOL> aColumns;
+ pColSet->getColumns( nTab, aColumns);
+ for (auto i : aColumns)
+ {
+ if (0 <= i && i <= MAXCOL)
+ aCol[i].StartListeners(rCxt, bAll);
+ }
+ }
}
void ScTable::AttachFormulaCells(
More information about the Libreoffice-commits
mailing list