[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:12:05 PDT 2013
sc/inc/column.hxx | 1 +
sc/qa/unit/ucalc.cxx | 14 ++++++++++++++
sc/source/core/data/column.cxx | 39 +++++++++++++++++++++++++++++++++++++--
3 files changed, 52 insertions(+), 2 deletions(-)
New commits:
commit 6fb61764dd4ac6c46e93628ae067c9e319314ee2
Author: Laurent Godard <lgodard.libre at laposte.net>
Date: Thu Oct 3 18:11:02 2013 +0200
ScColumn::UpdateNoteCaption() helper for moved cells
Change-Id: Iab5828ce5294e46a28303ac0fbd06f085c3e6a6b
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 00e6058..8969bedd 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -498,6 +498,7 @@ public:
void CopyCellNotesToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol, SCROW nRowOffsetDest=0) const;
void DuplicateNotes(SCROW nStartRow, size_t nDataSize, ScColumn& rDestCol, sc::ColumnBlockPosition& maDestBlockPos, SCROW nRowOffsetDest=0 ) const;
+ void UpdateNoteCaptions();
void InterpretDirtyCells( SCROW nRow1, SCROW nRow2 );
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 7dec2ac..24b47fd 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -3993,18 +3993,32 @@ void Test::testShiftCells()
// Text into cell E5.
m_pDoc->SetString(4, 3, 0, aTestVal);
+ // put a Note in cell E5
+ OUString aHello("Hello");
+ ScAddress rAddr(4, 3, 0);
+ ScPostIt* pNote = m_pDoc->GetOrCreateNote(rAddr);
+ pNote->SetText(rAddr, aHello);
+
+ CPPUNIT_ASSERT_MESSAGE("there should be a note", m_pDoc->HasNote(4, 3, 0));
+
// Insert cell at D5. This should shift the string cell to right.
m_pDoc->InsertCol(3, 0, 3, 0, 3, 1);
OUString aStr = m_pDoc->GetString(5, 3, 0);
CPPUNIT_ASSERT_MESSAGE("We should have a string cell here.", aStr == aTestVal);
CPPUNIT_ASSERT_MESSAGE("D5 is supposed to be blank.", m_pDoc->IsBlockEmpty(0, 3, 4, 3, 4));
+ CPPUNIT_ASSERT_MESSAGE("there should be NO note", !m_pDoc->HasNote(4, 3, 0));
+ CPPUNIT_ASSERT_MESSAGE("there should be a note", m_pDoc->HasNote(5, 3, 0));
+
// Delete cell D5, to shift the text cell back into D5.
m_pDoc->DeleteCol(3, 0, 3, 0, 3, 1);
aStr = m_pDoc->GetString(4, 3, 0);
CPPUNIT_ASSERT_MESSAGE("We should have a string cell here.", aStr == aTestVal);
CPPUNIT_ASSERT_MESSAGE("E5 is supposed to be blank.", m_pDoc->IsBlockEmpty(0, 4, 4, 4, 4));
+ CPPUNIT_ASSERT_MESSAGE("there should be NO note", !m_pDoc->HasNote(5, 3, 0));
+ CPPUNIT_ASSERT_MESSAGE("there should be a note", m_pDoc->HasNote(4, 3, 0));
+
m_pDoc->DeleteTab(0);
}
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 3de3fdb..dc75b99 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2183,12 +2183,44 @@ void resetColumnPosition(sc::CellStoreType& rCells, SCCOL nCol)
}
+void ScColumn::UpdateNoteCaptions()
+{
+ sc::CellNoteStoreType::const_iterator itBlk = maCellNotes.begin(), itBlkEnd = maCellNotes.end();
+ sc::cellnote_block::const_iterator itData, itDataEnd;
+
+ SCROW curRow = 0;
+ for (;itBlk==itBlkEnd;++itBlk)
+ {
+ if (itBlk->data)
+ {
+ // non empty block
+ itData = sc::cellnote_block::begin(*itBlk->data);
+ itDataEnd = sc::cellnote_block::end(*itBlk->data);
+ for(;itData==itDataEnd; ++itData)
+ {
+ ScPostIt* pNote = *itData;
+ pNote->UpdateCaptionPos(ScAddress(nCol, curRow, nTab));
+ curRow +=1;
+ }
+ }
+ else
+ {
+ // empty block
+ curRow += itBlk->size;
+ }
+ }
+}
+
void ScColumn::SwapCol(ScColumn& rCol)
{
maBroadcasters.swap(rCol.maBroadcasters);
maCells.swap(rCol.maCells);
maCellTextAttrs.swap(rCol.maCellTextAttrs);
- maCellNotes.swap(rCol.maCellNotes); // TODO : notes update caption ?
+ maCellNotes.swap(rCol.maCellNotes);
+
+ // notes update caption
+ UpdateNoteCaptions();
+ rCol.UpdateNoteCaptions();
ScAttrArray* pTempAttr = rCol.pAttrArray;
rCol.pAttrArray = pAttrArray;
@@ -2232,10 +2264,13 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol)
// Move the broadcasters to the destination column.
maBroadcasters.transfer(nStartRow, nEndRow, rCol.maBroadcasters, nStartRow);
- maCellNotes.transfer(nStartRow, nEndRow, rCol.maCellNotes, nStartRow); // TODO : notes - update caption ?
maCells.transfer(nStartRow, nEndRow, rCol.maCells, nStartRow);
maCellTextAttrs.transfer(nStartRow, nEndRow, rCol.maCellTextAttrs, nStartRow);
+ // move the notes to the destination column
+ maCellNotes.transfer(nStartRow, nEndRow, rCol.maCellNotes, nStartRow);
+ UpdateNoteCaptions();
+
// Re-group transferred formula cells.
aPos = rCol.maCells.position(nStartRow);
sc::SharedFormulaUtil::joinFormulaCellAbove(aPos);
More information about the Libreoffice-commits
mailing list