diff options
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/copy_paste_test.cxx | 28 | ||||
-rw-r--r-- | sc/qa/unit/data/xlsx/tdf122716_font_with_charset.xlsx | bin | 0 -> 8551 bytes |
2 files changed, 28 insertions, 0 deletions
diff --git a/sc/qa/unit/copy_paste_test.cxx b/sc/qa/unit/copy_paste_test.cxx index 41d764e82381..b1691fc23d5d 100644 --- a/sc/qa/unit/copy_paste_test.cxx +++ b/sc/qa/unit/copy_paste_test.cxx @@ -45,6 +45,7 @@ public: void tdf113500_autofillMixed(); void tdf137625_autofillMergedUserlist(); void tdf137624_autofillMergedMixed(); + void tdf122716_rtf_portion_encoding(); CPPUNIT_TEST_SUITE(ScCopyPasteTest); CPPUNIT_TEST(testCopyPasteXLS); @@ -62,6 +63,7 @@ public: CPPUNIT_TEST(tdf113500_autofillMixed); CPPUNIT_TEST(tdf137625_autofillMergedUserlist); CPPUNIT_TEST(tdf137624_autofillMergedMixed); + CPPUNIT_TEST(tdf122716_rtf_portion_encoding); CPPUNIT_TEST_SUITE_END(); private: @@ -775,6 +777,32 @@ void ScCopyPasteTest::tdf137624_autofillMergedMixed() } } +void ScCopyPasteTest::tdf122716_rtf_portion_encoding() +{ + // Given a document with an explicitly defined "204" (Russian) charset for a font, + // and a cell having contents of "Šampūnas", which has character "Š" representable + // in Windows-1252 (RTF default), but not in Windows-1251 (i.e. charset 204): + createScDoc("xlsx/tdf122716_font_with_charset.xlsx"); + ScModelObj* pModelObj = comphelper::getFromUnoTunnel<ScModelObj>(mxComponent); + // Obtain a transferable, similar to what happens on copy to clipboard: + auto xTransferable = pModelObj->getSelection(); + // Get the RTF data: + auto rtf_any = xTransferable->getTransferData({ u"text/rtf"_ustr, {}, {} }); + css::uno::Sequence<sal_Int8> rtf_bytes; + CPPUNIT_ASSERT(rtf_any >>= rtf_bytes); + OString rtf_string(reinterpret_cast<const char*>(rtf_bytes.getConstArray()), + rtf_bytes.getLength()); + // Check that the font with charset was actually emitted + CPPUNIT_ASSERT(rtf_string.indexOf("\\fcharset204 Liberation Sans;") >= 0); + // Make sure that Unicode markup is emitted for the non-Ascii characters. + // Without the fix, "\u352" wasn't there, because the export was using Windows-1252 + // encoding unconditionally, even though the exported font defined a different one; + // so the exported characters only had Unicode markup, when not representable in the + // Windows-1252 encoding, and "Š" got exported as "\'8a". On import to Writer, font + // encoding was used, and "\'8a" was interpreted as a Cyrillic alphabet character. + CPPUNIT_ASSERT(rtf_string.indexOf("\\u352\\'3famp\\u363\\'3fnas") >= 0); +} + ScCopyPasteTest::ScCopyPasteTest() : ScModelTestBase(u"/sc/qa/unit/data/"_ustr) { diff --git a/sc/qa/unit/data/xlsx/tdf122716_font_with_charset.xlsx b/sc/qa/unit/data/xlsx/tdf122716_font_with_charset.xlsx Binary files differnew file mode 100644 index 000000000000..6c2326e3ed28 --- /dev/null +++ b/sc/qa/unit/data/xlsx/tdf122716_font_with_charset.xlsx |