summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-03-09 22:08:38 +0100
committerEike Rathke <erack@redhat.com>2017-03-09 22:10:22 +0100
commitb3354ad2482737b49bd8d7593d355671197c4551 (patch)
treedb53a89530a47c00349529f978cccc4b943f5c20
parent60c5b392b77f15d11dd98890565abc68daee02a8 (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 af2e645cca5b..dcb9a9076f9e 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -790,22 +790,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);
}
@@ -3236,6 +3243,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
@@ -3451,6 +3462,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");
@@ -4032,6 +4046,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");
@@ -5020,6 +5037,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.
@@ -5057,6 +5077,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 b24a3dae9ca0..7a071c37269f 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);
{