[Libreoffice-commits] core.git: Branch 'feature/sc-notes-storage' - sc/qa
Laurent Godard
lgodard.libre at laposte.net
Thu Sep 19 07:33:12 PDT 2013
sc/qa/unit/ucalc.cxx | 83 +++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 81 insertions(+), 2 deletions(-)
New commits:
commit 212305239c1df0b8142c73b554e0f89bcc59b29b
Author: Laurent Godard <lgodard.libre at laposte.net>
Date: Thu Sep 19 16:30:34 2013 +0200
unit test notes & copy/paste & clipboard transpose
- test on clipboard transpose fails
Change-Id: I3d2ecd43a3aab86639cb01d9eeb7c0d0d5a1de5d
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 4891e13..b66f0d4 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1497,11 +1497,18 @@ void Test::testSheetCopy()
bool bHidden = m_pDoc->RowHidden(0, 0, &nRow1, &nRow2);
CPPUNIT_ASSERT_MESSAGE("new sheet should have all rows visible", !bHidden && nRow1 == 0 && nRow2 == MAXROW);
+ // insert a note
+ ScAddress aAdrA1 (0, 0, 0); // empty cell content
+ OUString aHelloA1("Hello world in A1");
+ ScPostIt *pNoteA1 = m_pDoc->GetOrCreateNote(aAdrA1);
+ pNoteA1->SetText(aAdrA1, aHelloA1);
+
// Copy and test the result.
m_pDoc->CopyTab(0, 1);
CPPUNIT_ASSERT_MESSAGE("document now should have two sheets.", m_pDoc->GetTableCount() == 2);
bHidden = m_pDoc->RowHidden(0, 1, &nRow1, &nRow2);
CPPUNIT_ASSERT_MESSAGE("copied sheet should also have all rows visible as the original.", !bHidden && nRow1 == 0 && nRow2 == MAXROW);
+ CPPUNIT_ASSERT_MESSAGE("There should be note on A1 in new sheet", m_pDoc->HasNote(ScAddress (0, 0, 1)));
m_pDoc->DeleteTab(1);
m_pDoc->SetRowHidden(5, 10, 0, true);
@@ -2895,6 +2902,20 @@ void Test::testCopyPaste()
double fValue = m_pDoc->GetValue(ScAddress(1,0,0));
ASSERT_DOUBLES_EQUAL_MESSAGE("formula should return 8", fValue, 8);
+ // 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);
+
//copy Sheet1.A1:C1 to Sheet2.A2:C2
ScRange aRange(0,0,0,2,0,0);
ScDocument aClipDoc(SCDOCMODE_CLIP);
@@ -2917,7 +2938,7 @@ void Test::testCopyPaste()
fValue = m_pDoc->GetValue(ScAddress(0,1,1));
CPPUNIT_ASSERT_MESSAGE("copied value should be 1", fValue == 1);
- //chack local range name after copying
+ //check local range name after copying
pLocal1 = m_pDoc->GetRangeName(1)->findByUpperName(OUString("LOCAL1"));
CPPUNIT_ASSERT_MESSAGE("local range name 1 should be copied", pLocal1);
ScRange aRangeLocal1;
@@ -2926,13 +2947,26 @@ void Test::testCopyPaste()
pLocal2 = m_pDoc->GetRangeName(1)->findByUpperName(OUString("LOCAL2"));
CPPUNIT_ASSERT_MESSAGE("local2 should not be copied", pLocal2 == NULL);
+ // check notes after copying
+ CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet2.A2", m_pDoc->HasNote(ScAddress(0, 1, 1)));
+ CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet2.B2", m_pDoc->HasNote(ScAddress(1, 1, 1)));
+ CPPUNIT_ASSERT_MESSAGE("There should be a note on Sheet2.C2", m_pDoc->HasNote(ScAddress(2, 1, 1)));
+ CPPUNIT_ASSERT_MESSAGE("Note content on Sheet1.A1 not copied to Sheet2.A2, empty cell content",
+ m_pDoc->GetNote(ScAddress(0, 0, 0))->GetText() == m_pDoc->GetNote(ScAddress(0, 1, 1))->GetText());
+ CPPUNIT_ASSERT_MESSAGE("Note content on Sheet1.B1 not copied to Sheet2.B2, formula cell content",
+ m_pDoc->GetNote(ScAddress(1, 0, 0))->GetText() == m_pDoc->GetNote(ScAddress(1, 1, 1))->GetText());
+ CPPUNIT_ASSERT_MESSAGE("Note content on Sheet1.C1 not copied to Sheet2.C2, string cell content",
+ m_pDoc->GetNote(ScAddress(2, 0, 0))->GetText() == m_pDoc->GetNote(ScAddress(2, 1, 1))->GetText());
//check undo and redo
pUndo->Undo();
fValue = m_pDoc->GetValue(ScAddress(1,1,1));
ASSERT_DOUBLES_EQUAL_MESSAGE("after undo formula should return nothing", fValue, 0);
aString = m_pDoc->GetString(2, 1, 1);
- CPPUNIT_ASSERT_MESSAGE("after undo string should be removed", aString.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("")));
+ CPPUNIT_ASSERT_MESSAGE("after undo, string should be removed", aString.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("")));
+ CPPUNIT_ASSERT_MESSAGE("after undo, note on A2 should be removed", !m_pDoc->HasNote(ScAddress(0, 1, 1)));
+ CPPUNIT_ASSERT_MESSAGE("after undo, note on B2 should be removed", !m_pDoc->HasNote(ScAddress(1, 1, 1)));
+ CPPUNIT_ASSERT_MESSAGE("after undo, note on C2 should be removed", !m_pDoc->HasNote(ScAddress(2, 1, 1)));
pUndo->Redo();
fValue = m_pDoc->GetValue(ScAddress(1,1,1));
@@ -2942,6 +2976,51 @@ void Test::testCopyPaste()
m_pDoc->GetFormula(1,1,1, aString);
CPPUNIT_ASSERT_MESSAGE("Formula should be correct again", aString == aFormulaString);
+ CPPUNIT_ASSERT_MESSAGE("After Redo, there should be a note on Sheet2.A2", m_pDoc->HasNote(ScAddress(0, 1, 1)));
+ CPPUNIT_ASSERT_MESSAGE("After Redo, there should be a note on Sheet2.B2", m_pDoc->HasNote(ScAddress(1, 1, 1)));
+ CPPUNIT_ASSERT_MESSAGE("After Redo, there should be a note on Sheet2.C2", m_pDoc->HasNote(ScAddress(2, 1, 1)));
+ CPPUNIT_ASSERT_MESSAGE("After Redo, note again on Sheet2.A2, empty cell content",
+ m_pDoc->GetNote(ScAddress(0, 0, 0))->GetText() == m_pDoc->GetNote(ScAddress(0, 1, 1))->GetText());
+ CPPUNIT_ASSERT_MESSAGE("After Redo, note again on Sheet2.B2, formula cell content",
+ m_pDoc->GetNote(ScAddress(1, 0, 0))->GetText() == m_pDoc->GetNote(ScAddress(1, 1, 1))->GetText());
+ CPPUNIT_ASSERT_MESSAGE("After Redo, note again on Sheet2.C2, string cell content",
+ 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"));
+
+ aRange = ScRange(0,0,0,2,0,0);
+ ScDocument aNewClipDoc(SCDOCMODE_CLIP);
+ copyToClip(m_pDoc, aRange, &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);
+
+ //check values after transposed copy/paste
+
+ aString = m_pDoc->GetString(3, 3, 2);
+ 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);
+ 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 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);
}
More information about the Libreoffice-commits
mailing list