sc/qa/unit/ucalc.cxx | 75 +++++++++++++++++++++++++++++++++++++++ sc/qa/unit/ucalc.hxx | 2 + sc/source/core/data/column3.cxx | 1 sc/source/core/data/document.cxx | 3 + sc/source/ui/view/viewfun3.cxx | 3 + 5 files changed, 81 insertions(+), 3 deletions(-)
New commits: commit 0c12aa670b83b76241077dfb8bc21f40a55b1667 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Thu Feb 6 14:11:43 2014 -0500 fdo#74573: Skip deletion of destination area when 'skip empty' is on. Also, adjust handling of mix document aka paste functions with this change. When using paste function (add, subtract, etc), the behavior between the 'skip empty' flag on and off makes no difference. Let's set the flag to off when paste function is used. Change-Id: I67724ba923c9260b2c14464e4123b8445712dbaf diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index fb6518e..b97e396 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -731,7 +731,6 @@ public: void operator() (const sc::CellStoreType::value_type& node, size_t nOffset, size_t nDataSize) { - SCROW nSrcRow1 = node.position + nOffset; bool bCopyCellNotes = mrCxt.isCloneNotes(); diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 9f5b3bb..fdbb1fa 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -2690,7 +2690,8 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar SCCOL nCol2 = pRange->aEnd.Col(); SCROW nRow2 = pRange->aEnd.Row(); - DeleteArea(nCol1, nRow1, nCol2, nRow2, rMark, nDelFlag); + if (!bSkipAttrForEmpty) + DeleteArea(nCol1, nRow1, nCol2, nRow2, rMark, nDelFlag); if (CopyOneCellFromClip(aCxt, nCol1, nRow1, nCol2, nRow2)) continue; diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx index e501458..fd16a60 100644 --- a/sc/source/ui/view/viewfun3.cxx +++ b/sc/source/ui/view/viewfun3.cxx @@ -1188,8 +1188,9 @@ bool ScViewFunc::PasteFromClip( sal_uInt16 nFlags, ScDocument* pClipDoc, // ScDocument* pMixDoc = NULL; - if ( bSkipEmpty || nFunction ) + if (nFunction) { + bSkipEmpty = false; if ( nFlags & IDF_CONTENTS ) { pMixDoc = new ScDocument( SCDOCMODE_UNDO ); commit 4f2482c6a82e2c32511cd9bd9adea863191f7199 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Thu Feb 6 14:11:02 2014 -0500 fdo#74573: Write test for pasting with empty cells skipped. Change-Id: I8ede86b248a9b3a17d077442537e2ec37034f597 diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 3bab048..81e1902 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -3594,6 +3594,81 @@ void Test::testCopyPasteTranspose() } +void Test::testCopyPasteSkipEmpty() +{ + m_pDoc->InsertTab(0, "Test"); + + ScRange aSrcRange(0,0,0,0,4,0); + ScRange aDestRange(1,0,0,1,4,0); + + ScMarkData aMark; + aMark.SetMarkArea(aDestRange); + + // Put some texts in A1:A5. + m_pDoc->SetString(ScAddress(1,0,0), "A"); + m_pDoc->SetString(ScAddress(1,1,0), "B"); + m_pDoc->SetString(ScAddress(1,2,0), "C"); + m_pDoc->SetString(ScAddress(1,3,0), "D"); + m_pDoc->SetString(ScAddress(1,4,0), "E"); + + // Prepare a clipboard content interleaved with empty cells. + ScDocument aClipDoc(SCDOCMODE_CLIP); + aClipDoc.ResetClip(m_pDoc, &aMark); + aClipDoc.SetClipParam(ScClipParam(aSrcRange, false)); + aClipDoc.SetString(ScAddress(0,0,0), "Clip1"); + aClipDoc.SetString(ScAddress(0,2,0), "Clip2"); + aClipDoc.SetString(ScAddress(0,4,0), "Clip3"); + + CPPUNIT_ASSERT_EQUAL(CELLTYPE_STRING, aClipDoc.GetCellType(ScAddress(0,0,0))); + CPPUNIT_ASSERT_EQUAL(CELLTYPE_NONE, aClipDoc.GetCellType(ScAddress(0,1,0))); + CPPUNIT_ASSERT_EQUAL(CELLTYPE_STRING, aClipDoc.GetCellType(ScAddress(0,2,0))); + CPPUNIT_ASSERT_EQUAL(CELLTYPE_NONE, aClipDoc.GetCellType(ScAddress(0,3,0))); + CPPUNIT_ASSERT_EQUAL(CELLTYPE_STRING, aClipDoc.GetCellType(ScAddress(0,4,0))); + + // Create undo document. + ScDocument* pUndoDoc = new ScDocument(SCDOCMODE_UNDO); + pUndoDoc->InitUndo(m_pDoc, 0, 0); + m_pDoc->CopyToDocument(aDestRange, IDF_CONTENTS, false, pUndoDoc, &aMark); + + // Paste clipboard content onto A1:A5 but skip empty cells. + bool bSkipEmpty = true; + m_pDoc->CopyFromClip(aDestRange, aMark, IDF_CONTENTS, pUndoDoc, &aClipDoc, true, false, false, bSkipEmpty); + + // Create redo document. + ScDocument* pRedoDoc = new ScDocument(SCDOCMODE_UNDO); + pRedoDoc->InitUndo(m_pDoc, 0, 0); + m_pDoc->CopyToDocument(aDestRange, IDF_CONTENTS, false, pRedoDoc, &aMark); + + // Create an undo object for this. + ScRefUndoData* pRefUndoData = new ScRefUndoData(m_pDoc); + ScUndoPaste aUndo(&getDocShell(), aDestRange, aMark, pUndoDoc, pRedoDoc, IDF_CONTENTS, pRefUndoData); + + // Check the content after the paste. + CPPUNIT_ASSERT_EQUAL(OUString("Clip1"), m_pDoc->GetString(ScAddress(1,0,0))); + CPPUNIT_ASSERT_EQUAL(OUString("B"), m_pDoc->GetString(ScAddress(1,1,0))); + CPPUNIT_ASSERT_EQUAL(OUString("Clip2"), m_pDoc->GetString(ScAddress(1,2,0))); + CPPUNIT_ASSERT_EQUAL(OUString("D"), m_pDoc->GetString(ScAddress(1,3,0))); + CPPUNIT_ASSERT_EQUAL(OUString("Clip3"), m_pDoc->GetString(ScAddress(1,4,0))); + + // Undo, and check the content. + aUndo.Undo(); + CPPUNIT_ASSERT_EQUAL(OUString("A"), m_pDoc->GetString(ScAddress(1,0,0))); + CPPUNIT_ASSERT_EQUAL(OUString("B"), m_pDoc->GetString(ScAddress(1,1,0))); + CPPUNIT_ASSERT_EQUAL(OUString("C"), m_pDoc->GetString(ScAddress(1,2,0))); + CPPUNIT_ASSERT_EQUAL(OUString("D"), m_pDoc->GetString(ScAddress(1,3,0))); + CPPUNIT_ASSERT_EQUAL(OUString("E"), m_pDoc->GetString(ScAddress(1,4,0))); + + // Redo, and check the content again. + aUndo.Redo(); + CPPUNIT_ASSERT_EQUAL(OUString("Clip1"), m_pDoc->GetString(ScAddress(1,0,0))); + CPPUNIT_ASSERT_EQUAL(OUString("B"), m_pDoc->GetString(ScAddress(1,1,0))); + CPPUNIT_ASSERT_EQUAL(OUString("Clip2"), m_pDoc->GetString(ScAddress(1,2,0))); + CPPUNIT_ASSERT_EQUAL(OUString("D"), m_pDoc->GetString(ScAddress(1,3,0))); + CPPUNIT_ASSERT_EQUAL(OUString("Clip3"), m_pDoc->GetString(ScAddress(1,4,0))); + + m_pDoc->DeleteTab(0); +} + void Test::testUndoCut() { m_pDoc->InsertTab(0, "Test"); diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 67a7581..dfa3a4b 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -239,6 +239,7 @@ public: void testCopyPaste(); void testCopyPasteAsLink(); void testCopyPasteTranspose(); + void testCopyPasteSkipEmpty(); void testUndoCut(); void testMoveBlock(); void testCopyPasteRelativeFormula(); @@ -400,6 +401,7 @@ public: CPPUNIT_TEST(testCopyPaste); CPPUNIT_TEST(testCopyPasteAsLink); CPPUNIT_TEST(testCopyPasteTranspose); + CPPUNIT_TEST(testCopyPasteSkipEmpty); CPPUNIT_TEST(testUndoCut); CPPUNIT_TEST(testMoveBlock); CPPUNIT_TEST(testCopyPasteRelativeFormula); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits