fdo#71076: Write test for this.

This was actually just one element of all that contributed to this bug.
Unfortunately it's a bit hard to test the others.

Change-Id: I7a0d88c0b829e7b7859aecfc20df87f6837ecb4a
This commit is contained in:
Kohei Yoshida
2014-06-20 09:54:25 -04:00
parent f75b2bf96e
commit 01dd299bde
3 changed files with 28 additions and 2 deletions

View File

@@ -1217,13 +1217,14 @@ public:
/** /**
* Copy only raw cell values to another document. Formula cells are * Copy only raw cell values to another document. Formula cells are
* converted to raw cells. No formatting info are copied. * converted to raw cells. No formatting info are copied except for
* number formats.
* *
* @param rSrcRange source range in the source document * @param rSrcRange source range in the source document
* @param nDestTab table in the clip document to copy to. * @param nDestTab table in the clip document to copy to.
* @param pDestDoc document to copy to * @param pDestDoc document to copy to
*/ */
void CopyStaticToDocument(const ScRange& rSrcRange, SCTAB nDestTab, ScDocument* pDestDoc); SC_DLLPUBLIC void CopyStaticToDocument(const ScRange& rSrcRange, SCTAB nDestTab, ScDocument* pDestDoc);
/** /**
* Copy only cell, nothing but cell to another document. * Copy only cell, nothing but cell to another document.

Binary file not shown.

View File

@@ -174,6 +174,7 @@ public:
void testExternalRefCacheXLSX(); void testExternalRefCacheXLSX();
void testExternalRefCacheODS(); void testExternalRefCacheODS();
void testHybridSharedStringODS(); void testHybridSharedStringODS();
void testCopyMergedNumberFormats();
CPPUNIT_TEST_SUITE(ScFiltersTest); CPPUNIT_TEST_SUITE(ScFiltersTest);
CPPUNIT_TEST(testBasicCellContentODS); CPPUNIT_TEST(testBasicCellContentODS);
@@ -252,6 +253,7 @@ public:
CPPUNIT_TEST(testExternalRefCacheXLSX); CPPUNIT_TEST(testExternalRefCacheXLSX);
CPPUNIT_TEST(testExternalRefCacheODS); CPPUNIT_TEST(testExternalRefCacheODS);
CPPUNIT_TEST(testHybridSharedStringODS); CPPUNIT_TEST(testHybridSharedStringODS);
CPPUNIT_TEST(testCopyMergedNumberFormats);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
private: private:
@@ -2583,6 +2585,29 @@ void ScFiltersTest::testHybridSharedStringODS()
xDocSh->DoClose(); xDocSh->DoClose();
} }
void ScFiltersTest::testCopyMergedNumberFormats()
{
ScDocShellRef xDocSh = loadDoc("copy-merged-number-formats.", ODS);
CPPUNIT_ASSERT(xDocSh.Is());
ScDocument* pDoc = xDocSh->GetDocument();
// Cells B1, C1 and D1 are formatted as dates.
OUString aStrB1 = pDoc->GetString(ScAddress(1,0,0));
OUString aStrC1 = pDoc->GetString(ScAddress(2,0,0));
OUString aStrD1 = pDoc->GetString(ScAddress(3,0,0));
ScDocument aCopyDoc;
aCopyDoc.InsertTab(0, "CopyHere");
pDoc->CopyStaticToDocument(ScRange(1,0,0,3,0,0), 0, &aCopyDoc);
// Make sure the date formats are copied to the new document.
CPPUNIT_ASSERT_EQUAL(aStrB1, aCopyDoc.GetString(ScAddress(1,0,0)));
CPPUNIT_ASSERT_EQUAL(aStrC1, aCopyDoc.GetString(ScAddress(2,0,0)));
CPPUNIT_ASSERT_EQUAL(aStrD1, aCopyDoc.GetString(ScAddress(3,0,0)));
xDocSh->DoClose();
}
ScFiltersTest::ScFiltersTest() ScFiltersTest::ScFiltersTest()
: ScBootstrapFixture( "/sc/qa/unit/data" ) : ScBootstrapFixture( "/sc/qa/unit/data" )
{ {