Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Hello Noel,

As you asked I'm sending a patch here with most of the changes
incorporated. I've done total rework again and made a bit more
modular, removed unnecessary things and now it look way better than
what i was getting yesterday. Please have a look before you make
changes on you end and if you think this is good enough to be pushed
into Master please do so. I guess I'd be better if you make the
runtime decision thing above this patch.

As of now there are might be some printf's lying around so ignore them
as of now.
Awaiting your feedback on this.

Thanks and regards



On Mon, Jul 4, 2011 at 9:09 PM, Noel Power <nopower@novell.com> wrote:
On 04/07/11 11:29, Anurag Jain wrote:

Hello Noel,

I'm sending the inputwin.cxx with the changes I've made in
ScInputBargroup. Do not push it as of now. I'd be making some more
changes as mentioned in above mail before it can be pushed.

I guess it really isn't usable without a header file :-( I really was
looking for a patch that addressed the issues we talked about previously
that would allow me to at least start to try and integrate your work.

On Mon, Jul 4, 2011 at 3:53 PM, Anurag Jain<anuragjainfzd@gmail.com>
 wrote:

Hello Noel,

Yes I have made some changes as you mentioned this weekend. There are
certain thing I'm not getting properly.

1: I'm able to toggle the height of ScMultiBar and ScInputBarGroup on
button click. But the increment happens inside the ScInputWindow i.e.
the excess window size do not appear. It toggles inside the
ScInputWindow. To make it look the height of complete panel should be
varied.So in order to do that will it be a good idea to add a
ScInputWindow object in ScInputBarGroup and use it to vary the whole
panel's height ?

hmm, it seems that somehow the toolbar doesn't resize as expected, don't
know why, might be worth doing some debugging in
vcl/source/window/toolbox.cxx

2: Also one more thing, when button is clicked twice , the position
window, and other formula images all disappears leaving a blank on
left side of panel. I guess the ScInputBarGroup changes its vertical
position. I tried resetting it always to (nLeft,0) but the LO did not
start for some reason. As of now I'm trying to fix that. I'll discuss
about these problems today in IRC and things required to be improved a
little bit before putting it in master branch.

no idea at all about that, it sounds like either a paint problem ( but
that's easy to check by forcing repaint but moving the window offscreen and
back ) or the controls have been repositioned somehow, again some debugging
of the size and position attributes of the toolbar items should give you an
idea

I am going to try to integrate the code as it was before whatever new work
you have done because I there is little time left, it is better to have some
code integrated rather than none :-). I didn't look at the inputwin.cxx that
you attached in any great detail but I don't like the name of the new
textbox ScMultiBar, it is I think misleading, I liked some of the other
alternatives you suggested better ( e.g. ScMultiText ).
I know I suggested that you rename the class to something new but I thought
maybe you could reuse the old one ( e.g. inherit from it ) to avoid
duplicating *all* the code there. My main concern was to separate the new
from old code ( without excessive logic ( if/then ) branches in the code
especially with the requirement of having some code in master )... I will
try to fix that when integrating the code

Noel




-- 
Anurag Jain
Final yr B.Tech CSE
SASTRA University
Thanjavur(T.N.)-613402
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index dc12376..ede8585 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -172,12 +172,10 @@ ScInputWindow::ScInputWindow( Window* pParent, SfxBindings* pBind ) :
     InsertItem      ( SID_INPUT_EQUAL,   IMAGE( SID_INPUT_EQUAL ), 0,    4 );
     InsertSeparator (                                                                              
                  5 );
     InsertWindow    ( 7, &aBarGroup, 0,                              6 );
-//  InsertWindow    ( 8, &maScrollBar, 0,                                 8 );
 
+    printf("Ctor ScInputWindow\n");
     aWndPos       .SetQuickHelpText( ScResId( SCSTR_QHELP_POSWND ) );
     aWndPos    .SetHelpId              ( HID_INSWIN_POS );
-//    aTextWindow.SetQuickHelpText( ScResId( SCSTR_QHELP_INPUTWND ) );
-//    aTextWindow.SetHelpId            ( HID_INSWIN_INPUT );
 
     // kein SetHelpText, die Hilfetexte kommen aus der Hilfe
 
@@ -193,8 +191,7 @@ ScInputWindow::ScInputWindow( Window* pParent, SfxBindings* pBind ) :
     SetHelpId( HID_SC_INPUTWIN );      // fuer die ganze Eingabezeile
 
     aWndPos            .Show();
-//  maScrollBar .Show();
-    aBarGroup   .Show();
+    //aBarGroup   .Show();
 
     pInputHdl = SC_MOD()->GetInputHdl( pViewSh, false );    // use own handler even if ref-handler 
is set
     if (pInputHdl)
@@ -487,15 +484,22 @@ void ScInputWindow::Select()
 void ScInputWindow::Resize()
 {
     ToolBox::Resize();
+/*    
+
 
     long nWidth = GetSizePixel().Width();
     long nLeft  = aBarGroup.GetPosPixel().X();
     Size aSize  = aBarGroup.GetSizePixel();
 
+    printf("resize ScInputWindow\n");
     aSize.Width() = Max( ((long)(nWidth - nLeft - 10)), (long)0 );
     aSize.Height()= TBX_WINDOW_HEIGHT;
+    
+    
     aBarGroup.SetSizePixel( aSize );
-    aBarGroup.Invalidate();
+    aBarGroup.Invalidate();*/
+
+    
 
     aBarGroup.Resize();
 }
@@ -723,19 +727,17 @@ ScInputBarGroup::ScInputBarGroup(Window* pParent)
     :   Window          ( pParent, WinBits(WB_HIDE) ),
         aTextWindow      ( this ),
         maScrollBar     ( this,  WB_VERT | WB_DRAG ),
