[Libreoffice-commits] core.git: sc/inc sc/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Sun Nov 24 12:25:05 PST 2013
sc/inc/document.hxx | 1 +
sc/inc/table.hxx | 1 +
sc/source/core/data/document.cxx | 16 ++++++++++++++++
sc/source/core/data/table2.cxx | 14 ++++++++++++++
sc/source/ui/view/cellsh.cxx | 17 +----------------
5 files changed, 33 insertions(+), 16 deletions(-)
New commits:
commit 288be67406110dc5e0f957d79fcf775076ee513c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun Nov 24 21:22:20 2013 +0100
checking every cell on a sheet is expensive, related fdo#71934
This is only the first of two places that does this.
Change-Id: I57fe1eb07630ecd86b112e88b7ad32c16e9f793a
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 49fd571..b9e3dc3 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -909,6 +909,7 @@ public:
SCROW GetNotePosition( SCTAB nTab, SCCOL nCol, size_t nIndex ) const;
SC_DLLPUBLIC void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const;
+ bool ContainsNotesInRange( const ScRangeList& rRange ) const;
SC_DLLPUBLIC void SetDrawPageSize(SCTAB nTab);
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 8eb75be..5938dcb 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -382,6 +382,7 @@ public:
SCROW GetNotePosition( SCCOL nCol, size_t nIndex ) const;
void GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const;
+ bool ContainsNotesInRange( const ScRange& rRange ) const;
bool TestInsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize ) const;
void InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE nSize );
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 80696e4..708300e 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -6226,6 +6226,22 @@ void ScDocument::GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const
}
}
+bool ScDocument::ContainsNotesInRange( const ScRangeList& rRange ) const
+{
+ for( size_t i = 0; i < rRange.size(); ++i)
+ {
+ const ScRange* pRange = rRange[i];
+ for( SCTAB nTab = pRange->aStart.Tab(); nTab < pRange->aEnd.Tab(); ++nTab )
+ {
+ bool bContainsNote = maTabs[nTab]->ContainsNotesInRange( *pRange );
+ if(bContainsNote)
+ return true;
+ }
+ }
+
+ return false;
+}
+
void ScDocument::SetAutoNameCache( ScAutoNameCache* pCache )
{
delete pAutoNameCache;
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 29e10c9..c0d41d1 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1516,6 +1516,20 @@ void ScTable::GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const
aCol[nCol].GetAllNoteEntries(rNotes);
}
+bool ScTable::ContainsNotesInRange( const ScRange& rRange ) const
+{
+ SCROW nStartRow = rRange.aStart.Row();
+ SCROW nEndRow = rRange.aEnd.Row();
+ for (SCCOL nCol = rRange.aStart.Col(); nCol <= rRange.aEnd.Col(); ++nCol)
+ {
+ bool bContainsNote = !aCol[nCol].IsNotesEmptyBlock(nStartRow, nEndRow);
+ if(bContainsNote)
+ return true;
+ }
+
+ return false;
+}
+
CellType ScTable::GetCellType( SCCOL nCol, SCROW nRow ) const
{
if (ValidColRow( nCol, nRow ))
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx
index 943379f..8895f96 100644
--- a/sc/source/ui/view/cellsh.cxx
+++ b/sc/source/ui/view/cellsh.cxx
@@ -979,22 +979,7 @@ void ScCellShell::GetState(SfxItemSet &rSet)
// look for at least one note in selection
ScRangeList aRanges;
rMark.FillRangeListWithMarks( &aRanges, false );
- size_t nCount = aRanges.size();
- for (size_t nPos = 0; nPos < nCount && !bEnable; ++nPos)
- {
- SCTAB aTab = aRanges[nPos]->aStart.Tab();
- for (SCCOL aCol=aRanges[nPos]->aStart.Col(); aCol <= aRanges[nPos]->aEnd.Col() && !bEnable; aCol++)
- {
- for (SCROW aRow=aRanges[nPos]->aStart.Row(); aRow <= aRanges[nPos]->aEnd.Row(); aRow++)
- {
- if (pDoc->HasNote(aCol, aRow, aTab))
- {
- bEnable = true;
- break;
- }
- }
- }
- }
+ bEnable = pDoc->ContainsNotesInRange( aRanges );
}
}
else
More information about the Libreoffice-commits
mailing list