From fa419956a170395d5df4f66c9564de6253d77d6d Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 8 Aug 2011 21:55:58 +0100 Subject: Convert directly from RTL_TEXTENCODING_IBM_437 to unicode When we draw this text we assume it's in RTL_TEXTENCODING_IBM_437 and convert from RTL_TEXTENCODING_IBM_437 to unicode. So why when we determine the width to use convert from RTL_TEXTENCODING_IBM_437 to the system encoding, which could be anything, and get the width of that ? --- svtools/source/filter/sgvtext.cxx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/svtools/source/filter/sgvtext.cxx b/svtools/source/filter/sgvtext.cxx index ed83389d8fee..c3dfeff557e2 100644 --- a/svtools/source/filter/sgvtext.cxx +++ b/svtools/source/filter/sgvtext.cxx @@ -693,27 +693,28 @@ UCHAR Upcase(UCHAR c) sal_uInt16 GetCharWidth(OutputDevice& rOut, UCHAR c) { - UCHAR c1; sal_uInt16 ChrWidth; - c1 = ByteString::Convert((char)c,RTL_TEXTENCODING_IBM_437, gsl_getSystemTextEncoding() ); if (c==' ') { ChrWidth=(sal_uInt16)rOut.GetTextWidth( String('A') ); if (rOut.GetFont().GetPitch()!=PITCH_FIXED) { ChrWidth=MulDiv(ChrWidth,DefaultSpace,100); } - } else { + } + else + { // with MaxChar == 255 c cannot be greater than MaxChar // assert if MaxChar is ever changed OSL_ENSURE( MaxChar == 255, "MaxChar not 255" ); + OSL_ENSURE(sizeof(UCHAR) == 1, "should be 1"); if (c>=MinChar /*&& c<=MaxChar*/) { - ChrWidth=(sal_uInt16)rOut.GetTextWidth(String((char)c1)); + ChrWidth=(sal_uInt16)rOut.GetTextWidth(rtl::OUString(reinterpret_cast(&c), 1, RTL_TEXTENCODING_IBM_437)); } else { - ChrWidth=(sal_uInt16)rOut.GetTextWidth(String('A')); + ChrWidth=(sal_uInt16)rOut.GetTextWidth(rtl::OUString(static_cast('A'))); } } return ChrWidth; -- cgit