sc/source/ui/app/inputwin.cxx |   18 +++++++++++-------
 sc/source/ui/inc/inputwin.hxx |    2 ++
 2 files changed, 13 insertions(+), 7 deletions(-)

New commits:
commit 7580fff93292d08bc6f42792f256b832f5c4bad6
Author: Noel Power <noel.po...@novell.com>
Date:   Wed Jan 25 12:36:17 2012 +0000

    fix initial height of multiline input window
    
    There is a hardcoded preferred height for the input window that was getting 
picked up becuase the result of GetTextHeight was just '1' ( due to no font 
being set up ) We shouldn't use a hardcoded value, we should always use the 
proper text height e.g. the result of a successfull call to  GetTextHeight() ( 
the patch makes sure we get a decent result from this call )

diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 1ae727c..3771d37 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -1128,6 +1128,15 @@ ScMultiTextWnd::ScMultiTextWnd( ScInputBarGroup* pParen, 
ScTabViewShell* pViewSh
         mnLastExpandedLines( INPUTWIN_MULTILINES ),
         mbInvalidate( false )
 {
+    // Calculate the text height, need to set a font for that. Probably we 
could set the font
+    // here ( on this Window ) and avoid the temp Window. OTOH vcl is such a 
mystery I prefer
+    // to minimise possible unexpected side-affects this way
+    Window aTmp(this, WB_BORDER );
+    aTmp.SetFont(aTextFont);
+    mnTextHeight = LogicToPixel(Size(0,aTmp.GetTextHeight())).Height() ;
+    Size aBorder;
+    aBorder = CalcWindowSize( aBorder);
+    mnBorderHeight = aBorder.Height();
     nTextStartPos = TEXT_MULTI_STARTPOS;
 }
 
@@ -1158,13 +1167,8 @@ EditView* ScMultiTextWnd::GetEditView()
 
 long ScMultiTextWnd::GetPixelHeightForLines( long nLines )
 {
-    long height = ( LogicToPixel(Size(0,GetTextHeight())).Height() );
-    // need to figure out why GetTextHeight is not set up when I need it
-    // some initialisation timing issue ?
-    height = Max ( long( 14 ), height );
-    // add padding ( for the borders of the window I guess ) otherwise we
-    // chop slightly the top and bottom of whatever is in the inputbox
-    return ( nLines *  height ) + 4;
+    // add padding ( for the borders of the window )
+    return ( nLines *  mnTextHeight ) + mnBorderHeight;
 }
 
 void ScMultiTextWnd::SetNumLines( long nLines )
diff --git a/sc/source/ui/inc/inputwin.hxx b/sc/source/ui/inc/inputwin.hxx
index eec7fed..185ac45 100644
--- a/sc/source/ui/inc/inputwin.hxx
+++ b/sc/source/ui/inc/inputwin.hxx
@@ -204,6 +204,8 @@ private:
     ScInputBarGroup& mrGroupBar;
     long mnLines;
     long mnLastExpandedLines;
+    long mnTextHeight;
+    long mnBorderHeight;
     bool mbInvalidate;
 };
 
_______________________________________________
Libreoffice-commits mailing list
Libreoffice-commits@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to