[Libreoffice-commits] .: sw/source
Miklos Vajna
vmiklos at kemper.freedesktop.org
Thu May 10 07:51:31 PDT 2012
sw/source/filter/ww8/rtfattributeoutput.cxx | 6 +++---
sw/source/filter/ww8/rtfexport.cxx | 18 ++----------------
sw/source/filter/ww8/wrtw8sty.cxx | 2 +-
3 files changed, 6 insertions(+), 20 deletions(-)
New commits:
commit 07d01742c69f1c0335bc7e1b57abd8341ce255e7
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Thu May 10 16:45:50 2012 +0200
i#119219 fix non-unicode RTF export
There were two problems here:
- non-unicode charset being set to Shift JIS for all UTF-8 text
- non-unicode text using UTF-8
Change-Id: I533d3e950a4ebd611b5d5db8a95e724e729a641f
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 3629384..b3da716 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -412,10 +412,10 @@ void RtfAttributeOutput::EndRunProperties( const SwRedlineData* /*pRedlineData*/
m_aRun->append(m_aStyles.makeStringAndClear());
}
-void RtfAttributeOutput::RunText( const String& rText, rtl_TextEncoding eCharSet )
+void RtfAttributeOutput::RunText( const String& rText, rtl_TextEncoding /*eCharSet*/ )
{
SAL_INFO("sw.rtf", OSL_THIS_FUNC);
- RawText( rText, 0, eCharSet );
+ RawText( rText, 0, m_rExport.eCurrentEncoding );
}
OStringBuffer& RtfAttributeOutput::RunText()
@@ -1911,7 +1911,7 @@ 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.maFontHelper.GetId(rFont));
- m_rExport.eCurrentEncoding = rtl_getTextEncodingFromWindowsCharset(sw::ms::rtl_TextEncodingToWinCharset(rFont.GetCharSet()));
+ m_rExport.eCurrentEncoding = rtl_getTextEncodingFromWindowsCharset(rtl_getBestWindowsCharsetFromTextEncoding(rFont.GetCharSet()));
}
void RtfAttributeOutput::CharFontSize( const SvxFontHeightItem& rFontSize)
diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx
index 8101125..801ed5b 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -882,27 +882,13 @@ OString RtfExport::OutChar(sal_Unicode c, int *pUCMode, rtl_TextEncoding eDestEn
if (c >= ' ' && c <= '~')
aBuf.append((sal_Char)c);
else {
- //If we can't convert to the dest encoding, or if
- //its an uncommon multibyte sequence which most
- //readers won't be able to handle correctly, then
- //If we can't convert to the dest encoding, then
- //export as unicode
OUString sBuf(&c, 1);
OString sConverted;
- sal_uInt32 nFlags =
- RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR |
- RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR;
- bool bWriteAsUnicode = !(sBuf.convertToString(&sConverted,
- eDestEnc, nFlags))
- || (RTL_TEXTENCODING_UTF8==eDestEnc); // #i43933# do not export UTF-8 chars in RTF;
- if (bWriteAsUnicode)
- sBuf.convertToString(&sConverted,
- eDestEnc, OUSTRING_TO_OSTRING_CVTFLAGS);
+ sBuf.convertToString(&sConverted, eDestEnc, OUSTRING_TO_OSTRING_CVTFLAGS);
const sal_Int32 nLen = sConverted.getLength();
- if (bWriteAsUnicode && pUCMode)
+ if (pUCMode)
{
- // then write as unicode - character
if (*pUCMode != nLen)
{
aBuf.append("\\uc");
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index 700066b..f475108 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -735,7 +735,7 @@ void wwFont::WriteRtf( const RtfAttributeOutput* rAttrOutput ) const
{
rAttrOutput->FontFamilyType( meFamily, *this );
rAttrOutput->FontPitchType( mePitch );
- rAttrOutput->FontCharset( sw::ms::rtl_TextEncodingToWinCharset( meChrSet ) );
+ rAttrOutput->FontCharset( rtl_getBestWindowsCharsetFromTextEncoding( meChrSet ) );
rAttrOutput->StartFont( msFamilyNm );
if ( mbAlt )
rAttrOutput->FontAlternateName( msAltNm );
More information about the Libreoffice-commits
mailing list