From 12aa3151ab993fff1ae312ae7b1d5bbcfc379b07 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Sun, 24 Nov 2013 21:22:20 +0100 Subject: 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 --- sc/source/core/data/document.cxx | 16 ++++++++++++++++ sc/source/core/data/table2.cxx | 14 ++++++++++++++ 2 files changed, 30 insertions(+) (limited to 'sc/source/core/data') diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 80696e4bd0ed..708300e72a88 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -6226,6 +6226,22 @@ void ScDocument::GetAllNoteEntries( std::vector& 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 29e10c90d09f..c0d41d1ae6cf 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -1516,6 +1516,20 @@ void ScTable::GetAllNoteEntries( std::vector& 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 )) -- cgit v1.2.3