LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/inc - inputhdl.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 14 25 56.0 %
Date: 2013-07-09 Functions: 13 24 54.2 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10