[Libreoffice] [GSOC][PATCH] Multiline inputbar

Anurag Jain anuragjainfzd at gmail.com
Thu May 12 15:23:54 PDT 2011


Hello There,

I'm posting here the git diff of the work I've done till now.
@Kohei Since I do not want to disturb my master branch I'm here
pasting the diff only. Please create a feature branch and apply it, so
that I can clone that branch and commit on that.


diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index a293c22..8019fee 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -31,6 +31,8 @@

 #include <algorithm>

+#include<stdio.h>
+
 #include "scitems.hxx"
 #include <editeng/eeitem.hxx>

@@ -137,10 +139,11 @@ ScInputWindow::ScInputWindow( Window* pParent,
SfxBindings* pBind ) :
 // mit WB_CLIPCHILDREN, sonst Flicker
         ToolBox         ( pParent,
WinBits(WB_BORDER|WB_3DLOOK|WB_CLIPCHILDREN) ),
         aWndPos         ( this ),
+//      maScrollBar     ( this,  WB_VERT | WB_DRAG ),
         aTextWindow     ( this ),
         pInputHdl		( NULL ),
         pBindings       ( pBind ),
-        aTextOk			( ScResId( SCSTR_QHELP_BTNOK ) ),		// nicht immer
neu aus Resource
+        aTextOk			( ScResId( SCSTR_QHELP_BTNOK ) ),		// not always
new from Resource
         aTextCancel		( ScResId( SCSTR_QHELP_BTNCANCEL ) ),
         aTextSum		( ScResId( SCSTR_QHELP_BTNSUM ) ),
         aTextEqual		( ScResId( SCSTR_QHELP_BTNEQUAL ) ),
@@ -161,7 +164,7 @@ ScInputWindow::ScInputWindow( Window* pParent,
SfxBindings* pBind ) :
     }
     DBG_ASSERT( pViewSh, "no view shell for input window" );

-    // Positionsfenster, 3 Buttons, Eingabefenster
+    // Position window, 3 buttons, input window
     InsertWindow    ( 1, &aWndPos, 0,								      0 );
     InsertSeparator ( 												   	  1 );
     InsertItem      ( SID_INPUT_FUNCTION, IMAGE( SID_INPUT_FUNCTION ), 0, 2 );
@@ -169,12 +172,21 @@ ScInputWindow::ScInputWindow( Window* pParent,
SfxBindings* pBind ) :
     InsertItem      ( SID_INPUT_EQUAL,	  IMAGE( SID_INPUT_EQUAL ), 0,    4 );
     InsertSeparator ( 												      5 );
     InsertWindow    ( 7, &aTextWindow, 0,                                 6 );
+//  InsertWindow    ( 8, &maScrollBar, 0,                                 8 );

     aWndPos	   .SetQuickHelpText( ScResId( SCSTR_QHELP_POSWND ) );
     aWndPos    .SetHelpId		( HID_INSWIN_POS );
     aTextWindow.SetQuickHelpText( ScResId( SCSTR_QHELP_INPUTWND ) );
     aTextWindow.SetHelpId		( HID_INSWIN_INPUT );

+/*
+    maScrollBar.SetPageSize( 1 );
+    maScrollBar.SetVisibleSize( 1 );
+    maScrollBar.SetLineSize( 1 );
+    maScrollBar.SetRange( Range( 0, 1 ) );
+    maScrollBar.SetThumbPos( 10 );
+*/
+
     //	kein SetHelpText, die Hilfetexte kommen aus der Hilfe

     SetItemText ( SID_INPUT_FUNCTION, ScResId( SCSTR_QHELP_BTNCALC ) );
@@ -189,6 +201,7 @@ ScInputWindow::ScInputWindow( Window* pParent,
SfxBindings* pBind ) :
     SetHelpId( HID_SC_INPUTWIN );	// fuer die ganze Eingabezeile

     aWndPos		.Show();
+//  maScrollBar .Show();
     aTextWindow	.Show();

     pInputHdl = SC_MOD()->GetInputHdl( pViewSh, false );    // use
own handler even if ref-handler is set
@@ -489,7 +502,11 @@ void ScInputWindow::Resize()
     long nLeft  = aTextWindow.GetPosPixel().X();
     Size aSize  = aTextWindow.GetSizePixel();

