LCOV - code coverage report
Current view: top level - sc/source/ui/inc - inputhdl.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 14 25 56.0 %
Date: 2012-08-25 Functions: 13 24 54.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1 4 25.0 %

           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                 :            : #ifndef SC_INPUTHDL_HXX
      30                 :            : #define SC_INPUTHDL_HXX
      31                 :            : 
      32                 :            : #include "global.hxx"
      33                 :            : #include "address.hxx"
      34                 :            : #include "typedstrdata.hxx"
      35                 :            : 
      36                 :            : #include <tools/fract.hxx>
      37                 :            : #include <tools/gen.hxx>
      38                 :            : #include <editeng/svxenum.hxx>
      39                 :            : 
      40                 :            : #include <set>
      41                 :            : 
      42                 :            : #include <boost/noncopyable.hpp>
      43                 :            : 
      44                 :            : class ScDocument;
      45                 :            : class ScTabViewShell;
      46                 :            : class ScInputWindow;
      47                 :            : class ScPatternAttr;
      48                 :            : class ScEditEngineDefaulter;
      49                 :            : class EditView;
      50                 :            : class EditTextObject;
      51                 :            : class ScInputHdlState;
      52                 :            : class ScRangeFindList;
      53                 :            : class Timer;
      54                 :            : class KeyEvent;
      55                 :            : class CommandEvent;
      56                 :            : 
      57                 :            : struct ESelection;
      58                 :            : 
      59                 :            : //========================================================================
      60                 :            : //  ScInputHandler
      61                 :            : //========================================================================
      62                 :            : 
      63                 :            : class ScInputHandler : boost::noncopyable
      64                 :            : {
      65                 :            : private:
      66                 :            :     ScInputWindow*          pInputWin;
      67                 :            : 
      68                 :            :     ScEditEngineDefaulter*  pEngine;                // edited data in the sheet
      69                 :            :     EditView*               pTableView;                 // associated active EditView
      70                 :            :     EditView*               pTopView;                   // EditView in dthe input row
      71                 :            : 
      72                 :            :     ScTypedCaseStrSet* pColumnData;
      73                 :            :     ScTypedCaseStrSet* pFormulaData;
      74                 :            :     ScTypedCaseStrSet* pFormulaDataPara;
      75                 :            :     ScTypedCaseStrSet::const_iterator miAutoPosColumn;
      76                 :            :     ScTypedCaseStrSet::const_iterator miAutoPosFormula;
      77                 :            : 
      78                 :            :     Window*                 pTipVisibleParent;
      79                 :            :     sal_uLong                   nTipVisible;
      80                 :            :     Window*                 pTipVisibleSecParent;
      81                 :            :     sal_uLong                   nTipVisibleSec;
      82                 :            :     rtl::OUString           aManualTip;
      83                 :            :     rtl::OUString           aAutoSearch;
      84                 :            : 
      85                 :            :     rtl::OUString           aCurrentText;
      86                 :            : 
      87                 :            :     rtl::OUString           aFormText;                  // for autopilot function
      88                 :            :     xub_StrLen              nFormSelStart;              // Selection for autopilot function
      89                 :            :     xub_StrLen              nFormSelEnd;
      90                 :            : 
      91                 :            :     sal_uInt16                  nAutoPar;                   // autom.parentheses than can be overwritten
      92                 :            : 
      93                 :            :     ScAddress               aCursorPos;
      94                 :            :     ScInputMode             eMode;
      95                 :            :     bool                    bUseTab:1;                    // Scrolling possible
      96                 :            :     bool                    bTextValid:1;                 // Text is not in edit engine
      97                 :            :     bool                    bModified:1;
      98                 :            :     bool                    bSelIsRef:1;
      99                 :            :     bool                    bFormulaMode:1;
     100                 :            :     bool                    bInRangeUpdate:1;
     101                 :            :     bool                    bParenthesisShown:1;
     102                 :            :     bool                    bCreatingFuncView:1;
     103                 :            :     bool                    bInEnterHandler:1;
     104                 :            :     bool                    bCommandErrorShown:1;
     105                 :            :     bool                    bInOwnChange:1;
     106                 :            : 
     107                 :            :     bool                    bProtected:1;
     108                 :            :     bool                    bCellHasPercentFormat:1;
     109                 :            :     bool                    bLastIsSymbol:1;
     110                 :            :     sal_uLong                   nValidation;
     111                 :            :     SvxCellHorJustify       eAttrAdjust;
     112                 :            : 
     113                 :            :     Fraction                aScaleX;                    // for ref MapMode
     114                 :            :     Fraction                aScaleY;
     115                 :            : 
     116                 :            :     ScTabViewShell*         pRefViewSh;
     117                 :            :     ScTabViewShell*         pActiveViewSh;
     118                 :            : 
     119                 :            :     const ScPatternAttr*    pLastPattern;
     120                 :            :     SfxItemSet*             pEditDefaults;
     121                 :            : 
     122                 :            :     ScInputHdlState*        pLastState;
     123                 :            :     Timer*                  pDelayTimer;
     124                 :            : 
     125                 :            :     ScRangeFindList*        pRangeFindList;
     126                 :            : 
     127                 :            :     static bool             bAutoComplete;              // from app options
     128                 :            :     static bool             bOptLoaded;
     129                 :            : 
     130                 :            : #ifdef _INPUTHDL_CXX
     131                 :            : private:
     132                 :            :     void            UpdateActiveView();
     133                 :            :     void            SyncViews( EditView* pSourceView = NULL );
     134                 :            :     /**
     135                 :            :      * @param cTyped typed character. If 0, look at existing document content
     136                 :            :      *               for text or number.
     137                 :            :      * @param bInputActivated true if the cell input mode is activated (via
     138                 :            :      *                        F2), false otherwise.
     139                 :            :      * @return true if the new edit mode has been started.
     140                 :            :      */
     141                 :            :     bool            StartTable( sal_Unicode cTyped, bool bFromCommand, bool bInputActivated );
     142                 :            :     void            RemoveSelection();
     143                 :            :     void            UpdateFormulaMode();
     144                 :            :     void            InvalidateAttribs();
     145                 :            :     void            ImplCreateEditEngine();
     146                 :            :     DECL_LINK(      DelayTimer, Timer* );
     147                 :            :     void            GetColData();
     148                 :            :     void            UseColData();
     149                 :            :     void            NextAutoEntry( bool bBack );
     150                 :            :     void            UpdateAdjust( sal_Unicode cTyped );
     151                 :            :     void            GetFormulaData();
     152                 :            :     void            UseFormulaData();
     153                 :            :     void            NextFormulaEntry( bool bBack );
     154                 :            :     void            PasteFunctionData();
     155                 :            :     void            PasteManualTip();
     156                 :            :     EditView*       GetFuncEditView();
     157                 :            :     void            RemoveAdjust();
     158                 :            :     void            RemoveRangeFinder();
     159                 :            :     void            DeleteRangeFinder();
     160                 :            :     void            UpdateParenthesis();
     161                 :            :     void            UpdateAutoCorrFlag();
     162                 :            :     void            ResetAutoPar();
     163                 :            :     void            AutoParAdded();
     164                 :            :     bool            CursorAtClosingPar();
     165                 :            :     void            SkipClosingPar();
     166                 :            :     DECL_LINK( ModifyHdl, void* );
     167                 :            :     DECL_LINK( ShowHideTipVisibleParentListener, VclWindowEvent* );
     168                 :            :     DECL_LINK( ShowHideTipVisibleSecParentListener, VclWindowEvent* );
     169                 :            : #endif
     170                 :            : 
     171                 :            : public:
     172                 :            :                     ScInputHandler();
     173                 :            :     virtual         ~ScInputHandler();
     174                 :            : 
     175                 :            :     void            SetMode( ScInputMode eNewMode );
     176                 :        668 :     bool            IsInputMode() const { return (eMode != SC_INPUT_NONE); }
     177                 :        109 :     bool            IsEditMode() const  { return (eMode != SC_INPUT_NONE &&
     178 [ -  + ][ #  # ]:        109 :                                                   eMode != SC_INPUT_TYPE); }
     179                 :          0 :     bool            IsTopMode() const   { return (eMode == SC_INPUT_TOP);  }
     180                 :            : 
     181                 :            :     const rtl::OUString& GetEditString();
     182                 :        229 :     const rtl::OUString& GetFormString() const { return aFormText; }
     183                 :            : 
     184                 :       2687 :     const ScAddress& GetCursorPos() const   { return aCursorPos; }
     185                 :            : 
     186                 :            :     bool            GetTextAndFields( ScEditEngineDefaulter& rDestEngine );
     187                 :            : 
     188                 :            :     bool            KeyInput( const KeyEvent& rKEvt, bool bStartEdit = false );
     189                 :            :     void            EnterHandler( sal_uInt8 nBlockMode = 0 );
     190                 :            :     void            CancelHandler();
     191                 :            :     void            SetReference( const ScRange& rRef, ScDocument* pDoc );
     192                 :            :     void            AddRefEntry();
     193                 :            : 
     194                 :            :     bool            InputCommand( const CommandEvent& rCEvt, bool bForce );
     195                 :            : 
     196                 :            :     void            InsertFunction( const String& rFuncName, bool bAddPar = true );
     197                 :            :     void            ClearText();
     198                 :            : 
     199                 :            :     void            InputSelection( EditView* pView );
     200                 :            :     void            InputChanged( EditView* pView, bool bFromNotify = false );
     201                 :            : 
     202                 :            :     void            ViewShellGone(ScTabViewShell* pViewSh);
     203                 :          0 :     void            SetRefViewShell(ScTabViewShell* pRefVsh) {pRefViewSh=pRefVsh;}
     204                 :            : 
     205                 :            :     void            NotifyChange( const ScInputHdlState* pState, bool bForce = false,
     206                 :            :                                   ScTabViewShell* pSourceSh = NULL,
     207                 :            :                                   bool bStopEditing = true);
     208                 :            :     void            UpdateCellAdjust( SvxCellHorJustify eJust );
     209                 :            : 
     210                 :            :     void            ResetDelayTimer(); //BugId 54702
     211                 :            : 
     212                 :            :     void            HideTip();
     213                 :            :     void            HideTipBelow();
     214                 :            :     void            ShowTipCursor();
     215                 :            :     void            ShowTip( const String& rText );     // at Cursor
     216                 :            :     void            ShowTipBelow( const String& rText );
     217                 :            : 
     218                 :            :     void            SetRefScale( const Fraction& rX, const Fraction& rY );
     219                 :            :     void            UpdateRefDevice();
     220                 :            : 
     221                 :            :     EditView*       GetActiveView();
     222                 :          0 :     EditView*       GetTableView()      { return pTableView; }
     223                 :          0 :     EditView*       GetTopView()        { return pTopView; }
     224                 :            : 
     225                 :            :     bool            DataChanging( sal_Unicode cTyped = 0, bool bFromCommand = false );
     226                 :            :     void            DataChanged( bool bFromTopNotify = false );
     227                 :            : 
     228                 :          0 :     bool            TakesReturn() const     { return ( nTipVisible != 0 ); }
     229                 :            : 
     230                 :          0 :     void            SetModified()       { bModified = true; }
     231                 :            : 
     232                 :          0 :     bool            GetSelIsRef() const     { return bSelIsRef; }
     233                 :          0 :     void            SetSelIsRef(bool bSet)  { bSelIsRef = bSet; }
     234                 :            : 
     235                 :            :     void            ShowRefFrame();
     236                 :            : 
     237                 :       1278 :     ScRangeFindList* GetRangeFindList()     { return pRangeFindList; }
     238                 :            : 
     239                 :            :     void            UpdateRange( sal_uInt16 nIndex, const ScRange& rNew );
     240                 :            : 
     241                 :            :     // Communication with the autopilot function
     242                 :            :     void            InputGetSelection       ( xub_StrLen& rStart, xub_StrLen& rEnd );
     243                 :            :     void            InputSetSelection       ( xub_StrLen nStart, xub_StrLen nEnd );
     244                 :            :     void            InputReplaceSelection   ( const rtl::OUString& rStr );
     245                 :            : 
     246                 :       2229 :     bool            IsFormulaMode() const                   { return bFormulaMode; }
     247                 :       1278 :     ScInputWindow*  GetInputWindow()                        { return pInputWin; }
     248                 :        454 :     void            SetInputWindow( ScInputWindow* pNew )   { pInputWin = pNew; }
     249                 :            :     void            StopInputWinEngine( bool bAll );
     250                 :            : 
     251                 :          0 :     bool            IsInEnterHandler() const                { return bInEnterHandler; }
     252                 :          0 :     bool            IsInOwnChange() const                   { return bInOwnChange; }
     253                 :            : 
     254                 :            :     bool            IsModalMode( SfxObjectShell* pDocSh );
     255                 :            : 
     256                 :            :     void            ForgetLastPattern();
     257                 :            : 
     258                 :            :     void            UpdateSpellSettings( bool bFromStartTab = false );
     259                 :            : 
     260                 :            :     void            FormulaPreview();
     261                 :            : 
     262                 :            :     Size            GetTextSize();      // in 1/100mm
     263                 :            : 
     264                 :            :                     // actually private, public for SID_INPUT_SUM
     265                 :            :     void            InitRangeFinder( const String& rFormula );
     266                 :            : 
     267                 :          0 :     static void     SetAutoComplete(bool bSet)  { bAutoComplete = bSet; }
     268                 :            : };
     269                 :            : 
     270                 :            : //========================================================================
     271                 :            : //  ScInputHdlState
     272                 :            : //========================================================================
     273                 :            : class ScInputHdlState
     274                 :            : {
     275                 :            :     friend class ScInputHandler;
     276                 :            : 
     277                 :            : public:
     278                 :            :         ScInputHdlState( const ScAddress& rCurPos,
     279                 :            :                          const ScAddress& rStartPos,
     280                 :            :                          const ScAddress& rEndPos,
     281                 :            :                          const String& rString,
     282                 :            :                          const EditTextObject* pData );
     283                 :            :         ScInputHdlState( const ScInputHdlState& rCpy );
     284                 :            :         ~ScInputHdlState();
     285                 :            : 
     286                 :            :     ScInputHdlState&    operator= ( const ScInputHdlState& r );
     287                 :            :     int                 operator==( const ScInputHdlState& r ) const;
     288                 :            :     int                 operator!=( const ScInputHdlState& r ) const
     289                 :            :                             { return !operator==( r ); }
     290                 :            : 
     291                 :        640 :     const ScAddress&        GetPos() const          { return aCursorPos; }
     292                 :        640 :     const ScAddress&        GetStartPos() const     { return aStartPos; }
     293                 :        640 :     const ScAddress&        GetEndPos() const       { return aEndPos; }
     294                 :        640 :     const String&           GetString() const       { return aString; }
     295                 :       1272 :     const EditTextObject*   GetEditData() const     { return pEditData; }
     296                 :            : 
     297                 :            : private:
     298                 :            :     ScAddress       aCursorPos;
     299                 :            :     ScAddress       aStartPos;
     300                 :            :     ScAddress       aEndPos;
     301                 :            :     String          aString;
     302                 :            :     EditTextObject* pEditData;
     303                 :            : };
     304                 :            : 
     305                 :            : #endif
     306                 :            : 
     307                 :            : 
     308                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10