summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/document.hxx5
-rw-r--r--sc/qa/unit/data/ods/copy-merged-number-formats.odsbin0 -> 23185 bytes
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx25
3 files changed, 28 insertions, 2 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 700086dae7f1..5d6cc276153b 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 000000000000..39555e0b4480
--- /dev/null
+++ b/sc/qa/unit/data/ods/copy-merged-number-formats.ods
Binary files differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 2e5a8f6df0d4..bdc58b840d0f 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" )
{