-        bIsMultiLine    ( false )
+        aButton         ( this, ScResId( 1 )),
+        bIsMultiLine    ( this )
 {
-
       aTextWindow.Show();
       aTextWindow.SetQuickHelpText( ScResId( SCSTR_QHELP_INPUTWND ) );
       aTextWindow.SetHelpId            ( HID_INSWIN_INPUT );
+      aButton.SetClickHdl      ( LINK( this, ScInputBarGroup, ClickHdl ) );
+      aButton.Show();
+      aButton.Enable();
 
-      maScrollBar.SetPageSize( 1 );
-      maScrollBar.SetVisibleSize( 1 );
-      maScrollBar.SetLineSize( 1 );
-      maScrollBar.SetRange( Range( 0, 1 ) );
-      maScrollBar.SetThumbPos( 10 );
-      maScrollBar.Show();
+      printf("Ctor inputbargroup\n");
 }
 
 ScInputBarGroup::~ScInputBarGroup()
@@ -749,13 +751,21 @@ void ScInputBarGroup::SetTextString( const String& rString )
 
 void ScInputBarGroup::Resize()
 {
-    long nWidth = GetSizePixel().Width();
-    long nLeft  = aTextWindow.GetPosPixel().X();
-    Size aSize  = aTextWindow.GetSizePixel();
-    aSize.Width() = Max( ((long)(nWidth - nLeft - 40)), (long)0 );
-    aSize.Height()=22;
-    aTextWindow.SetSizePixel( aSize );
-    aTextWindow.Invalidate();
+    long nWidth = GetParent()->GetSizePixel().Width();
+    long nLeft  = GetPosPixel().X();
+    Size aSize  = GetSizePixel();
+    aSize.Width() = Max( ((long)(nWidth - nLeft - 10)), (long)0 );
+    if(bIsMultiLine)
+    aSize.Height()=3*TBX_WINDOW_HEIGHT;
+    else
+    aSize.Height()=TBX_WINDOW_HEIGHT;
+    SetSizePixel(aSize);
+    Invalidate();
+    
+    aButton.SetPosSizePixel(Point(aSize.Width()-40,0),Size(15,22));
+    
+    aTextWindow.Resize(); 
+    printf("resize inputbargroup  %d %d\n",nWidth,nLeft);
 }
 
 void ScInputBarGroup::GainFocus()
@@ -790,18 +800,42 @@ void ScInputBarGroup::SetFormulaMode(bool bSet)
     aTextWindow.SetFormulaMode(bSet);
 }
 
+IMPL_LINK( ScInputBarGroup, ClickHdl, PushButton*, pBtn )
+{
+
+if(!bIsMultiLine)
+{   
+    bIsMultiLine=true;
+    aTextWindow.SetMultiLineStatus(true);
+    Resize();
+    printf("pressed\n");
+}
+else 
+{
+    bIsMultiLine=false;
+    aTextWindow.SetMultiLineStatus(false);
+    Resize();
+    printf("pressed again\n");
+}
+    
+
+return 0;
+}
+
+
 //========================================================================
-//                                                     Input Window
+//                                                     Multi Textbar
 //========================================================================
 
-ScTextWnd::ScTextWnd( Window* pParent )
+ScMultibar::ScMultibar( Window* pParent )
     :          Window           ( pParent, WinBits(WB_HIDE | WB_BORDER) ),
         DragSourceHelper( this ),
         pEditEngine     ( NULL ),
         pEditView       ( NULL ),
         bIsInsertMode( sal_True ),
         bFormulaMode ( false ),
-        bInputMode   ( false )
+        bInputMode   ( false ),
+        bIsMultiLine ( false )
 {
     EnableRTL( false );                // EditEngine can't be used with VCL EnableRTL
 
@@ -832,10 +866,10 @@ ScTextWnd::ScTextWnd( Window* pParent )
     SetLineColor               ( COL_BLACK );
     SetMapMode             ( MAP_TWIP );
     SetPointer             ( POINTER_TEXT );
-//    StartEditEngine();
+    printf("Ctor scmultibar\n");
 }
 
-ScTextWnd::~ScTextWnd()
+ScMultibar::~ScMultibar()
 {
     while (!maAccTextDatas.empty()) {
         maAccTextDatas.back()->Dispose();
@@ -844,7 +878,26 @@ ScTextWnd::~ScTextWnd()
     delete pEditEngine;
 }
 
-void ScTextWnd::Paint( const Rectangle& rRec )
+bool ScMultibar::GetMultiLineStatus()
+{
+    return bIsMultiLine;
+}
+
+void ScMultibar::SetMultiLineStatus(bool bMode)
+{
+    bIsMultiLine=bMode;
+}
+
+int ScMultibar::GetLineCount()
+{
+   if(pEditView)
+    {
+       return pEditEngine->GetLineCount(0);
+    }
+    return 1;
+}
+
+void ScMultibar::Paint( const Rectangle& rRec )
 {
     // We always use edit engine to draw text at all times.
     if (!pEditEngine)
@@ -856,10 +909,22 @@ void ScTextWnd::Paint( const Rectangle& rRec )
     }
 }
 
