summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-03-09 22:08:38 +0100
committerHenry Castro <hcastro@collabora.com>2017-05-03 13:37:04 -0400
commitaacb7e3029dd7a1f4baed2234388f66b41001018 (patch)
treebc4ae511289ead55ba9ebe94cf8e5a6461216098
parent0efa1517a7aad5a6c3ff5129cfb7da82be920c9f (diff)
sprinkle some drawing layers over test cases
... so things actually work like intended and creation of caption objects doesn't silently fail. Well, it does SAL_WARN or OSL_ENSURE but that's never displayed unless a test fails. Change-Id: Ibf4cc075cc3d6dadbe8f6208b2949310124b5749
-rw-r--r--sc/qa/unit/ucalc.cxx49
-rw-r--r--sc/qa/unit/ucalc_sort.cxx3
2 files changed, 39 insertions, 13 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index a80283514ef7..df6061d15f99 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -738,22 +738,29 @@ void Test::testCopyToDocument()
// Copy statically to another document.
- ScDocument aDestDoc(SCDOCMODE_DOCUMENT);
- aDestDoc.InsertTab(0, "src");
- m_pDoc->CopyStaticToDocument(ScRange(0,1,0,0,3,0), 0, &aDestDoc); // Copy A2:A4
- m_pDoc->CopyStaticToDocument(ScAddress(0,0,0), 0, &aDestDoc); // Copy A1
- m_pDoc->CopyStaticToDocument(ScRange(0,4,0,0,7,0), 0, &aDestDoc); // Copy A5:A8
-
- CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(0,0,0), aDestDoc.GetString(0,0,0));
- CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(0,1,0), aDestDoc.GetString(0,1,0));
- CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(0,2,0), aDestDoc.GetString(0,2,0));
- CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(0,3,0), aDestDoc.GetString(0,3,0));
- CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(0,4,0), aDestDoc.GetString(0,4,0));
+ ScDocShellRef xDocSh2;
+ getNewDocShell(xDocSh2);
+ ScDocument* pDestDoc = &xDocSh2->GetDocument();
+ pDestDoc->InsertTab(0, "src");
+ pDestDoc->InitDrawLayer(xDocSh2.get()); // for note caption objects
+
+ m_pDoc->CopyStaticToDocument(ScRange(0,1,0,0,3,0), 0, pDestDoc); // Copy A2:A4
+ m_pDoc->CopyStaticToDocument(ScAddress(0,0,0), 0, pDestDoc); // Copy A1
+ m_pDoc->CopyStaticToDocument(ScRange(0,4,0,0,7,0), 0, pDestDoc); // Copy A5:A8
+
+ CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(0,0,0), pDestDoc->GetString(0,0,0));
+ CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(0,1,0), pDestDoc->GetString(0,1,0));
+ CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(0,2,0), pDestDoc->GetString(0,2,0));
+ CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(0,3,0), pDestDoc->GetString(0,3,0));
+ CPPUNIT_ASSERT_EQUAL(m_pDoc->GetString(0,4,0), pDestDoc->GetString(0,4,0));
// verify note
- CPPUNIT_ASSERT_MESSAGE("There should be a note in A1 destDocument", aDestDoc.HasNote(ScAddress(0, 0, 0)));
+ CPPUNIT_ASSERT_MESSAGE("There should be a note in A1 destDocument", pDestDoc->HasNote(ScAddress(0, 0, 0)));
CPPUNIT_ASSERT_EQUAL_MESSAGE("The notes content should be the same on both documents",
- m_pDoc->GetNote(ScAddress(0, 0, 0))->GetText(), aDestDoc.GetNote(ScAddress(0, 0, 0))->GetText());
+ m_pDoc->GetNote(ScAddress(0, 0, 0))->GetText(), pDestDoc->GetNote(ScAddress(0, 0, 0))->GetText());
+
+ pDestDoc->DeleteTab(0);
+ closeDocShell(xDocSh2);
m_pDoc->DeleteTab(0);
}
@@ -3041,6 +3048,10 @@ void Test::testCopyPaste()
{
m_pDoc->InsertTab(0, "Sheet1");
m_pDoc->InsertTab(1, "Sheet2");
+
+ // We need a drawing layer in order to create caption objects.
+ m_pDoc->InitDrawLayer(&getDocShell());
+
//test copy&paste + ScUndoPaste
//copy local and global range names in formulas
//string cells and value cells
@@ -3256,6 +3267,9 @@ void Test::testCopyPasteTranspose()
m_pDoc->InsertTab(0, "Sheet1");
m_pDoc->InsertTab(1, "Sheet2");
+ // We need a drawing layer in order to create caption objects.
+ m_pDoc->InitDrawLayer(&getDocShell());
+
m_pDoc->SetValue(0, 0, 0, 1);
m_pDoc->SetString(1, 0, 0, "=A1+1");
m_pDoc->SetString(2, 0, 0, "test");
@@ -3844,6 +3858,9 @@ void Test::testMoveBlock()
{
m_pDoc->InsertTab(0, "SheetNotes");
+ // We need a drawing layer in order to create caption objects.
+ m_pDoc->InitDrawLayer(&getDocShell());
+
m_pDoc->SetValue(0, 0, 0, 1);
m_pDoc->SetString(1, 0, 0, "=A1+1");
m_pDoc->SetString(2, 0, 0, "test");
@@ -4835,6 +4852,9 @@ void Test::testShiftCells()
{
m_pDoc->InsertTab(0, "foo");
+ // We need a drawing layer in order to create caption objects.
+ m_pDoc->InitDrawLayer(&getDocShell());
+
OUString aTestVal("Some Text");
// Text into cell E5.
@@ -4872,6 +4892,9 @@ void Test::testNoteBasic()
{
m_pDoc->InsertTab(0, "PostIts");
+ // We need a drawing layer in order to create caption objects.
+ m_pDoc->InitDrawLayer(&getDocShell());
+
CPPUNIT_ASSERT(!m_pDoc->HasNotes());
// Check for note's presence in all tables before inserting any notes.
diff --git a/sc/qa/unit/ucalc_sort.cxx b/sc/qa/unit/ucalc_sort.cxx
index 7ec786d7a5ad..d99132f7dda5 100644
--- a/sc/qa/unit/ucalc_sort.cxx
+++ b/sc/qa/unit/ucalc_sort.cxx
@@ -31,6 +31,9 @@ void Test::testSort()
{
m_pDoc->InsertTab(0, "test1");
+ // We need a drawing layer in order to create caption objects.
+ m_pDoc->InitDrawLayer(&getDocShell());
+
ScRange aDataRange;
ScAddress aPos(0,0,0);
{