LCOV - code coverage report
Current view: top level - sc/source/ui/app - inputwin.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 476 1299 36.6 %
Date: 2012-08-25 Functions: 59 131 45.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 450 1978 22.8 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <algorithm>
      31                 :            : 
      32                 :            : #include "scitems.hxx"
      33                 :            : #include <editeng/eeitem.hxx>
      34                 :            : 
      35                 :            : #include <sfx2/app.hxx>
      36                 :            : #include <editeng/adjitem.hxx>
      37                 :            : #include <editeng/editview.hxx>
      38                 :            : #include <editeng/editstat.hxx>
      39                 :            : #include <editeng/frmdiritem.hxx>
      40                 :            : #include <editeng/lspcitem.hxx>
      41                 :            : #include <sfx2/bindings.hxx>
      42                 :            : #include <sfx2/viewfrm.hxx>
      43                 :            : #include <sfx2/dispatch.hxx>
      44                 :            : #include <sfx2/event.hxx>
      45                 :            : #include <sfx2/imgmgr.hxx>
      46                 :            : #include <stdlib.h>     // qsort
      47                 :            : #include <editeng/scriptspaceitem.hxx>
      48                 :            : #include <editeng/scripttypeitem.hxx>
      49                 :            : #include <vcl/cursor.hxx>
      50                 :            : #include <vcl/help.hxx>
      51                 :            : #include <svl/stritem.hxx>
      52                 :            : #include <stdio.h>
      53                 :            : 
      54                 :            : #include "inputwin.hxx"
      55                 :            : #include "scmod.hxx"
      56                 :            : #include "uiitems.hxx"
      57                 :            : #include "global.hxx"
      58                 :            : #include "scresid.hxx"
      59                 :            : #include "sc.hrc"
      60                 :            : #include "globstr.hrc"
      61                 :            : #include "reffact.hxx"
      62                 :            : #include "editutil.hxx"
      63                 :            : #include "inputhdl.hxx"
      64                 :            : #include "tabvwsh.hxx"
      65                 :            : #include "document.hxx"
      66                 :            : #include "docsh.hxx"
      67                 :            : #include "appoptio.hxx"
      68                 :            : #include "rangenam.hxx"
      69                 :            : #include <formula/compiler.hrc>
      70                 :            : #include "dbdata.hxx"
      71                 :            : #include "rangeutl.hxx"
      72                 :            : #include "docfunc.hxx"
      73                 :            : #include "funcdesc.hxx"
      74                 :            : #include "markdata.hxx"
      75                 :            : #include <editeng/fontitem.hxx>
      76                 :            : #include <com/sun/star/accessibility/XAccessible.hpp>
      77                 :            : #include "AccessibleEditObject.hxx"
      78                 :            : #include "AccessibleText.hxx"
      79                 :            : #include <svtools/miscopt.hxx>
      80                 :            : #include <comphelper/string.hxx>
      81                 :            : #include <com/sun/star/frame/XLayoutManager.hpp>
      82                 :            : #include <com/sun/star/frame/XModel.hpp>
      83                 :            : #include <com/sun/star/frame/XController.hpp>
      84                 :            : 
      85                 :            : #define THESIZE             1000000 //!!! langt... :-)
      86                 :            : #define TBX_WINDOW_HEIGHT   22 // in Pixeln - fuer alle Systeme gleich?
      87                 :            : #define LEFT_OFFSET         5
      88                 :            : #define INPUTWIN_MULTILINES 6
      89                 :            : const long BUTTON_OFFSET = 2; ///< space between input line and the button to expand / collapse
      90                 :            : const long ADDITIONAL_BORDER = 1; ///< height of the line at the bottom
      91                 :            : const long ADDITIONAL_SPACE = 4; ///< additional vertical space when the multiline edit has more lines
      92                 :            : 
      93                 :            : using com::sun::star::uno::Reference;
      94                 :            : using com::sun::star::uno::UNO_QUERY;
      95                 :            : 
      96                 :            : using com::sun::star::frame::XLayoutManager;
      97                 :            : using com::sun::star::frame::XModel;
      98                 :            : using com::sun::star::frame::XFrame;
      99                 :            : using com::sun::star::frame::XController;
     100                 :            : using com::sun::star::beans::XPropertySet;
     101                 :            : 
     102                 :            : 
     103                 :            : enum ScNameInputType
     104                 :            : {
     105                 :            :     SC_NAME_INPUT_CELL,
     106                 :            :     SC_NAME_INPUT_RANGE,
     107                 :            :     SC_NAME_INPUT_NAMEDRANGE,
     108                 :            :     SC_NAME_INPUT_DATABASE,
     109                 :            :     SC_NAME_INPUT_ROW,
     110                 :            :     SC_NAME_INPUT_SHEET,
     111                 :            :     SC_NAME_INPUT_DEFINE,
     112                 :            :     SC_NAME_INPUT_BAD_NAME,
     113                 :            :     SC_NAME_INPUT_BAD_SELECTION,
     114                 :            :     SC_MANAGE_NAMES
     115                 :            : };
     116                 :            : 
     117                 :            : 
     118                 :        458 : ScTextWndBase::ScTextWndBase( Window* pParent,  WinBits nStyle )
     119                 :        458 :     : Window ( pParent, nStyle )
     120                 :            : {
     121 [ -  + ][ +  - ]:        458 :     if ( IsNativeControlSupported( CTRL_EDITBOX, PART_ENTIRE_CONTROL ) )
     122                 :            :     {
     123         [ #  # ]:          0 :         SetType( WINDOW_CALCINPUTLINE );
     124         [ #  # ]:          0 :         SetBorderStyle( WINDOW_BORDER_NWF );
     125                 :            :     }
     126                 :        458 : }
     127                 :            : 
     128                 :            : //==================================================================
     129                 :            : //  class ScInputWindowWrapper
     130                 :            : //==================================================================
     131                 :            : 
     132 [ +  - ][ +  - ]:        280 : SFX_IMPL_CHILDWINDOW_WITHID(ScInputWindowWrapper,FID_INPUTLINE_STATUS)
     133                 :            : 
     134                 :        229 : ScInputWindowWrapper::ScInputWindowWrapper( Window*          pParentP,
     135                 :            :                                             sal_uInt16           nId,
     136                 :            :                                             SfxBindings*     pBindings,
     137                 :            :                                             SfxChildWinInfo* /* pInfo */ )
     138                 :        229 :     :   SfxChildWindow( pParentP, nId )
     139                 :            : {
     140 [ +  - ][ +  - ]:        229 :     ScInputWindow* pWin=new ScInputWindow( pParentP, pBindings );
     141                 :        229 :     pWindow = pWin;
     142                 :            : 
     143         [ +  - ]:        229 :     pWin->Show();
     144                 :            : 
     145 [ +  - ][ +  - ]:        229 :     pWin->SetSizePixel( pWin->CalcWindowSizePixel() );
     146                 :            : 
     147                 :        229 :     eChildAlignment = SFX_ALIGN_LOWESTTOP;
     148         [ +  - ]:        229 :     pBindings->Invalidate( FID_TOGGLEINPUTLINE );
     149                 :        229 : }
     150                 :            : 
     151                 :            : //  GetInfo fliegt wieder raus, wenn es ein SFX_IMPL_TOOLBOX gibt !!!!
     152                 :            : 
     153                 :        245 : SfxChildWinInfo ScInputWindowWrapper::GetInfo() const
     154                 :            : {
     155                 :        245 :     SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
     156                 :        245 :     return aInfo;
     157                 :            : }
     158                 :            : 
     159                 :            : //==================================================================
     160                 :            : 
     161                 :            : #define IMAGE(id) pImgMgr->SeekImage(id)
     162                 :        458 : bool lcl_isExperimentalMode()
     163                 :            : {
     164                 :            :     // make inputbar feature on by default, leave the switch for the
     165                 :            :     // moment in case we need to back it out easily
     166                 :        458 :     return true;
     167                 :            : }
     168                 :            : 
     169                 :            : //==================================================================
     170                 :            : //  class ScInputWindow
     171                 :            : //==================================================================
     172                 :            : 
     173                 :        229 : ScTextWndBase* lcl_chooseRuntimeImpl( Window* pParent, SfxBindings* pBind )
     174                 :            : {
     175                 :        229 :     ScTabViewShell* pViewSh = NULL;
     176                 :        229 :     SfxDispatcher* pDisp = pBind->GetDispatcher();
     177         [ +  - ]:        229 :     if ( pDisp )
     178                 :            :     {
     179                 :        229 :         SfxViewFrame* pViewFrm = pDisp->GetFrame();
     180         [ +  - ]:        229 :         if ( pViewFrm )
     181 [ +  - ][ +  - ]:        229 :             pViewSh = PTR_CAST( ScTabViewShell, pViewFrm->GetViewShell() );
     182                 :            :     }
     183                 :            : 
     184         [ -  + ]:        229 :     if ( !lcl_isExperimentalMode() )
     185         [ #  # ]:          0 :         return new ScTextWnd( pParent, pViewSh );
     186         [ +  - ]:        229 :     return new ScInputBarGroup( pParent, pViewSh );
     187                 :            : }
     188                 :            : 
     189                 :        229 : ScInputWindow::ScInputWindow( Window* pParent, SfxBindings* pBind ) :
     190                 :            : // mit WB_CLIPCHILDREN, sonst Flicker
     191                 :            :         ToolBox         ( pParent, WinBits(WB_CLIPCHILDREN) ),
     192                 :            :         aWndPos         ( this ),
     193                 :            :         pRuntimeWindow ( lcl_chooseRuntimeImpl( this, pBind ) ),
     194                 :        229 :         aTextWindow    ( *pRuntimeWindow ),
     195                 :            :         pInputHdl       ( NULL ),
     196                 :            :         pBindings       ( pBind ),
     197                 :            :         aTextOk         ( ScResId( SCSTR_QHELP_BTNOK ) ),       // nicht immer neu aus Resource
     198                 :            :         aTextCancel     ( ScResId( SCSTR_QHELP_BTNCANCEL ) ),
     199                 :            :         aTextSum        ( ScResId( SCSTR_QHELP_BTNSUM ) ),
     200                 :            :         aTextEqual      ( ScResId( SCSTR_QHELP_BTNEQUAL ) ),
     201                 :            :         mnMaxY          (0),
     202                 :            :         bIsOkCancelMode ( false ),
     203                 :            :         bIsMultiLine    ( false ),
     204                 :            :         bInResize       ( false ),
     205 [ +  - ][ +  - ]:        458 :         mbIsMultiLine   ( lcl_isExperimentalMode() )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     206                 :            : {
     207         [ +  - ]:        229 :     ScModule*        pScMod  = SC_MOD();
     208         [ +  - ]:        229 :     SfxImageManager* pImgMgr = SfxImageManager::GetImageManager( pScMod );
     209                 :            : 
     210                 :            :     // #i73615# don't rely on SfxViewShell::Current while constructing the input line
     211                 :            :     // (also for GetInputHdl below)
     212                 :        229 :     ScTabViewShell* pViewSh = NULL;
     213                 :        229 :     SfxDispatcher* pDisp = pBind->GetDispatcher();
     214         [ +  - ]:        229 :     if ( pDisp )
     215                 :            :     {
     216         [ +  - ]:        229 :         SfxViewFrame* pViewFrm = pDisp->GetFrame();
     217         [ +  - ]:        229 :         if ( pViewFrm )
     218 [ +  - ][ +  - ]:        229 :             pViewSh = PTR_CAST( ScTabViewShell, pViewFrm->GetViewShell() );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     219                 :            :     }
     220                 :            :     OSL_ENSURE( pViewSh, "no view shell for input window" );
     221                 :            : 
     222                 :            :     // Position window, 3 buttons, input window
     223         [ +  - ]:        229 :     InsertWindow    ( 1, &aWndPos, 0,                                     0 );
     224         [ +  - ]:        229 :     InsertSeparator (                                                     1 );
     225 [ +  - ][ +  - ]:        229 :     InsertItem      ( SID_INPUT_FUNCTION, IMAGE( SID_INPUT_FUNCTION ), 0, 2 );
                 [ +  - ]
     226 [ +  - ][ +  - ]:        229 :     InsertItem      ( SID_INPUT_SUM,      IMAGE( SID_INPUT_SUM ), 0,      3 );
                 [ +  - ]
     227 [ +  - ][ +  - ]:        229 :     InsertItem      ( SID_INPUT_EQUAL,    IMAGE( SID_INPUT_EQUAL ), 0,    4 );
                 [ +  - ]
     228         [ +  - ]:        229 :     InsertSeparator (                                                     5 );
     229         [ +  - ]:        229 :     InsertWindow    ( 7, &aTextWindow, 0,                                 6 );
     230                 :            : 
     231 [ +  - ][ +  - ]:        229 :     aWndPos    .SetQuickHelpText( ScResId( SCSTR_QHELP_POSWND ) );
         [ +  - ][ +  - ]
     232         [ +  - ]:        229 :     aWndPos    .SetHelpId       ( HID_INSWIN_POS );
     233 [ +  - ][ +  - ]:        229 :     aTextWindow.SetQuickHelpText( ScResId( SCSTR_QHELP_INPUTWND ) );
         [ +  - ][ +  - ]
     234         [ +  - ]:        229 :     aTextWindow.SetHelpId       ( HID_INSWIN_INPUT );
     235                 :            : 
     236                 :            :     //  kein SetHelpText, die Hilfetexte kommen aus der Hilfe
     237                 :            : 
     238 [ +  - ][ +  - ]:        229 :     SetItemText ( SID_INPUT_FUNCTION, ScResId( SCSTR_QHELP_BTNCALC ) );
         [ +  - ][ +  - ]
     239         [ +  - ]:        229 :     SetHelpId   ( SID_INPUT_FUNCTION, HID_INSWIN_CALC );
     240                 :            : 
     241         [ +  - ]:        229 :     SetItemText ( SID_INPUT_SUM, aTextSum );
     242         [ +  - ]:        229 :     SetHelpId   ( SID_INPUT_SUM, HID_INSWIN_SUMME );
     243                 :            : 
     244         [ +  - ]:        229 :     SetItemText ( SID_INPUT_EQUAL, aTextEqual );
     245         [ +  - ]:        229 :     SetHelpId   ( SID_INPUT_EQUAL, HID_INSWIN_FUNC );
     246                 :            : 
     247         [ +  - ]:        229 :     SetHelpId( HID_SC_INPUTWIN );   // fuer die ganze Eingabezeile
     248                 :            : 
     249         [ +  - ]:        229 :     aWndPos     .Show();
     250         [ +  - ]:        229 :     aTextWindow.Show();
     251                 :            : 
     252 [ +  - ][ +  - ]:        229 :     pInputHdl = SC_MOD()->GetInputHdl( pViewSh, false );    // use own handler even if ref-handler is set
     253         [ +  - ]:        229 :     if (pInputHdl)
     254                 :        229 :         pInputHdl->SetInputWindow( this );
     255                 :            : 
     256 [ +  - ][ -  + ]:        229 :     if (pInputHdl && !pInputHdl->GetFormString().isEmpty())
                 [ -  + ]
     257                 :            :     {
     258                 :            :         //  Umschalten waehrend der Funktionsautopilot aktiv ist
     259                 :            :         //  -> Inhalt des Funktionsautopiloten wieder anzeigen
     260                 :            :         //! auch Selektion (am InputHdl gemerkt) wieder anzeigen
     261                 :            : 
     262 [ #  # ][ #  # ]:          0 :         aTextWindow.SetTextString( pInputHdl->GetFormString() );
                 [ #  # ]
     263                 :            :     }
     264 [ +  - ][ -  + ]:        229 :     else if ( pInputHdl && pInputHdl->IsInputMode() )
                 [ -  + ]
     265                 :            :     {
     266                 :            :         //  wenn waehrend des Editierens die Eingabezeile weg war
     267                 :            :         //  (Editieren einer Formel, dann umschalten zu fremdem Dokument/Hilfe),
     268                 :            :         //  wieder den gerade editierten Text aus dem InputHandler anzeigen
     269                 :            : 
     270 [ #  # ][ #  # ]:          0 :         aTextWindow.SetTextString( pInputHdl->GetEditString() );    // Text anzeigen
         [ #  # ][ #  # ]
     271         [ #  # ]:          0 :         if ( pInputHdl->IsTopMode() )
     272         [ #  # ]:          0 :             pInputHdl->SetMode( SC_INPUT_TABLE );       // Focus kommt eh nach unten
     273                 :            :     }
     274         [ +  - ]:        229 :     else if ( pViewSh )
     275         [ +  - ]:        229 :         pViewSh->UpdateInputHandler( sal_True ); // unbedingtes Update
     276                 :            : 
     277         [ +  - ]:        229 :     pImgMgr->RegisterToolBox( this );
     278 [ +  - ][ +  - ]:        229 :     SetAccessibleName(ScResId(STR_ACC_TOOLBAR_FORMULA));
         [ +  - ][ +  - ]
     279                 :        229 : }
     280                 :            : 
     281 [ +  - ][ +  - ]:        225 : ScInputWindow::~ScInputWindow()
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     282                 :            : {
     283                 :        225 :     sal_Bool bDown = ( ScGlobal::pSysLocale == NULL );    // after Clear?
     284                 :            : 
     285                 :            :     //  if any view's input handler has a pointer to this input window, reset it
     286                 :            :     //  (may be several ones, #74522#)
     287                 :            :     //  member pInputHdl is not used here
     288                 :            : 
     289         [ +  - ]:        225 :     if ( !bDown )
     290                 :            :     {
     291         [ +  - ]:        225 :         TypeId aScType = TYPE(ScTabViewShell);
     292         [ +  - ]:        225 :         SfxViewShell* pSh = SfxViewShell::GetFirst( &aScType );
     293         [ +  + ]:        459 :         while ( pSh )
     294                 :            :         {
     295         [ +  - ]:        234 :             ScInputHandler* pHdl = ((ScTabViewShell*)pSh)->GetInputHandler();
     296 [ +  - ][ +  + ]:        234 :             if ( pHdl && pHdl->GetInputWindow() == this )
                 [ +  + ]
     297                 :            :             {
     298                 :        225 :                 pHdl->SetInputWindow( NULL );
     299         [ +  - ]:        225 :                 pHdl->StopInputWinEngine( false );  // reset pTopView pointer
     300                 :            :             }
     301         [ +  - ]:        234 :             pSh = SfxViewShell::GetNext( *pSh, &aScType );
     302                 :            :         }
     303                 :            :     }
     304                 :            : 
     305 [ +  - ][ +  - ]:        225 :     SfxImageManager::GetImageManager( SC_MOD() )->ReleaseToolBox( this );
                 [ +  - ]
     306         [ -  + ]:        450 : }
     307                 :            : 
     308                 :         32 : void ScInputWindow::SetInputHandler( ScInputHandler* pNew )
     309                 :            : {
     310                 :            :     //  wird im Activate der View gerufen...
     311                 :            : 
     312         [ -  + ]:         32 :     if ( pNew != pInputHdl )
     313                 :            :     {
     314                 :            :         //  Bei Reload (letzte Version) ist pInputHdl der Input-Handler der alten,
     315                 :            :         //  geloeschten ViewShell, darum hier auf keinen Fall anfassen!
     316                 :            : 
     317                 :          0 :         pInputHdl = pNew;
     318         [ #  # ]:          0 :         if (pInputHdl)
     319                 :          0 :             pInputHdl->SetInputWindow( this );
     320                 :            :     }
     321                 :         32 : }
     322                 :            : 
     323                 :          0 : bool ScInputWindow::UseSubTotal(ScRangeList* pRangeList) const
     324                 :            : {
     325                 :          0 :     bool bSubTotal = false;
     326 [ #  # ][ #  # ]:          0 :     ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
     327         [ #  # ]:          0 :     if ( pViewSh )
     328                 :            :     {
     329         [ #  # ]:          0 :         ScDocument* pDoc = pViewSh->GetViewData()->GetDocument();
     330         [ #  # ]:          0 :         size_t nRangeCount (pRangeList->size());
     331                 :          0 :         size_t nRangeIndex (0);
     332 [ #  # ][ #  # ]:          0 :         while (!bSubTotal && nRangeIndex < nRangeCount)
                 [ #  # ]
     333                 :            :         {
     334         [ #  # ]:          0 :             const ScRange* pRange = (*pRangeList)[nRangeIndex];
     335         [ #  # ]:          0 :             if( pRange )
     336                 :            :             {
     337                 :          0 :                 SCTAB nTabEnd(pRange->aEnd.Tab());
     338                 :          0 :                 SCTAB nTab(pRange->aStart.Tab());
     339 [ #  # ][ #  # ]:          0 :                 while (!bSubTotal && nTab <= nTabEnd)
                 [ #  # ]
     340                 :            :                 {
     341                 :          0 :                     SCROW nRowEnd(pRange->aEnd.Row());
     342                 :          0 :                     SCROW nRow(pRange->aStart.Row());
     343 [ #  # ][ #  # ]:          0 :                     while (!bSubTotal && nRow <= nRowEnd)
                 [ #  # ]
     344                 :            :                     {
     345 [ #  # ][ #  # ]:          0 :                         if (pDoc->RowFiltered(nRow, nTab))
     346                 :          0 :                             bSubTotal = true;
     347                 :            :                         else
     348                 :          0 :                             ++nRow;
     349                 :            :                     }
     350                 :          0 :                     ++nTab;
     351                 :            :                 }
     352                 :            :             }
     353                 :          0 :             ++nRangeIndex;
     354                 :            :         }
     355                 :            : 
     356 [ #  # ][ #  # ]:          0 :         const ScDBCollection::NamedDBs& rDBs = pDoc->GetDBCollection()->getNamedDBs();
     357 [ #  # ][ #  # ]:          0 :         ScDBCollection::NamedDBs::const_iterator itr = rDBs.begin(), itrEnd = rDBs.end();
     358 [ #  # ][ #  # ]:          0 :         for (; !bSubTotal && itr != itrEnd; ++itr)
         [ #  # ][ #  # ]
                 [ #  # ]
     359                 :            :         {
     360         [ #  # ]:          0 :             const ScDBData& rDB = *itr;
     361         [ #  # ]:          0 :             if (!rDB.HasAutoFilter())
     362                 :          0 :                 continue;
     363                 :            : 
     364                 :          0 :             nRangeIndex = 0;
     365 [ #  # ][ #  # ]:          0 :             while (!bSubTotal && nRangeIndex < nRangeCount)
                 [ #  # ]
     366                 :            :             {
     367         [ #  # ]:          0 :                 const ScRange* pRange = (*pRangeList)[nRangeIndex];
     368         [ #  # ]:          0 :                 if( pRange )
     369                 :            :                 {
     370                 :          0 :                     ScRange aDBArea;
     371         [ #  # ]:          0 :                     rDB.GetArea(aDBArea);
     372 [ #  # ][ #  # ]:          0 :                     if (aDBArea.Intersects(*pRange))
     373                 :          0 :                         bSubTotal = true;
     374                 :            :                 }
     375                 :          0 :                 ++nRangeIndex;
     376                 :            :             }
     377                 :            :         }
     378                 :            :     }
     379                 :          0 :     return bSubTotal;
     380                 :            : }
     381                 :            : 
     382                 :          0 : void ScInputWindow::Select()
     383                 :            : {
     384                 :          0 :     ScModule* pScMod = SC_MOD();
     385                 :          0 :     ToolBox::Select();
     386                 :            : 
     387   [ #  #  #  #  :          0 :     switch ( GetCurItemId() )
                   #  # ]
     388                 :            :     {
     389                 :            :         case SID_INPUT_FUNCTION:
     390                 :            :             {
     391                 :            :                 //! new method at ScModule to query if function autopilot is open
     392                 :          0 :                 SfxViewFrame* pViewFrm = SfxViewFrame::Current();
     393 [ #  # ][ #  # ]:          0 :                 if ( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) )
                 [ #  # ]
     394                 :            :                 {
     395                 :            :                     pViewFrm->GetDispatcher()->Execute( SID_OPENDLG_FUNCTION,
     396                 :          0 :                                               SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD );
     397                 :            : 
     398                 :            :                     //  die Toolbox wird sowieso disabled, also braucht auch nicht umgeschaltet
     399                 :            :                     //  zu werden, egal ob's geklappt hat oder nicht
     400                 :            : //                  SetOkCancelMode();
     401                 :            :                 }
     402                 :            :             }
     403                 :          0 :             break;
     404                 :            : 
     405                 :            :         case SID_INPUT_CANCEL:
     406                 :          0 :             pScMod->InputCancelHandler();
     407                 :          0 :             SetSumAssignMode();
     408                 :          0 :             break;
     409                 :            : 
     410                 :            :         case SID_INPUT_OK:
     411                 :          0 :             pScMod->InputEnterHandler();
     412                 :          0 :             SetSumAssignMode();
     413                 :          0 :             aTextWindow.Invalidate();       // sonst bleibt Selektion stehen
     414                 :          0 :             break;
     415                 :            : 
     416                 :            :         case SID_INPUT_SUM:
     417                 :            :             {
     418 [ #  # ][ #  # ]:          0 :                 ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
     419         [ #  # ]:          0 :                 if ( pViewSh )
     420                 :            :                 {
     421                 :          0 :                     const ScMarkData& rMark = pViewSh->GetViewData()->GetMarkData();
     422 [ #  # ][ #  # ]:          0 :                     if ( rMark.IsMarked() || rMark.IsMultiMarked() )
                 [ #  # ]
     423                 :            :                     {
     424         [ #  # ]:          0 :                         ScRangeList aMarkRangeList;
     425         [ #  # ]:          0 :                         rMark.FillRangeListWithMarks( &aMarkRangeList, false );
     426         [ #  # ]:          0 :                         ScDocument* pDoc = pViewSh->GetViewData()->GetDocument();
     427                 :            : 
     428                 :            :                         // check if one of the marked ranges is empty
     429                 :          0 :                         bool bEmpty = false;
     430         [ #  # ]:          0 :                         const size_t nCount = aMarkRangeList.size();
     431         [ #  # ]:          0 :                         for ( size_t i = 0; i < nCount; ++i )
     432                 :            :                         {
     433         [ #  # ]:          0 :                             const ScRange aRange( *aMarkRangeList[i] );
     434 [ #  # ][ #  # ]:          0 :                             if ( pDoc->IsBlockEmpty( aRange.aStart.Tab(),
     435                 :          0 :                                     aRange.aStart.Col(), aRange.aStart.Row(),
     436                 :          0 :                                     aRange.aEnd.Col(), aRange.aEnd.Row() ) )
     437                 :            :                             {
     438                 :          0 :                                 bEmpty = true;
     439                 :            :                                 break;
     440                 :            :                             }
     441                 :            :                         }
     442                 :            : 
     443         [ #  # ]:          0 :                         if ( bEmpty )
     444                 :            :                         {
     445         [ #  # ]:          0 :                             ScRangeList aRangeList;
     446         [ #  # ]:          0 :                             const sal_Bool bDataFound = pViewSh->GetAutoSumArea( aRangeList );
     447         [ #  # ]:          0 :                             if ( bDataFound )
     448                 :            :                             {
     449         [ #  # ]:          0 :                                 ScAddress aAddr = aRangeList.back()->aEnd;
     450         [ #  # ]:          0 :                                 aAddr.IncRow();
     451         [ #  # ]:          0 :                                 const sal_Bool bSubTotal( UseSubTotal( &aRangeList ) );
     452         [ #  # ]:          0 :                                 pViewSh->EnterAutoSum( aRangeList, bSubTotal, aAddr );
     453         [ #  # ]:          0 :                             }
     454                 :            :                         }
     455                 :            :                         else
     456                 :            :                         {
     457         [ #  # ]:          0 :                             const sal_Bool bSubTotal( UseSubTotal( &aMarkRangeList ) );
     458         [ #  # ]:          0 :                             for ( size_t i = 0; i < nCount; ++i )
     459                 :            :                             {
     460         [ #  # ]:          0 :                                 const ScRange aRange( *aMarkRangeList[i] );
     461                 :          0 :                                 const bool bSetCursor = ( i == nCount - 1 ? true : false );
     462                 :          0 :                                 const bool bContinue = ( i != 0  ? true : false );
     463 [ #  # ][ #  # ]:          0 :                                 if ( !pViewSh->AutoSum( aRange, bSubTotal, bSetCursor, bContinue ) )
     464                 :            :                                 {
     465         [ #  # ]:          0 :                                     pViewSh->MarkRange( aRange, false, false );
     466         [ #  # ]:          0 :                                     pViewSh->SetCursor( aRange.aEnd.Col(), aRange.aEnd.Row() );
     467         [ #  # ]:          0 :                                     const ScRangeList aRangeList;
     468                 :          0 :                                     ScAddress aAddr = aRange.aEnd;
     469         [ #  # ]:          0 :                                     aAddr.IncRow();
     470                 :            :                                     const String aFormula = pViewSh->GetAutoSumFormula(
     471         [ #  # ]:          0 :                                         aRangeList, bSubTotal, aAddr );
     472         [ #  # ]:          0 :                                     SetFuncString( aFormula );
     473 [ #  # ][ #  # ]:          0 :                                     break;
     474                 :            :                                 }
     475                 :            :                             }
     476         [ #  # ]:          0 :                         }
     477                 :            :                     }
     478                 :            :                     else                                    // nur in Eingabezeile einfuegen
     479                 :            :                     {
     480         [ #  # ]:          0 :                         ScRangeList aRangeList;
     481         [ #  # ]:          0 :                         const sal_Bool bDataFound = pViewSh->GetAutoSumArea( aRangeList );
     482         [ #  # ]:          0 :                         const sal_Bool bSubTotal( UseSubTotal( &aRangeList ) );
     483         [ #  # ]:          0 :                         ScAddress aAddr = pViewSh->GetViewData()->GetCurPos();
     484         [ #  # ]:          0 :                         const String aFormula = pViewSh->GetAutoSumFormula( aRangeList, bSubTotal, aAddr );
     485         [ #  # ]:          0 :                         SetFuncString( aFormula );
     486                 :            : 
     487 [ #  # ][ #  # ]:          0 :                         if ( bDataFound && pScMod->IsEditMode() )
         [ #  # ][ #  # ]
     488                 :            :                         {
     489         [ #  # ]:          0 :                             ScInputHandler* pHdl = pScMod->GetInputHdl( pViewSh );
     490         [ #  # ]:          0 :                             if ( pHdl )
     491                 :            :                             {
     492         [ #  # ]:          0 :                                 pHdl->InitRangeFinder( aFormula );
     493                 :            : 
     494                 :            :                                 //! SetSelection am InputHandler ???
     495                 :            :                                 //! bSelIsRef setzen ???
     496         [ #  # ]:          0 :                                 const xub_StrLen nOpen = aFormula.Search('(');
     497                 :          0 :                                 const xub_StrLen nLen = aFormula.Len();
     498 [ #  # ][ #  # ]:          0 :                                 if ( nOpen != STRING_NOTFOUND && nLen > nOpen )
     499                 :            :                                 {
     500                 :          0 :                                     sal_uInt8 nAdd(1);
     501         [ #  # ]:          0 :                                     if (bSubTotal)
     502                 :          0 :                                         nAdd = 3;
     503                 :          0 :                                     ESelection aSel(0,nOpen+nAdd,0,nLen-1);
     504                 :          0 :                                     EditView* pTableView = pHdl->GetTableView();
     505         [ #  # ]:          0 :                                     if (pTableView)
     506         [ #  # ]:          0 :                                         pTableView->SetSelection(aSel);
     507                 :          0 :                                     EditView* pTopView = pHdl->GetTopView();
     508         [ #  # ]:          0 :                                     if (pTopView)
     509         [ #  # ]:          0 :                                         pTopView->SetSelection(aSel);
     510                 :            :                                 }
     511                 :            :                             }
     512 [ #  # ][ #  # ]:          0 :                         }
     513                 :            :                     }
     514                 :            :                 }
     515                 :            :             }
     516                 :          0 :             break;
     517                 :            : 
     518                 :            :         case SID_INPUT_EQUAL:
     519                 :            :         {
     520                 :          0 :             aTextWindow.StartEditEngine();
     521         [ #  # ]:          0 :             if ( pScMod->IsEditMode() )         // nicht, wenn z.B. geschuetzt
     522                 :            :             {
     523                 :          0 :                 aTextWindow.StartEditEngine();
     524 [ #  # ][ #  # ]:          0 :                 aTextWindow.SetTextString(rtl::OUString('='));
                 [ #  # ]
     525                 :            : 
     526                 :          0 :                 EditView* pView = aTextWindow.GetEditView();
     527         [ #  # ]:          0 :                 if (pView)
     528                 :            :                 {
     529         [ #  # ]:          0 :                     pView->SetSelection( ESelection(0,1, 0,1) );
     530                 :          0 :                     pScMod->InputChanged(pView);
     531                 :          0 :                     SetOkCancelMode();
     532                 :          0 :                     pView->SetEditEngineUpdateMode(sal_True);
     533                 :            :                 }
     534                 :            :             }
     535                 :          0 :             break;
     536                 :            :         }
     537                 :            :     }
     538                 :          0 : }
     539                 :            : 
     540                 :        216 : void ScInputWindow::Paint( const Rectangle& rRect )
     541                 :            : {
     542         [ +  - ]:        216 :     ToolBox::Paint( rRect );
     543                 :            : 
     544                 :            :     // draw a line at the bottom to distinguish that from the grid
     545                 :            :     // (we have space for that thanks to ADDITIONAL_BORDER)
     546                 :        216 :     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     547         [ +  - ]:        216 :     SetLineColor( rStyleSettings.GetShadowColor() );
     548                 :            : 
     549         [ +  - ]:        216 :     Size aSize = GetSizePixel();
     550         [ +  - ]:        216 :     DrawLine( Point( 0, aSize.Height() - 1 ), Point( aSize.Width() - 1, aSize.Height() - 1 ) );
     551                 :        216 : }
     552                 :            : 
     553                 :       1374 : void ScInputWindow::Resize()
     554                 :            : {
     555                 :       1374 :     ToolBox::Resize();
     556         [ +  - ]:       1374 :     if ( mbIsMultiLine )
     557                 :            :     {
     558         [ +  - ]:       1374 :         aTextWindow.Resize();
     559         [ +  - ]:       1374 :         Size aSize = GetSizePixel();
     560         [ +  - ]:       1374 :         aSize.Height() = CalcWindowSizePixel().Height() + ADDITIONAL_BORDER;
     561         [ -  + ]:       1374 :         ScInputBarGroup* pGroupBar = dynamic_cast< ScInputBarGroup* > ( pRuntimeWindow.get() );
     562         [ +  - ]:       1374 :         if ( pGroupBar )
     563                 :            :         {
     564                 :            :             // To ensure smooth display and prevent the items in the toolbar being
     565                 :            :             // repositioned ( vertically ) we lock the vertical positioning of the toolbox
     566                 :            :             // items when we are displaying > 1 line.
     567                 :            :             // So, we need to adjust the height of the toolbox accordingly. If we don't
     568                 :            :             // then the largest item ( e.g. the GroupBar window ) will actually be
     569                 :            :             // positioned such that the toolbar will cut off the bottom of that item
     570         [ -  + ]:       1374 :             if ( pGroupBar->GetNumLines() > 1 )
     571                 :          0 :                 aSize.Height() += pGroupBar->GetVertOffset() + ADDITIONAL_SPACE;
     572                 :            :         }
     573         [ +  - ]:       1374 :         SetSizePixel(aSize);
     574         [ +  - ]:       1374 :         Invalidate();
     575                 :            :     }
     576                 :            :     else
     577                 :            :     {
     578         [ #  # ]:          0 :         long nWidth = GetSizePixel().Width();
     579         [ #  # ]:          0 :         long nLeft  = aTextWindow.GetPosPixel().X();
     580         [ #  # ]:          0 :         Size aSize  = aTextWindow.GetSizePixel();
     581                 :            : 
     582                 :          0 :         aSize.Width() = Max( ((long)(nWidth - nLeft - 5)), (long)0 );
     583                 :            : 
     584         [ #  # ]:          0 :         aTextWindow.SetSizePixel( aSize );
     585         [ #  # ]:          0 :         aTextWindow.Invalidate();
     586                 :            :     }
     587                 :       1374 : }
     588                 :            : 
     589                 :          0 : void ScInputWindow::SetFuncString( const String& rString, sal_Bool bDoEdit )
     590                 :            : {
     591                 :            :     //! new method at ScModule to query if function autopilot is open
     592                 :          0 :     SfxViewFrame* pViewFrm = SfxViewFrame::Current();
     593 [ #  # ][ #  # ]:          0 :     EnableButtons( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) );
     594                 :          0 :     aTextWindow.StartEditEngine();
     595                 :            : 
     596                 :          0 :     ScModule* pScMod = SC_MOD();
     597         [ #  # ]:          0 :     if ( pScMod->IsEditMode() )
     598                 :            :     {
     599         [ #  # ]:          0 :         if ( bDoEdit )
     600                 :          0 :             aTextWindow.GrabFocus();
     601                 :          0 :         aTextWindow.SetTextString( rString );
     602                 :          0 :         EditView* pView = aTextWindow.GetEditView();
     603         [ #  # ]:          0 :         if (pView)
     604                 :            :         {
     605                 :          0 :             xub_StrLen nLen = rString.Len();
     606                 :            : 
     607         [ #  # ]:          0 :             if ( nLen > 0 )
     608                 :            :             {
     609                 :          0 :                 nLen--;
     610         [ #  # ]:          0 :                 pView->SetSelection( ESelection( 0, nLen, 0, nLen ) );
     611                 :            :             }
     612                 :            : 
     613                 :          0 :             pScMod->InputChanged(pView);
     614         [ #  # ]:          0 :             if ( bDoEdit )
     615                 :          0 :                 SetOkCancelMode();          // nicht, wenn gleich hinterher Enter/Cancel
     616                 :            : 
     617                 :          0 :             pView->SetEditEngineUpdateMode(sal_True);
     618                 :            :         }
     619                 :            :     }
     620                 :          0 : }
     621                 :            : 
     622                 :        645 : void ScInputWindow::SetPosString( const String& rStr )
     623                 :            : {
     624                 :        645 :     aWndPos.SetPos( rStr );
     625                 :        645 : }
     626                 :            : 
     627                 :        586 : void ScInputWindow::SetTextString( const String& rString )
     628                 :            : {
     629         [ +  - ]:        586 :     if (rString.Len() <= 32767)
     630                 :        586 :         aTextWindow.SetTextString(rString);
     631                 :            :     else
     632                 :            :     {
     633         [ #  # ]:          0 :         String aNew = rString;
     634         [ #  # ]:          0 :         aNew.Erase(32767);
     635 [ #  # ][ #  # ]:          0 :         aTextWindow.SetTextString(aNew);
     636                 :            :     }
     637                 :        586 : }
     638                 :            : 
     639                 :          0 : void ScInputWindow::SetOkCancelMode()
     640                 :            : {
     641                 :            :     //! new method at ScModule to query if function autopilot is open
     642                 :          0 :     SfxViewFrame* pViewFrm = SfxViewFrame::Current();
     643 [ #  # ][ #  # ]:          0 :     EnableButtons( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) );
     644                 :            : 
     645                 :          0 :     ScModule* pScMod = SC_MOD();
     646                 :          0 :     SfxImageManager* pImgMgr = SfxImageManager::GetImageManager( pScMod );
     647         [ #  # ]:          0 :     if (!bIsOkCancelMode)
     648                 :            :     {
     649                 :          0 :         RemoveItem( 3 ); // SID_INPUT_SUM und SID_INPUT_EQUAL entfernen
     650                 :          0 :         RemoveItem( 3 );
     651         [ #  # ]:          0 :         InsertItem( SID_INPUT_CANCEL, IMAGE( SID_INPUT_CANCEL ), 0, 3 );
     652         [ #  # ]:          0 :         InsertItem( SID_INPUT_OK,     IMAGE( SID_INPUT_OK ),     0, 4 );
     653                 :          0 :         SetItemText ( SID_INPUT_CANCEL, aTextCancel );
     654         [ #  # ]:          0 :         SetHelpId   ( SID_INPUT_CANCEL, HID_INSWIN_CANCEL );
     655                 :          0 :         SetItemText ( SID_INPUT_OK,     aTextOk );
     656         [ #  # ]:          0 :         SetHelpId   ( SID_INPUT_OK,     HID_INSWIN_OK );
     657                 :          0 :         bIsOkCancelMode = sal_True;
     658                 :            :     }
     659                 :          0 : }
     660                 :            : 
     661                 :        640 : void ScInputWindow::SetSumAssignMode()
     662                 :            : {
     663                 :            :     //! new method at ScModule to query if function autopilot is open
     664                 :        640 :     SfxViewFrame* pViewFrm = SfxViewFrame::Current();
     665 [ +  - ][ +  + ]:        640 :     EnableButtons( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) );
     666                 :            : 
     667                 :        640 :     ScModule* pScMod = SC_MOD();
     668                 :        640 :     SfxImageManager* pImgMgr = SfxImageManager::GetImageManager( pScMod );
     669         [ -  + ]:        640 :     if (bIsOkCancelMode)
     670                 :            :     {
     671                 :            :         // SID_INPUT_CANCEL, und SID_INPUT_OK entfernen
     672                 :          0 :         RemoveItem( 3 );
     673                 :          0 :         RemoveItem( 3 );
     674         [ #  # ]:          0 :         InsertItem( SID_INPUT_SUM,   IMAGE( SID_INPUT_SUM ),     0, 3 );
     675         [ #  # ]:          0 :         InsertItem( SID_INPUT_EQUAL, IMAGE( SID_INPUT_EQUAL ),   0, 4 );
     676                 :          0 :         SetItemText ( SID_INPUT_SUM,   aTextSum );
     677         [ #  # ]:          0 :         SetHelpId   ( SID_INPUT_SUM,   HID_INSWIN_SUMME );
     678                 :          0 :         SetItemText ( SID_INPUT_EQUAL, aTextEqual );
     679         [ #  # ]:          0 :         SetHelpId   ( SID_INPUT_EQUAL, HID_INSWIN_FUNC );
     680                 :          0 :         bIsOkCancelMode = false;
     681                 :            : 
     682                 :          0 :         SetFormulaMode(false);      // kein editieren -> keine Formel
     683                 :            :     }
     684                 :        640 : }
     685                 :            : 
     686                 :          0 : void ScInputWindow::SetFormulaMode( sal_Bool bSet )
     687                 :            : {
     688                 :          0 :     aWndPos.SetFormulaMode(bSet);
     689                 :          0 :     aTextWindow.SetFormulaMode(bSet);
     690                 :          0 : }
     691                 :            : 
     692                 :          0 : void ScInputWindow::SetText( const String& rString )
     693                 :            : {
     694                 :          0 :     ToolBox::SetText(rString);
     695                 :          0 : }
     696                 :            : 
     697                 :          0 : String ScInputWindow::GetText() const
     698                 :            : {
     699                 :          0 :     return ToolBox::GetText();
     700                 :            : }
     701                 :            : 
     702                 :        844 : sal_Bool ScInputWindow::IsInputActive()
     703                 :            : {
     704                 :        844 :     return aTextWindow.IsInputActive();
     705                 :            : }
     706                 :            : 
     707                 :          0 : EditView* ScInputWindow::GetEditView()
     708                 :            : {
     709                 :          0 :     return aTextWindow.GetEditView();
     710                 :            : }
     711                 :            : 
     712                 :          0 : void ScInputWindow::MakeDialogEditView()
     713                 :            : {
     714                 :          0 :     aTextWindow.MakeDialogEditView();
     715                 :          0 : }
     716                 :            : 
     717                 :         94 : void ScInputWindow::StopEditEngine( sal_Bool bAll )
     718                 :            : {
     719                 :         94 :     aTextWindow.StopEditEngine( bAll );
     720                 :         94 : }
     721                 :            : 
     722                 :          0 : void ScInputWindow::TextGrabFocus()
     723                 :            : {
     724                 :          0 :     aTextWindow.TextGrabFocus();
     725                 :          0 : }
     726                 :            : 
     727                 :          0 : void ScInputWindow::TextInvalidate()
     728                 :            : {
     729                 :          0 :     aTextWindow.Invalidate();
     730                 :          0 : }
     731                 :            : 
     732                 :          0 : void ScInputWindow::SwitchToTextWin()
     733                 :            : {
     734                 :            :     // used for shift-ctrl-F2
     735                 :            : 
     736                 :          0 :     aTextWindow.StartEditEngine();
     737         [ #  # ]:          0 :     if ( SC_MOD()->IsEditMode() )
     738                 :            :     {
     739                 :          0 :         aTextWindow.TextGrabFocus();
     740                 :          0 :         EditView* pView = aTextWindow.GetEditView();
     741         [ #  # ]:          0 :         if (pView)
     742                 :            :         {
     743 [ #  # ][ #  # ]:          0 :             sal_uInt16 nPara =  pView->GetEditEngine()->GetParagraphCount() ? ( pView->GetEditEngine()->GetParagraphCount() - 1 ) : 0;
         [ #  # ][ #  # ]
                 [ #  # ]
     744 [ #  # ][ #  # ]:          0 :             xub_StrLen nLen = pView->GetEditEngine()->GetTextLen( nPara );
     745                 :          0 :             ESelection aSel( nPara, nLen, nPara, nLen );
     746         [ #  # ]:          0 :             pView->SetSelection( aSel );                // set cursor to end of text
     747                 :            :         }
     748                 :            :     }
     749                 :          0 : }
     750                 :            : 
     751                 :          0 : void ScInputWindow::PosGrabFocus()
     752                 :            : {
     753                 :          0 :     aWndPos.GrabFocus();
     754                 :          0 : }
     755                 :            : 
     756                 :        640 : void ScInputWindow::EnableButtons( sal_Bool bEnable )
     757                 :            : {
     758                 :            :     //  when enabling buttons, always also enable the input window itself
     759 [ +  + ][ +  + ]:        640 :     if ( bEnable && !IsEnabled() )
                 [ +  + ]
     760                 :          2 :         Enable();
     761                 :            : 
     762                 :        640 :     EnableItem( SID_INPUT_FUNCTION,                                   bEnable );
     763         [ -  + ]:        640 :     EnableItem( bIsOkCancelMode ? SID_INPUT_CANCEL : SID_INPUT_SUM,   bEnable );
     764         [ -  + ]:        640 :     EnableItem( bIsOkCancelMode ? SID_INPUT_OK     : SID_INPUT_EQUAL, bEnable );
     765                 :            : //  Invalidate();
     766                 :        640 : }
     767                 :            : 
     768                 :       1092 : void ScInputWindow::StateChanged( StateChangedType nType )
     769                 :            : {
     770                 :       1092 :     ToolBox::StateChanged( nType );
     771                 :            : 
     772         [ +  + ]:       1092 :     if ( nType == STATE_CHANGE_INITSHOW ) Resize();
     773                 :       1092 : }
     774                 :            : 
     775                 :          0 : void ScInputWindow::DataChanged( const DataChangedEvent& rDCEvt )
     776                 :            : {
     777 [ #  # ][ #  # ]:          0 :     if ( rDCEvt.GetType() == DATACHANGED_SETTINGS && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
                 [ #  # ]
     778                 :            :     {
     779                 :            :         //  update item images
     780                 :          0 :         ScModule*        pScMod  = SC_MOD();
     781                 :          0 :         SfxImageManager* pImgMgr = SfxImageManager::GetImageManager( pScMod );
     782                 :            :         // IMAGE macro uses pScMod, pImgMg
     783                 :            : 
     784         [ #  # ]:          0 :         SetItemImage( SID_INPUT_FUNCTION, IMAGE( SID_INPUT_FUNCTION ) );
     785         [ #  # ]:          0 :         if ( bIsOkCancelMode )
     786                 :            :         {
     787         [ #  # ]:          0 :             SetItemImage( SID_INPUT_CANCEL, IMAGE( SID_INPUT_CANCEL ) );
     788         [ #  # ]:          0 :             SetItemImage( SID_INPUT_OK,     IMAGE( SID_INPUT_OK ) );
     789                 :            :         }
     790                 :            :         else
     791                 :            :         {
     792         [ #  # ]:          0 :             SetItemImage( SID_INPUT_SUM,   IMAGE( SID_INPUT_SUM ) );
     793         [ #  # ]:          0 :             SetItemImage( SID_INPUT_EQUAL, IMAGE( SID_INPUT_EQUAL ) );
     794                 :            :         }
     795                 :            :     }
     796                 :            : 
     797                 :          0 :     ToolBox::DataChanged( rDCEvt );
     798                 :          0 : }
     799                 :            : 
     800                 :          0 : bool ScInputWindow::IsPointerAtResizePos()
     801                 :            : {
     802 [ #  # ][ #  # ]:          0 :     if ( GetOutputSizePixel().Height() - GetPointerPosPixel().Y() <= 4  )
     803                 :          0 :         return true;
     804                 :            :     else
     805                 :          0 :         return false;
     806                 :            : }
     807                 :            : 
     808                 :          0 : void ScInputWindow::MouseMove( const MouseEvent& rMEvt )
     809                 :            : {
     810         [ #  # ]:          0 :     if ( mbIsMultiLine )
     811                 :            :     {
     812         [ #  # ]:          0 :         Point aPosPixel = GetPointerPosPixel();
     813                 :            : 
     814         [ #  # ]:          0 :         ScInputBarGroup* pGroupBar = dynamic_cast< ScInputBarGroup* > ( pRuntimeWindow.get() );
     815                 :            : 
     816 [ #  # ][ #  # ]:          0 :         if ( bInResize || IsPointerAtResizePos() )
         [ #  # ][ #  # ]
     817         [ #  # ]:          0 :             SetPointer( Pointer( POINTER_WINDOW_SSIZE ) );
     818                 :            :         else
     819         [ #  # ]:          0 :             SetPointer( Pointer( POINTER_ARROW ) );
     820                 :            : 
     821         [ #  # ]:          0 :         if ( bInResize )
     822                 :            :         {
     823                 :            :             // detect direction
     824                 :          0 :             long nResizeThreshold = ( (long)TBX_WINDOW_HEIGHT * 0.7 );
     825                 :          0 :             bool bResetPointerPos = false;
     826                 :            : 
     827                 :            :             // Detect attempt to expand toolbar too much
     828         [ #  # ]:          0 :             if ( aPosPixel.Y() >= mnMaxY )
     829                 :            :             {
     830                 :          0 :                 bResetPointerPos = true;
     831                 :          0 :                 aPosPixel.Y() = mnMaxY;
     832                 :            :             } // or expanding down
     833 [ #  # ][ #  # ]:          0 :             else if ( GetOutputSizePixel().Height() - aPosPixel.Y() < -nResizeThreshold  )
     834                 :            :             {
     835         [ #  # ]:          0 :                 pGroupBar->IncrementVerticalSize();
     836                 :          0 :                 bResetPointerPos = true;
     837                 :            :             } // or shrinking up
     838 [ #  # ][ #  # ]:          0 :             else if ( ( GetOutputSizePixel().Height() - aPosPixel.Y()  ) > nResizeThreshold )
     839                 :            :             {
     840                 :          0 :                 bResetPointerPos = true;
     841         [ #  # ]:          0 :                 pGroupBar->DecrementVerticalSize();
     842                 :            :             }
     843                 :            : 
     844         [ #  # ]:          0 :             if ( bResetPointerPos )
     845                 :            :             {
     846         [ #  # ]:          0 :                 aPosPixel.Y() =  GetOutputSizePixel().Height();
     847         [ #  # ]:          0 :                 SetPointerPosPixel( aPosPixel );
     848                 :            :             }
     849                 :            :         }
     850                 :            :     }
     851                 :          0 :     ToolBox::MouseMove( rMEvt );
     852                 :          0 : }
     853                 :            : 
     854                 :          0 : void ScInputWindow::MouseButtonDown( const MouseEvent& rMEvt )
     855                 :            : {
     856         [ #  # ]:          0 :     if ( mbIsMultiLine )
     857                 :            :     {
     858         [ #  # ]:          0 :         if ( rMEvt.IsLeft() )
     859                 :            :         {
     860         [ #  # ]:          0 :             if ( IsPointerAtResizePos() )
     861                 :            :             {
     862                 :            :                 // Don't leave the mouse pointer leave *this* window
     863                 :          0 :                 CaptureMouse();
     864                 :          0 :                 bInResize = true;
     865                 :            :                 // find the height of the gridwin, we don't wan't to be
     866                 :            :                 // able to expand the toolbar too far so we need to
     867                 :            :                 // caculate an upper limit
     868                 :            :                 // I'd prefer to leave at least a single column header and a
     869                 :            :                 // row but I don't know how to get that value in pixels.
     870                 :            :                 // Use TBX_WINDOW_HEIGHT for the moment
     871                 :          0 :                 ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
     872 [ #  # ][ #  # ]:          0 :                 mnMaxY =  GetOutputSizePixel().Height() + ( pViewSh->GetGridHeight(SC_SPLIT_TOP) + pViewSh->GetGridHeight(SC_SPLIT_BOTTOM) ) - TBX_WINDOW_HEIGHT;
     873                 :            :             }
     874                 :            :         }
     875                 :            :     }
     876                 :          0 :     ToolBox::MouseButtonDown( rMEvt );
     877                 :          0 : }
     878                 :          0 : void ScInputWindow::MouseButtonUp( const MouseEvent& rMEvt )
     879                 :            : {
     880         [ #  # ]:          0 :     if ( mbIsMultiLine )
     881                 :            :     {
     882                 :          0 :         ReleaseMouse();
     883         [ #  # ]:          0 :         if ( rMEvt.IsLeft() )
     884                 :            :         {
     885                 :          0 :             bInResize = false;
     886                 :          0 :             mnMaxY = 0;
     887                 :            :         }
     888                 :            :     }
     889                 :          0 :     ToolBox::MouseButtonUp( rMEvt );
     890                 :          0 : }
     891                 :            : 
     892                 :            : 
     893                 :            : //========================================================================
     894                 :            : //                  ScInputBarGroup
     895                 :            : //========================================================================
     896                 :            : 
     897                 :        229 : ScInputBarGroup::ScInputBarGroup(Window* pParent, ScTabViewShell* pViewSh)
     898                 :            :     :   ScTextWndBase        ( pParent, WinBits(WB_HIDE |  WB_TABSTOP ) ),
     899                 :            :         aMultiTextWnd        ( this, pViewSh ),
     900                 :            :         aButton              ( this, WB_TABSTOP | WB_RECTSTYLE | WB_SMALLSTYLE ),
     901                 :            :         aScrollBar           ( this, WB_TABSTOP | WB_VERT | WB_DRAG ),
     902 [ +  - ][ +  - ]:        229 :         nVertOffset          ( 0 )
                 [ +  - ]
     903                 :            : {
     904         [ +  - ]:        229 :       aMultiTextWnd.Show();
     905 [ +  - ][ +  - ]:        229 :       aMultiTextWnd.SetQuickHelpText( ScResId( SCSTR_QHELP_INPUTWND ) );
         [ +  - ][ +  - ]
     906         [ +  - ]:        229 :       aMultiTextWnd.SetHelpId( HID_INSWIN_INPUT );
     907                 :            : 
     908         [ +  - ]:        229 :       Size aSize( GetSettings().GetStyleSettings().GetScrollBarSize(), aMultiTextWnd.GetPixelHeightForLines(1) );
     909                 :            : 
     910         [ +  - ]:        229 :       aButton.SetClickHdl( LINK( this, ScInputBarGroup, ClickHdl ) );
     911         [ +  - ]:        229 :       aButton.SetSizePixel( aSize );
     912         [ +  - ]:        229 :       aButton.Enable();
     913         [ +  - ]:        229 :       aButton.SetSymbol( SYMBOL_SPIN_DOWN  );
     914 [ +  - ][ +  - ]:        229 :       aButton.SetQuickHelpText( ScResId( SCSTR_QHELP_EXPAND_FORMULA ) );
         [ +  - ][ +  - ]
     915         [ +  - ]:        229 :       aButton.Show();
     916                 :            : 
     917         [ +  - ]:        229 :       aScrollBar.SetSizePixel( aSize );
     918         [ +  - ]:        229 :       aScrollBar.SetScrollHdl( LINK( this, ScInputBarGroup, Impl_ScrollHdl ) );
     919                 :        229 : }
     920                 :            : 
     921 [ +  - ][ +  - ]:        225 : ScInputBarGroup::~ScInputBarGroup()
                 [ +  - ]
     922                 :            : {
     923                 :            : 
     924         [ -  + ]:        450 : }
     925                 :            : 
     926                 :            : void
     927                 :          0 : ScInputBarGroup::InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData )
     928                 :            : {
     929                 :          0 :     aMultiTextWnd.InsertAccessibleTextData( rTextData );
     930                 :          0 : }
     931                 :            : 
     932                 :            : void
     933                 :          0 : ScInputBarGroup::RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData )
     934                 :            : {
     935                 :          0 :     aMultiTextWnd.RemoveAccessibleTextData( rTextData );
     936                 :          0 : }
     937                 :            : 
     938                 :            : const String&
     939                 :          0 : ScInputBarGroup::GetTextString() const
     940                 :            : {
     941                 :          0 :     return aMultiTextWnd.GetTextString();
     942                 :            : }
     943                 :            : 
     944                 :        586 : void ScInputBarGroup::SetTextString( const String& rString )
     945                 :            : {
     946                 :        586 :     aMultiTextWnd.SetTextString(rString);
     947                 :        586 : }
     948                 :            : 
     949                 :       2455 : void ScInputBarGroup::Resize()
     950                 :            : {
     951         [ +  - ]:       2455 :     Window *w=GetParent();
     952                 :            :     ScInputWindow *pParent;
     953         [ -  + ]:       2455 :     pParent=dynamic_cast<ScInputWindow*>(w);
     954                 :            : 
     955         [ +  - ]:       2455 :     if(pParent==NULL)
     956                 :            :     {
     957                 :            :         OSL_FAIL("The parent window pointer pParent is null");
     958                 :       2455 :         return;
     959                 :            :     }
     960                 :            : 
     961         [ +  - ]:       2455 :     long nWidth = pParent->GetSizePixel().Width();
     962         [ +  - ]:       2455 :     long nLeft  = GetPosPixel().X();
     963                 :            : 
     964         [ +  - ]:       2455 :     Size aSize  = GetSizePixel();
     965                 :       2455 :     aSize.Width() = Max( ((long)(nWidth - nLeft - LEFT_OFFSET)), (long)0 );
     966                 :            : 
     967 [ +  - ][ +  - ]:       2455 :     aScrollBar.SetPosPixel(Point( aSize.Width() - aButton.GetSizePixel().Width(), aButton.GetSizePixel().Height() ) );
                 [ +  - ]
     968                 :            : 
     969                 :       2455 :     Size aTmpSize( aSize );
     970         [ +  - ]:       2455 :     aTmpSize.Width() = aTmpSize.Width() - aButton.GetSizePixel().Width() - BUTTON_OFFSET;
     971         [ +  - ]:       2455 :     aMultiTextWnd.SetSizePixel(aTmpSize);
     972                 :            : 
     973         [ +  - ]:       2455 :     aMultiTextWnd.Resize();
     974                 :            : 
     975         [ +  - ]:       2455 :     aSize.Height() = aMultiTextWnd.GetSizePixel().Height();
     976                 :            : 
     977         [ +  - ]:       2455 :     SetSizePixel(aSize);
     978                 :            : 
     979         [ -  + ]:       2455 :     if( aMultiTextWnd.GetNumLines() > 1 )
     980                 :            :     {
     981         [ #  # ]:          0 :         aButton.SetSymbol( SYMBOL_SPIN_UP  );
     982 [ #  # ][ #  # ]:          0 :         aButton.SetQuickHelpText( ScResId( SCSTR_QHELP_COLLAPSE_FORMULA ) );
         [ #  # ][ #  # ]
     983         [ #  # ]:          0 :         Size scrollSize = aButton.GetSizePixel();
     984 [ #  # ][ #  # ]:          0 :         scrollSize.Height() = aMultiTextWnd.GetSizePixel().Height() - aButton.GetSizePixel().Height();
     985         [ #  # ]:          0 :         aScrollBar.SetSizePixel( scrollSize );
     986                 :            : 
     987         [ #  # ]:          0 :         Size aOutSz = aMultiTextWnd.GetOutputSize();
     988                 :            : 
     989         [ #  # ]:          0 :         aScrollBar.SetVisibleSize( aOutSz.Height() );
     990                 :          0 :         aScrollBar.SetPageSize( aOutSz.Height() );
     991         [ #  # ]:          0 :         aScrollBar.SetLineSize( aMultiTextWnd.GetTextHeight() );
     992 [ #  # ][ #  # ]:          0 :         aScrollBar.SetRange( Range( 0, aMultiTextWnd.GetEditEngTxtHeight() ) );
     993                 :            : 
     994         [ #  # ]:          0 :         aScrollBar.Resize();
     995         [ #  # ]:          0 :         aScrollBar.Show();
     996                 :            :     }
     997                 :            :     else
     998                 :            :     {
     999         [ +  - ]:       2455 :         aButton.SetSymbol( SYMBOL_SPIN_DOWN  );
    1000 [ +  - ][ +  - ]:       2455 :         aButton.SetQuickHelpText( ScResId( SCSTR_QHELP_EXPAND_FORMULA ) );
         [ +  - ][ +  - ]
    1001         [ +  - ]:       2455 :         aScrollBar.Hide();
    1002                 :            :     }
    1003                 :            : 
    1004 [ +  - ][ +  - ]:       2455 :     aButton.SetPosPixel(Point(aSize.Width() - aButton.GetSizePixel().Width(), 0));
    1005                 :            : 
    1006         [ +  - ]:       2455 :     Invalidate();
    1007                 :            : }
    1008                 :            : 
    1009                 :         94 : void ScInputBarGroup::StopEditEngine( sal_Bool bAll )
    1010                 :            : {
    1011                 :         94 :     aMultiTextWnd.StopEditEngine( bAll );
    1012                 :         94 : }
    1013                 :            : 
    1014                 :          0 : void ScInputBarGroup::StartEditEngine()
    1015                 :            : {
    1016                 :          0 :     aMultiTextWnd.StartEditEngine();
    1017                 :          0 : }
    1018                 :            : 
    1019                 :            : 
    1020                 :          0 : void ScInputBarGroup::MakeDialogEditView()
    1021                 :            : {
    1022                 :          0 :     aMultiTextWnd.MakeDialogEditView();
    1023                 :          0 : }
    1024                 :            : 
    1025                 :            : 
    1026                 :          0 : EditView* ScInputBarGroup::GetEditView()
    1027                 :            : {
    1028                 :          0 :     return aMultiTextWnd.GetEditView();
    1029                 :            : }
    1030                 :            : 
    1031                 :        844 : sal_Bool ScInputBarGroup::IsInputActive()
    1032                 :            : {
    1033                 :        844 :     return aMultiTextWnd.IsInputActive();
    1034                 :            : }
    1035                 :            : 
    1036                 :          0 : void ScInputBarGroup::SetFormulaMode(sal_Bool bSet)
    1037                 :            : {
    1038                 :          0 :     aMultiTextWnd.SetFormulaMode(bSet);
    1039                 :          0 : }
    1040                 :            : 
    1041                 :          0 : void ScInputBarGroup::IncrementVerticalSize()
    1042                 :            : {
    1043                 :          0 :     aMultiTextWnd.SetNumLines( aMultiTextWnd.GetNumLines() + 1 );
    1044                 :          0 :     TriggerToolboxLayout();
    1045                 :          0 : }
    1046                 :            : 
    1047                 :          0 : void ScInputBarGroup::DecrementVerticalSize()
    1048                 :            : {
    1049         [ #  # ]:          0 :     if ( aMultiTextWnd.GetNumLines() > 1 )
    1050                 :            :     {
    1051                 :          0 :         aMultiTextWnd.SetNumLines( aMultiTextWnd.GetNumLines() - 1 );
    1052                 :          0 :         TriggerToolboxLayout();
    1053                 :            :     }
    1054                 :          0 : }
    1055                 :            : 
    1056                 :          0 : IMPL_LINK_NOARG(ScInputBarGroup, ClickHdl)
    1057                 :            : {
    1058                 :          0 :     Window *w=GetParent();
    1059                 :            :     ScInputWindow *pParent;
    1060         [ #  # ]:          0 :     pParent=dynamic_cast<ScInputWindow*>(w);
    1061                 :            : 
    1062         [ #  # ]:          0 :     if(pParent==NULL)
    1063                 :            :     {
    1064                 :            :         OSL_FAIL("The parent window pointer pParent is null");
    1065                 :          0 :         return 1;
    1066                 :            :     }
    1067         [ #  # ]:          0 :     if( aMultiTextWnd.GetNumLines() > 1 )
    1068                 :            :     {
    1069                 :          0 :         aMultiTextWnd.SetNumLines( 1 );
    1070                 :            :     }
    1071                 :            :     else
    1072                 :            :     {
    1073                 :          0 :         aMultiTextWnd.SetNumLines( aMultiTextWnd.GetLastNumExpandedLines() );
    1074                 :            :     }
    1075                 :          0 :     TriggerToolboxLayout();
    1076                 :            :     // Restore focus to input line(s) if necessary
    1077         [ #  # ]:          0 :     if (  SC_MOD()->GetInputHdl()->IsTopMode() )
    1078                 :          0 :         aMultiTextWnd.GrabFocus();
    1079                 :          0 :     return 0;
    1080                 :            : }
    1081                 :            : 
    1082                 :          0 : void ScInputBarGroup::TriggerToolboxLayout()
    1083                 :            : {
    1084                 :          0 :     Window *w=GetParent();
    1085                 :            :     ScInputWindow *pParent;
    1086         [ #  # ]:          0 :     pParent=dynamic_cast<ScInputWindow*>(w);
    1087                 :          0 :     SfxViewFrame* pViewFrm = SfxViewFrame::Current();
    1088                 :            : 
    1089                 :            :     // Capture the vertical position of this window in the toolbar, when we increase
    1090                 :            :     // the size of the toolbar to accomadate expanded line input we need to take this
    1091                 :            :     // into account
    1092         [ #  # ]:          0 :     if ( !nVertOffset )
    1093                 :          0 :         nVertOffset = pParent->GetItemPosRect( pParent->GetItemCount() - 1 ).Top();
    1094                 :            : 
    1095         [ #  # ]:          0 :     if ( pViewFrm )
    1096                 :            :     {
    1097 [ #  # ][ #  # ]:          0 :         Reference< com::sun::star::beans::XPropertySet > xPropSet( pViewFrm->GetFrame().GetFrameInterface(), UNO_QUERY );
                 [ #  # ]
    1098                 :          0 :         Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
    1099                 :            : 
    1100         [ #  # ]:          0 :         if ( xPropSet.is() )
    1101                 :            :         {
    1102 [ #  # ][ #  # ]:          0 :             com::sun::star::uno::Any aValue = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )));
                 [ #  # ]
    1103         [ #  # ]:          0 :             aValue >>= xLayoutManager;
    1104                 :            :         }
    1105                 :            : 
    1106         [ #  # ]:          0 :         if ( xLayoutManager.is() )
    1107                 :            :         {
    1108         [ #  # ]:          0 :             if ( aMultiTextWnd.GetNumLines() > 1)
    1109         [ #  # ]:          0 :                 pParent->SetToolbarLayoutMode( TBX_LAYOUT_LOCKVERT );
    1110                 :            :             else
    1111         [ #  # ]:          0 :                 pParent->SetToolbarLayoutMode( TBX_LAYOUT_NORMAL );
    1112 [ #  # ][ #  # ]:          0 :             xLayoutManager->lock();
    1113         [ #  # ]:          0 :             DataChangedEvent aFakeUpdate( DATACHANGED_SETTINGS, NULL,  SETTINGS_STYLE );
    1114                 :            :             // this basically will trigger the reposititioning of the
    1115                 :            :             // items in the toolbar from ImplFormat ( which is controlled by
    1116                 :            :             // mnWinHeight ) which in turn is updated in ImplCalcItem which is
    1117                 :            :             // controlled by mbCalc. Additionally the ImplFormat above is
    1118                 :            :             // controlled via mbFormat. It seems the easiest way to get these
    1119                 :            :             // booleans set is to send in the fake event below.
    1120         [ #  # ]:          0 :             pParent->DataChanged( aFakeUpdate);
    1121                 :            :             // highest item in toolbar will have been calculated via the
    1122                 :            :             // event above. Call resize on InputBar to pick up the height
    1123                 :            :             // change
    1124         [ #  # ]:          0 :             pParent->Resize();
    1125                 :            :             // unlock relayouts the toolbars in the 4 quadrants
    1126 [ #  # ][ #  # ]:          0 :             xLayoutManager->unlock();
    1127                 :          0 :         }
    1128                 :            :     }
    1129                 :          0 : }
    1130                 :            : 
    1131                 :          0 : IMPL_LINK_NOARG(ScInputBarGroup, Impl_ScrollHdl)
    1132                 :            : {
    1133                 :          0 :     aMultiTextWnd.DoScroll();
    1134                 :          0 :     return 0;
    1135                 :            : }
    1136                 :            : 
    1137                 :          0 : void ScInputBarGroup::TextGrabFocus()
    1138                 :            : {
    1139                 :          0 :     aMultiTextWnd.TextGrabFocus();
    1140                 :          0 : }
    1141                 :            : 
    1142                 :            : //========================================================================
    1143                 :            : //                      ScMultiTextWnd
    1144                 :            : //========================================================================
    1145                 :            : 
    1146                 :        229 : ScMultiTextWnd::ScMultiTextWnd( ScInputBarGroup* pParen, ScTabViewShell* pViewSh )
    1147                 :            :     :
    1148                 :            :         ScTextWnd( pParen, pViewSh ),
    1149                 :            :         mrGroupBar(* pParen ),
    1150                 :            :         mnLines( 1 ),
    1151                 :            :         mnLastExpandedLines( INPUTWIN_MULTILINES ),
    1152                 :        229 :         mbInvalidate( false )
    1153                 :            : {
    1154                 :        229 :     Size aBorder;
    1155         [ +  - ]:        229 :     aBorder = CalcWindowSize( aBorder);
    1156                 :        229 :     mnBorderHeight = aBorder.Height();
    1157                 :        229 : }
    1158                 :            : 
    1159                 :        225 : ScMultiTextWnd::~ScMultiTextWnd()
    1160                 :            : {
    1161         [ -  + ]:        225 : }
    1162                 :            : 
    1163                 :        485 : void ScMultiTextWnd::Paint( const Rectangle& rRec )
    1164                 :            : {
    1165                 :        485 :     EditView* pView = GetEditView();
    1166         [ +  - ]:        485 :     if ( pView )
    1167                 :            :     {
    1168         [ +  + ]:        485 :         if ( mbInvalidate )
    1169                 :            :         {
    1170                 :        254 :             pView->Invalidate();
    1171                 :        254 :             mbInvalidate = false;
    1172                 :            :         }
    1173                 :        485 :         pEditView->Paint( rRec );
    1174                 :            :     }
    1175                 :        485 : }
    1176                 :            : 
    1177                 :        485 : EditView* ScMultiTextWnd::GetEditView()
    1178                 :            : {
    1179         [ +  + ]:        485 :     if ( !pEditView )
    1180                 :        205 :         InitEditEngine();
    1181                 :        485 :     return pEditView;
    1182                 :            : }
    1183                 :            : 
    1184                 :       4428 : long ScMultiTextWnd::GetPixelHeightForLines( long nLines )
    1185                 :            : {
    1186                 :            :     // add padding ( for the borders of the window )
    1187         [ +  - ]:       4428 :     return ( nLines * LogicToPixel( Size( 0, GetTextHeight() ) ).Height() ) + mnBorderHeight;
    1188                 :            : }
    1189                 :            : 
    1190                 :          0 : void ScMultiTextWnd::SetNumLines( long nLines )
    1191                 :            : {
    1192                 :          0 :     mnLines = nLines;
    1193         [ #  # ]:          0 :     if ( nLines > 1 )
    1194                 :            :     {
    1195                 :          0 :         mnLastExpandedLines = nLines;
    1196                 :          0 :         Resize();
    1197                 :            :     }
    1198                 :          0 : }
    1199                 :            : 
    1200                 :       4199 : void ScMultiTextWnd::Resize()
    1201                 :            : {
    1202                 :            :     // Only Height is recalculated here, Width is applied from
    1203                 :            :     // parent/container window
    1204         [ +  - ]:       4199 :     Size aTextBoxSize = GetSizePixel();
    1205                 :            : 
    1206         [ +  - ]:       4199 :     aTextBoxSize.Height() = GetPixelHeightForLines( mnLines );
    1207         [ +  - ]:       4199 :     SetSizePixel( aTextBoxSize );
    1208                 :            : 
    1209         [ +  + ]:       4199 :     if(pEditView)
    1210                 :            :     {
    1211                 :        205 :         Size aOutputSize = GetOutputSizePixel();
    1212 [ +  - ][ +  - ]:        205 :         Rectangle aOutputArea = PixelToLogic( Rectangle( Point(), aOutputSize ));
    1213         [ +  - ]:        205 :         pEditView->SetOutputArea( aOutputArea );
    1214                 :            : 
    1215                 :            :         // Don't leave an empty area at the bottom if we can move the text down.
    1216 [ +  - ][ +  - ]:        205 :         long nMaxVisAreaTop = pEditEngine->GetTextHeight() - aOutputArea.GetHeight();
    1217 [ +  - ][ -  + ]:        205 :         if (pEditView->GetVisArea().Top() > nMaxVisAreaTop)
    1218                 :            :         {
    1219 [ #  # ][ #  # ]:          0 :             pEditView->Scroll(0, pEditView->GetVisArea().Top() - nMaxVisAreaTop);
    1220                 :            :         }
    1221                 :            : 
    1222 [ +  - ][ +  - ]:        205 :         pEditEngine->SetPaperSize( PixelToLogic( Size( aOutputSize.Width(), 10000 ) ) );
    1223                 :            :     }
    1224                 :            : 
    1225         [ +  - ]:       4199 :     SetScrollBarRange();
    1226                 :       4199 : }
    1227                 :            : 
    1228                 :        197 : IMPL_LINK(ScMultiTextWnd, ModifyHdl, EENotify*, pNotify)
    1229                 :            : {
    1230                 :        197 :     ScTextWnd::NotifyHdl( pNotify );
    1231                 :        197 :     return 0;
    1232                 :            : }
    1233                 :            : 
    1234                 :        552 : IMPL_LINK(ScMultiTextWnd, NotifyHdl, EENotify*, pNotify)
    1235                 :            : {
    1236                 :            :     // need to process EE_NOTIFY_TEXTVIEWSCROLLED here
    1237                 :            :     // sometimes we don't seem to get EE_NOTIFY_TEXTVIEWSCROLLED e.g. when
    1238                 :            :     // we insert text at the begining of the text so the cursor never moves
    1239                 :            :     // down to generate a scroll event
    1240                 :            : 
    1241 [ +  - ][ +  - ]:        552 :     if ( pNotify && ( pNotify->eNotificationType == EE_NOTIFY_TEXTVIEWSCROLLED
                 [ +  + ]
    1242                 :            :                  ||   pNotify->eNotificationType == EE_NOTIFY_TEXTHEIGHTCHANGED ) )
    1243                 :         71 :         SetScrollBarRange();
    1244                 :        552 :     return 0;
    1245                 :            : }
    1246                 :            : 
    1247                 :        349 : long ScMultiTextWnd::GetEditEngTxtHeight()
    1248                 :            : {
    1249         [ +  - ]:        349 :     return pEditView ? pEditView->GetEditEngine()->GetTextHeight() : 0;
    1250                 :            : }
    1251                 :            : 
    1252                 :       4856 : void ScMultiTextWnd::SetScrollBarRange()
    1253                 :            : {
    1254         [ +  + ]:       4856 :     if ( pEditView )
    1255                 :            :     {
    1256                 :        349 :         ScrollBar& rVBar = mrGroupBar.GetScrollBar();
    1257         [ +  - ]:        349 :         rVBar.SetRange( Range( 0, GetEditEngTxtHeight() ) );
    1258                 :        349 :         long currentDocPos = pEditView->GetVisArea().TopLeft().Y();
    1259                 :        349 :         rVBar.SetThumbPos( currentDocPos );
    1260                 :            :     }
    1261                 :       4856 : }
    1262                 :            : 
    1263                 :            : void
    1264                 :        586 : ScMultiTextWnd::DoScroll()
    1265                 :            : {
    1266         [ +  + ]:        586 :     if ( pEditView )
    1267                 :            :     {
    1268                 :         73 :         ScrollBar& rVBar = mrGroupBar.GetScrollBar();
    1269                 :         73 :         long currentDocPos = pEditView->GetVisArea().TopLeft().Y();
    1270                 :         73 :         long nDiff = currentDocPos - rVBar.GetThumbPos();
    1271                 :         73 :         pEditView->Scroll( 0, nDiff );
    1272                 :         73 :         currentDocPos = pEditView->GetVisArea().TopLeft().Y();
    1273                 :         73 :         rVBar.SetThumbPos( currentDocPos );
    1274                 :            :     }
    1275                 :        586 : }
    1276                 :            : 
    1277                 :          0 : void ScMultiTextWnd::StartEditEngine()
    1278                 :            : {
    1279                 :            :     //  Bei "eigener Modalitaet" (Doc-modale Dialoge) nicht aktivieren
    1280                 :          0 :     SfxObjectShell* pObjSh = SfxObjectShell::Current();
    1281 [ #  # ][ #  # ]:          0 :     if ( pObjSh && pObjSh->IsInModalMode() )
                 [ #  # ]
    1282                 :          0 :         return;
    1283                 :            : 
    1284 [ #  # ][ #  # ]:          0 :     if ( !pEditView || !pEditEngine )
    1285                 :            :     {
    1286                 :          0 :         InitEditEngine();
    1287                 :            :     }
    1288                 :            : 
    1289                 :          0 :     SC_MOD()->SetInputMode( SC_INPUT_TOP );
    1290                 :            : 
    1291                 :          0 :     SfxViewFrame* pViewFrm = SfxViewFrame::Current();
    1292         [ #  # ]:          0 :     if (pViewFrm)
    1293                 :          0 :         pViewFrm->GetBindings().Invalidate( SID_ATTR_INSERT );
    1294                 :            : }
    1295                 :            : 
    1296                 :        205 : void lcl_ExtendEditFontAttribs( SfxItemSet& rSet )
    1297                 :            : {
    1298                 :        205 :     const SfxPoolItem& rFontItem = rSet.Get( EE_CHAR_FONTINFO );
    1299                 :        205 :     rSet.Put( rFontItem, EE_CHAR_FONTINFO_CJK );
    1300                 :        205 :     rSet.Put( rFontItem, EE_CHAR_FONTINFO_CTL );
    1301                 :        205 :     const SfxPoolItem& rHeightItem = rSet.Get( EE_CHAR_FONTHEIGHT );
    1302                 :        205 :     rSet.Put( rHeightItem, EE_CHAR_FONTHEIGHT_CJK );
    1303                 :        205 :     rSet.Put( rHeightItem, EE_CHAR_FONTHEIGHT_CTL );
    1304                 :        205 :     const SfxPoolItem& rWeightItem = rSet.Get( EE_CHAR_WEIGHT );
    1305                 :        205 :     rSet.Put( rWeightItem, EE_CHAR_WEIGHT_CJK );
    1306                 :        205 :     rSet.Put( rWeightItem, EE_CHAR_WEIGHT_CTL );
    1307                 :        205 :     const SfxPoolItem& rItalicItem = rSet.Get( EE_CHAR_ITALIC );
    1308                 :        205 :     rSet.Put( rItalicItem, EE_CHAR_ITALIC_CJK );
    1309                 :        205 :     rSet.Put( rItalicItem, EE_CHAR_ITALIC_CTL );
    1310                 :        205 :     const SfxPoolItem& rLangItem = rSet.Get( EE_CHAR_LANGUAGE );
    1311                 :        205 :     rSet.Put( rLangItem, EE_CHAR_LANGUAGE_CJK );
    1312                 :        205 :     rSet.Put( rLangItem, EE_CHAR_LANGUAGE_CTL );
    1313                 :        205 : }
    1314                 :            : 
    1315                 :          0 : void lcl_ModifyRTLDefaults( SfxItemSet& rSet )
    1316                 :            : {
    1317 [ #  # ][ #  # ]:          0 :     rSet.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
                 [ #  # ]
    1318                 :            : 
    1319                 :            :     //  always using rtl writing direction would break formulas
    1320                 :            :     //rSet.Put( SvxFrameDirectionItem( FRMDIR_HORI_RIGHT_TOP, EE_PARA_WRITINGDIR ) );
    1321                 :            : 
    1322                 :            :     //  PaperSize width is limited to USHRT_MAX in RTL mode (because of EditEngine's
    1323                 :            :     //  sal_uInt16 values in EditLine), so the text may be wrapped and line spacing must be
    1324                 :            :     //  increased to not see the beginning of the next line.
    1325         [ #  # ]:          0 :     SvxLineSpacingItem aItem( SVX_LINESPACE_TWO_LINES, EE_PARA_SBL );
    1326                 :          0 :     aItem.SetPropLineSpace( 200 );
    1327 [ #  # ][ #  # ]:          0 :     rSet.Put( aItem );
    1328                 :          0 : }
    1329                 :            : 
    1330                 :          0 : void lcl_ModifyRTLVisArea( EditView* pEditView )
    1331                 :            : {
    1332         [ #  # ]:          0 :     Rectangle aVisArea = pEditView->GetVisArea();
    1333 [ #  # ][ #  # ]:          0 :     Size aPaper = pEditView->GetEditEngine()->GetPaperSize();
    1334                 :          0 :     long nDiff = aPaper.Width() - aVisArea.Right();
    1335                 :          0 :     aVisArea.Left()  += nDiff;
    1336                 :          0 :     aVisArea.Right() += nDiff;
    1337         [ #  # ]:          0 :     pEditView->SetVisArea(aVisArea);
    1338                 :          0 : }
    1339                 :            : 
    1340                 :            : 
    1341                 :        205 : void ScMultiTextWnd::InitEditEngine()
    1342                 :            : {
    1343                 :            :     ScFieldEditEngine* pNew;
    1344                 :        205 :     ScTabViewShell* pViewSh = GetViewShell();
    1345                 :        205 :     ScDocShell* pDocSh = NULL;
    1346         [ +  - ]:        205 :     if ( pViewSh )
    1347                 :            :     {
    1348                 :        205 :         pDocSh = pViewSh->GetViewData()->GetDocShell();
    1349         [ +  - ]:        205 :         ScDocument* pDoc = pViewSh->GetViewData()->GetDocument();
    1350 [ +  - ][ +  - ]:        205 :         pNew = new ScFieldEditEngine(pDoc, pDoc->GetEnginePool(), pDoc->GetEditPool());
         [ +  - ][ +  - ]
    1351                 :            :     }
    1352                 :            :     else
    1353 [ #  # ][ #  # ]:          0 :         pNew = new ScFieldEditEngine(NULL, EditEngine::CreatePool(), NULL, true);
                 [ #  # ]
    1354                 :        205 :     pNew->SetExecuteURL( false );
    1355                 :        205 :     pEditEngine = pNew;
    1356                 :            : 
    1357         [ +  - ]:        205 :     Size barSize=GetSizePixel();
    1358         [ +  - ]:        205 :     pEditEngine->SetUpdateMode( false );
    1359 [ +  - ][ +  - ]:        205 :     pEditEngine->SetPaperSize( PixelToLogic(Size(barSize.Width(),10000)) );
    1360                 :            :     pEditEngine->SetWordDelimiters(
    1361 [ +  - ][ +  - ]:        205 :                     ScEditUtil::ModifyDelimiters( pEditEngine->GetWordDelimiters() ) );
         [ +  - ][ +  - ]
                 [ +  - ]
    1362                 :            : 
    1363         [ +  - ]:        205 :     UpdateAutoCorrFlag();
    1364                 :            : 
    1365                 :            :     {
    1366 [ +  - ][ +  - ]:        205 :         SfxItemSet* pSet = new SfxItemSet( pEditEngine->GetEmptyItemSet() );
                 [ +  - ]
    1367         [ +  - ]:        205 :         pEditEngine->SetFontInfoInItemSet( *pSet, aTextFont );
    1368         [ +  - ]:        205 :         lcl_ExtendEditFontAttribs( *pSet );
    1369                 :            :         // turn off script spacing to match DrawText output
    1370 [ +  - ][ +  - ]:        205 :         pSet->Put( SvxScriptSpaceItem( false, EE_PARA_ASIANCJKSPACING ) );
                 [ +  - ]
    1371         [ -  + ]:        205 :         if ( bIsRTL )
    1372         [ #  # ]:          0 :             lcl_ModifyRTLDefaults( *pSet );
    1373         [ +  - ]:        205 :         pEditEngine->SetDefaults( pSet );
    1374                 :            :     }
    1375                 :            : 
    1376                 :            :     //  Wenn in der Zelle URL-Felder enthalten sind, muessen die auch in
    1377                 :            :     //  die Eingabezeile uebernommen werden, weil sonst die Positionen nicht stimmen.
    1378                 :            : 
    1379                 :        205 :     sal_Bool bFilled = false;
    1380 [ +  - ][ +  - ]:        205 :     ScInputHandler* pHdl = SC_MOD()->GetInputHdl();
    1381         [ +  - ]:        205 :     if ( pHdl )                 //!     Testen, ob's der richtige InputHdl ist?
    1382         [ +  - ]:        205 :         bFilled = pHdl->GetTextAndFields( *pEditEngine );
    1383                 :            : 
    1384         [ +  - ]:        205 :     pEditEngine->SetUpdateMode( sal_True );
    1385                 :            : 
    1386                 :            :     //  aString ist die Wahrheit...
    1387 [ -  + ][ #  # ]:        205 :     if ( bFilled && pEditEngine->GetText() == aString )
         [ #  # ][ #  # ]
         [ -  + ][ #  # ]
           [ -  +  #  # ]
    1388         [ #  # ]:          0 :         Invalidate();                                           // Repaint fuer (hinterlegte) Felder
    1389                 :            :     else
    1390         [ +  - ]:        205 :         pEditEngine->SetText(aString);               // dann wenigstens den richtigen Text
    1391                 :            : 
    1392 [ +  - ][ +  - ]:        205 :     pEditView = new EditView( pEditEngine, this );
                 [ +  - ]
    1393         [ +  - ]:        205 :     pEditView->SetInsertMode(bIsInsertMode);
    1394                 :            : 
    1395                 :            :     // Text aus Clipboard wird als ASCII einzeilig uebernommen
    1396         [ +  - ]:        205 :     sal_uLong n = pEditView->GetControlWord();
    1397         [ +  - ]:        205 :     pEditView->SetControlWord( n | EV_CNTRL_SINGLELINEPASTE  );
    1398                 :            : 
    1399         [ +  - ]:        205 :     pEditEngine->InsertView( pEditView, EE_APPEND );
    1400                 :            : 
    1401         [ +  - ]:        205 :     Resize();
    1402                 :            : 
    1403         [ -  + ]:        205 :     if ( bIsRTL )
    1404         [ #  # ]:          0 :         lcl_ModifyRTLVisArea( pEditView );
    1405                 :            : 
    1406 [ +  - ][ +  - ]:        205 :     pEditEngine->SetModifyHdl(LINK(this, ScMultiTextWnd, ModifyHdl));
    1407 [ +  - ][ +  - ]:        205 :     pEditEngine->SetNotifyHdl(LINK(this, ScMultiTextWnd, NotifyHdl));
    1408                 :            : 
    1409         [ -  + ]:        205 :     if (!maAccTextDatas.empty())
    1410 [ #  # ][ #  # ]:          0 :         maAccTextDatas.back()->StartEdit();
    1411                 :            : 
    1412                 :            :     //  as long as EditEngine and DrawText sometimes differ for CTL text,
    1413                 :            :     //  repaint now to have the EditEngine's version visible
    1414         [ +  - ]:        205 :     if (pDocSh)
    1415                 :            :     {
    1416                 :        205 :         ScDocument* pDoc = pDocSh->GetDocument();    // any document
    1417 [ +  - ][ +  - ]:        205 :         sal_uInt8 nScript = pDoc->GetStringScriptType( aString );
    1418         [ -  + ]:        205 :         if ( nScript & SCRIPTTYPE_COMPLEX )
    1419         [ #  # ]:          0 :             Invalidate();
    1420                 :            :     }
    1421                 :        205 : }
    1422                 :            : 
    1423                 :         94 : void ScMultiTextWnd::StopEditEngine( sal_Bool bAll )
    1424                 :            : {
    1425         [ +  + ]:         94 :     if ( pEditEngine )
    1426         [ +  - ]:         30 :         pEditEngine->SetNotifyHdl(Link());
    1427                 :         94 :     ScTextWnd::StopEditEngine( bAll );
    1428                 :         94 : }
    1429                 :            : 
    1430                 :        586 : void ScMultiTextWnd::SetTextString( const String& rNewString )
    1431                 :            : {
    1432                 :            :     // Ideally it would be best to create on demand the EditEngine/EditView here, but... for
    1433                 :            :     // the initialisation scenario where a cell is first clicked on we end up with the text in the
    1434                 :            :     // inputbar window scrolled to the bottom if we do that here ( because the tableview and topview
    1435                 :            :     // are synced I guess ).
    1436                 :            :     // should fix that I suppose :-/ need to look a bit further into that
    1437                 :        586 :     mbInvalidate = true; // ensure next Paint ( that uses editengine ) call will call Invalidate first
    1438                 :        586 :     ScTextWnd::SetTextString( rNewString );
    1439                 :        586 :     SetScrollBarRange();
    1440                 :        586 :     DoScroll();
    1441                 :        586 : }
    1442                 :            : //========================================================================
    1443                 :            : //                                                      ScTextWnd
    1444                 :            : //========================================================================
    1445                 :            : 
    1446                 :        229 : ScTextWnd::ScTextWnd( Window* pParent, ScTabViewShell* pViewSh )
    1447                 :            :     :   ScTextWndBase        ( pParent, WinBits(WB_HIDE | WB_BORDER) ),
    1448                 :            :         DragSourceHelper( this ),
    1449                 :            :         pEditEngine  ( NULL ),
    1450                 :            :         pEditView    ( NULL ),
    1451                 :            :         bIsInsertMode( sal_True ),
    1452                 :            :         bFormulaMode ( false ),
    1453                 :            :         bInputMode   ( false ),
    1454 [ +  - ][ +  - ]:        229 :         mpViewShell(pViewSh)
         [ +  - ][ +  - ]
    1455                 :            : {
    1456         [ +  - ]:        229 :     EnableRTL( false );     // EditEngine can't be used with VCL EnableRTL
    1457                 :            : 
    1458         [ +  - ]:        229 :     bIsRTL = GetSettings().GetLayoutRTL();
    1459                 :            : 
    1460                 :            :     //  always use application font, so a font with cjk chars can be installed
    1461         [ +  - ]:        229 :     Font aAppFont = GetFont();
    1462         [ +  - ]:        229 :     aTextFont = aAppFont;
    1463 [ +  - ][ +  - ]:        229 :     aTextFont.SetSize( PixelToLogic( aAppFont.GetSize(), MAP_TWIP ) );  // AppFont ist in Pixeln
         [ +  - ][ +  - ]
                 [ +  - ]
    1464                 :            : 
    1465         [ +  - ]:        229 :     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
    1466                 :            : 
    1467                 :        229 :     Color aBgColor= rStyleSettings.GetWindowColor();
    1468                 :        229 :     Color aTxtColor= rStyleSettings.GetWindowTextColor();
    1469                 :            : 
    1470         [ +  - ]:        229 :     aTextFont.SetTransparent ( sal_True );
    1471         [ +  - ]:        229 :     aTextFont.SetFillColor   ( aBgColor );
    1472                 :            :     //aTextFont.SetColor         ( COL_FIELDTEXT );
    1473         [ +  - ]:        229 :     aTextFont.SetColor       (aTxtColor);
    1474         [ +  - ]:        229 :     aTextFont.SetWeight      ( WEIGHT_NORMAL );
    1475                 :            : 
    1476                 :        229 :     Size aSize(1,TBX_WINDOW_HEIGHT);
    1477         [ +  - ]:        229 :     Size aMinEditSize( Edit::GetMinimumEditSize() );
    1478         [ -  + ]:        229 :     if( aMinEditSize.Height() > aSize.Height() )
    1479                 :          0 :         aSize.Height() = aMinEditSize.Height();
    1480         [ +  - ]:        229 :     SetSizePixel        ( aSize );
    1481 [ +  - ][ +  - ]:        229 :     SetBackground       ( aBgColor );
                 [ +  - ]
    1482         [ +  - ]:        229 :     SetLineColor        ( COL_BLACK );
    1483 [ +  - ][ +  - ]:        229 :     SetMapMode          ( MAP_TWIP );
                 [ +  - ]
    1484         [ +  - ]:        229 :     SetPointer          ( POINTER_TEXT );
    1485 [ +  - ][ +  - ]:        229 :     SetFont( aTextFont );
    1486                 :        229 : }
    1487                 :            : 
    1488 [ +  - ][ +  - ]:        225 : ScTextWnd::~ScTextWnd()
                 [ +  - ]
    1489                 :            : {
    1490         [ -  + ]:        225 :     while (!maAccTextDatas.empty()) {
    1491 [ #  # ][ #  # ]:          0 :         maAccTextDatas.back()->Dispose();
    1492                 :            :     }
    1493 [ +  + ][ +  - ]:        225 :     delete pEditView;
    1494 [ +  + ][ +  - ]:        225 :     delete pEditEngine;
    1495         [ -  + ]:        225 : }
    1496                 :            : 
    1497                 :          0 : void ScTextWnd::Paint( const Rectangle& rRec )
    1498                 :            : {
    1499         [ #  # ]:          0 :     if (pEditView)
    1500                 :          0 :         pEditView->Paint( rRec );
    1501                 :            :     else
    1502                 :            :     {
    1503                 :          0 :         SetFont( aTextFont );
    1504                 :            : 
    1505                 :          0 :         long nDiff =  GetOutputSizePixel().Height()
    1506 [ #  # ][ #  # ]:          0 :                     - LogicToPixel( Size( 0, GetTextHeight() ) ).Height();
    1507                 :            : //      if (nDiff<2) nDiff=2;       // mind. 1 Pixel
    1508                 :            : 
    1509                 :          0 :         long nStartPos = 0;
    1510         [ #  # ]:          0 :         if ( bIsRTL )
    1511                 :            :         {
    1512                 :            :             //  right-align
    1513                 :          0 :             nStartPos += GetOutputSizePixel().Width() -
    1514 [ #  # ][ #  # ]:          0 :                         LogicToPixel( Size( GetTextWidth( aString ), 0 ) ).Width();
    1515                 :            : 
    1516                 :            :             //  LayoutMode isn't changed as long as ModifyRTLDefaults doesn't include SvxFrameDirectionItem
    1517                 :            :         }
    1518                 :            : 
    1519 [ #  # ][ #  # ]:          0 :         DrawText( PixelToLogic( Point( nStartPos, nDiff/2 ) ), aString );
    1520                 :            :     }
    1521                 :          0 : }
    1522                 :            : 
    1523                 :          0 : void ScTextWnd::Resize()
    1524                 :            : {
    1525         [ #  # ]:          0 :     if (pEditView)
    1526                 :            :     {
    1527                 :          0 :         Size aSize = GetOutputSizePixel();
    1528                 :          0 :         long nDiff =  aSize.Height()
    1529 [ #  # ][ #  # ]:          0 :                     - LogicToPixel( Size( 0, GetTextHeight() ) ).Height();
    1530                 :            : 
    1531                 :            :         pEditView->SetOutputArea(
    1532                 :            :             PixelToLogic( Rectangle( Point( 0, (nDiff > 0) ? nDiff/2 : 1 ),
    1533 [ #  # ][ #  # ]:          0 :                                      aSize ) ) );
         [ #  # ][ #  # ]
    1534                 :            :     }
    1535                 :          0 : }
    1536                 :            : 
    1537                 :          0 : void ScTextWnd::MouseMove( const MouseEvent& rMEvt )
    1538                 :            : {
    1539         [ #  # ]:          0 :     if (pEditView)
    1540                 :          0 :         pEditView->MouseMove( rMEvt );
    1541                 :          0 : }
    1542                 :            : 
    1543                 :          0 : void ScTextWnd::MouseButtonDown( const MouseEvent& rMEvt )
    1544                 :            : {
    1545         [ #  # ]:          0 :     if (!HasFocus())
    1546                 :            :     {
    1547                 :          0 :         StartEditEngine();
    1548         [ #  # ]:          0 :         if ( SC_MOD()->IsEditMode() )
    1549                 :          0 :             GrabFocus();
    1550                 :            :     }
    1551                 :            : 
    1552         [ #  # ]:          0 :     if (pEditView)
    1553                 :            :     {
    1554                 :          0 :         pEditView->SetEditEngineUpdateMode( sal_True );
    1555                 :          0 :         pEditView->MouseButtonDown( rMEvt );
    1556                 :            :     }
    1557                 :          0 : }
    1558                 :            : 
    1559                 :          0 : void ScTextWnd::MouseButtonUp( const MouseEvent& rMEvt )
    1560                 :            : {
    1561         [ #  # ]:          0 :     if (pEditView)
    1562         [ #  # ]:          0 :         if (pEditView->MouseButtonUp( rMEvt ))
    1563                 :            :         {
    1564   [ #  #  #  # ]:          0 :             if ( rMEvt.IsMiddle() &&
                 [ #  # ]
    1565                 :          0 :                      GetSettings().GetMouseSettings().GetMiddleButtonAction() == MOUSE_MIDDLE_PASTESELECTION )
    1566                 :            :             {
    1567                 :            :                 //  EditView may have pasted from selection
    1568                 :          0 :                 SC_MOD()->InputChanged( pEditView );
    1569                 :            :             }
    1570                 :            :             else
    1571                 :          0 :                 SC_MOD()->InputSelection( pEditView );
    1572                 :            :         }
    1573                 :          0 : }
    1574                 :            : 
    1575                 :          0 : void ScTextWnd::Command( const CommandEvent& rCEvt )
    1576                 :            : {
    1577                 :          0 :     bInputMode = sal_True;
    1578                 :          0 :     sal_uInt16 nCommand = rCEvt.GetCommand();
    1579         [ #  # ]:          0 :     if ( pEditView /* && ( nCommand == COMMAND_STARTDRAG || nCommand == COMMAND_VOICE ) */ )
    1580                 :            :     {
    1581                 :          0 :         ScModule* pScMod = SC_MOD();
    1582                 :          0 :         ScTabViewShell* pStartViewSh = ScTabViewShell::GetActiveViewShell();
    1583                 :            : 
    1584                 :            :         // don't modify the font defaults here - the right defaults are
    1585                 :            :         // already set in StartEditEngine when the EditEngine is created
    1586                 :            : 
    1587                 :            :         // verhindern, dass die EditView beim View-Umschalten wegkommt
    1588                 :          0 :         pScMod->SetInEditCommand( true );
    1589                 :          0 :         pEditView->Command( rCEvt );
    1590                 :          0 :         pScMod->SetInEditCommand( false );
    1591                 :            : 
    1592                 :            :         //  COMMAND_STARTDRAG heiss noch lange nicht, dass der Inhalt geaendert wurde
    1593                 :            :         //  darum in dem Fall kein InputChanged
    1594                 :            :         //! erkennen, ob mit Move gedraggt wurde, oder Drag&Move irgendwie verbieten
    1595                 :            : 
    1596         [ #  # ]:          0 :         if ( nCommand == COMMAND_STARTDRAG )
    1597                 :            :         {
    1598                 :            :             //  ist auf eine andere View gedraggt worden?
    1599                 :          0 :             ScTabViewShell* pEndViewSh = ScTabViewShell::GetActiveViewShell();
    1600 [ #  # ][ #  # ]:          0 :             if ( pEndViewSh != pStartViewSh && pStartViewSh != NULL )
    1601                 :            :             {
    1602                 :          0 :                 ScViewData* pViewData = pStartViewSh->GetViewData();
    1603                 :          0 :                 ScInputHandler* pHdl = pScMod->GetInputHdl( pStartViewSh );
    1604 [ #  # ][ #  # ]:          0 :                 if ( pHdl && pViewData->HasEditView( pViewData->GetActivePart() ) )
                 [ #  # ]
    1605                 :            :                 {
    1606                 :          0 :                     pHdl->CancelHandler();
    1607                 :          0 :                     pViewData->GetView()->ShowCursor();     // fehlt bei KillEditView, weil nicht aktiv
    1608                 :            :                 }
    1609                 :            :             }
    1610                 :            :         }
    1611         [ #  # ]:          0 :         else if ( nCommand == COMMAND_CURSORPOS )
    1612                 :            :         {
    1613                 :            :             //  don't call InputChanged for COMMAND_CURSORPOS
    1614                 :            :         }
    1615         [ #  # ]:          0 :         else if ( nCommand == COMMAND_INPUTLANGUAGECHANGE )
    1616                 :            :         {
    1617                 :            :             // #i55929# Font and font size state depends on input language if nothing is selected,
    1618                 :            :             // so the slots have to be invalidated when the input language is changed.
    1619                 :            : 
    1620                 :          0 :             SfxViewFrame* pViewFrm = SfxViewFrame::Current();
    1621         [ #  # ]:          0 :             if (pViewFrm)
    1622                 :            :             {
    1623                 :          0 :                 SfxBindings& rBindings = pViewFrm->GetBindings();
    1624                 :          0 :                 rBindings.Invalidate( SID_ATTR_CHAR_FONT );
    1625                 :          0 :                 rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
    1626                 :            :             }
    1627                 :            :         }
    1628         [ #  # ]:          0 :         else if ( nCommand == COMMAND_WHEEL )
    1629                 :            :         {
    1630                 :            :             //don't call InputChanged for COMMAND_WHEEL
    1631                 :            :         }
    1632                 :            :         else
    1633                 :          0 :             SC_MOD()->InputChanged( pEditView );
    1634                 :            :     }
    1635                 :            :     else
    1636                 :          0 :         Window::Command(rCEvt);     //  sonst soll sich die Basisklasse drum kuemmern...
    1637                 :            : 
    1638                 :          0 :     bInputMode = false;
    1639                 :          0 : }
    1640                 :            : 
    1641                 :          0 : void ScTextWnd::StartDrag( sal_Int8 /* nAction */, const Point& rPosPixel )
    1642                 :            : {
    1643         [ #  # ]:          0 :     if ( pEditView )
    1644                 :            :     {
    1645         [ #  # ]:          0 :         CommandEvent aDragEvent( rPosPixel, COMMAND_STARTDRAG, sal_True );
    1646         [ #  # ]:          0 :         pEditView->Command( aDragEvent );
    1647                 :            : 
    1648                 :            :         //  handling of d&d to different view (CancelHandler) can't be done here,
    1649                 :            :         //  because the call returns before d&d is complete.
    1650                 :            :     }
    1651                 :          0 : }
    1652                 :            : 
    1653                 :          0 : void ScTextWnd::KeyInput(const KeyEvent& rKEvt)
    1654                 :            : {
    1655                 :          0 :     bInputMode = sal_True;
    1656         [ #  # ]:          0 :     if (!SC_MOD()->InputKeyEvent( rKEvt ))
    1657                 :            :     {
    1658                 :          0 :         sal_Bool bUsed = false;
    1659                 :          0 :         ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
    1660         [ #  # ]:          0 :         if ( pViewSh )
    1661                 :          0 :             bUsed = pViewSh->SfxKeyInput(rKEvt);    // nur Acceleratoren, keine Eingabe
    1662         [ #  # ]:          0 :         if (!bUsed)
    1663                 :          0 :             Window::KeyInput( rKEvt );
    1664                 :            :     }
    1665                 :          0 :     bInputMode = false;
    1666                 :          0 : }
    1667                 :            : 
    1668                 :          0 : void ScTextWnd::GetFocus()
    1669                 :            : {
    1670                 :          0 :     ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
    1671         [ #  # ]:          0 :     if ( pViewSh )
    1672                 :          0 :         pViewSh->SetFormShellAtTop( false );     // focus in input line -> FormShell no longer on top
    1673                 :          0 : }
    1674                 :            : 
    1675                 :          0 : void ScTextWnd::LoseFocus()
    1676                 :            : {
    1677                 :          0 : }
    1678                 :            : 
    1679                 :          0 : String ScTextWnd::GetText() const
    1680                 :            : {
    1681                 :            :     //  ueberladen, um per Testtool an den Text heranzukommen
    1682                 :            : 
    1683         [ #  # ]:          0 :     if ( pEditEngine )
    1684                 :          0 :         return pEditEngine->GetText();
    1685                 :            :     else
    1686                 :          0 :         return GetTextString();
    1687                 :            : }
    1688                 :            : 
    1689                 :          0 : void ScTextWnd::SetFormulaMode( sal_Bool bSet )
    1690                 :            : {
    1691         [ #  # ]:          0 :     if ( bSet != bFormulaMode )
    1692                 :            :     {
    1693                 :          0 :         bFormulaMode = bSet;
    1694                 :          0 :         UpdateAutoCorrFlag();
    1695                 :            :     }
    1696                 :          0 : }
    1697                 :            : 
    1698                 :        205 : void ScTextWnd::UpdateAutoCorrFlag()
    1699                 :            : {
    1700         [ +  - ]:        205 :     if ( pEditEngine )
    1701                 :            :     {
    1702                 :        205 :         sal_uLong nControl = pEditEngine->GetControlWord();
    1703                 :        205 :         sal_uLong nOld = nControl;
    1704         [ -  + ]:        205 :         if ( bFormulaMode )
    1705                 :          0 :             nControl &= ~EE_CNTRL_AUTOCORRECT;      // keine Autokorrektur in Formeln
    1706                 :            :         else
    1707                 :        205 :             nControl |= EE_CNTRL_AUTOCORRECT;       // sonst schon
    1708         [ +  - ]:        205 :         if ( nControl != nOld )
    1709                 :        205 :             pEditEngine->SetControlWord( nControl );
    1710                 :            :     }
    1711                 :        205 : }
    1712                 :            : 
    1713                 :        205 : ScTabViewShell* ScTextWnd::GetViewShell()
    1714                 :            : {
    1715                 :        205 :     return mpViewShell;
    1716                 :            : }
    1717                 :            : 
    1718                 :          0 : void ScTextWnd::StartEditEngine()
    1719                 :            : {
    1720                 :            :     //  Bei "eigener Modalitaet" (Doc-modale Dialoge) nicht aktivieren
    1721                 :          0 :     SfxObjectShell* pObjSh = SfxObjectShell::Current();
    1722 [ #  # ][ #  # ]:          0 :     if ( pObjSh && pObjSh->IsInModalMode() )
                 [ #  # ]
    1723                 :          0 :         return;
    1724                 :            : 
    1725 [ #  # ][ #  # ]:          0 :     if ( !pEditView || !pEditEngine )
    1726                 :            :     {
    1727                 :            :         ScFieldEditEngine* pNew;
    1728                 :          0 :         ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
    1729         [ #  # ]:          0 :         if ( pViewSh )
    1730                 :            :         {
    1731                 :          0 :             ScDocument* pDoc = pViewSh->GetViewData()->GetDocument();
    1732         [ #  # ]:          0 :             pNew = new ScFieldEditEngine(pDoc, pDoc->GetEnginePool(), pDoc->GetEditPool());
    1733                 :            :         }
    1734                 :            :         else
    1735         [ #  # ]:          0 :             pNew = new ScFieldEditEngine(NULL, EditEngine::CreatePool(), NULL, true);
    1736                 :          0 :         pNew->SetExecuteURL( false );
    1737                 :          0 :         pEditEngine = pNew;
    1738                 :            : 
    1739                 :          0 :         pEditEngine->SetUpdateMode( false );
    1740 [ #  # ][ #  # ]:          0 :         pEditEngine->SetPaperSize( Size( bIsRTL ? USHRT_MAX : THESIZE, 300 ) );
    1741                 :            :         pEditEngine->SetWordDelimiters(
    1742 [ #  # ][ #  # ]:          0 :                         ScEditUtil::ModifyDelimiters( pEditEngine->GetWordDelimiters() ) );
                 [ #  # ]
    1743                 :            : 
    1744                 :          0 :         UpdateAutoCorrFlag();
    1745                 :            : 
    1746                 :            :         {
    1747         [ #  # ]:          0 :             SfxItemSet* pSet = new SfxItemSet( pEditEngine->GetEmptyItemSet() );
    1748                 :          0 :             pEditEngine->SetFontInfoInItemSet( *pSet, aTextFont );
    1749                 :          0 :             lcl_ExtendEditFontAttribs( *pSet );
    1750                 :            :             // turn off script spacing to match DrawText output
    1751         [ #  # ]:          0 :             pSet->Put( SvxScriptSpaceItem( false, EE_PARA_ASIANCJKSPACING ) );
    1752         [ #  # ]:          0 :             if ( bIsRTL )
    1753                 :          0 :                 lcl_ModifyRTLDefaults( *pSet );
    1754                 :          0 :             pEditEngine->SetDefaults( pSet );
    1755                 :            :         }
    1756                 :            : 
    1757                 :            :         //  Wenn in der Zelle URL-Felder enthalten sind, muessen die auch in
    1758                 :            :         //  die Eingabezeile uebernommen werden, weil sonst die Positionen nicht stimmen.
    1759                 :            : 
    1760                 :          0 :         sal_Bool bFilled = false;
    1761                 :          0 :         ScInputHandler* pHdl = SC_MOD()->GetInputHdl();
    1762         [ #  # ]:          0 :         if ( pHdl )         //! Testen, ob's der richtige InputHdl ist?
    1763                 :          0 :             bFilled = pHdl->GetTextAndFields( *pEditEngine );
    1764                 :            : 
    1765                 :          0 :         pEditEngine->SetUpdateMode( sal_True );
    1766                 :            : 
    1767                 :            :         //  aString ist die Wahrheit...
    1768 [ #  # ][ #  # ]:          0 :         if ( bFilled && pEditEngine->GetText() == aString )
         [ #  # ][ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
    1769                 :          0 :             Invalidate();                       // Repaint fuer (hinterlegte) Felder
    1770                 :            :         else
    1771                 :          0 :             pEditEngine->SetText(aString);      // dann wenigstens den richtigen Text
    1772                 :            : 
    1773 [ #  # ][ #  # ]:          0 :         pEditView = new EditView( pEditEngine, this );
    1774                 :          0 :         pEditView->SetInsertMode(bIsInsertMode);
    1775                 :            : 
    1776                 :            :         // Text aus Clipboard wird als ASCII einzeilig uebernommen
    1777                 :          0 :         sal_uLong n = pEditView->GetControlWord();
    1778                 :          0 :         pEditView->SetControlWord( n | EV_CNTRL_SINGLELINEPASTE );
    1779                 :            : 
    1780                 :          0 :         pEditEngine->InsertView( pEditView, EE_APPEND );
    1781                 :            : 
    1782                 :          0 :         Resize();
    1783                 :            : 
    1784         [ #  # ]:          0 :         if ( bIsRTL )
    1785                 :          0 :             lcl_ModifyRTLVisArea( pEditView );
    1786                 :            : 
    1787         [ #  # ]:          0 :         pEditEngine->SetModifyHdl(LINK(this, ScTextWnd, NotifyHdl));
    1788                 :            : 
    1789         [ #  # ]:          0 :         if (!maAccTextDatas.empty())
    1790                 :          0 :             maAccTextDatas.back()->StartEdit();
    1791                 :            : 
    1792                 :            :         //  as long as EditEngine and DrawText sometimes differ for CTL text,
    1793                 :            :         //  repaint now to have the EditEngine's version visible
    1794                 :            : //        SfxObjectShell* pObjSh = SfxObjectShell::Current();
    1795 [ #  # ][ #  # ]:          0 :         if ( pObjSh && pObjSh->ISA(ScDocShell) )
                 [ #  # ]
    1796                 :            :         {
    1797                 :          0 :             ScDocument* pDoc = ((ScDocShell*)pObjSh)->GetDocument();    // any document
    1798         [ #  # ]:          0 :             sal_uInt8 nScript = pDoc->GetStringScriptType( aString );
    1799         [ #  # ]:          0 :             if ( nScript & SCRIPTTYPE_COMPLEX )
    1800                 :          0 :                 Invalidate();
    1801                 :            :         }
    1802                 :            :     }
    1803                 :            : 
    1804                 :          0 :     SC_MOD()->SetInputMode( SC_INPUT_TOP );
    1805                 :            : 
    1806                 :          0 :     SfxViewFrame* pViewFrm = SfxViewFrame::Current();
    1807         [ #  # ]:          0 :     if (pViewFrm)
    1808                 :          0 :         pViewFrm->GetBindings().Invalidate( SID_ATTR_INSERT );
    1809                 :            : }
    1810                 :            : 
    1811                 :          0 : IMPL_LINK_NOARG(ScTextWnd, NotifyHdl)
    1812                 :            : {
    1813 [ +  - ][ -  + ]:        197 :     if (pEditView && !bInputMode)
    1814                 :            :     {
    1815                 :          0 :         ScInputHandler* pHdl = SC_MOD()->GetInputHdl();
    1816                 :            : 
    1817                 :            :         //  Use the InputHandler's InOwnChange flag to prevent calling InputChanged
    1818                 :            :         //  while an InputHandler method is modifying the EditEngine content
    1819                 :            : 
    1820 [ #  # ][ #  # ]:          0 :         if ( pHdl && !pHdl->IsInOwnChange() )
                 [ #  # ]
    1821                 :          0 :             pHdl->InputChanged( pEditView, sal_True );  // #i20282# InputChanged must know if called from modify handler
    1822                 :            :     }
    1823                 :            : 
    1824                 :        197 :     return 0;
    1825                 :            : }
    1826                 :            : 
    1827                 :         94 : void ScTextWnd::StopEditEngine( sal_Bool bAll )
    1828                 :            : {
    1829         [ +  + ]:         94 :     if (pEditView)
    1830                 :            :     {
    1831         [ -  + ]:         30 :         if (!maAccTextDatas.empty())
    1832                 :          0 :             maAccTextDatas.back()->EndEdit();
    1833                 :            : 
    1834                 :         30 :         ScModule* pScMod = SC_MOD();
    1835                 :            : 
    1836         [ -  + ]:         30 :         if (!bAll)
    1837                 :          0 :             pScMod->InputSelection( pEditView );
    1838         [ +  - ]:         30 :         aString = pEditEngine->GetText();
    1839                 :         30 :         bIsInsertMode = pEditView->IsInsertMode();
    1840                 :         30 :         sal_Bool bSelection = pEditView->HasSelection();
    1841         [ +  - ]:         30 :         pEditEngine->SetModifyHdl(Link());
    1842         [ +  - ]:         30 :         DELETEZ(pEditView);
    1843         [ +  - ]:         30 :         DELETEZ(pEditEngine);
    1844                 :            : 
    1845 [ -  + ][ #  # ]:         30 :         if ( pScMod->IsEditMode() && !bAll )
                 [ -  + ]
    1846                 :          0 :             pScMod->SetInputMode(SC_INPUT_TABLE);
    1847                 :            : 
    1848                 :         30 :         SfxViewFrame* pViewFrm = SfxViewFrame::Current();
    1849         [ +  - ]:         30 :         if (pViewFrm)
    1850                 :         30 :             pViewFrm->GetBindings().Invalidate( SID_ATTR_INSERT );
    1851                 :            : 
    1852         [ -  + ]:         30 :         if (bSelection)
    1853                 :          0 :             Invalidate();           // damit Selektion nicht stehenbleibt
    1854                 :            :     }
    1855                 :         94 : }
    1856                 :            : 
    1857                 :        586 : void ScTextWnd::SetTextString( const String& rNewString )
    1858                 :            : {
    1859         [ +  + ]:        586 :     if ( rNewString != aString )
    1860                 :            :     {
    1861                 :        118 :         bInputMode = sal_True;
    1862                 :            : 
    1863                 :            :         //  Position der Aenderung suchen, nur Rest painten
    1864                 :            : 
    1865         [ +  + ]:        118 :         if (!pEditEngine)
    1866                 :            :         {
    1867                 :            :             sal_Bool bPaintAll;
    1868         [ -  + ]:         47 :             if ( bIsRTL )
    1869                 :          0 :                 bPaintAll = sal_True;
    1870                 :            :             else
    1871                 :            :             {
    1872                 :            :                 //  test if CTL script type is involved
    1873                 :         47 :                 sal_uInt8 nOldScript = 0;
    1874                 :         47 :                 sal_uInt8 nNewScript = 0;
    1875                 :         47 :                 SfxObjectShell* pObjSh = SfxObjectShell::Current();
    1876 [ +  - ][ +  + ]:         47 :                 if ( pObjSh && pObjSh->ISA(ScDocShell) )
                 [ +  + ]
    1877                 :            :                 {
    1878                 :            :                     //  any document can be used (used only for its break iterator)
    1879                 :         37 :                     ScDocument* pDoc = ((ScDocShell*)pObjSh)->GetDocument();
    1880         [ +  - ]:         37 :                     nOldScript = pDoc->GetStringScriptType( aString );
    1881         [ +  - ]:         37 :                     nNewScript = pDoc->GetStringScriptType( rNewString );
    1882                 :            :                 }
    1883 [ +  - ][ -  + ]:         47 :                 bPaintAll = ( nOldScript & SCRIPTTYPE_COMPLEX ) || ( nNewScript & SCRIPTTYPE_COMPLEX );
    1884                 :            :             }
    1885                 :            : 
    1886         [ -  + ]:         47 :             if ( bPaintAll )
    1887                 :            :             {
    1888                 :            :                 // if CTL is involved, the whole text has to be redrawn
    1889                 :          0 :                 Invalidate();
    1890                 :            :             }
    1891                 :            :             else
    1892                 :            :             {
    1893                 :         47 :                 long nTextSize = 0;
    1894                 :            :                 xub_StrLen nDifPos;
    1895         [ +  + ]:         47 :                 if (rNewString.Len() > aString.Len())
    1896         [ +  - ]:         37 :                     nDifPos = rNewString.Match(aString);
    1897                 :            :                 else
    1898         [ +  - ]:         10 :                     nDifPos = aString.Match(rNewString);
    1899                 :            : 
    1900         [ +  - ]:         47 :                 long nSize1 = GetTextWidth(aString);
    1901         [ +  - ]:         47 :                 long nSize2 = GetTextWidth(rNewString);
    1902 [ +  + ][ +  + ]:         47 :                 if ( nSize1>0 && nSize2>0 )
    1903                 :          8 :                     nTextSize = Max( nSize1, nSize2 );
    1904                 :            :                 else
    1905         [ +  - ]:         39 :                     nTextSize = GetOutputSize().Width();        // Ueberlauf
    1906                 :            : 
    1907         [ -  + ]:         47 :                 if (nDifPos == STRING_MATCH)
    1908                 :          0 :                     nDifPos = 0;
    1909                 :            : 
    1910                 :            :                                                 // -1 wegen Rundung und "A"
    1911         [ +  - ]:         47 :                 Point aLogicStart = PixelToLogic(Point(0,0));
    1912                 :         47 :                 long nStartPos = aLogicStart.X();
    1913                 :         47 :                 long nInvPos = nStartPos;
    1914         [ +  + ]:         47 :                 if (nDifPos)
    1915         [ +  - ]:          8 :                     nInvPos += GetTextWidth(aString,0,nDifPos);
    1916                 :            : 
    1917                 :         47 :                 sal_uInt16 nFlags = 0;
    1918         [ +  + ]:         47 :                 if ( nDifPos == aString.Len() )         // only new characters appended
    1919                 :         37 :                     nFlags = INVALIDATE_NOERASE;        // then background is already clear
    1920                 :            :                 Invalidate( Rectangle( nInvPos, 0,
    1921         [ +  - ]:         94 :                                         nStartPos+nTextSize, GetOutputSize().Height()-1 ),
    1922 [ +  - ][ +  - ]:         47 :                             nFlags );
    1923                 :            :             }
    1924                 :            :         }
    1925                 :            :         else
    1926                 :            :         {
    1927                 :         71 :             pEditEngine->SetText(rNewString);
    1928                 :            :         }
    1929                 :            : 
    1930                 :        118 :         aString = rNewString;
    1931                 :            : 
    1932         [ -  + ]:        118 :         if (!maAccTextDatas.empty())
    1933                 :          0 :             maAccTextDatas.back()->TextChanged();
    1934                 :            : 
    1935                 :        118 :         bInputMode = false;
    1936                 :            :     }
    1937                 :        586 : }
    1938                 :            : 
    1939                 :          0 : const String& ScTextWnd::GetTextString() const
    1940                 :            : {
    1941                 :          0 :     return aString;
    1942                 :            : }
    1943                 :            : 
    1944                 :        844 : sal_Bool ScTextWnd::IsInputActive()
    1945                 :            : {
    1946                 :        844 :     return HasFocus();
    1947                 :            : }
    1948                 :            : 
    1949                 :          0 : EditView* ScTextWnd::GetEditView()
    1950                 :            : {
    1951                 :          0 :     return pEditView;
    1952                 :            : }
    1953                 :            : 
    1954                 :          0 : void ScTextWnd::MakeDialogEditView()
    1955                 :            : {
    1956         [ #  # ]:          0 :     if ( pEditView ) return;
    1957                 :            : 
    1958                 :            :     ScFieldEditEngine* pNew;
    1959                 :          0 :     ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
    1960         [ #  # ]:          0 :     if ( pViewSh )
    1961                 :            :     {
    1962                 :          0 :         ScDocument* pDoc = pViewSh->GetViewData()->GetDocument();
    1963         [ #  # ]:          0 :         pNew = new ScFieldEditEngine(pDoc, pDoc->GetEnginePool(), pDoc->GetEditPool());
    1964                 :            :     }
    1965                 :            :     else
    1966         [ #  # ]:          0 :         pNew = new ScFieldEditEngine(NULL, EditEngine::CreatePool(), NULL, true);
    1967                 :          0 :     pNew->SetExecuteURL( false );
    1968                 :          0 :     pEditEngine = pNew;
    1969                 :            : 
    1970                 :          0 :     pEditEngine->SetUpdateMode( false );
    1971 [ #  # ][ #  # ]:          0 :     pEditEngine->SetWordDelimiters( pEditEngine->GetWordDelimiters() += '=' );
    1972 [ #  # ][ #  # ]:          0 :     pEditEngine->SetPaperSize( Size( bIsRTL ? USHRT_MAX : THESIZE, 300 ) );
    1973                 :            : 
    1974         [ #  # ]:          0 :     SfxItemSet* pSet = new SfxItemSet( pEditEngine->GetEmptyItemSet() );
    1975                 :          0 :     pEditEngine->SetFontInfoInItemSet( *pSet, aTextFont );
    1976                 :          0 :     lcl_ExtendEditFontAttribs( *pSet );
    1977         [ #  # ]:          0 :     if ( bIsRTL )
    1978                 :          0 :         lcl_ModifyRTLDefaults( *pSet );
    1979                 :          0 :     pEditEngine->SetDefaults( pSet );
    1980                 :          0 :     pEditEngine->SetUpdateMode( sal_True );
    1981                 :            : 
    1982 [ #  # ][ #  # ]:          0 :     pEditView   = new EditView( pEditEngine, this );
    1983                 :          0 :     pEditEngine->InsertView( pEditView, EE_APPEND );
    1984                 :            : 
    1985                 :          0 :     Resize();
    1986                 :            : 
    1987         [ #  # ]:          0 :     if ( bIsRTL )
    1988                 :          0 :         lcl_ModifyRTLVisArea( pEditView );
    1989                 :            : 
    1990         [ #  # ]:          0 :     if (!maAccTextDatas.empty())
    1991                 :          0 :         maAccTextDatas.back()->StartEdit();
    1992                 :            : }
    1993                 :            : 
    1994                 :          0 : void ScTextWnd::ImplInitSettings()
    1995                 :            : {
    1996         [ #  # ]:          0 :     bIsRTL = GetSettings().GetLayoutRTL();
    1997                 :            : 
    1998         [ #  # ]:          0 :     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
    1999                 :            : 
    2000                 :          0 :     Color aBgColor= rStyleSettings.GetWindowColor();
    2001                 :          0 :     Color aTxtColor= rStyleSettings.GetWindowTextColor();
    2002                 :            : 
    2003         [ #  # ]:          0 :     aTextFont.SetFillColor   ( aBgColor );
    2004         [ #  # ]:          0 :     aTextFont.SetColor       (aTxtColor);
    2005 [ #  # ][ #  # ]:          0 :     SetBackground           ( aBgColor );
                 [ #  # ]
    2006         [ #  # ]:          0 :     Invalidate();
    2007                 :          0 : }
    2008                 :            : 
    2009                 :          0 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > ScTextWnd::CreateAccessible()
    2010                 :            : {
    2011                 :            :     return new ScAccessibleEditObject(GetAccessibleParentWindow()->GetAccessible(), NULL, this,
    2012                 :            :         rtl::OUString(String(ScResId(STR_ACC_EDITLINE_NAME))),
    2013 [ #  # ][ #  # ]:          0 :         rtl::OUString(String(ScResId(STR_ACC_EDITLINE_DESCR))), ScAccessibleEditObject::EditLine);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2014                 :            : }
    2015                 :            : 
    2016                 :          0 : void ScTextWnd::InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData )
    2017                 :            : {
    2018                 :            :     OSL_ENSURE( ::std::find( maAccTextDatas.begin(), maAccTextDatas.end(), &rTextData ) == maAccTextDatas.end(),
    2019                 :            :         "ScTextWnd::InsertAccessibleTextData - passed object already registered" );
    2020         [ #  # ]:          0 :     maAccTextDatas.push_back( &rTextData );
    2021                 :          0 : }
    2022                 :            : 
    2023                 :          0 : void ScTextWnd::RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData )
    2024                 :            : {
    2025                 :          0 :     AccTextDataVector::iterator aEnd = maAccTextDatas.end();
    2026         [ #  # ]:          0 :     AccTextDataVector::iterator aIt = ::std::find( maAccTextDatas.begin(), aEnd, &rTextData );
    2027                 :            :     OSL_ENSURE( aIt != aEnd, "ScTextWnd::RemoveAccessibleTextData - passed object not registered" );
    2028 [ #  # ][ #  # ]:          0 :     if( aIt != aEnd )
    2029         [ #  # ]:          0 :         maAccTextDatas.erase( aIt );
    2030                 :          0 : }
    2031                 :            : 
    2032                 :            : // -----------------------------------------------------------------------
    2033                 :            : 
    2034                 :          0 : void ScTextWnd::DataChanged( const DataChangedEvent& rDCEvt )
    2035                 :            : {
    2036   [ #  #  #  # ]:          0 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
                 [ #  # ]
    2037                 :          0 :          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
    2038                 :            :     {
    2039                 :          0 :         ImplInitSettings();
    2040                 :          0 :         Invalidate();
    2041                 :            :     }
    2042                 :            :     else
    2043                 :          0 :         Window::DataChanged( rDCEvt );
    2044                 :          0 : }
    2045                 :            : 
    2046                 :          0 : void ScTextWnd::TextGrabFocus()
    2047                 :            : {
    2048                 :          0 :     GrabFocus();
    2049                 :          0 : }
    2050                 :            : 
    2051                 :            : //========================================================================
    2052                 :            : //                          Positionsfenster
    2053                 :            : //========================================================================
    2054                 :            : 
    2055                 :        229 : ScPosWnd::ScPosWnd( Window* pParent ) :
    2056                 :            :     ComboBox    ( pParent, WinBits(WB_HIDE | WB_DROPDOWN) ),
    2057                 :            :     pAccel      ( NULL ),
    2058                 :            :     nTipVisible ( 0 ),
    2059 [ +  - ][ +  - ]:        229 :     bFormulaMode( false )
    2060                 :            : {
    2061                 :            :     Size aSize( GetTextWidth( rtl::OUString("GW99999:GW99999") ),
    2062 [ +  - ][ +  - ]:        229 :                 GetTextHeight() );
         [ +  - ][ +  - ]
    2063                 :        229 :     aSize.Width() += 25;    // ??
    2064         [ +  - ]:        229 :     aSize.Height() = CalcWindowSizePixel(11);       // Funktionen: 10 MRU + "andere..."
    2065         [ +  - ]:        229 :     SetSizePixel( aSize );
    2066                 :            : 
    2067         [ +  - ]:        229 :     FillRangeNames();
    2068                 :            : 
    2069 [ +  - ][ +  - ]:        229 :     StartListening( *SFX_APP() );       // fuer Navigator-Bereichsnamen-Updates
    2070                 :        229 : }
    2071                 :            : 
    2072 [ +  - ][ +  - ]:        225 : ScPosWnd::~ScPosWnd()
    2073                 :            : {
    2074 [ +  - ][ +  - ]:        225 :     EndListening( *SFX_APP() );
    2075                 :            : 
    2076         [ +  - ]:        225 :     HideTip();
    2077                 :            : 
    2078 [ -  + ][ #  # ]:        225 :     delete pAccel;
    2079         [ -  + ]:        225 : }
    2080                 :            : 
    2081                 :          0 : void ScPosWnd::SetFormulaMode( sal_Bool bSet )
    2082                 :            : {
    2083         [ #  # ]:          0 :     if ( bSet != bFormulaMode )
    2084                 :            :     {
    2085                 :          0 :         bFormulaMode = bSet;
    2086                 :            : 
    2087         [ #  # ]:          0 :         if ( bSet )
    2088                 :          0 :             FillFunctions();
    2089                 :            :         else
    2090                 :          0 :             FillRangeNames();
    2091                 :            : 
    2092                 :          0 :         HideTip();
    2093                 :            :     }
    2094                 :          0 : }
    2095                 :            : 
    2096                 :        645 : void ScPosWnd::SetPos( const String& rPosStr )
    2097                 :            : {
    2098         [ +  + ]:        645 :     if ( aPosStr != rPosStr )
    2099                 :            :     {
    2100                 :        291 :         aPosStr = rPosStr;
    2101                 :        291 :         SetText(aPosStr);
    2102                 :            :     }
    2103                 :        645 : }
    2104                 :            : 
    2105                 :            : namespace {
    2106                 :            : 
    2107                 :          0 : rtl::OUString createLocalRangeName(const rtl::OUString& rName, const rtl::OUString& rTableName)
    2108                 :            : {
    2109         [ #  # ]:          0 :     rtl::OUStringBuffer aString (rName);
    2110 [ #  # ][ #  # ]:          0 :     aString.append(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" (")));
    2111         [ #  # ]:          0 :     aString.append(rTableName);
    2112 [ #  # ][ #  # ]:          0 :     aString.append(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")")));
    2113         [ #  # ]:          0 :     return aString.makeStringAndClear();
    2114                 :            : }
    2115                 :            : 
    2116                 :            : }
    2117                 :            : 
    2118                 :        748 : void ScPosWnd::FillRangeNames()
    2119                 :            : {
    2120                 :        748 :     Clear();
    2121                 :            : 
    2122                 :        748 :     SfxObjectShell* pObjSh = SfxObjectShell::Current();
    2123 [ +  - ][ +  + ]:        748 :     if ( pObjSh && pObjSh->ISA(ScDocShell) )
                 [ +  + ]
    2124                 :            :     {
    2125                 :        528 :         ScDocument* pDoc = ((ScDocShell*)pObjSh)->GetDocument();
    2126                 :            : 
    2127 [ +  - ][ +  - ]:        528 :         InsertEntry(ScGlobal::GetRscString( STR_MANAGE_NAMES ));
    2128         [ +  - ]:        528 :         SetSeparatorPos(0);
    2129                 :            : 
    2130                 :        528 :         ScRange aDummy;
    2131         [ +  - ]:        528 :         std::set<rtl::OUString> aSet;
    2132         [ +  - ]:        528 :         ScRangeName* pRangeNames = pDoc->GetRangeName();
    2133 [ +  - ][ +  + ]:        528 :         if (!pRangeNames->empty())
    2134                 :            :         {
    2135 [ +  - ][ +  - ]:         65 :             ScRangeName::const_iterator itrBeg = pRangeNames->begin(), itrEnd = pRangeNames->end();
         [ +  - ][ +  - ]
    2136 [ +  - ][ +  - ]:        422 :             for (ScRangeName::const_iterator itr = itrBeg; itr != itrEnd; ++itr)
                 [ +  + ]
    2137                 :            :             {
    2138 [ +  - ][ +  - ]:        357 :                 if (itr->second->IsValidReference(aDummy))
                 [ +  - ]
    2139 [ +  - ][ +  - ]:        357 :                     aSet.insert(itr->second->GetName());
    2140                 :            :             }
    2141                 :            :         }
    2142 [ +  - ][ +  + ]:       1212 :         for (SCTAB i = 0; i < pDoc->GetTableCount(); ++i)
    2143                 :            :         {
    2144         [ +  - ]:        684 :             ScRangeName* pLocalRangeName = pDoc->GetRangeName(i);
    2145 [ +  - ][ +  - ]:        684 :             if (pLocalRangeName && !pLocalRangeName->empty())
         [ -  + ][ -  + ]
    2146                 :            :             {
    2147                 :          0 :                 rtl::OUString aTableName;
    2148         [ #  # ]:          0 :                 pDoc->GetName(i, aTableName);
    2149 [ #  # ][ #  # ]:          0 :                 for (ScRangeName::const_iterator itr = pLocalRangeName->begin(); itr != pLocalRangeName->end(); ++itr)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2150                 :            :                 {
    2151 [ #  # ][ #  # ]:          0 :                     if (itr->second->IsValidReference(aDummy))
                 [ #  # ]
    2152 [ #  # ][ #  # ]:          0 :                         aSet.insert(createLocalRangeName(itr->second->GetName(), aTableName));
                 [ #  # ]
    2153                 :          0 :                 }
    2154                 :            :             }
    2155                 :            :         }
    2156                 :            : 
    2157         [ +  + ]:        528 :         if (!aSet.empty())
    2158                 :            :         {
    2159         [ +  + ]:        844 :             for (std::set<rtl::OUString>::iterator itr = aSet.begin();
    2160                 :        422 :                     itr != aSet.end(); ++itr)
    2161                 :            :             {
    2162 [ +  - ][ +  - ]:        357 :                 InsertEntry(*itr);
                 [ +  - ]
    2163                 :            :             }
    2164                 :        528 :         }
    2165                 :            :     }
    2166                 :        748 :     SetText(aPosStr);
    2167                 :        748 : }
    2168                 :            : 
    2169                 :          0 : void ScPosWnd::FillFunctions()
    2170                 :            : {
    2171         [ #  # ]:          0 :     Clear();
    2172                 :            : 
    2173         [ #  # ]:          0 :     String aFirstName;
    2174 [ #  # ][ #  # ]:          0 :     const ScAppOptions& rOpt = SC_MOD()->GetAppOptions();
    2175                 :          0 :     sal_uInt16 nMRUCount = rOpt.GetLRUFuncListCount();
    2176                 :          0 :     const sal_uInt16* pMRUList = rOpt.GetLRUFuncList();
    2177         [ #  # ]:          0 :     if (pMRUList)
    2178                 :            :     {
    2179         [ #  # ]:          0 :         const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
    2180                 :          0 :         sal_uLong nListCount = pFuncList->GetCount();
    2181         [ #  # ]:          0 :         for (sal_uInt16 i=0; i<nMRUCount; i++)
    2182                 :            :         {
    2183                 :          0 :             sal_uInt16 nId = pMRUList[i];
    2184         [ #  # ]:          0 :             for (sal_uLong j=0; j<nListCount; j++)
    2185                 :            :             {
    2186         [ #  # ]:          0 :                 const ScFuncDesc* pDesc = pFuncList->GetFunction( j );
    2187 [ #  # ][ #  # ]:          0 :                 if ( pDesc->nFIndex == nId && pDesc->pFuncName )
    2188                 :            :                 {
    2189 [ #  # ][ #  # ]:          0 :                     InsertEntry( *pDesc->pFuncName );
                 [ #  # ]
    2190         [ #  # ]:          0 :                     if (!aFirstName.Len())
    2191         [ #  # ]:          0 :                         aFirstName = *pDesc->pFuncName;
    2192                 :          0 :                     break;  // nicht weitersuchen
    2193                 :            :                 }
    2194                 :            :             }
    2195                 :            :         }
    2196                 :            :     }
    2197                 :            : 
    2198                 :            :     //! Eintrag "Andere..." fuer Funktions-Autopilot wieder aufnehmen,
    2199                 :            :     //! wenn der Funktions-Autopilot mit dem bisher eingegebenen Text arbeiten kann!
    2200                 :            : 
    2201                 :            : //  InsertEntry( ScGlobal::GetRscString(STR_FUNCTIONLIST_MORE) );
    2202                 :            : 
    2203 [ #  # ][ #  # ]:          0 :     SetText(aFirstName);
    2204                 :          0 : }
    2205                 :            : 
    2206                 :       7805 : void ScPosWnd::Notify( SfxBroadcaster&, const SfxHint& rHint )
    2207                 :            : {
    2208         [ +  - ]:       7805 :     if ( !bFormulaMode )
    2209                 :            :     {
    2210                 :            :         //  muss die Liste der Bereichsnamen updgedated werden?
    2211                 :            : 
    2212         [ +  + ]:       7805 :         if ( rHint.ISA(SfxSimpleHint) )
    2213                 :            :         {
    2214                 :       6305 :             sal_uLong nHintId = ((SfxSimpleHint&)rHint).GetId();
    2215 [ +  + ][ +  + ]:       6305 :             if ( nHintId == SC_HINT_AREAS_CHANGED || nHintId == SC_HINT_NAVIGATOR_UPDATEALL)
    2216                 :        281 :                 FillRangeNames();
    2217                 :            :         }
    2218         [ +  - ]:       1500 :         else if ( rHint.ISA(SfxEventHint) )
    2219                 :            :         {
    2220                 :       1500 :             sal_uLong nEventId = ((SfxEventHint&)rHint).GetEventId();
    2221         [ +  + ]:       1500 :             if ( nEventId == SFX_EVENT_ACTIVATEDOC )
    2222                 :        238 :                 FillRangeNames();
    2223                 :            :         }
    2224                 :            :     }
    2225                 :       7805 : }
    2226                 :            : 
    2227                 :        225 : void ScPosWnd::HideTip()
    2228                 :            : {
    2229         [ -  + ]:        225 :     if ( nTipVisible )
    2230                 :            :     {
    2231                 :          0 :         Help::HideTip( nTipVisible );
    2232                 :          0 :         nTipVisible = 0;
    2233                 :            :     }
    2234                 :        225 : }
    2235                 :            : 
    2236                 :          0 : ScNameInputType lcl_GetInputType( const String& rText )
    2237                 :            : {
    2238                 :          0 :     ScNameInputType eRet = SC_NAME_INPUT_BAD_NAME;      // the more general error
    2239                 :            : 
    2240                 :          0 :     ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
    2241         [ #  # ]:          0 :     if ( pViewSh )
    2242                 :            :     {
    2243                 :          0 :         ScViewData* pViewData = pViewSh->GetViewData();
    2244         [ #  # ]:          0 :         ScDocument* pDoc = pViewData->GetDocument();
    2245                 :          0 :         SCTAB nTab = pViewData->GetTabNo();
    2246         [ #  # ]:          0 :         formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
    2247                 :            : 
    2248                 :            :         // test in same order as in SID_CURRENTCELL execute
    2249                 :            : 
    2250                 :          0 :         ScRange aRange;
    2251                 :          0 :         ScAddress aAddress;
    2252                 :          0 :         ScRangeUtil aRangeUtil;
    2253                 :            :         SCTAB nNameTab;
    2254                 :            :         sal_Int32 nNumeric;
    2255                 :            : 
    2256 [ #  # ][ #  # ]:          0 :         if (rText == ScGlobal::GetRscString(STR_MANAGE_NAMES))
                 [ #  # ]
    2257                 :          0 :             eRet = SC_MANAGE_NAMES;
    2258 [ #  # ][ #  # ]:          0 :         else if ( aRange.Parse( rText, pDoc, eConv ) & SCA_VALID )
    2259                 :          0 :             eRet = SC_NAME_INPUT_RANGE;
    2260 [ #  # ][ #  # ]:          0 :         else if ( aAddress.Parse( rText, pDoc, eConv ) & SCA_VALID )
    2261                 :          0 :             eRet = SC_NAME_INPUT_CELL;
    2262 [ #  # ][ #  # ]:          0 :         else if ( aRangeUtil.MakeRangeFromName( rText, pDoc, nTab, aRange, RUTL_NAMES, eConv ) )
    2263                 :          0 :             eRet = SC_NAME_INPUT_NAMEDRANGE;
    2264 [ #  # ][ #  # ]:          0 :         else if ( aRangeUtil.MakeRangeFromName( rText, pDoc, nTab, aRange, RUTL_DBASE, eConv ) )
    2265                 :          0 :             eRet = SC_NAME_INPUT_DATABASE;
    2266 [ #  # ][ #  # ]:          0 :         else if ( comphelper::string::isdigitAsciiString( rText ) &&
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
    2267                 :            :                   ( nNumeric = rText.ToInt32() ) > 0 && nNumeric <= MAXROW+1 )
    2268                 :          0 :             eRet = SC_NAME_INPUT_ROW;
    2269 [ #  # ][ #  # ]:          0 :         else if ( pDoc->GetTable( rText, nNameTab ) )
                 [ #  # ]
    2270                 :          0 :             eRet = SC_NAME_INPUT_SHEET;
    2271 [ #  # ][ #  # ]:          0 :         else if ( ScRangeData::IsNameValid( rText, pDoc ) )     // nothing found, create new range?
    2272                 :            :         {
    2273 [ #  # ][ #  # ]:          0 :             if ( pViewData->GetSimpleArea( aRange ) == SC_MARK_SIMPLE )
    2274                 :          0 :                 eRet = SC_NAME_INPUT_DEFINE;
    2275                 :            :             else
    2276                 :          0 :                 eRet = SC_NAME_INPUT_BAD_SELECTION;
    2277                 :            :         }
    2278                 :            :         else
    2279                 :          0 :             eRet = SC_NAME_INPUT_BAD_NAME;
    2280                 :            :     }
    2281                 :            : 
    2282                 :          0 :     return eRet;
    2283                 :            : }
    2284                 :            : 
    2285                 :          0 : void ScPosWnd::Modify()
    2286                 :            : {
    2287                 :          0 :     ComboBox::Modify();
    2288                 :            : 
    2289                 :          0 :     HideTip();
    2290                 :            : 
    2291 [ #  # ][ #  # ]:          0 :     if ( !IsTravelSelect() && !bFormulaMode )
                 [ #  # ]
    2292                 :            :     {
    2293                 :            :         // determine the action that would be taken for the current input
    2294                 :            : 
    2295         [ #  # ]:          0 :         ScNameInputType eType = lcl_GetInputType( GetText() );      // uses current view
    2296                 :          0 :         sal_uInt16 nStrId = 0;
    2297   [ #  #  #  #  :          0 :         switch ( eType )
                #  #  # ]
    2298                 :            :         {
    2299                 :            :             case SC_NAME_INPUT_CELL:
    2300                 :          0 :                 nStrId = STR_NAME_INPUT_CELL;
    2301                 :          0 :                 break;
    2302                 :            :             case SC_NAME_INPUT_RANGE:
    2303                 :            :             case SC_NAME_INPUT_NAMEDRANGE:
    2304                 :          0 :                 nStrId = STR_NAME_INPUT_RANGE;      // named range or range reference
    2305                 :          0 :                 break;
    2306                 :            :             case SC_NAME_INPUT_DATABASE:
    2307                 :          0 :                 nStrId = STR_NAME_INPUT_DBRANGE;
    2308                 :          0 :                 break;
    2309                 :            :             case SC_NAME_INPUT_ROW:
    2310                 :          0 :                 nStrId = STR_NAME_INPUT_ROW;
    2311                 :          0 :                 break;
    2312                 :            :             case SC_NAME_INPUT_SHEET:
    2313                 :          0 :                 nStrId = STR_NAME_INPUT_SHEET;
    2314                 :          0 :                 break;
    2315                 :            :             case SC_NAME_INPUT_DEFINE:
    2316                 :          0 :                 nStrId = STR_NAME_INPUT_DEFINE;
    2317                 :          0 :                 break;
    2318                 :            :             default:
    2319                 :            :                 // other cases (error): no tip help
    2320                 :          0 :                 break;
    2321                 :            :         }
    2322                 :            : 
    2323         [ #  # ]:          0 :         if ( nStrId )
    2324                 :            :         {
    2325                 :            :             // show the help tip at the text cursor position
    2326                 :            : 
    2327                 :          0 :             Window* pWin = GetSubEdit();
    2328         [ #  # ]:          0 :             if (!pWin)
    2329                 :          0 :                 pWin = this;
    2330                 :          0 :             Point aPos;
    2331         [ #  # ]:          0 :             Cursor* pCur = pWin->GetCursor();
    2332         [ #  # ]:          0 :             if (pCur)
    2333         [ #  # ]:          0 :                 aPos = pWin->LogicToPixel( pCur->GetPos() );
    2334         [ #  # ]:          0 :             aPos = pWin->OutputToScreenPixel( aPos );
    2335         [ #  # ]:          0 :             Rectangle aRect( aPos, aPos );
    2336                 :            : 
    2337 [ #  # ][ #  # ]:          0 :             String aText = ScGlobal::GetRscString( nStrId );
    2338                 :          0 :             sal_uInt16 nAlign = QUICKHELP_LEFT|QUICKHELP_BOTTOM;
    2339 [ #  # ][ #  # ]:          0 :             nTipVisible = Help::ShowTip(pWin, aRect, aText, nAlign);
    2340                 :            :         }
    2341                 :            :     }
    2342                 :          0 : }
    2343                 :            : 
    2344                 :          0 : void ScPosWnd::Select()
    2345                 :            : {
    2346                 :          0 :     ComboBox::Select();     //  in VCL gibt GetText() erst danach den ausgewaehlten Eintrag
    2347                 :            : 
    2348                 :          0 :     HideTip();
    2349                 :            : 
    2350         [ #  # ]:          0 :     if (!IsTravelSelect())
    2351                 :          0 :         DoEnter();
    2352                 :          0 : }
    2353                 :            : 
    2354                 :          0 : void ScPosWnd::DoEnter()
    2355                 :            : {
    2356         [ #  # ]:          0 :     String aText = GetText();
    2357         [ #  # ]:          0 :     if ( aText.Len() )
    2358                 :            :     {
    2359         [ #  # ]:          0 :         if ( bFormulaMode )
    2360                 :            :         {
    2361         [ #  # ]:          0 :             ScModule* pScMod = SC_MOD();
    2362 [ #  # ][ #  # ]:          0 :             if ( aText == ScGlobal::GetRscString(STR_FUNCTIONLIST_MORE) )
                 [ #  # ]
    2363                 :            :             {
    2364                 :            :                 //  Funktions-Autopilot
    2365                 :            :                 //! mit dem bisher eingegebenen Text weiterarbeiten !!!
    2366                 :            : 
    2367                 :            :                 //! new method at ScModule to query if function autopilot is open
    2368         [ #  # ]:          0 :                 SfxViewFrame* pViewFrm = SfxViewFrame::Current();
    2369 [ #  # ][ #  # ]:          0 :                 if ( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) )
         [ #  # ][ #  # ]
    2370                 :            :                     pViewFrm->GetDispatcher()->Execute( SID_OPENDLG_FUNCTION,
    2371         [ #  # ]:          0 :                                               SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD );
    2372                 :            :             }
    2373                 :            :             else
    2374                 :            :             {
    2375 [ #  # ][ #  # ]:          0 :                 ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2376         [ #  # ]:          0 :                 ScInputHandler* pHdl = pScMod->GetInputHdl( pViewSh );
    2377         [ #  # ]:          0 :                 if (pHdl)
    2378         [ #  # ]:          0 :                     pHdl->InsertFunction( aText );
    2379                 :            :             }
    2380                 :            :         }
    2381                 :            :         else
    2382                 :            :         {
    2383                 :            :             // depending on the input, select something or create a new named range
    2384                 :            : 
    2385         [ #  # ]:          0 :             ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
    2386         [ #  # ]:          0 :             if ( pViewSh )
    2387                 :            :             {
    2388                 :          0 :                 ScViewData* pViewData = pViewSh->GetViewData();
    2389                 :          0 :                 ScDocShell* pDocShell = pViewData->GetDocShell();
    2390                 :          0 :                 ScDocument* pDoc = pDocShell->GetDocument();
    2391                 :            : 
    2392         [ #  # ]:          0 :                 ScNameInputType eType = lcl_GetInputType( aText );
    2393 [ #  # ][ #  # ]:          0 :                 if ( eType == SC_NAME_INPUT_BAD_NAME || eType == SC_NAME_INPUT_BAD_SELECTION )
    2394                 :            :                 {
    2395         [ #  # ]:          0 :                     sal_uInt16 nId = ( eType == SC_NAME_INPUT_BAD_NAME ) ? STR_NAME_ERROR_NAME : STR_NAME_ERROR_SELECTION;
    2396         [ #  # ]:          0 :                     pViewSh->ErrorMessage( nId );
    2397                 :            :                 }
    2398         [ #  # ]:          0 :                 else if ( eType == SC_NAME_INPUT_DEFINE )
    2399                 :            :                 {
    2400         [ #  # ]:          0 :                     ScRangeName* pNames = pDoc->GetRangeName();
    2401                 :          0 :                     ScRange aSelection;
    2402 [ #  # ][ #  # ]:          0 :                     if ( pNames && !pNames->findByUpperName(ScGlobal::pCharClass->uppercase(aText)) &&
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
             #  #  #  # ]
                 [ #  # ]
    2403         [ #  # ]:          0 :                             (pViewData->GetSimpleArea( aSelection ) == SC_MARK_SIMPLE) )
    2404                 :            :                     {
    2405         [ #  # ]:          0 :                         ScRangeName aNewRanges( *pNames );
    2406                 :          0 :                         ScAddress aCursor( pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo() );
    2407         [ #  # ]:          0 :                         String aContent;
    2408 [ #  # ][ #  # ]:          0 :                         aSelection.Format( aContent, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
    2409 [ #  # ][ #  # ]:          0 :                         ScRangeData* pNew = new ScRangeData( pDoc, aText, aContent, aCursor );
                 [ #  # ]
    2410 [ #  # ][ #  # ]:          0 :                         if ( aNewRanges.insert(pNew) )
    2411                 :            :                         {
    2412         [ #  # ]:          0 :                             pDocShell->GetDocFunc().ModifyRangeNames( aNewRanges );
    2413         [ #  # ]:          0 :                             pViewSh->UpdateInputHandler(true);
    2414 [ #  # ][ #  # ]:          0 :                         }
    2415                 :            :                     }
    2416                 :            :                 }
    2417         [ #  # ]:          0 :                 else if (eType == SC_MANAGE_NAMES)
    2418                 :            :                 {
    2419         [ #  # ]:          0 :                     sal_uInt16          nId  = ScNameDlgWrapper::GetChildWindowId();
    2420                 :          0 :                     SfxViewFrame* pViewFrm = pViewSh->GetViewFrame();
    2421         [ #  # ]:          0 :                     SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
    2422                 :            : 
    2423 [ #  # ][ #  # ]:          0 :                     SC_MOD()->SetRefDialog( nId, pWnd ? false : sal_True );
    2424                 :            :                 }
    2425                 :            :                 else
    2426                 :            :                 {
    2427                 :            :                     // for all selection types, excecute the SID_CURRENTCELL slot.
    2428 [ #  # ][ #  # ]:          0 :                     if (eType == SC_NAME_INPUT_CELL || eType == SC_NAME_INPUT_RANGE)
    2429                 :            :                     {
    2430                 :            :                         // Note that SID_CURRENTCELL always expects address to
    2431                 :            :                         // be in Calc A1 format.  Convert the text.
    2432                 :          0 :                         ScRange aRange(0,0,pViewData->GetTabNo());
    2433 [ #  # ][ #  # ]:          0 :                         aRange.ParseAny(aText, pDoc, pDoc->GetAddressConvention());
    2434         [ #  # ]:          0 :                         aRange.Format(aText, SCR_ABS_3D, pDoc, ::formula::FormulaGrammar::CONV_OOO);
    2435                 :            :                     }
    2436                 :            : 
    2437         [ #  # ]:          0 :                     SfxStringItem aPosItem( SID_CURRENTCELL, aText );
    2438         [ #  # ]:          0 :                     SfxBoolItem aUnmarkItem( FN_PARAM_1, sal_True );        // remove existing selection
    2439                 :            : 
    2440         [ #  # ]:          0 :                     pViewSh->GetViewData()->GetDispatcher().Execute( SID_CURRENTCELL,
    2441                 :            :                                         SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD,
    2442 [ #  # ][ #  # ]:          0 :                                         &aPosItem, &aUnmarkItem, 0L );
                 [ #  # ]
    2443                 :            :                 }
    2444                 :            :             }
    2445                 :            :         }
    2446                 :            :     }
    2447                 :            :     else
    2448         [ #  # ]:          0 :         SetText( aPosStr );
    2449                 :            : 
    2450 [ #  # ][ #  # ]:          0 :     ReleaseFocus_Impl();
    2451                 :          0 : }
    2452                 :            : 
    2453                 :         12 : long ScPosWnd::Notify( NotifyEvent& rNEvt )
    2454                 :            : {
    2455                 :         12 :     long nHandled = 0;
    2456                 :            : 
    2457         [ -  + ]:         12 :     if ( rNEvt.GetType() == EVENT_KEYINPUT )
    2458                 :            :     {
    2459                 :          0 :         const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
    2460                 :            : 
    2461      [ #  #  # ]:          0 :         switch ( pKEvt->GetKeyCode().GetCode() )
    2462                 :            :         {
    2463                 :            :             case KEY_RETURN:
    2464                 :          0 :                 DoEnter();
    2465                 :          0 :                 nHandled = 1;
    2466                 :          0 :                 break;
    2467                 :            : 
    2468                 :            :             case KEY_ESCAPE:
    2469         [ #  # ]:          0 :                 if (nTipVisible)
    2470                 :            :                 {
    2471                 :            :                     // escape when the tip help is shown: only hide the tip
    2472                 :          0 :                     HideTip();
    2473                 :            :                 }
    2474                 :            :                 else
    2475                 :            :                 {
    2476         [ #  # ]:          0 :                     if (!bFormulaMode)
    2477                 :          0 :                         SetText( aPosStr );
    2478                 :          0 :                     ReleaseFocus_Impl();
    2479                 :            :                 }
    2480                 :          0 :                 nHandled = 1;
    2481                 :          0 :                 break;
    2482                 :            :         }
    2483                 :            :     }
    2484                 :            : 
    2485         [ +  - ]:         12 :     if ( !nHandled )
    2486                 :         12 :         nHandled = ComboBox::Notify( rNEvt );
    2487                 :            : 
    2488         [ -  + ]:         12 :     if ( rNEvt.GetType() == EVENT_LOSEFOCUS )
    2489                 :          0 :         HideTip();
    2490                 :            : 
    2491                 :         12 :     return nHandled;
    2492                 :            : }
    2493                 :            : 
    2494                 :          0 : void ScPosWnd::ReleaseFocus_Impl()
    2495                 :            : {
    2496                 :          0 :     HideTip();
    2497                 :            : 
    2498                 :          0 :     SfxViewShell* pCurSh = SfxViewShell::Current();
    2499 [ #  # ][ #  # ]:          0 :     ScInputHandler* pHdl = SC_MOD()->GetInputHdl( PTR_CAST( ScTabViewShell, pCurSh ) );
    2500 [ #  # ][ #  # ]:          0 :     if ( pHdl && pHdl->IsTopMode() )
                 [ #  # ]
    2501                 :            :     {
    2502                 :            :         //  Focus wieder in die Eingabezeile?
    2503                 :            : 
    2504                 :          0 :         ScInputWindow* pInputWin = pHdl->GetInputWindow();
    2505         [ #  # ]:          0 :         if (pInputWin)
    2506                 :            :         {
    2507                 :          0 :             pInputWin->TextGrabFocus();
    2508                 :          0 :             return;
    2509                 :            :         }
    2510                 :            :     }
    2511                 :            : 
    2512                 :            :     //  Focus auf die aktive View
    2513                 :            : 
    2514         [ #  # ]:          0 :     if ( pCurSh )
    2515                 :            :     {
    2516                 :          0 :         Window* pShellWnd = pCurSh->GetWindow();
    2517                 :            : 
    2518         [ #  # ]:          0 :         if ( pShellWnd )
    2519                 :          0 :             pShellWnd->GrabFocus();
    2520                 :            :     }
    2521                 :            : }
    2522                 :            : 
    2523                 :            : 
    2524                 :            : 
    2525                 :            : 
    2526                 :            : 
    2527                 :            : 
    2528                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10