summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-05-10 16:45:50 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-05-10 16:51:33 +0200
commit07d01742c69f1c0335bc7e1b57abd8341ce255e7 (patch)
tree74134a902b8017e7c74667401970431a92cd513f
parentea923cd424f6426d69a7fb375f5ac9e19ec2246a (diff)
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
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.cxx6
-rw-r--r--sw/source/filter/ww8/rtfexport.cxx18
-rw-r--r--sw/source/filter/ww8/wrtw8sty.cxx2
3 files changed, 6 insertions, 20 deletions
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 3629384ac7f6..b3da71658f36 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 8101125ded0a..801ed5b40fd2 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 700066bb5473..f4751086adfe 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 );