[Libreoffice-commits] core.git: sc/inc sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Tue Nov 18 09:39:38 PST 2014
sc/inc/column.hxx | 3 +--
sc/inc/table.hxx | 11 +++++++----
sc/source/core/data/column3.cxx | 31 ++++++++-----------------------
sc/source/core/data/documen2.cxx | 19 +++++++++++--------
sc/source/core/data/documen7.cxx | 3 ++-
sc/source/core/data/document.cxx | 24 +++++++-----------------
sc/source/core/data/table2.cxx | 10 ++--------
7 files changed, 38 insertions(+), 63 deletions(-)
New commits:
commit 746e20f8c6d819fa128417a4db815b2473278291
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Tue Nov 18 12:35:39 2014 -0500
Combine StartAllListeners() and StartNeededListeners()...
And call the new method StartListeners(). This also adjusts what was
previously StartAllListener() to be group-listener aware.
Change-Id: I74de45c00f5b8ef232eea9fe3b93aa44d1d8855b
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index b276533..5981c00 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -489,8 +489,7 @@ public:
void EndListening( SvtListener& rLst, SCROW nRow );
void StartListening( sc::StartListeningContext& rCxt, SCROW nRow, SvtListener& rListener );
void EndListening( sc::EndListeningContext& rCxt, SCROW nRow, SvtListener& rListener );
- void StartAllListeners();
- void StartNeededListeners( sc::StartListeningContext& rCxt ); // only for cells where NeedsListening()==true
+ void StartListeners( sc::StartListeningContext& rCxt, bool bAll );
void SetDirtyIfPostponed();
void BroadcastRecalcOnRefMove();
void TransferListeners( ScColumn& rDestCol, SCROW nRow1, SCROW nRow2, SCROW nRowDelta );
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 074b5d08..02a88ef 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -913,10 +913,14 @@ public:
void SetFormulaResults( SCCOL nCol, SCROW nRow, const formula::FormulaTokenRef* pResults, size_t nLen );
/**
- * Have formula cells with NeedsListening() == true start listening to the
- * document.
+ * Either start all formula cells as listeners unconditionally, or start
+ * those that are marked "needs listening".
+ *
+ * @param rCxt context object.
+ * @param bAll when true, start all formula cells as listeners. When
+ * false, only start those that are marked "needs listening".
*/
- void StartNeededListeners( sc::StartListeningContext& rCxt );
+ void StartListeners( sc::StartListeningContext& rCxt, bool bAll );
/**
* Mark formula cells dirty that have the mbPostponedDirty flag set or
@@ -1070,7 +1074,6 @@ private:
void EndListening( const ScAddress& rAddress, SvtListener* pListener );
void StartListening( sc::StartListeningContext& rCxt, SCCOL nCol, SCROW nRow, SvtListener& rListener );
void EndListening( sc::EndListeningContext& rCxt, SCCOL nCol, SCROW nRow, SvtListener& rListener );
- void StartAllListeners();
void AttachFormulaCells( sc::StartListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
void DetachFormulaCells( sc::EndListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 86ca776..150d609 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1500,23 +1500,14 @@ ScAttrIterator* ScColumn::CreateAttrIterator( SCROW nStartRow, SCROW nEndRow ) c
namespace {
-class StartAllListenersHandler
-{
- ScDocument* mpDoc;
-public:
- StartAllListenersHandler(ScDocument* pDoc) : mpDoc(pDoc) {}
-
- void operator() (size_t, ScFormulaCell* p)
- {
- p->StartListeningTo(mpDoc);
- }
-};
-
-class StartNeededListenersHandler
+class StartListenersHandler
{
sc::StartListeningContext* mpCxt;
+ bool mbAllListeners;
+
public:
- StartNeededListenersHandler( sc::StartListeningContext& rCxt ) : mpCxt(&rCxt) {}
+ StartListenersHandler( sc::StartListeningContext& rCxt, bool bAllListeners ) :
+ mpCxt(&rCxt), mbAllListeners(bAllListeners) {}
void operator() ( sc::CellStoreType::value_type& aBlk )
{
@@ -1529,7 +1520,7 @@ public:
for (; pp != ppEnd; ++pp)
{
ScFormulaCell& rFC = **pp;
- if (!rFC.NeedsListening())
+ if (!mbAllListeners && !rFC.NeedsListening())
continue;
if (rFC.IsSharedTop())
@@ -1545,15 +1536,9 @@ public:
}
-void ScColumn::StartAllListeners()
-{
- StartAllListenersHandler aFunc(pDocument);
- sc::ProcessFormula(maCells, aFunc);
-}
-
-void ScColumn::StartNeededListeners( sc::StartListeningContext& rCxt )
+void ScColumn::StartListeners( sc::StartListeningContext& rCxt, bool bAll )
{
- std::for_each(maCells.begin(), maCells.end(), StartNeededListenersHandler(rCxt));
+ std::for_each(maCells.begin(), maCells.end(), StartListenersHandler(rCxt, bAll));
}
namespace {
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 8938925..bfa78cb 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -99,6 +99,7 @@
#include "interpre.hxx"
#include <tokenstringcontext.hxx>
#include "docsh.hxx"
+#include <listenercontext.hxx>
using namespace com::sun::star;
@@ -765,10 +766,8 @@ bool ScDocument::MoveTab( SCTAB nOldPos, SCTAB nNewPos, ScProgress* pProgress )
if (*it)
(*it)->UpdateCompile();
SetNoListening( false );
- it = maTabs.begin();
- for (; it != maTabs.end(); ++it)
- if (*it)
- (*it)->StartAllListeners();
+ StartAllListeners();
+
// sheet names of references may not be valid until sheet is moved
pChartListenerCollection->UpdateScheduledSeriesRanges();
@@ -806,6 +805,7 @@ bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyM
sc::AutoCalcSwitch aACSwitch(*this, false);
sc::RefUpdateInsertTabContext aCxt(nNewPos, 1);
+ sc::StartListeningContext aSLCxt(*this);
if (bValid)
{
@@ -854,7 +854,7 @@ bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyM
SetNoListening( false );
for (TableContainer::iterator it = maTabs.begin(); it != maTabs.end(); ++it)
if (*it && it != maTabs.begin()+nOldPos && it != maTabs.begin()+nNewPos)
- (*it)->StartAllListeners();
+ (*it)->StartListeners(aSLCxt, true);
if (pValidationList)
pValidationList->UpdateInsertTab(aCxt);
@@ -889,8 +889,8 @@ bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyM
maTabs[nOldPos]->UpdateCompile();
maTabs[nNewPos]->UpdateCompile( true ); // maybe already compiled in Clone, but used names need recompilation
SetNoListening( false );
- maTabs[nOldPos]->StartAllListeners();
- maTabs[nNewPos]->StartAllListeners();
+ maTabs[nOldPos]->StartListeners(aSLCxt, true);
+ maTabs[nNewPos]->StartListeners(aSLCxt, true);
sc::SetFormulaDirtyContext aFormulaDirtyCxt;
SetAllFormulasDirty(aFormulaDirtyCxt);
@@ -1000,7 +1000,10 @@ sal_uLong ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
SetNoListening( false );
if ( !bResultsOnly )
- maTabs[nDestPos]->StartAllListeners();
+ {
+ sc::StartListeningContext aSLCxt(*this);
+ maTabs[nDestPos]->StartListeners(aSLCxt, true);
+ }
SetDirty( ScRange( 0, 0, nDestPos, MAXCOL, MAXROW, nDestPos));
if ( bResultsOnly )
diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx
index b7bdf30..6429fa5 100644
--- a/sc/source/core/data/documen7.cxx
+++ b/sc/source/core/data/documen7.cxx
@@ -620,9 +620,10 @@ void ScDocument::TrackFormulas( sal_uLong nHintId )
void ScDocument::StartAllListeners()
{
+ sc::StartListeningContext aCxt(*this);
for ( SCTAB i = 0; i < static_cast<SCTAB>(maTabs.size()); ++i )
if ( maTabs[i] )
- maTabs[i]->StartAllListeners();
+ maTabs[i]->StartListeners(aCxt, true);
}
void ScDocument::UpdateBroadcastAreas( UpdateRefMode eUpdateRefMode,
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index fb6e240..204fed3 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -530,10 +530,8 @@ bool ScDocument::InsertTab(
for (; it != maTabs.end(); ++it)
if ( *it )
(*it)->UpdateCompile();
- it = maTabs.begin();
- for (; it != maTabs.end(); ++it)
- if ( *it )
- (*it)->StartAllListeners();
+
+ StartAllListeners();
if (pValidationList)
pValidationList->UpdateInsertTab(aCxt);
@@ -622,10 +620,8 @@ bool ScDocument::InsertTabs( SCTAB nPos, const std::vector<OUString>& rNames,
if ( *it )
(*it)->UpdateCompile();
}
- it = maTabs.begin();
- for (; it != maTabs.end(); ++it)
- if ( *it )
- (*it)->StartAllListeners();
+
+ StartAllListeners();
if (pValidationList)
pValidationList->UpdateInsertTab(aCxt);
@@ -717,10 +713,7 @@ bool ScDocument::DeleteTab( SCTAB nTab )
// only be triggered after the loading is done.
if ( !bInsertingFromOtherDoc )
{
- it = maTabs.begin();
- for (; it != maTabs.end(); ++it)
- if ( *it )
- (*it)->StartAllListeners();
+ StartAllListeners();
sc::SetFormulaDirtyContext aFormulaDirtyCxt;
SetAllFormulasDirty(aFormulaDirtyCxt);
@@ -807,10 +800,7 @@ bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets )
// only be triggered after the loading is done.
if ( !bInsertingFromOtherDoc )
{
- it = maTabs.begin();
- for (; it != maTabs.end(); ++it)
- if ( *it )
- (*it)->StartAllListeners();
+ StartAllListeners();
sc::SetFormulaDirtyContext aFormulaDirtyCxt;
SetAllFormulasDirty(aFormulaDirtyCxt);
@@ -1173,7 +1163,7 @@ public:
void operator() (ScTable* p)
{
if (p)
- p->StartNeededListeners(*mpCxt);
+ p->StartListeners(*mpCxt, false);
}
};
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index f1d2d50..6e339db 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1023,10 +1023,10 @@ const ScColumn* ScTable::FetchColumn( SCCOL nCol ) const
return &aCol[nCol];
}
-void ScTable::StartAllListeners()
+void ScTable::StartListeners( sc::StartListeningContext& rCxt, bool bAll )
{
for (SCCOL i=0; i<=MAXCOL; i++)
- aCol[i].StartAllListeners();
+ aCol[i].StartListeners(rCxt, bAll);
}
void ScTable::AttachFormulaCells(
@@ -1043,12 +1043,6 @@ void ScTable::DetachFormulaCells(
aCol[nCol].DetachFormulaCells(rCxt, nRow1, nRow2);
}
-void ScTable::StartNeededListeners( sc::StartListeningContext& rCxt )
-{
- for (SCCOL i=0; i<=MAXCOL; i++)
- aCol[i].StartNeededListeners(rCxt);
-}
-
void ScTable::SetDirtyFromClip(
SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, sc::ColumnSpanSet& rBroadcastSpans )
{
More information about the Libreoffice-commits
mailing list