[Libreoffice-commits] core.git: sc/inc sc/qa
Kohei Yoshida
kohei.yoshida at collabora.com
Fri Jun 20 06:58:46 PDT 2014
sc/inc/document.hxx | 5 ++--
sc/qa/unit/data/ods/copy-merged-number-formats.ods |binary
sc/qa/unit/subsequent_filters-test.cxx | 25 +++++++++++++++++++++
3 files changed, 28 insertions(+), 2 deletions(-)
New commits:
commit 01dd299bded81700bc976881c6ea954a09015f9f
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Fri Jun 20 09:54:25 2014 -0400
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
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 700086d..5d6cc27 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1217,13 +1217,14 @@ public:
/**
* 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 nDestTab table in the clip 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.
diff --git a/sc/qa/unit/data/ods/copy-merged-number-formats.ods b/sc/qa/unit/data/ods/copy-merged-number-formats.ods
new file mode 100644
index 0000000..39555e0
Binary files /dev/null and b/sc/qa/unit/data/ods/copy-merged-number-formats.ods differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 2e5a8f6..bdc58b8 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -174,6 +174,7 @@ public:
void testExternalRefCacheXLSX();
void testExternalRefCacheODS();
void testHybridSharedStringODS();
+ void testCopyMergedNumberFormats();
CPPUNIT_TEST_SUITE(ScFiltersTest);
CPPUNIT_TEST(testBasicCellContentODS);
@@ -252,6 +253,7 @@ public:
CPPUNIT_TEST(testExternalRefCacheXLSX);
CPPUNIT_TEST(testExternalRefCacheODS);
CPPUNIT_TEST(testHybridSharedStringODS);
+ CPPUNIT_TEST(testCopyMergedNumberFormats);
CPPUNIT_TEST_SUITE_END();
private:
@@ -2583,6 +2585,29 @@ void ScFiltersTest::testHybridSharedStringODS()
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()
: ScBootstrapFixture( "/sc/qa/unit/data" )
{
More information about the Libreoffice-commits
mailing list