sw/qa/extras/rtfexport/data/tdf61901.rtf | 7 +++++++ sw/qa/extras/rtfexport/rtfexport.cxx | 20 ++++++++++++++++++++ sw/source/filter/ww8/rtfattributeoutput.cxx | 10 ++++++++++ 3 files changed, 37 insertions(+)
New commits: commit 181ead2326ea9359cd0077d7f3d955df1140d019 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Jul 19 08:20:07 2016 +0200 tdf#61901 RTF export: fix implicit font name of non-ascii text The problem was that in case we used \loch, then \f only had an affect on ascii characters, not on every other character range. Change-Id: I30a851fe28131f18f5c429273a24c1424d2cec22 Reviewed-on: https://gerrit.libreoffice.org/27310 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Jenkins <c...@libreoffice.org> (cherry picked from commit 43e049c32302620bbc134732286529496853d78a) Reviewed-on: https://gerrit.libreoffice.org/27383 Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/sw/qa/extras/rtfexport/data/tdf61901.rtf b/sw/qa/extras/rtfexport/data/tdf61901.rtf new file mode 100644 index 0000000..83c4ad7 --- /dev/null +++ b/sw/qa/extras/rtfexport/data/tdf61901.rtf @@ -0,0 +1,7 @@ +{\rtf1\ansi\deff11 +{\fonttbl +{\f11\fmodern\fcharset0 Courier New;} +{\f34\fmodern\fcharset204 Courier New Cyr;} +} +{\f34 \'c8\par} +} diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index f7a272d..5ca24e1 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -1050,6 +1050,26 @@ DECLARE_RTFEXPORT_TEST(testTdf98806, "tdf98806.rtf") CPPUNIT_ASSERT_EQUAL(OUString("BBB"), xBookmark->getAnchor()->getString()); } +DECLARE_RTFEXPORT_TEST(testTdf61901, "tdf61901.rtf") +{ + // Test the file directly, as current RTF import gives the correct font name with and without the fix. + if (mbExported) + { + SvStream* pStream = maTempFile.GetStream(StreamMode::READ); + OString sLine; + while (pStream->ReadLine(sLine)) + { + sal_Int32 nIndex = sLine.indexOf("\\loch\\loch"); + if (nIndex != -1) + { + // Make sure that \hich is always written after a \loch\loch. + OString sRemaining = sLine.copy(nIndex); + CPPUNIT_ASSERT(sRemaining.indexOf("\\hich") != -1); + } + } + } +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 2c8894d..de38628 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -2284,6 +2284,16 @@ void RtfAttributeOutput::CharFont(const SvxFontItem& rFont) m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_LOCH); m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_F); m_aStylesEnd.append((sal_Int32)m_rExport.m_aFontHelper.GetId(rFont)); + + if (!m_rExport.HasItem(RES_CHRATR_CJK_FONT) && !m_rExport.HasItem(RES_CHRATR_CTL_FONT)) + { + // Be explicit about that the given font should be used everywhere, not + // just for the loch range. + m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_HICH); + m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_AF); + m_aStylesEnd.append((sal_Int32)m_rExport.m_aFontHelper.GetId(rFont)); + } + // FIXME: this may be a tad expensive... but the charset needs to be // consistent with what wwFont::WriteRtf() does sw::util::FontMapExport aTmp(rFont.GetFamilyName());
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits