[Libreoffice-commits] core.git: sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Wed Apr 16 08:41:57 PDT 2014


 sc/source/ui/view/output2.cxx |   29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

New commits:
commit 21fc47e115530780ad45ae64e8076dc5e9fedb5e
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Wed Apr 16 11:41:19 2014 -0400

    fdo#75665: Fix the right-aligned case.
    
    Change-Id: I905c4e331f37ed2ffbdf5c89dde9fb6c9ca546cf

diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 90d562e..75efff3 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -2034,18 +2034,31 @@ void ScOutputData::DrawStrings( bool bPixelToLogic )
 
                             double fVisibleRatio = 1.0;
                             double fTextWidth = aVars.GetTextSize().Width();
+                            sal_Int32 nTextLen = aString.getLength();
                             if (eOutHorJust == SVX_HOR_JUSTIFY_LEFT && aAreaParam.mnRightClipLength > 0)
+                            {
                                 fVisibleRatio = (fTextWidth - aAreaParam.mnRightClipLength) / fTextWidth;
+                                if (0.0 < fVisibleRatio && fVisibleRatio < 1.0)
+                                {
+                                    // Only show the left-end segment.
+                                    sal_Int32 nShortLen = fVisibleRatio*nTextLen + 1;
+                                    aShort = aShort.copy(0, nShortLen);
+                                }
+                            }
                             else if (eOutHorJust == SVX_HOR_JUSTIFY_RIGHT && aAreaParam.mnLeftClipLength > 0)
-                                fVisibleRatio = (fTextWidth - aAreaParam.mnLeftClipLength) / fTextWidth;
-
-                            if (fVisibleRatio < 1.0)
                             {
-                                // Heuristically determine the length of the
-                                // visible section of the string.  Length + 1
-                                // to avoid becoming too short.
-                                sal_Int32 nShortLen = fVisibleRatio * aString.getLength() + 1;
-                                aShort = aShort.copy(0, nShortLen);
+                                fVisibleRatio = (fTextWidth - aAreaParam.mnLeftClipLength) / fTextWidth;
+                                if (0.0 < fVisibleRatio && fVisibleRatio < 1.0)
+                                {
+                                    // Only show the right-end segment.
+                                    sal_Int32 nShortLen = fVisibleRatio*nTextLen + 1;
+                                    aShort = aShort.copy(nTextLen-nShortLen);
+
+                                    // Adjust the text position after shortening of the string.
+                                    double fShortWidth = pFmtDevice->GetTextWidth(aShort);
+                                    double fOffset = fTextWidth - fShortWidth;
+                                    aDrawTextPos.Move(fOffset, 0);
+                                }
                             }
 
                             if (bMetaFile || pFmtDevice != mpDev || aZoomX != aZoomY)


More information about the Libreoffice-commits mailing list