[Libreoffice-commits] .: Branch 'feature/calc-multiline-input' - sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Thu Aug 4 06:27:49 PDT 2011


 sc/source/ui/app/inputwin.cxx |   83 ++++++++++++++++++++++++++++--------------
 1 file changed, 56 insertions(+), 27 deletions(-)

New commits:
commit d028facc9173094bcb5e9fffc265704e1430abbb
Author: ANURAG JAIN <anuragjainfzd at gmail.com>
Date:   Thu Aug 4 13:38:26 2011 +0530

    Implemented the resizing of output are in multi-line mode and added a NULL pointer check with a FAIL message. Still there are improvements to be done in the resizinf of the text box.

diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 8566bf9..f1c2598 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -510,12 +510,10 @@ void ScInputWindow::Resize()
         //aTextWindow.SetSizePixel( aSize );
         if( bIsMultiLine )
         {
-        printf("increased\n");
         aSize.Height()=77;
         }
         else
         {
-        printf("reduced\n");
         aSize.Height()=33;
         }
         SetSizePixel(aSize);
@@ -718,7 +716,6 @@ void ScInputWindow::EnableButtons( sal_Bool bEnable )
 void ScInputWindow::StateChanged( StateChangedType nType )
 {
     ToolBox::StateChanged( nType );
-    printf("here\n");
     if ( nType == STATE_CHANGE_INITSHOW ) Resize();
 }
 
@@ -807,15 +804,21 @@ void ScInputBarGroup::SetTextString( const String& rString )
 void ScInputBarGroup::Resize()
 {
     Window *w=GetParent();
-    ScInputWindow *sw;
-    sw=dynamic_cast<ScInputWindow*>(w);
+    ScInputWindow *pParent;
+    pParent=dynamic_cast<ScInputWindow*>(w);
 
-    long nWidth = sw->GetSizePixel().Width();
+    if(pParent==NULL)
+    {
+        OSL_FAIL("The parent window pointer pParent is null");
+        return;
+    }
+
+    long nWidth = pParent->GetSizePixel().Width();
     long nLeft  = GetPosPixel().X();
     Size aSize  = GetSizePixel();
     aSize.Width() = Max( ((long)(nWidth - nLeft - LEFT_OFFSET)), (long)0 );
 
-    if(sw->GetMultiLineStatus())
+    if(pParent->GetMultiLineStatus())
     {
         aSize.Height()=3*TBX_WINDOW_HEIGHT;
     }
@@ -873,19 +876,25 @@ void ScInputBarGroup::SetFormulaMode(sal_Bool bSet)
 IMPL_LINK( ScInputBarGroup, ClickHdl, PushButton*, pBtn )
 {
     Window *w=GetParent();
-    ScInputWindow *sw;
-    sw=dynamic_cast<ScInputWindow*>(w);
+    ScInputWindow *pParent;
+    pParent=dynamic_cast<ScInputWindow*>(w);
+    
+    if(pParent==NULL)
+    {
+        OSL_FAIL("The parent window pointer pParent is null");
+        return 1;
+    }
 
-    if(!sw->GetMultiLineStatus())
+    if(!pParent->GetMultiLineStatus())
     {
-        sw->SetMultiLineStatus(true);
+        pParent->SetMultiLineStatus(true);
     }
     else
     {
-        sw->SetMultiLineStatus(false);
+        pParent->SetMultiLineStatus(false);
     }
-    sw->Resize();
-    sw->RecalcItems();
+    pParent->Resize();
+    pParent->RecalcItems();
     return 0;
 }
 
@@ -922,34 +931,54 @@ void ScMultiTextWnd::Paint( const Rectangle& rRec )
 void ScMultiTextWnd::Resize()
 {
     Window *w=GetParent()->GetParent();
-    ScInputWindow *sw;
-    sw=dynamic_cast<ScInputWindow*>(w);
+    ScInputWindow *pParent;
+    pParent=dynamic_cast<ScInputWindow*>(w);
+
+    if(pParent==NULL)
+    {
+        OSL_FAIL("The parent window pointer pParent is null");
+        return;
+    }
 
     long nWidth = GetParent()->GetSizePixel().Width();
     long nLeft  = GetPosPixel().X();
     Size cSize  = GetSizePixel();
     cSize.Width() = Max( ((long)(nWidth - nLeft - 3*LEFT_OFFSET)), (long)0 );
 
-    if(sw->GetMultiLineStatus())
+    if(pParent->GetMultiLineStatus())
     {
         cSize.Height()=3*TBX_WINDOW_HEIGHT;
+        
+        if (pEditView)
+        {
+        
+        Size aSize = GetOutputSizePixel();
+        Size bSize = LogicToPixel(Size(0,pEditEngine->GetLineHeight(0,0)));
+        int nDiff=(aSize.Height()-bSize.Height())/2;
+        Point aPos(TEXT_STARTPOS,4);
+        Point aPos2(aSize.Width()-5,50);
+        pEditView->SetOutputArea(
+                PixelToLogic(Rectangle(aPos, aPos2)));
+        }
     }
     else
     {
         cSize.Height()=TBX_WINDOW_HEIGHT;
+        
+        if (pEditView)
+        {
+            Size aSize = GetOutputSizePixel();
+            Size bSize = LogicToPixel(Size(0,pEditEngine->GetLineHeight(0,0)));
+            int nDiff=(aSize.Height()-bSize.Height())/2;
+            Point aPos(TEXT_STARTPOS,nDiff*aSize.Height()/aSize.Height());
+            Point aPos2(aSize.Width()-5,(aSize.Height()-nDiff)*aSize.Height()/aSize.Height());
+            pEditView->SetOutputArea(
+                PixelToLogic(Rectangle(aPos, aPos2)));
+        } 
     }
     SetSizePixel(cSize);
 
-    if (pEditView)
-    {
-        Size aSize = GetOutputSizePixel();
-        Size bSize = LogicToPixel(Size(0,pEditEngine->GetLineHeight(0,0)));
-        int nDiff=(aSize.Height()-bSize.Height())/2;
-        Point aPos(TEXT_STARTPOS,nDiff*aSize.Height()/aSize.Height());
-        Point aPos2(aSize.Width()-5,(aSize.Height()-nDiff)*aSize.Height()/aSize.Height());
-        pEditView->SetOutputArea(
-            PixelToLogic(Rectangle(aPos, aPos2)));
-    }
+    
 }
 
 


More information about the Libreoffice-commits mailing list