summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-10-09 10:38:34 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-10-11 11:08:58 +0000
commitd5482208ba905df70e4012f5f5f0d9bc8bac443a (patch)
treedf700758f82d52afc491f406a6216768dea67c04 /sw
parent85da280aaa29775cda87af128bfdf7d37f4708f2 (diff)
Resolves: fdo#55546 center ellipsis tooltips that don't fit on screen
(cherry picked from commit 912ecaf565e68d2ca3fb9584712313e712749f75) Conflicts: sw/source/uibase/docvw/edtwin2.cxx sw/source/uibase/inc/edtwin.hxx Change-Id: Ic44c9032878892fa33c839e5aaac1996e7bed943 Reviewed-on: https://gerrit.libreoffice.org/11874 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/uibase/docvw/edtwin2.cxx17
-rw-r--r--sw/source/core/uibase/inc/edtwin.hxx5
2 files changed, 20 insertions, 2 deletions
diff --git a/sw/source/core/uibase/docvw/edtwin2.cxx b/sw/source/core/uibase/docvw/edtwin2.cxx
index bbcaaf1a6399..9fd7355ab70d 100644
--- a/sw/source/core/uibase/docvw/edtwin2.cxx
+++ b/sw/source/core/uibase/docvw/edtwin2.cxx
@@ -94,6 +94,17 @@ static OUString lcl_GetRedlineHelp( const SwRangeRedline& rRedl, bool bBalloon )
return sBuf.makeStringAndClear();
}
+OUString SwEditWin::ClipLongToolTip(const OUString& rTxt)
+{
+ OUString sDisplayTxt(rTxt);
+ long nTextWidth = GetTextWidth(sDisplayTxt);
+ long nMaxWidth = GetDesktopRectPixel().GetWidth() * 2 / 3;
+ nMaxWidth = PixelToLogic(Size(nMaxWidth, 0)).Width();
+ if (nTextWidth > nMaxWidth)
+ sDisplayTxt = GetEllipsisString(sDisplayTxt, nMaxWidth, TEXT_DRAW_CENTERELLIPSIS);
+ return sDisplayTxt;
+}
+
void SwEditWin::RequestHelp(const HelpEvent &rEvt)
{
SwWrtShell &rSh = m_rView.GetWrtShell();
@@ -369,7 +380,8 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt)
aPt = OutputToScreenPixel( LogicToPixel( aRect.BottomRight() ));
aRect.Right() = aPt.X();
aRect.Bottom() = aPt.Y();
- Help::ShowQuickHelp( this, aRect, sTxt, nStyle );
+ OUString sDisplayTxt(ClipLongToolTip(sTxt));
+ Help::ShowQuickHelp(this, aRect, sDisplayTxt, nStyle);
}
}
@@ -410,7 +422,8 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt)
sTxt = SW_RESSTR(nTabRes);
Size aTxtSize( GetTextWidth(sTxt), GetTextHeight());
Rectangle aRect(rEvt.GetMousePosPixel(), aTxtSize);
- Help::ShowQuickHelp(this, aRect, sTxt);
+ OUString sDisplayTxt(ClipLongToolTip(sTxt));
+ Help::ShowQuickHelp(this, aRect, sDisplayTxt);
}
bContinue = false;
}
diff --git a/sw/source/core/uibase/inc/edtwin.hxx b/sw/source/core/uibase/inc/edtwin.hxx
index aade966efa8c..7e5396de93be 100644
--- a/sw/source/core/uibase/inc/edtwin.hxx
+++ b/sw/source/core/uibase/inc/edtwin.hxx
@@ -285,6 +285,11 @@ public:
void SetUseInputLanguage( bool bNew );
bool IsUseInputLanguage() const { return m_bUseInputLanguage; }
+ /** fdo#55546 cut very long tooltips to 2/3 of the width of the screen
+ via center ellipsis
+ */
+ OUString ClipLongToolTip(const OUString& rTxt);
+
SwFrameControlsManager& GetFrameControlsManager() { return m_aFrameControlsManager; }
SwEditWin(Window *pParent, SwView &);