diff options
-rw-r--r-- | sw/qa/extras/rtfexport/data/fdo61507.rtf | 12 | ||||
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport.cxx | 19 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfexport.cxx | 15 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfexport.hxx | 2 |
4 files changed, 42 insertions, 6 deletions
diff --git a/sw/qa/extras/rtfexport/data/fdo61507.rtf b/sw/qa/extras/rtfexport/data/fdo61507.rtf new file mode 100644 index 000000000000..1fe8654f7f86 --- /dev/null +++ b/sw/qa/extras/rtfexport/data/fdo61507.rtf @@ -0,0 +1,12 @@ +{\rtf1 +{\info +{\upr +{\title \'c9\'c1???} +{\*\ud\uc0 +{\title \'c9\'c1 +{\uc1\u336 O\u368 U\u8749 ?} +} +} +} +} +Hello.} diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index be9b27b96500..529467092a8c 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -69,6 +69,7 @@ public: void testTextFrames(); void testFdo53604(); void testFdo52286(); + void testFdo61507(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -113,6 +114,7 @@ void Test::run() {"textframes.odt", &Test::testTextFrames}, {"fdo53604.odt", &Test::testFdo53604}, {"fdo52286.odt", &Test::testFdo52286}, + {"fdo61507.rtf", &Test::testFdo61507}, }; // Don't test the first import of these, for some reason those tests fail const char* aBlacklist[] = { @@ -463,6 +465,23 @@ void Test::testFdo52286() CPPUNIT_ASSERT_EQUAL(sal_Int32(58), getProperty<sal_Int32>(getRun(getParagraph(2), 2), "CharEscapementHeight")); } +void Test::testFdo61507() +{ + /* + * Unicode-only characters in \title confused Wordpad. Once the exporter + * was fixed to guard the problematic characters with \upr and \ud, the + * importer didn't cope with these new keywords. + */ + + uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<document::XDocumentProperties> xDocumentProperties(xDocumentPropertiesSupplier->getDocumentProperties()); + OUString aExpected = OUString("ÉÁŐŰ∭", 11, RTL_TEXTENCODING_UTF8); + CPPUNIT_ASSERT_EQUAL(aExpected, xDocumentProperties->getTitle()); + + // Only "Hello.", no additional characters. + CPPUNIT_ASSERT_EQUAL(6, getLength()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx index a2512059b46d..34073be45e87 100644 --- a/sw/source/filter/ww8/rtfexport.cxx +++ b/sw/source/filter/ww8/rtfexport.cxx @@ -395,7 +395,7 @@ void RtfExport::WriteInfo() } if (xDocProps.is()) { - OutUnicode(OOO_STRING_SVTOOLS_RTF_TITLE, xDocProps->getTitle()); + OutUnicode(OOO_STRING_SVTOOLS_RTF_TITLE, xDocProps->getTitle(), true); OutUnicode(OOO_STRING_SVTOOLS_RTF_SUBJECT, xDocProps->getSubject()); OutUnicode(OOO_STRING_SVTOOLS_RTF_KEYWORDS, @@ -801,13 +801,18 @@ SvStream& RtfExport::OutLong( long nVal ) return m_pWriter->OutLong( Strm(), nVal ); } -void RtfExport::OutUnicode(const sal_Char *pToken, const String &rContent) +void RtfExport::OutUnicode(const sal_Char *pToken, const String &rContent, bool bUpr) { if (rContent.Len()) { - Strm() << '{' << pToken << ' '; - Strm() << msfilter::rtfutil::OutString( rContent, eCurrentEncoding ).getStr(); - Strm() << '}'; + if (!bUpr) + { + Strm() << '{' << pToken << ' '; + Strm() << msfilter::rtfutil::OutString( rContent, eCurrentEncoding ).getStr(); + Strm() << '}'; + } + else + Strm() << msfilter::rtfutil::OutStringUpr(pToken, rContent, eCurrentEncoding).getStr(); } } diff --git a/sw/source/filter/ww8/rtfexport.hxx b/sw/source/filter/ww8/rtfexport.hxx index 6cd33ce4d3e5..8fc8e26c8886 100644 --- a/sw/source/filter/ww8/rtfexport.hxx +++ b/sw/source/filter/ww8/rtfexport.hxx @@ -155,7 +155,7 @@ public: SvStream& Strm(); SvStream& OutULong( sal_uLong nVal ); SvStream& OutLong( long nVal ); - void OutUnicode(const sal_Char *pToken, const String &rContent); + void OutUnicode(const sal_Char *pToken, const String &rContent, bool bUpr = false); void OutDateTime(const sal_Char* pStr, const util::DateTime& rDT ); void OutPageDescription( const SwPageDesc& rPgDsc, bool bWriteReset, bool bCheckForFirstPage ); |