1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef SC_INPUTHDL_HXX
21 #define SC_INPUTHDL_HXX
24 #include "address.hxx"
25 #include "typedstrdata.hxx"
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>
35 #include <boost/noncopyable.hpp>
41 class ScEditEngineDefaulter
;
44 class ScInputHdlState
;
45 class ScRangeFindList
;
52 //========================================================================
54 //========================================================================
56 class ScInputHandler
: boost::noncopyable
59 ScInputWindow
* pInputWin
;
61 ScEditEngineDefaulter
* pEngine
; // edited data in the sheet
62 EditView
* pTableView
; // associated active EditView
63 EditView
* pTopView
; // EditView in dthe input row
65 ScTypedCaseStrSet
* pColumnData
;
66 ScTypedCaseStrSet
* pFormulaData
;
67 ScTypedCaseStrSet
* pFormulaDataPara
;
68 ScTypedCaseStrSet::const_iterator miAutoPosColumn
;
69 ScTypedCaseStrSet::const_iterator miAutoPosFormula
;
71 Window
* pTipVisibleParent
;
72 sal_uLong nTipVisible
;
73 Window
* pTipVisibleSecParent
;
74 sal_uLong nTipVisibleSec
;
78 OUString aCurrentText
;
80 OUString aFormText
; // for autopilot function
81 xub_StrLen nFormSelStart
; // Selection for autopilot function
82 xub_StrLen nFormSelEnd
;
84 sal_uInt16 nAutoPar
; // autom.parentheses than can be overwritten
88 bool bUseTab
:1; // Scrolling possible
89 bool bTextValid
:1; // Text is not in edit engine
93 bool bInRangeUpdate
:1;
94 bool bParenthesisShown
:1;
95 bool bCreatingFuncView
:1;
96 bool bInEnterHandler
:1;
97 bool bCommandErrorShown
:1;
101 bool bCellHasPercentFormat
:1;
102 bool bLastIsSymbol
:1;
103 bool mbDocumentDisposing
:1;
104 sal_uLong nValidation
;
105 SvxCellHorJustify eAttrAdjust
;
107 Fraction aScaleX
; // for ref MapMode
110 ScTabViewShell
* pRefViewSh
;
111 ScTabViewShell
* pActiveViewSh
;
113 const ScPatternAttr
* pLastPattern
;
114 SfxItemSet
* pEditDefaults
;
116 ScInputHdlState
* pLastState
;
119 ScRangeFindList
* pRangeFindList
;
121 static bool bAutoComplete
; // from app options
122 static bool bOptLoaded
;
125 void UpdateActiveView();
126 void SyncViews( EditView
* pSourceView
= NULL
);
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.
134 bool StartTable( sal_Unicode cTyped
, bool bFromCommand
, bool bInputActivated
);
135 void RemoveSelection();
136 void UpdateFormulaMode();
137 void InvalidateAttribs();
138 void ImplCreateEditEngine();
139 DECL_LINK( DelayTimer
, Timer
* );
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();
151 void RemoveRangeFinder();
152 void DeleteRangeFinder();
153 void UpdateParenthesis();
154 void UpdateAutoCorrFlag();
157 bool CursorAtClosingPar();
158 void SkipClosingPar();
159 DECL_LINK( ModifyHdl
, void* );
160 DECL_LINK( ShowHideTipVisibleParentListener
, VclWindowEvent
* );
161 DECL_LINK( ShowHideTipVisibleSecParentListener
, VclWindowEvent
* );
165 virtual ~ScInputHandler();
167 void SetMode( ScInputMode eNewMode
);
168 bool IsInputMode() const { return (eMode
!= SC_INPUT_NONE
); }
169 bool IsEditMode() const { return (eMode
!= SC_INPUT_NONE
&&
170 eMode
!= SC_INPUT_TYPE
); }
171 bool IsTopMode() const { return (eMode
== SC_INPUT_TOP
); }
173 const OUString
& GetEditString();
174 const OUString
& GetFormString() const { return aFormText
; }
176 const ScAddress
& GetCursorPos() const { return aCursorPos
; }
178 bool GetTextAndFields( ScEditEngineDefaulter
& rDestEngine
);
180 bool KeyInput( const KeyEvent
& rKEvt
, bool bStartEdit
= false );
181 void EnterHandler( sal_uInt8 nBlockMode
= 0 );
182 void CancelHandler();
183 void SetReference( const ScRange
& rRef
, ScDocument
* pDoc
);
186 bool InputCommand( const CommandEvent
& rCEvt
, bool bForce
);
188 void InsertFunction( const String
& rFuncName
, bool bAddPar
= true );
191 void InputSelection( EditView
* pView
);
192 void InputChanged( EditView
* pView
, bool bFromNotify
= false );
194 void ViewShellGone(ScTabViewShell
* pViewSh
);
195 void SetRefViewShell(ScTabViewShell
* pRefVsh
) {pRefViewSh
=pRefVsh
;}
197 void NotifyChange( const ScInputHdlState
* pState
, bool bForce
= false,
198 ScTabViewShell
* pSourceSh
= NULL
,
199 bool bStopEditing
= true);
200 void UpdateCellAdjust( SvxCellHorJustify eJust
);
202 void ResetDelayTimer(); //BugId 54702
206 void ShowTipCursor();
207 void ShowTip( const String
& rText
); // at Cursor
208 void ShowTipBelow( const String
& rText
);
210 void SetRefScale( const Fraction
& rX
, const Fraction
& rY
);
211 void UpdateRefDevice();
213 EditView
* GetActiveView();
214 EditView
* GetTableView() { return pTableView
; }
215 EditView
* GetTopView() { return pTopView
; }
217 bool DataChanging( sal_Unicode cTyped
= 0, bool bFromCommand
= false );
218 void DataChanged( bool bFromTopNotify
= false, bool bSetModified
= true );
220 bool TakesReturn() const { return ( nTipVisible
!= 0 ); }
222 void SetModified() { bModified
= true; }
224 bool GetSelIsRef() const { return bSelIsRef
; }
225 void SetSelIsRef(bool bSet
) { bSelIsRef
= bSet
; }
229 ScRangeFindList
* GetRangeFindList() { return pRangeFindList
; }
231 void UpdateRange( sal_uInt16 nIndex
, const ScRange
& rNew
);
233 // Communication with the autopilot function
234 void InputGetSelection ( xub_StrLen
& rStart
, xub_StrLen
& rEnd
);
235 void InputSetSelection ( xub_StrLen nStart
, xub_StrLen nEnd
);
236 void InputReplaceSelection ( const OUString
& rStr
);
237 void InputTurnOffWinEngine();
239 bool IsFormulaMode() const { return bFormulaMode
; }
240 ScInputWindow
* GetInputWindow() { return pInputWin
; }
241 void SetInputWindow( ScInputWindow
* pNew
) { pInputWin
= pNew
; }
242 void StopInputWinEngine( bool bAll
);
244 bool IsInEnterHandler() const { return bInEnterHandler
; }
245 bool IsInOwnChange() const { return bInOwnChange
; }
247 bool IsModalMode( SfxObjectShell
* pDocSh
);
249 void ForgetLastPattern();
251 void UpdateSpellSettings( bool bFromStartTab
= false );
253 void FormulaPreview();
255 Size
GetTextSize(); // in 1/100mm
257 // actually private, public for SID_INPUT_SUM
258 void InitRangeFinder( const String
& rFormula
);
260 void SetDocumentDisposing( bool b
);
262 static void SetAutoComplete(bool bSet
) { bAutoComplete
= bSet
; }
265 //========================================================================
267 //========================================================================
268 class ScInputHdlState
270 friend class ScInputHandler
;
273 ScInputHdlState( const ScAddress
& rCurPos
,
274 const ScAddress
& rStartPos
,
275 const ScAddress
& rEndPos
,
276 const String
& rString
,
277 const EditTextObject
* pData
);
278 ScInputHdlState( const ScInputHdlState
& rCpy
);
281 ScInputHdlState
& operator= ( const ScInputHdlState
& r
);
282 int operator==( const ScInputHdlState
& r
) const;
283 int operator!=( const ScInputHdlState
& r
) const
284 { return !operator==( r
); }
286 const ScAddress
& GetPos() const { return aCursorPos
; }
287 const ScAddress
& GetStartPos() const { return aStartPos
; }
288 const ScAddress
& GetEndPos() const { return aEndPos
; }
289 const String
& GetString() const { return aString
; }
290 const EditTextObject
* GetEditData() const { return pEditData
; }
293 ScAddress aCursorPos
;
297 EditTextObject
* pEditData
;
303 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */