diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-11-14 12:19:09 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-11-14 12:19:09 +0000 |
commit | fb754a0df859e30255c25af8fa19bfaa75f257e7 (patch) | |
tree | 7e252acc2761f4912a5fa80d185649cf95755aea | |
parent | fff1cec87f3c81904dad98b7a2ccd50138264791 (diff) |
original would unconditionally truncate to nLen
-rw-r--r-- | sc/source/ui/docshell/docsh.cxx | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 4a0981d43658..65fccaafd7d8 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -1612,10 +1612,17 @@ void lcl_ScDocShell_GetFixedWidthString( rtl::OUString& rStr, const ScDocument& rtl::OUString aString = rStr; sal_Int32 nLen = lcl_ScDocShell_GetColWidthInChars( rDoc.GetColWidth( nCol, nTab ) ); + //If the text won't fit in the column if ( nLen < aString.getLength() ) { - if ( bValue ) - aString = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "###" )); + rtl::OUStringBuffer aReplacement; + if (bValue) + aReplacement.appendAscii(RTL_CONSTASCII_STRINGPARAM("###")); + else + aReplacement.append(aString); + //truncate to the number of characters that should fit, even in the + //bValue case nLen might be < len ### + aString = comphelper::string::truncateToLength(aReplacement, nLen).makeStringAndClear(); } if ( nLen > aString.getLength() ) { |