summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-08-08 21:55:58 +0100
committerCaolán McNamara <caolanm@redhat.com>2011-08-09 09:32:39 +0100
commitfa419956a170395d5df4f66c9564de6253d77d6d (patch)
treeea59d9525547a972113c043c3de039344fed0681
parentFix compilation errors with dbglevel>1 (diff)
downloadcore-fa419956a170395d5df4f66c9564de6253d77d6d.tar.gz
core-fa419956a170395d5df4f66c9564de6253d77d6d.zip
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 ?
-rw-r--r--svtools/source/filter/sgvtext.cxx11
1 files 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<sal_Char*>(&c), 1, RTL_TEXTENCODING_IBM_437));
}
else
{
- ChrWidth=(sal_uInt16)rOut.GetTextWidth(String('A'));
+ ChrWidth=(sal_uInt16)rOut.GetTextWidth(rtl::OUString(static_cast<sal_Unicode>('A')));
}
}
return ChrWidth;