sc/qa/unit/ucalc.cxx | 53 ++++++++++++++++++++++++++++++++++++++ sc/qa/unit/ucalc.hxx | 2 + sc/source/core/data/column.cxx | 9 ++++-- sc/source/ui/docshell/docfunc.cxx | 18 +++++------- 4 files changed, 68 insertions(+), 14 deletions(-)
New commits: commit 6ce4e50fe452ded99dac075eeaacc7ac03daf383 Author: Laurent Godard <lgodard.li...@laposte.net> Date: Mon Sep 23 18:08:42 2013 +0200 transport attached notes when moving a block of cell Change-Id: I608be1197cf4177aa67870ff34b61cf1fd67204c diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index fb0d07f..de928da 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -3067,6 +3067,59 @@ void Test::testCopyPasteTranspose() m_pDoc->DeleteTab(0); } +void Test::testMoveBlock() +{ + m_pDoc->InsertTab(0, "Sheet1"); + + m_pDoc->SetValue(0, 0, 0, 1); + m_pDoc->SetString(1, 0, 0, OUString("=A1+1")); + m_pDoc->SetString(2, 0, 0, OUString("test")); + + // add notes to A1:C1 + ScAddress aAdrA1 (0, 0, 0); // numerical cell content + OUString aHelloA1("Hello world in A1"); + ScPostIt *pNoteA1 = m_pDoc->GetOrCreateNote(aAdrA1); + pNoteA1->SetText(aAdrA1, aHelloA1); + ScAddress aAdrB1 (1, 0, 0); // formula cell content + OUString aHelloB1("Hello world in B1"); + ScPostIt *pNoteB1 = m_pDoc->GetOrCreateNote(aAdrB1); + pNoteB1->SetText(aAdrB1, aHelloB1); + ScAddress aAdrC1 (2, 0, 0); // string cell content + OUString aHelloC1("Hello world in C1"); + ScPostIt *pNoteC1 = m_pDoc->GetOrCreateNote(aAdrC1); + pNoteC1->SetText(aAdrC1, aHelloC1); + + // move notes to B1:D1 + bool bCut = true; + ScDocFunc& rDocFunc = getDocShell().GetDocFunc(); + bool bMoveDone = rDocFunc.MoveBlock(ScRange(0,0,0,2,0,0), ScAddress( 1, 0, 0), bCut, false, false, false); + + CPPUNIT_ASSERT_MESSAGE("Cells not moved", bMoveDone); + + //check cell content + OUString aString = m_pDoc->GetString(3, 0, 0); + CPPUNIT_ASSERT_MESSAGE("Cell D1 should contain: test", aString.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("test"))); + m_pDoc->GetFormula(2, 0, 0, aString); + CPPUNIT_ASSERT_MESSAGE("Cell C1 should contain an updated formula", aString.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("=B1+1"))); + double fValue = m_pDoc->GetValue(ScAddress(1, 0, 0)); + ASSERT_DOUBLES_EQUAL_MESSAGE("Cell B1 should contain 1", fValue, 1); + + // cell notes has been moved 1 cell right (event when overlapping) + CPPUNIT_ASSERT_MESSAGE("There should be NO note on A1", !m_pDoc->HasNote(ScAddress(0, 0, 0))); + CPPUNIT_ASSERT_MESSAGE("There should be a note on B1", m_pDoc->HasNote(ScAddress(1, 0, 0))); + CPPUNIT_ASSERT_MESSAGE("There should be a note on C1", m_pDoc->HasNote(ScAddress(2, 0, 0))); + CPPUNIT_ASSERT_MESSAGE("There should be a note on D1", m_pDoc->HasNote(ScAddress(3, 0, 0))); +/* still failing, wrong content ??? + OUString sNoteText; + sNoteText = m_pDoc->GetNote(ScAddress(1, 0, 0))->GetText(); + CPPUNIT_ASSERT_MESSAGE("Note content in B1", sNoteText == aHelloA1); + sNoteText = m_pDoc->GetNote(ScAddress(2, 0, 0))->GetText(); + CPPUNIT_ASSERT_MESSAGE("Note content in C1", sNoteText == aHelloB1); + sNoteText = m_pDoc->GetNote(ScAddress(3, 0, 0))->GetText(); + CPPUNIT_ASSERT_MESSAGE("Note content in D1", sNoteText == aHelloC1); +*/ + m_pDoc->DeleteTab(0); +} void Test::testCopyPasteRelativeFormula() { diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 1273241..0a141a3 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -215,6 +215,7 @@ public: void testAutofilter(); void testCopyPaste(); void testCopyPasteTranspose(); + void testMoveBlock(); void testCopyPasteRelativeFormula(); void testMergedCells(); void testUpdateReference(); @@ -348,6 +349,7 @@ public: CPPUNIT_TEST(testAutofilter); CPPUNIT_TEST(testCopyPaste); CPPUNIT_TEST(testCopyPasteTranspose); + CPPUNIT_TEST(testMoveBlock); CPPUNIT_TEST(testCopyPasteRelativeFormula); CPPUNIT_TEST(testMergedCells); CPPUNIT_TEST(testUpdateReference); diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 193c8d3..70df4d0 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -1670,7 +1670,7 @@ class CopyAsLinkHandler void duplicateNotes(SCROW nStartRow, size_t nDataSize ) // TODO : notes suboptimal { - // the link status is only for cell content as it is not possible to un-link a note + // the link status is only for cell content as it is not possible to un-link a note --> the note is copied sc::CellNoteStoreType maSrcCellNotes = mrSrcCol.GetCellNoteStore(); SCROW nRowMax = nStartRow + nDataSize; @@ -1885,6 +1885,7 @@ class CopyByCloneHandler aDestPos, true ); mrDestCol.GetDoc().ReleaseNote(aDestPos); mrDestCol.GetDoc().SetNote(aDestPos, pClonedNote); + pClonedNote->UpdateCaptionPos(aDestPos); } } } @@ -2232,9 +2233,9 @@ void resetColumnPosition(sc::CellStoreType& rCells, SCCOL nCol) void ScColumn::SwapCol(ScColumn& rCol) { maBroadcasters.swap(rCol.maBroadcasters); - maCellNotes.swap(rCol.maCellNotes); maCells.swap(rCol.maCells); maCellTextAttrs.swap(rCol.maCellTextAttrs); + maCellNotes.swap(rCol.maCellNotes); // TODO : notes update caption ? ScAttrArray* pTempAttr = rCol.pAttrArray; rCol.pAttrArray = pAttrArray; @@ -2278,7 +2279,7 @@ 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); + 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); @@ -2383,6 +2384,8 @@ public: { ScAddress aUndoPos(mnCol, nRow, mnTab); mbUpdated |= pCell->UpdateReference(mrCxt, mpUndoDoc, &aUndoPos); + + } bool isUpdated() const { return mbUpdated; } diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index 6241a0e..81c1966 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -2717,14 +2717,14 @@ sal_Bool ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos aDestMark.SelectTable( nTab, sal_True ); // Destination selektieren aDestMark.SetMarkArea( aPasteDest ); - /* Do not copy cell notes and drawing objects here. While pasting, the + /* Do not drawing objects here. While pasting, the function ScDocument::UpdateReference() is called which calls ScDrawLayer::MoveCells() which may move away inserted objects to wrong - positions (e.g. if source and destination range overlaps). Cell notes - and drawing objects are pasted below after doing all adjusting. */ - pDoc->CopyFromClip( aPasteDest, aDestMark, IDF_ALL & ~(IDF_NOTE | IDF_OBJECTS), + positions (e.g. if source and destination range overlaps).*/ + pDoc->CopyFromClip( aPasteDest, aDestMark, IDF_ALL & ~(IDF_OBJECTS), pRefUndoDoc, pClipDoc, sal_True, false, bIncludeFiltered ); + // skipped rows and merged cells don't mix if ( !bIncludeFiltered && pClipDoc->HasClipFilteredRows() ) UnmergeCells( aPasteDest, false ); @@ -2734,15 +2734,11 @@ sal_Bool ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos ScRange( 0,nDestRow,nDestTab, MAXCOL,nDestEndRow,nDestEndTab ), false ); - /* Paste cell notes and drawing objects after adjusting formula references + /* Paste drawing objects after adjusting formula references and row heights. There are no cell notes or drawing objects, if the - clipdoc does not contain a drawing layer. - #i102056# Passing IDF_NOTE only would overwrite cell contents with - empty note cells, therefore the special modifier IDF_ADDNOTES is passed - here too which changes the behaviour of ScColumn::CopyFromClip() to not - touch existing cells. */ + clipdoc does not contain a drawing layer.*/ if ( pClipDoc->GetDrawLayer() ) - pDoc->CopyFromClip( aPasteDest, aDestMark, IDF_NOTE | IDF_ADDNOTES | IDF_OBJECTS, + pDoc->CopyFromClip( aPasteDest, aDestMark, IDF_OBJECTS, pRefUndoDoc, pClipDoc, sal_True, false, bIncludeFiltered ); if (bRecord) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits