[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - sw/source
Stephan Bergmann
sbergman at redhat.com
Fri Jun 13 07:12:47 PDT 2014
sw/source/filter/ww8/writerwordglue.cxx | 41 +++++++++++++-------------------
1 file changed, 17 insertions(+), 24 deletions(-)
New commits:
commit 6a4e688c84a12ced4113ea28f9d8837d2d616690
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Fri Jun 13 10:09:41 2014 +0200
fdo#77979: Make rtl_TextEncodingToWinCharsetRTF work for non-Unicode
"LC_ALL=C make CppunitTest_sw_rtfexport" was still failing after
e47a02b1524061143d8e77a54eb95c77f2e6dae2 "fdo#77979: sw: RTF export: write non-
ASCII font names encoded," so for each given eTextEncoding determine a Windows
charset that can at least encode the font's name, and not only for Unicode-
related eTextEncodings.
Change-Id: If547566bb0cffc60411d8f667d76749a904f7a3f
(cherry picked from commit 0dc7d6367dcedff8741b64f5b8775ebf26f7f14f)
Reviewed-on: https://gerrit.libreoffice.org/9763
Reviewed-by: Michael Stahl <mstahl at redhat.com>
Tested-by: Michael Stahl <mstahl at redhat.com>
diff --git a/sw/source/filter/ww8/writerwordglue.cxx b/sw/source/filter/ww8/writerwordglue.cxx
index f4141e5..0f4c133 100644
--- a/sw/source/filter/ww8/writerwordglue.cxx
+++ b/sw/source/filter/ww8/writerwordglue.cxx
@@ -725,38 +725,31 @@ namespace sw
OUString const& rFontName, OUString const& rAltName,
rtl_TextEncoding eTextEncoding)
{
- static struct { rtl_TextEncoding enc; sal_uInt8 charset; }
+ sal_uInt8 nRet =
+ rtl_getBestWindowsCharsetFromTextEncoding(eTextEncoding);
+ rtl_TextEncoding enc2 = rtl_getTextEncodingFromWindowsCharset(nRet);
+ if (!(CanEncode(rFontName, enc2) && CanEncode(rAltName, enc2)))
+ {
+ static struct { rtl_TextEncoding enc; sal_uInt8 charset; }
const s_fallbacks [] = {
{ RTL_TEXTENCODING_MS_932, 0x80 }, // Shift-JIS
{ RTL_TEXTENCODING_MS_936, 0x86 }, // GB-2312
{ RTL_TEXTENCODING_MS_950, 0x88 }, // Big5
{ RTL_TEXTENCODING_MS_949, 0x81 }, // EUC-KR
};
- sal_uInt8 nRet =
- rtl_getBestWindowsCharsetFromTextEncoding(eTextEncoding);
- switch (eTextEncoding)
- {
- case RTL_TEXTENCODING_DONTKNOW:
- case RTL_TEXTENCODING_UCS2:
- case RTL_TEXTENCODING_UTF7:
- case RTL_TEXTENCODING_UTF8:
- case RTL_TEXTENCODING_JAVA_UTF8:
- for (size_t i = 0; i < SAL_N_ELEMENTS(s_fallbacks); ++i)
+ for (size_t i = 0; i < SAL_N_ELEMENTS(s_fallbacks); ++i)
+ {
+ // fall back to a charset that can at least encode the
+ // font's name
+ if (CanEncode(rFontName, s_fallbacks[i].enc)
+ && CanEncode(rAltName, s_fallbacks[i].enc))
{
- // fall back to a charset that can at least encode
- // the font's name
- if (CanEncode(rFontName, s_fallbacks[i].enc)
- && CanEncode(rAltName, s_fallbacks[i].enc))
- {
- return s_fallbacks[i].charset;
- }
+ return s_fallbacks[i].charset;
}
- SAL_INFO("sw.rtf", "no fallback charset found for font: "
- << rFontName << " " << rAltName);
- nRet = 0x01; // all hope lost: "default", whatever that is
- break;
- default:
- break;
+ }
+ SAL_INFO("sw.rtf", "no fallback charset found for font: "
+ << rFontName << " " << rAltName);
+ nRet = 0x01; // all hope lost: "default", whatever that is
}
return nRet;
}
More information about the Libreoffice-commits
mailing list