fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / inc / inputhdl.hxx
blobbfb8e62a5fac793a18f78e32d80448599ac645c3
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 #include <boost/noncopyable.hpp>
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;
51 struct ESelection;
53 // ScInputHandler
55 class ScInputHandler : boost::noncopyable
57 private:
58 VclPtr<ScInputWindow> pInputWin;
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
64 ScTypedCaseStrSet* pColumnData;
65 ScTypedCaseStrSet* pFormulaData;
66 ScTypedCaseStrSet* pFormulaDataPara;
67 ScTypedCaseStrSet::const_iterator miAutoPosColumn;
68 ScTypedCaseStrSet::const_iterator miAutoPosFormula;
70 VclPtr<vcl::Window> pTipVisibleParent;
71 sal_uLong nTipVisible;
72 VclPtr<vcl::Window> pTipVisibleSecParent;
73 sal_uLong nTipVisibleSec;
74 OUString aManualTip;
75 OUString aAutoSearch;
77 OUString aCurrentText;
79 OUString aFormText; // for autopilot function
80 sal_Int32 nFormSelStart; // Selection for autopilot function
81 sal_Int32 nFormSelEnd;
83 sal_uInt16 nAutoPar; // autom.parentheses than can be overwritten
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;
99 bool bProtected:1;
100 bool bCellHasPercentFormat:1;
101 bool bLastIsSymbol:1;
102 bool mbDocumentDisposing:1;
103 sal_uLong nValidation;
104 SvxCellHorJustify eAttrAdjust;
106 Fraction aScaleX; // for ref MapMode
107 Fraction aScaleY;
109 ScTabViewShell* pRefViewSh;
110 ScTabViewShell* pActiveViewSh;
112 const ScPatternAttr* pLastPattern;
113 SfxItemSet* pEditDefaults;
115 ScInputHdlState* pLastState;
116 Timer* pDelayTimer;
118 ScRangeFindList* pRangeFindList;
120 static bool bAutoComplete; // from app options
121 static bool bOptLoaded;
122 ::std::set< sal_Unicode > maFormulaChar; //fdo 75264
124 private:
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 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( OUString& rSelText );
161 DECL_LINK( ModifyHdl, void* );
162 DECL_LINK( ShowHideTipVisibleParentListener, VclWindowEvent* );
163 DECL_LINK( ShowHideTipVisibleSecParentListener, VclWindowEvent* );
165 public:
166 ScInputHandler();
167 virtual ~ScInputHandler();
169 void SetMode( ScInputMode eNewMode, const OUString* pInitText = NULL );
170 bool IsInputMode() const { return (eMode != SC_INPUT_NONE); }
171 bool IsEditMode() const { return (eMode != SC_INPUT_NONE &&
172 eMode != SC_INPUT_TYPE); }
173 bool IsTopMode() const { return (eMode == SC_INPUT_TOP); }
175 const OUString& GetEditString();
176 const OUString& GetFormString() const { return aFormText; }
178 const ScAddress& GetCursorPos() const { return aCursorPos; }
180 bool GetTextAndFields( ScEditEngineDefaulter& rDestEngine );
182 bool KeyInput( const KeyEvent& rKEvt, bool bStartEdit = false );
183 void EnterHandler( sal_uInt8 nBlockMode = 0 );
184 void CancelHandler();
185 void SetReference( const ScRange& rRef, ScDocument* pDoc );
186 void AddRefEntry();
188 bool InputCommand( const CommandEvent& rCEvt, bool bForce );
190 void InsertFunction( const OUString& rFuncName, bool bAddPar = true );
191 void ClearText();
193 void InputSelection( EditView* pView );
194 void InputChanged( EditView* pView, bool bFromNotify = false );
196 void ViewShellGone(ScTabViewShell* pViewSh);
197 void SetRefViewShell(ScTabViewShell* pRefVsh) {pRefViewSh=pRefVsh;}
199 void NotifyChange( const ScInputHdlState* pState, bool bForce = false,
200 ScTabViewShell* pSourceSh = NULL,
201 bool bStopEditing = true);
202 void UpdateCellAdjust( SvxCellHorJustify eJust );
204 void ResetDelayTimer(); //BugId 54702
206 void HideTip();
207 void HideTipBelow();
208 void ShowTipCursor();
209 void ShowTip( const OUString& rText ); // at Cursor
210 void ShowTipBelow( const OUString& rText );
212 void SetRefScale( const Fraction& rX, const Fraction& rY );
213 void UpdateRefDevice();
215 EditView* GetActiveView();
216 EditView* GetTableView() { return pTableView; }
217 EditView* GetTopView() { return pTopView; }
219 bool DataChanging( sal_Unicode cTyped = 0, bool bFromCommand = false );
220 void DataChanged( bool bFromTopNotify = false, bool bSetModified = true );
222 bool TakesReturn() const { return ( nTipVisible != 0 ); }
224 void SetModified() { bModified = true; }
226 bool GetSelIsRef() const { return bSelIsRef; }
227 void SetSelIsRef(bool bSet) { bSelIsRef = bSet; }
229 void ShowRefFrame();
231 ScRangeFindList* GetRangeFindList() { return pRangeFindList; }
233 void UpdateRange( sal_uInt16 nIndex, const ScRange& rNew );
235 // Communication with the autopilot function
236 void InputGetSelection ( sal_Int32& rStart, sal_Int32& rEnd );
237 void InputSetSelection ( sal_Int32 nStart, sal_Int32 nEnd );
238 void InputReplaceSelection ( const OUString& rStr );
239 void InputTurnOffWinEngine();
241 bool IsFormulaMode() const { return bFormulaMode; }
242 ScInputWindow* GetInputWindow() { return pInputWin; }
243 void SetInputWindow( ScInputWindow* pNew );
244 void StopInputWinEngine( bool bAll );
246 bool IsInEnterHandler() const { return bInEnterHandler; }
247 bool IsInOwnChange() const { return bInOwnChange; }
249 bool IsModalMode( SfxObjectShell* pDocSh );
251 void ForgetLastPattern();
253 void UpdateSpellSettings( bool bFromStartTab = false );
255 void FormulaPreview();
257 Size GetTextSize(); // in 1/100mm
259 // actually private, public for SID_INPUT_SUM
260 void InitRangeFinder(const OUString& rFormula);
262 void SetDocumentDisposing( bool b );
264 static void SetAutoComplete(bool bSet) { bAutoComplete = bSet; }
267 // ScInputHdlState
269 class ScInputHdlState
271 friend class ScInputHandler;
273 public:
274 ScInputHdlState( const ScAddress& rCurPos,
275 const ScAddress& rStartPos,
276 const ScAddress& rEndPos,
277 const OUString& rString,
278 const EditTextObject* pData );
279 ScInputHdlState( const ScInputHdlState& rCpy );
280 ~ScInputHdlState();
282 ScInputHdlState& operator= ( const ScInputHdlState& r );
283 bool operator==( const ScInputHdlState& r ) const;
284 bool operator!=( const ScInputHdlState& r ) const
285 { return !operator==( r ); }
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: */