sc/qa/unit/ucalc.cxx | 68 ++++++++++++++++++++++++++++++++++++--------------- sc/qa/unit/ucalc.hxx | 2 + 2 files changed, 51 insertions(+), 19 deletions(-)
New commits: commit 76fc361a4804298084cf5ad99abf373d4132b44c Author: Laurent Godard <lgodard.li...@laposte.net> Date: Fri Sep 20 13:55:17 2013 +0200 isolate testCopyPasteTranspose Change-Id: I0f01b5785e45371d856f3c2c94706a6f3af652e9 diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 139e7c6f..8488c20 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -2987,42 +2987,72 @@ void Test::testCopyPaste() m_pDoc->GetNote(ScAddress(2, 0, 0))->GetText() == m_pDoc->GetNote(ScAddress(2, 1, 1))->GetText()); - // transpose clipboard, paste and check on Sheet3 - m_pDoc->InsertTab(2, OUString("Sheet3")); + m_pDoc->DeleteTab(1); + m_pDoc->DeleteTab(0); +} + +void Test::testCopyPasteTranspose() +{ + + m_pDoc->InsertTab(0, OUString("Sheet1")); + m_pDoc->InsertTab(1, OUString("Sheet2")); + + m_pDoc->SetValue(0, 0, 0, 1); + m_pDoc->SetValue(1, 0, 0, 2); + m_pDoc->SetString(2, 0, 0, OUString("test")); - aRange = ScRange(0,0,0,2,0,0); + // add notes to A1:C1 + ScAddress aAdrA1 (0, 0, 0); // empty 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); + + // transpose clipboard, paste and check on Sheet2 + m_pDoc->InsertTab(1, OUString("Sheet2")); + + ScRange aSrcRange = ScRange(0,0,0,2,0,0); ScDocument aNewClipDoc(SCDOCMODE_CLIP); - copyToClip(m_pDoc, aRange, &aNewClipDoc); + copyToClip(m_pDoc, aSrcRange, &aNewClipDoc); ::std::auto_ptr<ScDocument> pTransClip; pTransClip.reset(new ScDocument(SCDOCMODE_CLIP)); aNewClipDoc.TransposeClip(pTransClip.get(), IDF_ALL, false); ScDocument* pTransposedClip = pTransClip.release(); - aRange = ScRange(3,1,2,3,3,2);//target: Sheet3.D2:D4 - aMark.SetMarkArea(aRange); - m_pDoc->CopyFromClip(aRange, aMark, IDF_ALL, NULL, pTransposedClip); + ScRange aDestRange = ScRange(3,1,1,3,3,1);//target: Sheet2.D2:D4 + ScMarkData aMark; + aMark.SetMarkArea(aSrcRange); + m_pDoc->CopyFromClip(aDestRange, aMark, IDF_ALL, NULL, pTransposedClip); //check values after transposed copy/paste -/* - aString = m_pDoc->GetString(3, 3, 2); + + OUString aString = m_pDoc->GetString(3, 3, 1); CPPUNIT_ASSERT_MESSAGE("Cell Sheet3.D4 should contain: test", aString.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("test"))); - fValue = m_pDoc->GetValue(ScAddress(3,1,2)); - m_pDoc->GetFormula(3,1,2, aString); + // check notes after transposed copy/paste + CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet2.D2", m_pDoc->HasNote(ScAddress(3, 1, 1))); + CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet2.D3", m_pDoc->HasNote(ScAddress(3, 2, 1))); + CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet2.D4", m_pDoc->HasNote(ScAddress(3, 3, 1))); + +/* + double fValue = m_pDoc->GetValue(ScAddress(3,1,1)); + m_pDoc->GetFormula(3,1,1, aString); ASSERT_DOUBLES_EQUAL_MESSAGE("transposed copied formula should return 2", fValue, 2); - CPPUNIT_ASSERT_MESSAGE("transposed formula string was not copied correctly", aString == aFormulaString); - fValue = m_pDoc->GetValue(ScAddress(3,2,3)); + // CPPUNIT_ASSERT_MESSAGE("transposed formula string was not copied correctly", aString == aFormulaString); + fValue = m_pDoc->GetValue(ScAddress(3,2,1)); CPPUNIT_ASSERT_MESSAGE("transposed copied value should be 1", fValue == 1); - - // check notes after transposed copy/paste - CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet3.D2", m_pDoc->HasNote(ScAddress(3, 1, 2))); - CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet3.D3", m_pDoc->HasNote(ScAddress(3, 2, 2))); - CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet3.D4", m_pDoc->HasNote(ScAddress(3, 3, 2))); */ - m_pDoc->DeleteTab(2); m_pDoc->DeleteTab(1); m_pDoc->DeleteTab(0); + } void Test::testCopyPasteRelativeFormula() diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index e97bb8d..bb48533 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -214,6 +214,7 @@ public: void testDataArea(); void testAutofilter(); void testCopyPaste(); + void testCopyPasteTranspose(); void testCopyPasteRelativeFormula(); void testMergedCells(); void testUpdateReference(); @@ -345,6 +346,7 @@ public: CPPUNIT_TEST(testToggleRefFlag); CPPUNIT_TEST(testAutofilter); CPPUNIT_TEST(testCopyPaste); + CPPUNIT_TEST(testCopyPasteTranspose); CPPUNIT_TEST(testCopyPasteRelativeFormula); CPPUNIT_TEST(testMergedCells); CPPUNIT_TEST(testUpdateReference); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits