From 463f2d4fe211e991d551be67be74cf2090afdb7e Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 16 Jan 2013 11:55:18 +0000 Subject: Related: fdo#59182 make SvxShowText::GetOptimalSize match its SetFont logic SetFont takes the window size to determine the best font size, so reverse that SetFont logic to get the desired optimal window size. Change-Id: I0d2e35a780552ca52aec20809bcb77d37b6a1bfb --- cui/source/dialogs/cuicharmap.cxx | 8 ++++++++ cui/source/inc/cuicharmap.hxx | 2 ++ 2 files changed, 10 insertions(+) diff --git a/cui/source/dialogs/cuicharmap.cxx b/cui/source/dialogs/cuicharmap.cxx index f457ba390399..c88da88ba719 100644 --- a/cui/source/dialogs/cuicharmap.cxx +++ b/cui/source/dialogs/cuicharmap.cxx @@ -241,6 +241,14 @@ void SvxShowText::SetFont( const Font& rFont ) Invalidate(); } +Size SvxShowText::GetOptimalSize() const +{ + const Font &rFont = GetFont(); + const Size rFontSize = rFont.GetSize(); + long nWinHeight = LogicToPixel(rFontSize).Height() * 2; + return Size( GetTextWidth( GetText() ) + 2 * 12, nWinHeight ); +} + void SvxShowText::Resize() { Control::Resize(); diff --git a/cui/source/inc/cuicharmap.hxx b/cui/source/inc/cuicharmap.hxx index e2e8e1c2486d..13af57378948 100644 --- a/cui/source/inc/cuicharmap.hxx +++ b/cui/source/inc/cuicharmap.hxx @@ -49,6 +49,8 @@ public: virtual void Resize(); + virtual Size GetOptimalSize() const; + protected: virtual void Paint( const Rectangle& ); -- cgit v1.2.3