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

Generated by: LCOV version 1.11