Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / sc / source / ui / inc / inputhdl.hxx
blob562955b9e4af59a46b9c0af22412c171451ebbe6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
23 #include "global.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>
34 #include <set>
36 class ScDocument;
37 class ScTabViewShell;
38 class ScInputWindow;
39 class ScPatternAttr;
40 class ScEditEngineDefaulter;
41 class EditView;
42 class EditTextObject;
43 class ScInputHdlState;
44 class ScRangeFindList;
45 class Timer;
46 class KeyEvent;
47 class CommandEvent;
49 struct ESelection;
51 // ScInputHandler
53 class ScInputHandler
55 private:
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;
72 OUString aManualTip;
73 OUString aAutoSearch;
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
83 ScAddress aCursorPos;
84 ScInputMode eMode;
85 bool bUseTab:1; // Scrolling possible
86 bool bTextValid:1; // Text is not in edit engine
87 bool bModified:1;
88 bool bSelIsRef:1;
89 bool bFormulaMode:1;
90 bool bInRangeUpdate:1;
91 bool bParenthesisShown:1;
92 bool bCreatingFuncView:1;
93 bool bInEnterHandler:1;
94 bool bCommandErrorShown:1;
95 bool bInOwnChange:1;
97 bool bProtected:1;
98 bool bCellHasPercentFormat:1;
99 bool bLastIsSymbol:1;
100 bool mbDocumentDisposing:1;
101 sal_uLong nValidation;
102 SvxCellHorJustify eAttrAdjust;
104 Fraction aScaleX; // for ref MapMode
105 Fraction aScaleY;
107 ScTabViewShell* pRefViewSh;
108 ScTabViewShell* pActiveViewSh;
110 const ScPatternAttr* pLastPattern;
111 SfxItemSet* pEditDefaults;
113 ScInputHdlState* pLastState;
114 Timer* pDelayTimer;
116 ScRangeFindList* pRangeFindList;
118 static bool bAutoComplete; // from app options
119 static bool bOptLoaded;
120 ::std::set< sal_Unicode > maFormulaChar; //fdo 75264
122 private:
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 );
138 void GetColData();
139 void UseColData();
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();
148 void RemoveAdjust();
149 void RemoveRangeFinder();
150 void DeleteRangeFinder();
151 void UpdateParenthesis();
152 void UpdateAutoCorrFlag();
153 void ResetAutoPar();
154 void AutoParAdded();
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 );
163 public:
164 ScInputHandler(const ScInputHandler&) = delete;
165 const ScInputHandler& operator=(const ScInputHandler&) = delete;
167 ScInputHandler();
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 );
187 void AddRefEntry();
189 void InputCommand( const CommandEvent& rCEvt );
191 void InsertFunction( const OUString& rFuncName, bool bAddPar = true );
192 void ClearText();
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
207 void HideTip();
208 void HideTipBelow();
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; }
231 void ShowRefFrame();
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; }
269 // ScInputHdlState
271 class ScInputHdlState
273 friend class ScInputHandler;
275 public:
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 );
282 ~ScInputHdlState();
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; }
293 private:
294 ScAddress aCursorPos;
295 ScAddress aStartPos;
296 ScAddress aEndPos;
297 OUString aString;
298 EditTextObject* pEditData;
301 #endif
303 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */