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 INCLUDED_SC_SOURCE_UI_INC_INPUTHDL_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_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 <vcl/vclptr.hxx>
32 #include <editeng/svxenum.hxx>
40 class ScEditEngineDefaulter
;
43 class ScInputHdlState
;
44 class ScRangeFindList
;
56 VclPtr
<ScInputWindow
> pInputWin
;
58 ScEditEngineDefaulter
* pEngine
; ///< Edited data in the sheet (when the user clicks into the sheet, and starts writing there).
59 EditView
* pTableView
; // associated active EditView
60 EditView
* pTopView
; // EditView in the input row
62 ScTypedCaseStrSet
* pColumnData
;
63 ScTypedCaseStrSet
* pFormulaData
;
64 ScTypedCaseStrSet
* pFormulaDataPara
;
65 ScTypedCaseStrSet::const_iterator miAutoPosColumn
;
66 ScTypedCaseStrSet::const_iterator miAutoPosFormula
;
68 VclPtr
<vcl::Window
> pTipVisibleParent
;
69 sal_uLong nTipVisible
;
70 VclPtr
<vcl::Window
> pTipVisibleSecParent
;
71 sal_uLong nTipVisibleSec
;
75 OUString aCurrentText
;
77 OUString aFormText
; // for autopilot function
78 sal_Int32 nFormSelStart
; // Selection for autopilot function
79 sal_Int32 nFormSelEnd
;
81 sal_uInt16 nAutoPar
; // autom.parentheses than can be overwritten
85 bool bUseTab
:1; // Scrolling possible
86 bool bTextValid
:1; // Text is not in edit engine
90 bool bInRangeUpdate
:1;
91 bool bParenthesisShown
:1;
92 bool bCreatingFuncView
:1;
93 bool bInEnterHandler
:1;
94 bool bCommandErrorShown
:1;
98 bool bCellHasPercentFormat
:1;
100 bool mbDocumentDisposing
:1;
101 sal_uLong nValidation
;
102 SvxCellHorJustify eAttrAdjust
;
104 Fraction aScaleX
; // for ref MapMode
107 ScTabViewShell
* pRefViewSh
;
108 ScTabViewShell
* pActiveViewSh
;
110 const ScPatternAttr
* pLastPattern
;
111 SfxItemSet
* pEditDefaults
;
113 ScInputHdlState
* pLastState
;
116 ScRangeFindList
* pRangeFindList
;
118 static bool bAutoComplete
; // from app options
119 static bool bOptLoaded
;
120 ::std::set
< sal_Unicode
> maFormulaChar
; //fdo 75264
123 void UpdateActiveView();
124 void SyncViews( EditView
* pSourceView
= nullptr );
126 * @param cTyped typed character. If 0, look at existing document content
127 * for text or number.
128 * @param bInputActivated true if the cell input mode is activated (via
129 * F2), false otherwise.
130 * @return true if the new edit mode has been started.
132 bool StartTable( sal_Unicode cTyped
, bool bFromCommand
, bool bInputActivated
);
133 void RemoveSelection();
134 void UpdateFormulaMode();
135 static void InvalidateAttribs();
136 void ImplCreateEditEngine();
137 DECL_LINK_TYPED( DelayTimer
, Timer
*, void );
140 void NextAutoEntry( bool bBack
);
141 void UpdateAdjust( sal_Unicode cTyped
);
142 void GetFormulaData();
143 void UseFormulaData();
144 void NextFormulaEntry( bool bBack
);
145 void PasteFunctionData();
146 void PasteManualTip();
147 EditView
* GetFuncEditView();
149 void RemoveRangeFinder();
150 void DeleteRangeFinder();
151 void UpdateParenthesis();
152 void UpdateAutoCorrFlag();
155 bool CursorAtClosingPar();
156 void SkipClosingPar();
157 bool GetFuncName( OUString
& aStart
, OUString
& aResult
); // fdo75264
158 void ShowArgumentsTip( OUString
& rSelText
);
159 DECL_LINK_TYPED( ModifyHdl
, LinkParamNone
*, void );
160 DECL_LINK_TYPED( ShowHideTipVisibleParentListener
, VclWindowEvent
&, void );
161 DECL_LINK_TYPED( ShowHideTipVisibleSecParentListener
, VclWindowEvent
&, void );
164 ScInputHandler(const ScInputHandler
&) = delete;
165 const ScInputHandler
& operator=(const ScInputHandler
&) = delete;
168 virtual ~ScInputHandler();
170 void SetMode( ScInputMode eNewMode
, const OUString
* pInitText
= nullptr );
171 bool IsInputMode() const { return (eMode
!= SC_INPUT_NONE
); }
172 bool IsEditMode() const { return (eMode
!= SC_INPUT_NONE
&&
173 eMode
!= SC_INPUT_TYPE
); }
174 bool IsTopMode() const { return (eMode
== SC_INPUT_TOP
); }
176 const OUString
& GetEditString();
177 const OUString
& GetFormString() const { return aFormText
; }
179 const ScAddress
& GetCursorPos() const { return aCursorPos
; }
181 bool GetTextAndFields( ScEditEngineDefaulter
& rDestEngine
);
183 bool KeyInput( const KeyEvent
& rKEvt
, bool bStartEdit
= false );
184 void EnterHandler( ScEnterMode nBlockMode
= ScEnterMode::NORMAL
);
185 void CancelHandler();
186 void SetReference( const ScRange
& rRef
, ScDocument
* pDoc
);
189 void InputCommand( const CommandEvent
& rCEvt
);
191 void InsertFunction( const OUString
& rFuncName
, bool bAddPar
= true );
194 void InputSelection( EditView
* pView
);
195 void InputChanged( EditView
* pView
, bool bFromNotify
= false );
197 void ViewShellGone(ScTabViewShell
* pViewSh
);
198 void SetRefViewShell(ScTabViewShell
* pRefVsh
) {pRefViewSh
=pRefVsh
;}
200 void NotifyChange( const ScInputHdlState
* pState
, bool bForce
= false,
201 ScTabViewShell
* pSourceSh
= nullptr,
202 bool bStopEditing
= true);
203 void UpdateCellAdjust( SvxCellHorJustify eJust
);
205 void ResetDelayTimer(); //BugId 54702
209 void ShowTipCursor();
210 void ShowTip( const OUString
& rText
); // at Cursor
211 void ShowTipBelow( const OUString
& rText
);
212 void ShowFuncList( const ::std::vector
< OUString
> & rFuncStrVec
);
214 void SetRefScale( const Fraction
& rX
, const Fraction
& rY
);
215 void UpdateRefDevice();
217 EditView
* GetActiveView();
218 EditView
* GetTableView() { return pTableView
; }
219 EditView
* GetTopView() { return pTopView
; }
221 bool DataChanging( sal_Unicode cTyped
= 0, bool bFromCommand
= false );
222 void DataChanged( bool bFromTopNotify
= false, bool bSetModified
= true );
224 bool TakesReturn() const { return ( nTipVisible
!= 0 ); }
226 void SetModified() { bModified
= true; }
228 bool GetSelIsRef() const { return bSelIsRef
; }
229 void SetSelIsRef(bool bSet
) { bSelIsRef
= bSet
; }
233 ScRangeFindList
* GetRangeFindList() { return pRangeFindList
; }
235 void UpdateRange( sal_uInt16 nIndex
, const ScRange
& rNew
);
237 // Communication with the autopilot function
238 void InputGetSelection ( sal_Int32
& rStart
, sal_Int32
& rEnd
);
239 void InputSetSelection ( sal_Int32 nStart
, sal_Int32 nEnd
);
240 void InputReplaceSelection ( const OUString
& rStr
);
241 void InputTurnOffWinEngine();
243 bool IsFormulaMode() const { return bFormulaMode
; }
244 ScInputWindow
* GetInputWindow() { return pInputWin
; }
245 void SetInputWindow( ScInputWindow
* pNew
);
246 void StopInputWinEngine( bool bAll
);
248 bool IsInEnterHandler() const { return bInEnterHandler
; }
249 bool IsInOwnChange() const { return bInOwnChange
; }
251 bool IsModalMode( SfxObjectShell
* pDocSh
);
253 void ForgetLastPattern();
255 void UpdateSpellSettings( bool bFromStartTab
= false );
257 void FormulaPreview();
259 Size
GetTextSize(); // in 1/100mm
261 // actually private, public for SID_INPUT_SUM
262 void InitRangeFinder(const OUString
& rFormula
);
264 void SetDocumentDisposing( bool b
);
266 static void SetAutoComplete(bool bSet
) { bAutoComplete
= bSet
; }
271 class ScInputHdlState
273 friend class ScInputHandler
;
276 ScInputHdlState( const ScAddress
& rCurPos
,
277 const ScAddress
& rStartPos
,
278 const ScAddress
& rEndPos
,
279 const OUString
& rString
,
280 const EditTextObject
* pData
);
281 ScInputHdlState( const ScInputHdlState
& rCpy
);
284 ScInputHdlState
& operator= ( const ScInputHdlState
& r
);
285 bool operator==( const ScInputHdlState
& r
) const;
287 const ScAddress
& GetPos() const { return aCursorPos
; }
288 const ScAddress
& GetStartPos() const { return aStartPos
; }
289 const ScAddress
& GetEndPos() const { return aEndPos
; }
290 const OUString
& GetString() const { return aString
; }
291 const EditTextObject
* GetEditData() const { return pEditData
; }
294 ScAddress aCursorPos
;
298 EditTextObject
* pEditData
;
303 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */