summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-04-16 11:41:19 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-04-16 11:42:27 -0400
commit21fc47e115530780ad45ae64e8076dc5e9fedb5e (patch)
tree22cfbb3770cb3cfa9baa2de38c9e60dac864fd1a
parent0c41a9e274eb4b4fecec282638b5ff4c496ebf5a (diff)
fdo#75665: Fix the right-aligned case.
Change-Id: I905c4e331f37ed2ffbdf5c89dde9fb6c9ca546cf
-rw-r--r--sc/source/ui/view/output2.cxx29
1 files changed, 21 insertions, 8 deletions
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 90d562e33996..75efff3c0369 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)