[Libreoffice-commits] .: Branch 'libreoffice-3-5' - sc/source

Eike Rathke erack at kemper.freedesktop.org
Fri May 11 05:40:25 PDT 2012


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

New commits:
commit a2859b0bdf4bc84ea02c3a59ae4d626739732643
Author: Noel Power <noel.power at 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 )
    (cherry picked from commit 7580fff93292d08bc6f42792f256b832f5c4bad6)
    
    Signed-off-by: Eike Rathke <erack at redhat.com>

diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index b7592e3..b61ccb9 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -1133,6 +1133,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;
 }
 
@@ -1163,13 +1172,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 ae8383d..b0facf1 100644
--- a/sc/source/ui/inc/inputwin.hxx
+++ b/sc/source/ui/inc/inputwin.hxx
@@ -207,6 +207,8 @@ private:
     ScInputBarGroup& mrGroupBar;
     long mnLines;
     long mnLastExpandedLines;
+    long mnTextHeight;
+    long mnBorderHeight;
     bool mbInvalidate;
 };
 


More information about the Libreoffice-commits mailing list