[Libreoffice-commits] core.git: Branch 'feature/sc-notes-storage' - sc/qa sc/source
Laurent Godard
lgodard.libre at laposte.net
Thu Oct 3 03:56:30 PDT 2013
sc/qa/unit/ucalc.cxx | 2 -
sc/source/core/data/column2.cxx | 41 +++++++++++++++++++++++++++++++++++-----
sc/source/core/data/column3.cxx | 11 ----------
3 files changed, 37 insertions(+), 17 deletions(-)
New commits:
commit 863c34d033d1e43aebe32445afdc4f0619cea292
Author: Laurent Godard <lgodard.libre at laposte.net>
Date: Thu Oct 3 12:55:24 2013 +0200
clone notes in CopyCellNotesToDocument
Change-Id: I804746be0ed74ff36fce5897fcb5d49ada0dfd1b
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index de49739..7dec2ac 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -3103,7 +3103,7 @@ void Test::testMoveBlock()
ScDocFunc& rDocFunc = getDocShell().GetDocFunc();
bool bMoveDone = rDocFunc.MoveBlock(ScRange(0, 0 ,0 ,2 ,0 ,0), ScAddress(1, 0, 0), bCut, false, false, false);
- std::cout << "B1 note after moveblock: " << m_pDoc->GetNote(aAddrB1)->GetText() << std::endl;
+ // std::cout << "B1 note after moveblock: " << m_pDoc->GetNote(aAddrB1)->GetText() << std::endl;
CPPUNIT_ASSERT_MESSAGE("Cells not moved", bMoveDone);
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 7c2c565..93887c7 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1616,9 +1616,12 @@ void ScColumn::CopyCellTextAttrsToDocument(SCROW nRow1, SCROW nRow2, ScColumn& r
}
}
-//void ScColumn::CopyCellNotesToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol) const
void ScColumn::CopyCellNotesToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol, SCROW nRowOffsetDest) const // TODO : notes promising factorisation
{
+
+ SCCOL nDestCol = rDestCol.GetCol();
+ SCTAB nDestTab = rDestCol.GetTab();
+
rDestCol.maCellNotes.set_empty(nRow1, nRow2); // Empty the destination range first.
sc::CellNoteStoreType::const_iterator itBlk = maCellNotes.begin(), itBlkEnd = maCellNotes.end();
@@ -1671,12 +1674,39 @@ void ScColumn::CopyCellNotesToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDest
size_t nOffset = nRowPos - nBlockStart + 1;
itDataEnd = sc::cellnote_block::begin(*itBlk->data);
std::advance(itDataEnd, nOffset);
- // TODO : notes need to duplicate notes
- rDestCol.maCellNotes.set(nBlockStart + nOffsetInBlock + nRowOffsetDest, itData, itDataEnd);
+ // need to clone notes
+ std::vector<ScPostIt*> vCloned;
+ vCloned.reserve(nOffset);
+ SCROW curRow = nBlockStart;
+ for (; itData != itDataEnd; ++itData, ++curRow)
+ {
+ ScPostIt* pSrcNote = *itData;
+ ScAddress aDestAddress = ScAddress(nDestCol, curRow + nRowOffsetDest, nDestTab);
+ ScAddress aSrcAddress = ScAddress(nCol, curRow, nTab );
+ ScPostIt* pClonedNote = pSrcNote->Clone(aSrcAddress, rDestCol.GetDoc(), aDestAddress, true );
+ vCloned.push_back(pClonedNote);
+ }
+
+ rDestCol.maCellNotes.set(nBlockStart + nOffsetInBlock + nRowOffsetDest, vCloned.begin(), vCloned.end());
+ // sc::CellNoteStoreType maDestCellNotes = rDestCol.GetCellNoteStore();
+ // maDestCellNotes.set(nBlockStart + nOffsetInBlock + nRowOffsetDest, vCloned.begin(), vCloned.end());
break;
}
- // TODO : notes need to duplicate notes
- rDestCol.maCellNotes.set(nBlockStart + nOffsetInBlock + nRowOffsetDest, itData, itDataEnd);
+ // need to clone notes
+ std::vector<ScPostIt*> vCloned;
+ vCloned.reserve(itBlk->size);
+ SCROW curRow = nBlockStart;
+ for (; itData != itDataEnd; ++itData, ++curRow)
+ {
+ ScPostIt* pSrcNote = *itData;
+ ScAddress aDestAddress = ScAddress(nDestCol, curRow + nRowOffsetDest, nDestTab);
+ ScAddress aSrcAddress = ScAddress(nCol, curRow, nTab );
+ ScPostIt* pClonedNote = pSrcNote->Clone(aSrcAddress, rDestCol.GetDoc(), aDestAddress, true );
+ vCloned.push_back(pClonedNote);
+ }
+ rDestCol.maCellNotes.set(nBlockStart + nOffsetInBlock + nRowOffsetDest, vCloned.begin(), vCloned.end());
+// sc::CellNoteStoreType maDestCellNotes = rDestCol.GetCellNoteStore();
+// maDestCellNotes.set(nBlockStart + nOffsetInBlock + nRowOffsetDest, vCloned.begin(), vCloned.end());
}
/*
@@ -1700,6 +1730,7 @@ void ScColumn::CopyCellNotesToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDest
void ScColumn::DuplicateNotes(SCROW nStartRow, size_t nDataSize, ScColumn& rDestCol, sc::ColumnBlockPosition& maDestBlockPos, SCROW nRowOffsetDest ) const
{
+
SCCOL nDestCol = rDestCol.GetCol(); // no more needed
SCTAB nDestTab = rDestCol.GetTab();
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 5c46c9b..a7dee56 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1633,8 +1633,6 @@ void ScColumn::SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, Edit
rBlockPos.miCellPos = maCells.set(rBlockPos.miCellPos, nRow, pEditText);
rBlockPos.miCellTextAttrPos = maCellTextAttrs.set(
rBlockPos.miCellTextAttrPos, nRow, sc::CellTextAttr());
-// ScPostIt* pPostIt;
-// rBlockPos.miCellNotePos = maCellNotes.set(rBlockPos.miCellNotePos, nRow, pPostIt);
CellStorageModified();
@@ -1769,9 +1767,6 @@ ScFormulaCell* ScColumn::SetFormulaCell( sc::ColumnBlockPosition& rBlockPos, SCR
rBlockPos.miCellPos = maCells.set(rBlockPos.miCellPos, nRow, pCell);
rBlockPos.miCellTextAttrPos = maCellTextAttrs.set(
rBlockPos.miCellTextAttrPos, nRow, sc::CellTextAttr());
-// ScPostIt* pPostIt;
-// rBlockPos.miCellNotePos = maCellNotes.set(
-// rBlockPos.miCellNotePos, nRow, pPostIt);
CellStorageModified();
@@ -2219,9 +2214,6 @@ void ScColumn::SetRawString(
rBlockPos.miCellPos = maCells.set(rBlockPos.miCellPos, nRow, rStr);
rBlockPos.miCellTextAttrPos = maCellTextAttrs.set(
rBlockPos.miCellTextAttrPos, nRow, sc::CellTextAttr());
-// ScPostIt* pPostIt;
-// rBlockPos.miCellNotePos = maCellNotes.set(
-// rBlockPos.miCellNotePos, nRow, pPostIt);
CellStorageModified();
@@ -2255,9 +2247,6 @@ void ScColumn::SetValue(
rBlockPos.miCellPos = maCells.set(rBlockPos.miCellPos, nRow, fVal);
rBlockPos.miCellTextAttrPos = maCellTextAttrs.set(
rBlockPos.miCellTextAttrPos, nRow, sc::CellTextAttr());
-// ScPostIt* pPostIt;
-// rBlockPos.miCellNotePos = maCellNotes.set(
-// rBlockPos.miCellNotePos, nRow, pPostIt);
CellStorageModified();
More information about the Libreoffice-commits
mailing list