-    aSize.Width() = Max( ((long)(nWidth - nLeft - 5)), (long)0 );
+    aSize.Width() = Max( ((long)(nWidth - nLeft - 40)), (long)0 );
+
+    printf("Inside ScInputWindow:Resize()\n");
+    printf("nWidth %ld nLeft %ld aSize.Width%ld \n",nWidth, nLeft,
aSize.Width());
+
     aTextWindow.SetSizePixel( aSize );
     aTextWindow.Invalidate();
 }
@@ -534,10 +551,15 @@ void ScInputWindow::SetPosString( const String& rStr )

 void ScInputWindow::SetTextString( const String& rString )
 {
+    int i = rString.Len();
     if (rString.Len() <= 32767)
+    {
         aTextWindow.SetTextString(rString);
+        printf("%d ScInputWnd:SetTextString(),  if \n",i);
+    }
     else
     {
+        printf("%d ScInputWnd:SetTextString(),  else \n",i);
         String aNew = rString;
         aNew.Erase(32767);
         aTextWindow.SetTextString(aNew);
@@ -705,7 +727,7 @@ void ScInputWindow::DataChanged( const
DataChangedEvent& rDCEvt )
 }

 //========================================================================
-// 							Eingabefenster
+// 							Input Window
 //========================================================================

 ScTextWnd::ScTextWnd( Window* pParent )
@@ -779,6 +801,8 @@ void ScTextWnd::Paint( const Rectangle& rRec )
             //	LayoutMode isn't changed as long as ModifyRTLDefaults
doesn't include SvxFrameDirectionItem
         }

+        printf("ScTextWnd::Paint() nDiff: %ld GOSP height %ld text
height \n",nDiff, GetOutputSizePixel().Height(), LogicToPixel( Size(
0, GetTextHeight() ) ).Height());
+
         DrawText( PixelToLogic( Point( nStartPos, nDiff/2 ) ), aString );
     }
 }
@@ -793,6 +817,8 @@ void ScTextWnd::Resize()

         aSize.Width() -= 2 * TEXT_STARTPOS - 1;

+        printf("ScTextWnd:Resize() width %ld \n",aSize.Width());
+
         pEditView->SetOutputArea(
             PixelToLogic( Rectangle( Point( TEXT_STARTPOS, (nDiff >
0) ? nDiff/2 : 1 ),
                                      aSize ) ) );
@@ -1036,8 +1062,16 @@ void ScTextWnd::StartEditEngine()
         pNew->SetExecuteURL( false );
         pEditEngine = pNew;

+        Size barSize=GetOutputSizePixel();
+
+        long barHeight=barSize.Height();
+        long textHeight=LogicToPixel( Size( 0, GetTextHeight() ) ).Height();
+        long nDiff =  barHeight - textHeight;
+
+        barSize.Height()=nDiff+barHeight;
+        barSize.Width() -= 2*TEXT_STARTPOS-4;
         pEditEngine->SetUpdateMode( false );
-        pEditEngine->SetPaperSize( Size( bIsRTL ? USHRT_MAX : THESIZE, 300 ) );
+        pEditEngine->SetPaperSize( PixelToLogic(barSize) );
         pEditEngine->SetWordDelimiters(
                         ScEditUtil::ModifyDelimiters(
pEditEngine->GetWordDelimiters() ) );

diff --git a/sc/source/ui/inc/inputwin.hxx b/sc/source/ui/inc/inputwin.hxx
index 6c3785d..338020a 100644
--- a/sc/source/ui/inc/inputwin.hxx
+++ b/sc/source/ui/inc/inputwin.hxx
@@ -34,6 +34,7 @@
 #include <sfx2/childwin.hxx>
 #include <svl/lstner.hxx>
 #include <vcl/combobox.hxx>
+#include <vcl/scrbar.hxx>
 #include <vcl/window.hxx>
 #include <svtools/transfer.hxx>

@@ -115,7 +116,7 @@ private:

 //========================================================================

-class ScPosWnd : public ComboBox, public SfxListener		// Positionsanzeige
+class ScPosWnd : public ComboBox, public SfxListener		// Position window
 {
 private:
     String			aPosStr;
@@ -199,6 +200,7 @@ protected:

 private:
     ScPosWnd		aWndPos;
+//  ScrollBar		maScrollBar;
     ScTextWnd		aTextWindow;
     ScInputHandler*	pInputHdl;
     SfxBindings*    pBindings;


Thanks and regards.

-- 
Anurag Jain
Final yr B.Tech CSE
SASTRA University
Thanjavur(T.N.)-613402


More information about the LibreOffice mailing list