From c55d52262ea1d5f869a9528fd051ee19e687f1cc Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Fri, 18 Jan 2013 14:36:33 -0500 Subject: fdo#58988, fdo#58562: Populate draw clip document with data for charts. Without populating the clip document, copying a chart (or charts) into clipboard makes the charts lose all their referenced data, which causes the pasted chart to appear empty. Change-Id: I3675f76baed19b48cec403964c19df00725a044b --- sc/qa/unit/ucalc.cxx | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'sc/qa') diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 9e116c3aeb60..6a2ac0fbfcfe 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -117,7 +117,7 @@ public: void testRangeList(); void testInput(); void testCellFunctions(); - + void testCopyToDocument(); /** * Make sure the SHEETS function gets properly updated during sheet * insertion and removal. @@ -268,6 +268,7 @@ public: CPPUNIT_TEST(testRangeList); CPPUNIT_TEST(testInput); CPPUNIT_TEST(testCellFunctions); + CPPUNIT_TEST(testCopyToDocument); CPPUNIT_TEST(testSheetsFunc); CPPUNIT_TEST(testVolatileFunc); CPPUNIT_TEST(testFormulaDepTracking); @@ -1153,6 +1154,34 @@ void Test::testCellFunctions() m_pDoc->DeleteTab(0); } +void Test::testCopyToDocument() +{ + CPPUNIT_ASSERT_MESSAGE ("failed to insert sheet", m_pDoc->InsertTab (0, "src")); + + m_pDoc->SetString(0, 0, 0, "Header"); + m_pDoc->SetString(0, 1, 0, "1"); + m_pDoc->SetString(0, 2, 0, "2"); + m_pDoc->SetString(0, 3, 0, "3"); + m_pDoc->SetString(0, 4, 0, "=4/2"); + m_pDoc->CalcAll(); + + // 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)); + + m_pDoc->DeleteTab(0); +} + void Test::testSheetsFunc() { rtl::OUString aTabName1("test1"); -- cgit