-void ScTextWnd::Resize()
-{
+void ScMultibar::Resize()
+{    
+    long nWidth = GetParent()->GetSizePixel().Width();
+    long nLeft  = GetPosPixel().X();
+    Size cSize  = GetSizePixel();
+    cSize.Width() = Max( ((long)(nWidth - nLeft - 40)), (long)0 );
+
+    if(bIsMultiLine)
+    cSize.Height()=3*TBX_WINDOW_HEIGHT;
+    else
+    cSize.Height()=TBX_WINDOW_HEIGHT;
+    
+    SetSizePixel(cSize);
+    
     if (pEditView)
-    {
+    {        
         Size aSize = GetOutputSizePixel();
         Size bSize = LogicToPixel(Size(0,pEditEngine->GetLineHeight(0,0)));
         int nDiff=(aSize.Height()-bSize.Height())/2;
@@ -870,13 +935,37 @@ void ScTextWnd::Resize()
     }
 }
 
-void ScTextWnd::MouseMove( const MouseEvent& rMEvt )
+void ScMultibar::SetSize(bool bIsMultiLine)
+{
+    printf("inside\n");
+    
+    
+    if(bIsMultiLine)
+    {
+
+        long nWidth = GetSizePixel().Width();
+        long nLeft  = GetPosPixel().X();
+        Size cSize  = GetSizePixel();
+        cSize.Width() = Max( ((long)(nWidth - nLeft - 40)), (long)0 );
+        cSize.Height()=3*TBX_WINDOW_HEIGHT;
+        SetSizePixel(cSize);
+        printf("true\n");
+    }
+    else
+        Resize();
+    
+
+    printf("resize scMultiBar  \n");
+
+}
+
+void ScMultibar::MouseMove( const MouseEvent& rMEvt )
 {
     if (pEditView)
         pEditView->MouseMove( rMEvt );
 }
 
-void ScTextWnd::MouseButtonDown( const MouseEvent& rMEvt )
+void ScMultibar::MouseButtonDown( const MouseEvent& rMEvt )
 {
     if (!HasFocus())
     {
@@ -892,7 +981,7 @@ void ScTextWnd::MouseButtonDown( const MouseEvent& rMEvt )
     }
 }
 
-void ScTextWnd::MouseButtonUp( const MouseEvent& rMEvt )
+void ScMultibar::MouseButtonUp( const MouseEvent& rMEvt )
 {
     if (pEditView)
         if (pEditView->MouseButtonUp( rMEvt ))
@@ -908,7 +997,7 @@ void ScTextWnd::MouseButtonUp( const MouseEvent& rMEvt )
         }
 }
 
-void ScTextWnd::Command( const CommandEvent& rCEvt )
+void ScMultibar::Command( const CommandEvent& rCEvt )
 {
     bInputMode = sal_True;
     sal_uInt16 nCommand = rCEvt.GetCommand();
@@ -970,7 +1059,7 @@ void ScTextWnd::Command( const CommandEvent& rCEvt )
     bInputMode = false;
 }
 
-void ScTextWnd::StartDrag( sal_Int8 /* nAction */, const Point& rPosPixel )
+void ScMultibar::StartDrag( sal_Int8 /* nAction */, const Point& rPosPixel )
 {
     if ( pEditView )
     {
@@ -982,7 +1071,7 @@ void ScTextWnd::StartDrag( sal_Int8 /* nAction */, const Point& rPosPixel )
     }
 }
 
-void ScTextWnd::KeyInput(const KeyEvent& rKEvt)
+void ScMultibar::KeyInput(const KeyEvent& rKEvt)
 {
     bInputMode = sal_True;
     if (!SC_MOD()->InputKeyEvent( rKEvt ))
@@ -997,28 +1086,27 @@ void ScTextWnd::KeyInput(const KeyEvent& rKEvt)
     bInputMode = false;
 }
 
-void ScTextWnd::GetFocus()
+void ScMultibar::GetFocus()
 {
     ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
     if ( pViewSh )
         pViewSh->SetFormShellAtTop( false );     // focus in input line -> FormShell no longer on 
top
 }
 
-void ScTextWnd::LoseFocus()
+void ScMultibar::LoseFocus()
 {
 }
 
-String ScTextWnd::GetText() const
+String ScMultibar::GetText() const
 {
     // ueberladen, um per Testtool an den Text heranzukommen
-printf("ScTextWnd::GetText()\n");
     if ( pEditEngine )
         return pEditEngine->GetText();
     else
         return GetTextString();
 }
 
-void ScTextWnd::SetFormulaMode( sal_Bool bSet )
+void ScMultibar::SetFormulaMode( sal_Bool bSet )
 {
     if ( bSet != bFormulaMode )
     {
@@ -1027,7 +1115,7 @@ void ScTextWnd::SetFormulaMode( sal_Bool bSet )
     }
 }
 
-void ScTextWnd::UpdateAutoCorrFlag()
+void ScMultibar::UpdateAutoCorrFlag()
 {
     if ( pEditEngine )
     {
@@ -1086,7 +1174,7 @@ void lcl_ModifyRTLVisArea( EditView* pEditView )
     pEditView->SetVisArea(aVisArea);
 }
 
-void ScTextWnd::InitEditEngine(SfxObjectShell* pObjSh)
+void ScMultibar::InitEditEngine(SfxObjectShell* pObjSh)
 {
     ScFieldEditEngine* pNew;
     ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
@@ -1156,7 +1244,7 @@ void ScTextWnd::InitEditEngine(SfxObjectShell* pObjSh)
     if ( bIsRTL )
         lcl_ModifyRTLVisArea( pEditView );
 
-    pEditEngine->SetModifyHdl(LINK(this, ScTextWnd, NotifyHdl));
+    pEditEngine->SetModifyHdl(LINK(this, ScMultibar, NotifyHdl));
 
     if (!maAccTextDatas.empty())
         maAccTextDatas.back()->StartEdit();
@@ -1173,7 +1261,7 @@ void ScTextWnd::InitEditEngine(SfxObjectShell* pObjSh)
     }
 }
 
-void ScTextWnd::StartEditEngine()
+void ScMultibar::StartEditEngine()
 {
     // Bei "eigener Modalitaet" (Doc-modale Dialoge) nicht aktivieren
 
@@ -1193,7 +1281,7 @@ void ScTextWnd::StartEditEngine()
         pViewFrm->GetBindings().Invalidate( SID_ATTR_INSERT );
 }
 
-IMPL_LINK(ScTextWnd, NotifyHdl, EENotify*, EMPTYARG)
+IMPL_LINK(ScMultibar, NotifyHdl, EENotify*, EMPTYARG)
 {
     if (pEditView && !bInputMode)
     {
@@ -1209,7 +1297,7 @@ IMPL_LINK(ScTextWnd, NotifyHdl, EENotify*, EMPTYARG)
     return 0;
 }
 
-void ScTextWnd::StopEditEngine( sal_Bool bAll )
+void ScMultibar::StopEditEngine( sal_Bool bAll )
 {
     printf("stopping editEngine\n");
 #if 0 // Make this a no-op for now.
@@ -1242,6 +1330,604 @@ void ScTextWnd::StopEditEngine( sal_Bool bAll )
 #endif
 }
 
+void ScMultibar::SetTextString( const String& rNewString )
+{
+    if ( rNewString != aString )
+    {
+        bInputMode = sal_True;
+
+        //     Position der Aenderung suchen, nur Rest painten
+
+        if (!pEditEngine)
+        {
+            sal_Bool bPaintAll;
+            if ( bIsRTL )
+                bPaintAll = sal_True;
+            else
+            {
+                //     test if CTL script type is involved
+                sal_uInt8 nOldScript = 0;
+                sal_uInt8 nNewScript = 0;
+                SfxObjectShell* pObjSh = SfxObjectShell::Current();
+                if ( pObjSh && pObjSh->ISA(ScDocShell) )
+                {
+                    // any document can be used (used only for its break iterator)
+                    ScDocument* pDoc = ((ScDocShell*)pObjSh)->GetDocument();
+                    nOldScript = pDoc->GetStringScriptType( aString );
+                    nNewScript = pDoc->GetStringScriptType( rNewString );
+                }
+                bPaintAll = ( nOldScript & SCRIPTTYPE_COMPLEX ) || ( nNewScript & 
SCRIPTTYPE_COMPLEX );
+            }
+
+            if ( bPaintAll )
+            {
+                // if CTL is involved, the whole text has to be redrawn
+                Invalidate();
+            }
+            else
+            {
+                long nTextSize = 0;
+                xub_StrLen nDifPos;
+                if (rNewString.Len() > aString.Len())
+                    nDifPos = rNewString.Match(aString);
+                else
+                    nDifPos = aString.Match(rNewString);
+
+                long nSize1 = GetTextWidth(aString);
+                long nSize2 = GetTextWidth(rNewString);
+                if ( nSize1>0 && nSize2>0 )
+                    nTextSize = Max( nSize1, nSize2 );
+                else
+                    nTextSize = GetOutputSize().Width();               // Ueberlauf
+
+                if (nDifPos == STRING_MATCH)
+                    nDifPos = 0;
+
+                                                // -1 wegen Rundung und "A"
+                Point aLogicStart = PixelToLogic(Point(TEXT_STARTPOS-1,0));
+                long nStartPos = aLogicStart.X();
+                long nInvPos = nStartPos;
+                if (nDifPos)
+                    nInvPos += GetTextWidth(aString,0,nDifPos);
+
+                sal_uInt16 nFlags = 0;
+                if ( nDifPos == aString.Len() )                        // only new characters 
appended
+                    nFlags = INVALIDATE_NOERASE;               // then background is already clear
+
+                Invalidate( Rectangle( nInvPos, 0,
+                                        nStartPos+nTextSize, GetOutputSize().Height()-1 ),
+                            nFlags );
+            }
+        }
+        else
+        {
+            pEditEngine->SetText(rNewString);
+        }
+
+        aString = rNewString;
+
+        if (!maAccTextDatas.empty())
+            maAccTextDatas.back()->TextChanged();
+
+        bInputMode = false;
+    }
+}
+
+const String& ScMultibar::GetTextString() const
+{
+    return aString;
+}
+
+sal_Bool ScMultibar::IsInputActive()
+{
+    return HasFocus();
+}
+
+EditView* ScMultibar::GetEditView()
+{
+    return pEditView;
+}
+
+void ScMultibar::MakeDialogEditView()
+{
+    if ( pEditView ) return;
+
+    ScFieldEditEngine* pNew;
+    ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+    if ( pViewSh )
+    {
+        const ScDocument* pDoc = pViewSh->GetViewData()->GetDocument();
+        pNew = new ScFieldEditEngine( pDoc->GetEnginePool(), pDoc->GetEditPool() );
+    }
+    else
+        pNew = new ScFieldEditEngine( EditEngine::CreatePool(),        NULL, sal_True );
+    pNew->SetExecuteURL( false );
+    pEditEngine = pNew;
+
+    pEditEngine->SetUpdateMode( false );
+    pEditEngine->SetWordDelimiters( pEditEngine->GetWordDelimiters() += '=' );
+    pEditEngine->SetPaperSize( Size( bIsRTL ? USHRT_MAX : THESIZE, 300 ) );
+
+    SfxItemSet* pSet = new SfxItemSet( pEditEngine->GetEmptyItemSet() );
+    pEditEngine->SetFontInfoInItemSet( *pSet, aTextFont );
+    lcl_ExtendEditFontAttribs( *pSet );
+    if ( bIsRTL )
+        lcl_ModifyRTLDefaults( *pSet );
+    pEditEngine->SetDefaults( pSet );
+    pEditEngine->SetUpdateMode( sal_True );
+
+    pEditView  = new EditView( pEditEngine, this );
+    pEditEngine->InsertView( pEditView, EE_APPEND );
+
+    Resize();
+
+    if ( bIsRTL )
+        lcl_ModifyRTLVisArea( pEditView );
+
+    if (!maAccTextDatas.empty())
+        maAccTextDatas.back()->StartEdit();
+}
+
+void ScMultibar::ImplInitSettings()
+{
+    bIsRTL = GetSettings().GetLayoutRTL();
+
+    const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+
+    Color aBgColor= rStyleSettings.GetWindowColor();
+    Color aTxtColor= rStyleSettings.GetWindowTextColor();
+
+    aTextFont.SetFillColor   ( aBgColor );
+    aTextFont.SetColor          (aTxtColor);
+    SetBackground                      ( aBgColor );
+    Invalidate();
+}
+
+::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > 
ScMultibar::CreateAccessible()
+{
+    return new ScAccessibleEditObject(GetAccessibleParentWindow()->GetAccessible(), NULL, this,
+        rtl::OUString(String(ScResId(STR_ACC_EDITLINE_NAME))),
+        rtl::OUString(String(ScResId(STR_ACC_EDITLINE_DESCR))), EditLine);
+}
+
+void ScMultibar::InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData )
+{
+    OSL_ENSURE( ::std::find( maAccTextDatas.begin(), maAccTextDatas.end(), &rTextData ) == 
maAccTextDatas.end(),
+        "ScMultibar::InsertAccessibleTextData - passed object already registered" );
+    maAccTextDatas.push_back( &rTextData );
+}
+
+void ScMultibar::RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData )
+{
+    AccTextDataVector::iterator aEnd = maAccTextDatas.end();
+    AccTextDataVector::iterator aIt = ::std::find( maAccTextDatas.begin(), aEnd, &rTextData );
+    OSL_ENSURE( aIt != aEnd, "ScMultibar::RemoveAccessibleTextData - passed object not registered" 
);
+    if( aIt != aEnd )
+        maAccTextDatas.erase( aIt );
+}
+
+// -----------------------------------------------------------------------
+
+void ScMultibar::DataChanged( const DataChangedEvent& rDCEvt )
+{
+    if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+         (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+    {
+        ImplInitSettings();
+        Invalidate();
+    }
+    else
+        Window::DataChanged( rDCEvt );
+}
+
+//========================================================================
+//                                                     Eingabefenster
+//========================================================================
+
+ScTextWnd::ScTextWnd( Window* pParent )
+    :  Window           ( pParent, WinBits(WB_HIDE | WB_BORDER) ),
+        DragSourceHelper( this ),
+        pEditEngine     ( NULL ),
+        pEditView       ( NULL ),
+        bIsInsertMode( sal_True ),
+        bFormulaMode ( false ),
+        bInputMode   ( false )
+{
+    EnableRTL( false );                // EditEngine can't be used with VCL EnableRTL
+
+    bIsRTL = GetSettings().GetLayoutRTL();
+
+    // always use application font, so a font with cjk chars can be installed
+    Font aAppFont = GetFont();
+    aTextFont = aAppFont;
+    aTextFont.SetSize( PixelToLogic( aAppFont.GetSize(), MAP_TWIP ) ); // AppFont ist in Pixeln
+
+    const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+
+    Color aBgColor= rStyleSettings.GetWindowColor();
+    Color aTxtColor= rStyleSettings.GetWindowTextColor();
+
+    aTextFont.SetTransparent ( sal_True );
+    aTextFont.SetFillColor   ( aBgColor );
+    //aTextFont.SetColor                ( COL_FIELDTEXT );
+    aTextFont.SetColor          (aTxtColor);
+    aTextFont.SetWeight                 ( WEIGHT_NORMAL );
+
+    Size aSize(1,TBX_WINDOW_HEIGHT);
+    Size aMinEditSize( Edit::GetMinimumEditSize() );
+    if( aMinEditSize.Height() > aSize.Height() )
+        aSize.Height() = aMinEditSize.Height();
+    SetSizePixel               ( aSize );
+    SetBackground              ( aBgColor );
+    SetLineColor               ( COL_BLACK );
+    SetMapMode             ( MAP_TWIP );
+    SetPointer             ( POINTER_TEXT );
+}
+
+ScTextWnd::~ScTextWnd()
+{
+    while (!maAccTextDatas.empty()) {
+        maAccTextDatas.back()->Dispose();
+    }
+    delete pEditView;
+    delete pEditEngine;
+}
+
+void ScTextWnd::Paint( const Rectangle& rRec )
+{
+    if (pEditView)
+        pEditView->Paint( rRec );
+    else
+    {
+        SetFont( aTextFont );
+
+        long nDiff =  GetOutputSizePixel().Height()
+                    - LogicToPixel( Size( 0, GetTextHeight() ) ).Height();
+//             if (nDiff<2) nDiff=2;           // mind. 1 Pixel
+
+        long nStartPos = TEXT_STARTPOS;
+        if ( bIsRTL )
+        {
+            // right-align
+            nStartPos += GetOutputSizePixel().Width() - 2*TEXT_STARTPOS -
+                        LogicToPixel( Size( GetTextWidth( aString ), 0 ) ).Width();
+
+            // LayoutMode isn't changed as long as ModifyRTLDefaults doesn't include 
SvxFrameDirectionItem
+        }
+
+        DrawText( PixelToLogic( Point( nStartPos, nDiff/2 ) ), aString );
+    }
+}
+
+void ScTextWnd::Resize()
+{
+    if (pEditView)
+    {
+        Size aSize = GetOutputSizePixel();
+        long nDiff =  aSize.Height()
+                    - LogicToPixel( Size( 0, GetTextHeight() ) ).Height();
+
+        aSize.Width() -= 2 * TEXT_STARTPOS - 1;
+
+        pEditView->SetOutputArea(
+            PixelToLogic( Rectangle( Point( TEXT_STARTPOS, (nDiff > 0) ? nDiff/2 : 1 ),
+                                     aSize ) ) );
+    }
+}
+
+void ScTextWnd::MouseMove( const MouseEvent& rMEvt )
+{
+    if (pEditView)
+        pEditView->MouseMove( rMEvt );
+}
+
+void ScTextWnd::MouseButtonDown( const MouseEvent& rMEvt )
+{
+    if (!HasFocus())
+    {
+        StartEditEngine();
+        if ( SC_MOD()->IsEditMode() )
+            GrabFocus();
+    }
+
+    if (pEditView)
+    {
+        pEditView->SetEditEngineUpdateMode( sal_True );
+        pEditView->MouseButtonDown( rMEvt );
+    }
+}
+
+void ScTextWnd::MouseButtonUp( const MouseEvent& rMEvt )
+{
+    if (pEditView)
+        if (pEditView->MouseButtonUp( rMEvt ))
+        {
+            if ( rMEvt.IsMiddle() &&
+                     GetSettings().GetMouseSettings().GetMiddleButtonAction() == 
MOUSE_MIDDLE_PASTESELECTION )
+            {
+                //     EditView may have pasted from selection
+                SC_MOD()->InputChanged( pEditView );
+            }
+            else
+                SC_MOD()->InputSelection( pEditView );
+        }
+}
+
+void ScTextWnd::Command( const CommandEvent& rCEvt )
+{
+    bInputMode = sal_True;
+    sal_uInt16 nCommand = rCEvt.GetCommand();
+    if ( pEditView /* && ( nCommand == COMMAND_STARTDRAG || nCommand == COMMAND_VOICE ) */ )
+    {
+        ScModule* pScMod = SC_MOD();
+        ScTabViewShell* pStartViewSh = ScTabViewShell::GetActiveViewShell();
+
+        // don't modify the font defaults here - the right defaults are
+        // already set in StartEditEngine when the EditEngine is created
+
+        // verhindern, dass die EditView beim View-Umschalten wegkommt
+        pScMod->SetInEditCommand( true );
+        pEditView->Command( rCEvt );
+        pScMod->SetInEditCommand( false );
+
+        //     COMMAND_STARTDRAG heiss noch lange nicht, dass der Inhalt geaendert wurde
+        //     darum in dem Fall kein InputChanged
+        //!    erkennen, ob mit Move gedraggt wurde, oder Drag&Move irgendwie verbieten
+
+        if ( nCommand == COMMAND_STARTDRAG )
+        {
+            // ist auf eine andere View gedraggt worden?
+            ScTabViewShell* pEndViewSh = ScTabViewShell::GetActiveViewShell();
+            if ( pEndViewSh != pStartViewSh && pStartViewSh != NULL )
+            {
+                ScViewData* pViewData = pStartViewSh->GetViewData();
+                ScInputHandler* pHdl = pScMod->GetInputHdl( pStartViewSh );
+                if ( pHdl && pViewData->HasEditView( pViewData->GetActivePart() ) )
+                {
+                    pHdl->CancelHandler();
+                    pViewData->GetView()->ShowCursor();                // fehlt bei KillEditView, 
weil nicht aktiv
+                }
+            }
+        }
+        else if ( nCommand == COMMAND_CURSORPOS )
+        {
+            // don't call InputChanged for COMMAND_CURSORPOS
+        }
+        else if ( nCommand == COMMAND_INPUTLANGUAGECHANGE )
+        {
+            // #i55929# Font and font size state depends on input language if nothing is selected,
+            // so the slots have to be invalidated when the input language is changed.
+
+            SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+            if (pViewFrm)
+            {
+                SfxBindings& rBindings = pViewFrm->GetBindings();
+                rBindings.Invalidate( SID_ATTR_CHAR_FONT );
+                rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
+            }
+        }
+        else
+            SC_MOD()->InputChanged( pEditView );
+    }
+    else
+        Window::Command(rCEvt);                //      sonst soll sich die Basisklasse drum 
kuemmern...
+
+    bInputMode = false;
+}
+
+void ScTextWnd::StartDrag( sal_Int8 /* nAction */, const Point& rPosPixel )
+{
+    if ( pEditView )
+    {
+        CommandEvent aDragEvent( rPosPixel, COMMAND_STARTDRAG, sal_True );
+        pEditView->Command( aDragEvent );
+
+        //     handling of d&d to different view (CancelHandler) can't be done here,
+        //     because the call returns before d&d is complete.
+    }
+}
+
+void ScTextWnd::KeyInput(const KeyEvent& rKEvt)
+{
+    bInputMode = sal_True;
+    if (!SC_MOD()->InputKeyEvent( rKEvt ))
+    {
+        sal_Bool bUsed = false;
+        ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+        if ( pViewSh )
+            bUsed = pViewSh->SfxKeyInput(rKEvt);       // nur Acceleratoren, keine Eingabe
+        if (!bUsed)
+            Window::KeyInput( rKEvt );
+    }
+    bInputMode = false;
+}
+
+void ScTextWnd::GetFocus()
+{
+    ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+    if ( pViewSh )
+        pViewSh->SetFormShellAtTop( false );     // focus in input line -> FormShell no longer on 
top
+}
+
+void ScTextWnd::LoseFocus()
+{
+}
+
+String ScTextWnd::GetText() const
+{
+    // ueberladen, um per Testtool an den Text heranzukommen
+
+    if ( pEditEngine )
+        return pEditEngine->GetText();
+    else
+        return GetTextString();
+}
+
+void ScTextWnd::SetFormulaMode( sal_Bool bSet )
+{
+    if ( bSet != bFormulaMode )
+    {
+        bFormulaMode = bSet;
+        UpdateAutoCorrFlag();
+    }
+}
+
+void ScTextWnd::UpdateAutoCorrFlag()
+{
+    if ( pEditEngine )
+    {
+        sal_uLong nControl = pEditEngine->GetControlWord();
+        sal_uLong nOld = nControl;
+        if ( bFormulaMode )
+            nControl &= ~EE_CNTRL_AUTOCORRECT;         // keine Autokorrektur in Formeln
+        else
+            nControl |= EE_CNTRL_AUTOCORRECT;          // sonst schon
+        if ( nControl != nOld )
+            pEditEngine->SetControlWord( nControl );
+    }
+}
+
+
+
+void ScTextWnd::StartEditEngine()
+{
+    // Bei "eigener Modalitaet" (Doc-modale Dialoge) nicht aktivieren
+    SfxObjectShell* pObjSh = SfxObjectShell::Current();
+    if ( pObjSh && pObjSh->IsInModalMode() )
+        return;
+
+    if ( !pEditView || !pEditEngine )
+    {
+        ScFieldEditEngine* pNew;
+        ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+        if ( pViewSh )
+        {
+            const ScDocument* pDoc = pViewSh->GetViewData()->GetDocument();
+            pNew = new ScFieldEditEngine( pDoc->GetEnginePool(), pDoc->GetEditPool() );
+        }
+        else
+            pNew = new ScFieldEditEngine( EditEngine::CreatePool(),    NULL, sal_True );
+        pNew->SetExecuteURL( false );
+        pEditEngine = pNew;
+
+        pEditEngine->SetUpdateMode( false );
+        pEditEngine->SetPaperSize( Size( bIsRTL ? USHRT_MAX : THESIZE, 300 ) );
+        pEditEngine->SetWordDelimiters(
+                        ScEditUtil::ModifyDelimiters( pEditEngine->GetWordDelimiters() ) );
+
+        UpdateAutoCorrFlag();
+
+        {
+            SfxItemSet* pSet = new SfxItemSet( pEditEngine->GetEmptyItemSet() );
+            pEditEngine->SetFontInfoInItemSet( *pSet, aTextFont );
+            lcl_ExtendEditFontAttribs( *pSet );
+            // turn off script spacing to match DrawText output
+            pSet->Put( SvxScriptSpaceItem( false, EE_PARA_ASIANCJKSPACING ) );
+            if ( bIsRTL )
+                lcl_ModifyRTLDefaults( *pSet );
+            pEditEngine->SetDefaults( pSet );
+        }
+
+        //     Wenn in der Zelle URL-Felder enthalten sind, muessen die auch in
+        //     die Eingabezeile uebernommen werden, weil sonst die Positionen nicht stimmen.
+
+        sal_Bool bFilled = false;
+        ScInputHandler* pHdl = SC_MOD()->GetInputHdl();
+        if ( pHdl )                    //!     Testen, ob's der richtige InputHdl ist?
+            bFilled = pHdl->GetTextAndFields( *pEditEngine );
+
+        pEditEngine->SetUpdateMode( sal_True );
+
+        //     aString ist die Wahrheit...
+        if ( bFilled && pEditEngine->GetText() == aString )
+            Invalidate();                                              // Repaint fuer 
(hinterlegte) Felder
+        else
+            pEditEngine->SetText(aString);             // dann wenigstens den richtigen Text
+
+        pEditView = new EditView( pEditEngine, this );
+        pEditView->SetInsertMode(bIsInsertMode);
+
+        // Text aus Clipboard wird als ASCII einzeilig uebernommen
+        sal_uLong n = pEditView->GetControlWord();
+        pEditView->SetControlWord( n | EV_CNTRL_SINGLELINEPASTE        );
+
+        pEditEngine->InsertView( pEditView, EE_APPEND );
+
+        Resize();
+
+        if ( bIsRTL )
+            lcl_ModifyRTLVisArea( pEditView );
+
+        pEditEngine->SetModifyHdl(LINK(this, ScTextWnd, NotifyHdl));
+
+        if (!maAccTextDatas.empty())
+            maAccTextDatas.back()->StartEdit();
+
+        //     as long as EditEngine and DrawText sometimes differ for CTL text,
+        //     repaint now to have the EditEngine's version visible
+//        SfxObjectShell* pObjSh = SfxObjectShell::Current();
+        if ( pObjSh && pObjSh->ISA(ScDocShell) )
+        {
+            ScDocument* pDoc = ((ScDocShell*)pObjSh)->GetDocument();   // any document
+            sal_uInt8 nScript = pDoc->GetStringScriptType( aString );
+            if ( nScript & SCRIPTTYPE_COMPLEX )
+                Invalidate();
+        }
+    }
+
+    SC_MOD()->SetInputMode( SC_INPUT_TOP );
+
+    SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+    if (pViewFrm)
+        pViewFrm->GetBindings().Invalidate( SID_ATTR_INSERT );
+}
+
+IMPL_LINK(ScTextWnd, NotifyHdl, EENotify*, EMPTYARG)
+{
+    if (pEditView && !bInputMode)
+    {
+        ScInputHandler* pHdl = SC_MOD()->GetInputHdl();
+
+        //     Use the InputHandler's InOwnChange flag to prevent calling InputChanged
+        //     while an InputHandler method is modifying the EditEngine content
+
+        if ( pHdl && !pHdl->IsInOwnChange() )
+            pHdl->InputChanged( pEditView, sal_True ); // #i20282# InputChanged must know if 
called from modify handler
+    }
+
+    return 0;
+}
+
+void ScTextWnd::StopEditEngine( sal_Bool bAll )
+{
+    if (pEditView)
+    {
+        if (!maAccTextDatas.empty())
+            maAccTextDatas.back()->EndEdit();
+
+        ScModule* pScMod = SC_MOD();
+
+        if (!bAll)
+            pScMod->InputSelection( pEditView );
+        aString = pEditEngine->GetText();
+        bIsInsertMode = pEditView->IsInsertMode();
+        sal_Bool bSelection = pEditView->HasSelection();
+        pEditEngine->SetModifyHdl(Link());
+        DELETEZ(pEditView);
+        DELETEZ(pEditEngine);
+
+        if ( pScMod->IsEditMode() && !bAll )
+            pScMod->SetInputMode(SC_INPUT_TABLE);
+
+        SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+        if (pViewFrm)
+            pViewFrm->GetBindings().Invalidate( SID_ATTR_INSERT );
+
+        if (bSelection)
+            Invalidate();                      // damit Selektion nicht stehenbleibt
+    }
+}
+
 void ScTextWnd::SetTextString( const String& rNewString )
 {
     if ( rNewString != aString )
diff --git a/sc/source/ui/inc/inputwin.hxx b/sc/source/ui/inc/inputwin.hxx
index 9448158..5c88242 100644
--- a/sc/source/ui/inc/inputwin.hxx
+++ b/sc/source/ui/inc/inputwin.hxx
@@ -64,7 +64,6 @@ public:
                         // fuer FunktionsAutopiloten
     void                       MakeDialogEditView();
 
-    void            InitEditEngine(SfxObjectShell* pObjSh);
     void                       StartEditEngine();
     void                       StopEditEngine( sal_Bool bAll );
 
@@ -110,6 +109,80 @@ private:
     sal_Bool           bIsRTL;
     sal_Bool           bIsInsertMode;
     sal_Bool           bFormulaMode;
+
+    // #102710#; this flag should be true if a key input or a command is handled
+    // it prevents the call of InputChanged in the ModifyHandler of the EditEngine
+    sal_Bool        bInputMode;
+};
+
+
+
+//========================================================================
+
+class ScMultibar : public Window, public DragSourceHelper              // edit window
+{
+public:
+                    ScMultibar( Window* pParent );
+    virtual                    ~ScMultibar();
+
+    void                       SetTextString( const String& rString );
+    const String&      GetTextString() const;
+    virtual void       Resize();
+    sal_Bool                   IsInputActive();
+    EditView*          GetEditView();
+
+                        // fuer FunktionsAutopiloten
+    void                       MakeDialogEditView();
+
+    void            InitEditEngine(SfxObjectShell* pObjSh);
+    void                       StartEditEngine();
+    void                       StopEditEngine( sal_Bool bAll );
+
+    virtual void       DataChanged( const DataChangedEvent& rDCEvt );
+
+    void                       SetFormulaMode( sal_Bool bSet );
+
+    virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > 
CreateAccessible();
+
+    void            InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData );
+    void            RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData );
+    void            SetSize(bool bIsMultiLine);
+    int             GetLineCount();
+    bool            GetMultiLineStatus();
+    void            SetMultiLineStatus(bool bMode);
+    DECL_LINK( NotifyHdl, EENotify* );
+
+protected:
+    virtual void       Paint( const Rectangle& rRec );
+
+
+    virtual void       MouseMove( const MouseEvent& rMEvt );
+    virtual void       MouseButtonDown( const MouseEvent& rMEvt );
+    virtual void       MouseButtonUp( const MouseEvent& rMEvt );
+    virtual void       Command( const CommandEvent& rCEvt );
+    virtual void       KeyInput(const KeyEvent& rKEvt);
+    virtual void       GetFocus();
+    virtual void       LoseFocus();
+
+    virtual void       StartDrag( sal_Int8 nAction, const Point& rPosPixel );
+
+    virtual String     GetText() const;
+private:
+    void                       ImplInitSettings();
+    void                       UpdateAutoCorrFlag();
+
+private:
+    typedef ::std::vector< ScAccessibleEditLineTextData* > AccTextDataVector;
+
+    String             aString;
+    Font               aTextFont;
+    ScEditEngineDefaulter*     pEditEngine;                    // erst bei Bedarf angelegt
+    EditView*  pEditView;
+    AccTextDataVector maAccTextDatas;   // #i105267# text datas may be cloned, remember all copies
+    sal_Bool           bIsRTL;
+    sal_Bool           bIsInsertMode;
+    sal_Bool           bFormulaMode;
+    bool            bIsMultiLine;
     // #102710#; this flag should be true if a key input or a command is handled
     // it prevents the call of InputChanged in the ModifyHandler of the EditEngine
     sal_Bool        bInputMode;
@@ -172,10 +245,12 @@ public:
     bool            IsInputActive();
 private:
 
-    ScTextWnd       aTextWindow;
+    ScMultibar      aTextWindow;
     ScrollBar          maScrollBar;
+    PushButton      aButton;
     bool            bIsMultiLine;
-
+    DECL_LINK( ClickHdl,        PushButton* );
+    
 };
 
 //========================================================================

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.