[Libreoffice-commits] core.git: Branch 'feature/sc-notes-storage' - sc/inc sc/qa sc/source
Laurent Godard
lgodard.libre at laposte.net
Thu Oct 3 09:49:35 PDT 2013
sc/inc/column.hxx | 1 +
sc/qa/unit/ucalc.cxx | 6 ++++++
sc/source/core/data/column2.cxx | 17 +++++++++++++++++
sc/source/core/data/table2.cxx | 11 +----------
4 files changed, 25 insertions(+), 10 deletions(-)
New commits:
commit 6ae7bdb173adcd7e4640786023d7ffb926a452cb
Author: Laurent Godard <lgodard.libre at laposte.net>
Date: Thu Oct 3 18:48:35 2013 +0200
IsNotesEmptyBlock() helper function
Change-Id: I91af7359dd412ae9f885d4c36e013f6de7454e4b
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 8969bedd..38808b1 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -492,6 +492,7 @@ public:
void DeleteCellNote( SCROW nRow );
bool HasCellNotes() const;
void SetCellNote( SCROW nRow, ScPostIt* pNote);
+ bool IsNotesEmptyBlock(SCROW nStartRow, SCROW nEndRow) const;
SCROW GetCellNotesMaxRow() const;
SCROW GetCellNotesMinRow() const;
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 24b47fd..250e5aa 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -4037,6 +4037,12 @@ void Test::testNoteDeleteRow()
CPPUNIT_ASSERT_MESSAGE("there should be a note", pDoc->HasNote(1, 1, 0));
+ // test with IsBlockEmpty
+ bool bIgnoreNotes = true;
+ CPPUNIT_ASSERT_MESSAGE("The Block should be detected as empty (no Notes)", pDoc->IsBlockEmpty(0, 0, 0, 100, 100, bIgnoreNotes));
+ bIgnoreNotes = false;
+ CPPUNIT_ASSERT_MESSAGE("The Block should NOT be detected as empty", !pDoc->IsBlockEmpty(0, 0, 0, 100, 100, bIgnoreNotes));
+
pDoc->DeleteRow(0, 0, MAXCOL, 0, 1, 1);
CPPUNIT_ASSERT_MESSAGE("there should be no more note", !pDoc->HasNote(1, 1, 0));
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 292bf64..cc845cf 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1189,6 +1189,23 @@ bool ScColumn::IsEmptyBlock(SCROW nStartRow, SCROW nEndRow) const
return nEndRow < nNextRow;
}
+bool ScColumn::IsNotesEmptyBlock(SCROW nStartRow, SCROW nEndRow) const
+{
+ std::pair<sc::CellNoteStoreType::const_iterator,size_t> aPos = maCellNotes.position(nStartRow);
+ sc::CellNoteStoreType::const_iterator it = aPos.first;
+ if (it == maCellNotes.end())
+ // Invalid row number.
+ return false;
+
+ if (it->type != sc::element_type_empty)
+ // Non-empty cell at the start position.
+ return false;
+
+ // start position of next block which is not empty.
+ SCROW nNextRow = nStartRow + it->size - aPos.second;
+ return nEndRow < nNextRow;
+}
+
SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirection eDir ) const
{
// Given a range of rows, find a top or bottom empty segment.
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 433f61d..43a43d1 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1783,16 +1783,7 @@ bool ScTable::IsBlockEmpty( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
bEmpty = aCol[i].IsEmptyBlock( nRow1, nRow2 );
if (!bIgnoreNotes && bEmpty)
{
- if ( pDocument->HasColNotes(i, nTab) )
- {
- sc::CellNoteStoreType& maCellNotes = pDocument->GetColNotes(i, nTab);
- for (SCROW nRow=nRow1; nRow <= nRow2 && bEmpty; nRow++) // TODO : notes suboptimal ?
- {
- ScPostIt* pNote = maCellNotes.get<ScPostIt*>(nRow);
- if (pNote)
- bEmpty = false;
- }
- }
+ bEmpty = aCol[i].IsNotesEmptyBlock(nRow1, nRow2);
}
}
return bEmpty;
More information about the Libreoffice-commits
mailing list