xref: /aoo41x/main/sc/source/ui/inc/inputhdl.hxx (revision 38d50f7b)
1*38d50f7bSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*38d50f7bSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*38d50f7bSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*38d50f7bSAndrew Rist  * distributed with this work for additional information
6*38d50f7bSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*38d50f7bSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*38d50f7bSAndrew Rist  * "License"); you may not use this file except in compliance
9*38d50f7bSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*38d50f7bSAndrew Rist  *
11*38d50f7bSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*38d50f7bSAndrew Rist  *
13*38d50f7bSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*38d50f7bSAndrew Rist  * software distributed under the License is distributed on an
15*38d50f7bSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*38d50f7bSAndrew Rist  * KIND, either express or implied.  See the License for the
17*38d50f7bSAndrew Rist  * specific language governing permissions and limitations
18*38d50f7bSAndrew Rist  * under the License.
19*38d50f7bSAndrew Rist  *
20*38d50f7bSAndrew Rist  *************************************************************/
21*38d50f7bSAndrew Rist 
22*38d50f7bSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SC_INPUTHDL_HXX
25cdf0e10cSrcweir #define SC_INPUTHDL_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "global.hxx"
28cdf0e10cSrcweir #include "address.hxx"
29cdf0e10cSrcweir #include <tools/fract.hxx>
30cdf0e10cSrcweir #include <tools/gen.hxx>
31cdf0e10cSrcweir #include <editeng/svxenum.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir class ScDocument;
34cdf0e10cSrcweir class ScTabView;
35cdf0e10cSrcweir class ScTabViewShell;
36cdf0e10cSrcweir class ScInputWindow;
37cdf0e10cSrcweir class ScPatternAttr;
38cdf0e10cSrcweir class EditEngine;
39cdf0e10cSrcweir class ScEditEngineDefaulter;
40cdf0e10cSrcweir class EditView;
41cdf0e10cSrcweir class EditTextObject;
42cdf0e10cSrcweir class ScInputHdlState;
43cdf0e10cSrcweir class TypedScStrCollection;
44cdf0e10cSrcweir class ScRangeFindList;
45cdf0e10cSrcweir class Timer;
46cdf0e10cSrcweir class KeyEvent;
47cdf0e10cSrcweir class CommandEvent;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir struct ESelection;
50cdf0e10cSrcweir 
51cdf0e10cSrcweir //========================================================================
52cdf0e10cSrcweir //	ScInputHandler
53cdf0e10cSrcweir //========================================================================
54cdf0e10cSrcweir 
55cdf0e10cSrcweir class ScInputHandler
56cdf0e10cSrcweir {
57cdf0e10cSrcweir private:
58cdf0e10cSrcweir 	ScInputWindow*			pInputWin;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir 	ScEditEngineDefaulter*	pEngine;   				// editierte Daten in der Tabelle
61cdf0e10cSrcweir 	EditView*				pTableView;					// aktive EditView dazu
62cdf0e10cSrcweir 	EditView*				pTopView;					// EditView in der Eingabezeile
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 	TypedScStrCollection*		pColumnData;
65cdf0e10cSrcweir 	TypedScStrCollection*		pFormulaData;
66cdf0e10cSrcweir     TypedScStrCollection*		pFormulaDataPara;
67cdf0e10cSrcweir 	Window*					pTipVisibleParent;
68cdf0e10cSrcweir 	sal_uLong					nTipVisible;
69cdf0e10cSrcweir 	Window*					pTipVisibleSecParent;
70cdf0e10cSrcweir     sal_uLong                   nTipVisibleSec;
71cdf0e10cSrcweir 	String					aManualTip;
72cdf0e10cSrcweir 	String					aAutoSearch;
73cdf0e10cSrcweir 	sal_uInt16					nAutoPos;
74cdf0e10cSrcweir 	sal_Bool					bUseTab;					// Blaettern moeglich
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 	sal_Bool					bTextValid;					// Text noch nicht in Edit-Engine
77cdf0e10cSrcweir 	String					aCurrentText;
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 	String					aFormText;					// fuer Funktions-Autopilot
80cdf0e10cSrcweir 	xub_StrLen				nFormSelStart;				// Selektion fuer Funktions-Autopilot
81cdf0e10cSrcweir 	xub_StrLen				nFormSelEnd;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 	sal_uInt16					nAutoPar;					// autom.parentheses than can be overwritten
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 	ScAddress				aCursorPos;
86cdf0e10cSrcweir 	ScInputMode				eMode;
87cdf0e10cSrcweir 	sal_Bool					bModified;
88cdf0e10cSrcweir 	sal_Bool					bSelIsRef;
89cdf0e10cSrcweir 	sal_Bool					bFormulaMode;
90cdf0e10cSrcweir 	sal_Bool					bInRangeUpdate;
91cdf0e10cSrcweir 	sal_Bool					bParenthesisShown;
92cdf0e10cSrcweir 	sal_Bool					bCreatingFuncView;
93cdf0e10cSrcweir 	sal_Bool					bInEnterHandler;
94cdf0e10cSrcweir 	sal_Bool					bCommandErrorShown;
95cdf0e10cSrcweir 	sal_Bool					bInOwnChange;
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 	sal_Bool					bProtected;
98cdf0e10cSrcweir 	sal_Bool					bCellHasPercentFormat;
99cdf0e10cSrcweir 	sal_uLong					nValidation;
100cdf0e10cSrcweir     SvxCellHorJustify       eAttrAdjust;
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 	Fraction				aScaleX;					// fuer Ref-MapMode
103cdf0e10cSrcweir 	Fraction				aScaleY;
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 	ScTabViewShell*			pRefViewSh;
106cdf0e10cSrcweir 	ScTabViewShell*			pActiveViewSh;
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	const ScPatternAttr*	pLastPattern;
109cdf0e10cSrcweir 	SfxItemSet*			 	pEditDefaults;
110cdf0e10cSrcweir 	sal_Bool					bLastIsSymbol;
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 	ScInputHdlState*		pLastState;
113cdf0e10cSrcweir 	Timer*					pDelayTimer;
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 	ScRangeFindList*		pRangeFindList;
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 	static sal_Bool				bAutoComplete;				// aus App-Optionen
118cdf0e10cSrcweir 	static sal_Bool				bOptLoaded;
119cdf0e10cSrcweir 
120cdf0e10cSrcweir #ifdef _INPUTHDL_CXX
121cdf0e10cSrcweir private:
122cdf0e10cSrcweir 	void			UpdateActiveView();
123cdf0e10cSrcweir 	void			SyncViews( EditView* pSourceView = NULL );
124cdf0e10cSrcweir 	sal_Bool			StartTable( sal_Unicode cTyped, sal_Bool bFromCommand );
125cdf0e10cSrcweir 	void			RemoveSelection();
126cdf0e10cSrcweir 	void			UpdateFormulaMode();
127cdf0e10cSrcweir 	void			InvalidateAttribs();
128cdf0e10cSrcweir 	void			ImplCreateEditEngine();
129cdf0e10cSrcweir 	DECL_LINK(		DelayTimer, Timer* );
130cdf0e10cSrcweir 	void			GetColData();
131cdf0e10cSrcweir 	void			UseColData();
132cdf0e10cSrcweir 	void			NextAutoEntry( sal_Bool bBack );
133cdf0e10cSrcweir 	void			UpdateAdjust( sal_Unicode cTyped );
134cdf0e10cSrcweir 	void			GetFormulaData();
135cdf0e10cSrcweir 	void			UseFormulaData();
136cdf0e10cSrcweir 	void			NextFormulaEntry( sal_Bool bBack );
137cdf0e10cSrcweir 	void			PasteFunctionData();
138cdf0e10cSrcweir 	void			PasteManualTip();
139cdf0e10cSrcweir 	EditView*		GetFuncEditView();
140cdf0e10cSrcweir 	void			RemoveAdjust();
141cdf0e10cSrcweir 	void			RemoveRangeFinder();
142cdf0e10cSrcweir 	void			DeleteRangeFinder();
143cdf0e10cSrcweir 	void			UpdateParenthesis();
144cdf0e10cSrcweir 	void			UpdateAutoCorrFlag();
145cdf0e10cSrcweir 	void			ResetAutoPar();
146cdf0e10cSrcweir 	void			AutoParAdded();
147cdf0e10cSrcweir 	sal_Bool			CursorAtClosingPar();
148cdf0e10cSrcweir 	void			SkipClosingPar();
149cdf0e10cSrcweir 	DECL_LINK( ModifyHdl, void* );
150cdf0e10cSrcweir 	DECL_LINK( ShowHideTipVisibleParentListener, VclWindowEvent* );
151cdf0e10cSrcweir 	DECL_LINK( ShowHideTipVisibleSecParentListener, VclWindowEvent* );
152cdf0e10cSrcweir #endif
153cdf0e10cSrcweir 
154cdf0e10cSrcweir public:
155cdf0e10cSrcweir 					ScInputHandler();
156cdf0e10cSrcweir 	virtual			~ScInputHandler();
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 	void			SetMode( ScInputMode eNewMode );
IsInputMode() const159cdf0e10cSrcweir 	sal_Bool			IsInputMode() const	{ return (eMode != SC_INPUT_NONE); }
IsEditMode() const160cdf0e10cSrcweir 	sal_Bool			IsEditMode() const	{ return (eMode != SC_INPUT_NONE &&
161cdf0e10cSrcweir 												  eMode != SC_INPUT_TYPE); }
IsTopMode() const162cdf0e10cSrcweir 	sal_Bool			IsTopMode() const	{ return (eMode == SC_INPUT_TOP);  }
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 	const String&	GetEditString();
GetFormString() const165cdf0e10cSrcweir 	const String&	GetFormString() const	{ return aFormText; }
166cdf0e10cSrcweir 
GetCursorPos() const167cdf0e10cSrcweir     const ScAddress& GetCursorPos() const   { return aCursorPos; }
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 	sal_Bool			GetTextAndFields( ScEditEngineDefaulter& rDestEngine );
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 	sal_Bool			KeyInput( const KeyEvent& rKEvt, sal_Bool bStartEdit = sal_False );
172cdf0e10cSrcweir 	void			EnterHandler( sal_uInt8 nBlockMode = 0 );
173cdf0e10cSrcweir 	void			CancelHandler();
174cdf0e10cSrcweir 	void			SetReference( const ScRange& rRef, ScDocument* pDoc );
175cdf0e10cSrcweir 	void			AddRefEntry();
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 	sal_Bool			InputCommand( const CommandEvent& rCEvt, sal_Bool bForce );
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 	void			InsertFunction( const String& rFuncName, sal_Bool bAddPar = sal_True );
180cdf0e10cSrcweir 	void			ClearText();
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 	void			InputSelection( EditView* pView );
183cdf0e10cSrcweir 	void			InputChanged( EditView* pView, sal_Bool bFromNotify = sal_False );
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 	void			ViewShellGone(ScTabViewShell* pViewSh);
SetRefViewShell(ScTabViewShell * pRefVsh)186cdf0e10cSrcweir 	void			SetRefViewShell(ScTabViewShell*	pRefVsh) {pRefViewSh=pRefVsh;}
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 
189cdf0e10cSrcweir 	void			NotifyChange( const ScInputHdlState* pState, sal_Bool bForce = sal_False,
190cdf0e10cSrcweir 									ScTabViewShell* pSourceSh = NULL,
191cdf0e10cSrcweir                                     sal_Bool bStopEditing = sal_True);
192cdf0e10cSrcweir     void            UpdateCellAdjust( SvxCellHorJustify eJust );
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 	void			ResetDelayTimer(); //BugId 54702
195cdf0e10cSrcweir 
196cdf0e10cSrcweir 	void			HideTip();
197cdf0e10cSrcweir     void            HideTipBelow();
198cdf0e10cSrcweir     void            ShowTipCursor();
199cdf0e10cSrcweir 	void			ShowTip( const String& rText );		// am Cursor
200cdf0e10cSrcweir     void			ShowTipBelow( const String& rText );
201cdf0e10cSrcweir 
202cdf0e10cSrcweir 	void			SetRefScale( const Fraction& rX, const Fraction& rY );
203cdf0e10cSrcweir 	void			UpdateRefDevice();
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 	EditView*		GetActiveView();
GetTableView()206cdf0e10cSrcweir 	EditView*		GetTableView()		{ return pTableView; }
GetTopView()207cdf0e10cSrcweir 	EditView*		GetTopView()		{ return pTopView; }
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 	sal_Bool			DataChanging( sal_Unicode cTyped = 0, sal_Bool bFromCommand = sal_False );
210cdf0e10cSrcweir     void            DataChanged( sal_Bool bFromTopNotify = sal_False, sal_Bool bSetModified = sal_True );
211cdf0e10cSrcweir 
TakesReturn() const212cdf0e10cSrcweir 	sal_Bool			TakesReturn() const		{ return ( nTipVisible != 0 ); }
213cdf0e10cSrcweir 
SetModified()214cdf0e10cSrcweir 	void			SetModified()		{ bModified = sal_True; }
215cdf0e10cSrcweir 
GetSelIsRef() const216cdf0e10cSrcweir 	sal_Bool			GetSelIsRef() const		{ return bSelIsRef; }
SetSelIsRef(sal_Bool bSet)217cdf0e10cSrcweir 	void			SetSelIsRef(sal_Bool bSet)	{ bSelIsRef = bSet; }
218cdf0e10cSrcweir 
219cdf0e10cSrcweir 	void			ShowRefFrame();
220cdf0e10cSrcweir 
GetRangeFindList()221cdf0e10cSrcweir 	ScRangeFindList* GetRangeFindList()		{ return pRangeFindList; }
222cdf0e10cSrcweir 
223cdf0e10cSrcweir 	void			UpdateRange( sal_uInt16 nIndex, const ScRange& rNew );
224cdf0e10cSrcweir 
225cdf0e10cSrcweir 	// Kommunikation mit Funktionsautopilot
226cdf0e10cSrcweir 	void			InputGetSelection		( xub_StrLen& rStart, xub_StrLen& rEnd );
227cdf0e10cSrcweir 	void		 	InputSetSelection		( xub_StrLen nStart, xub_StrLen nEnd );
228cdf0e10cSrcweir 	void		 	InputReplaceSelection	( const String& rStr );
229cdf0e10cSrcweir 	String			InputGetFormulaStr		();
230cdf0e10cSrcweir 
IsFormulaMode() const231cdf0e10cSrcweir 	sal_Bool			IsFormulaMode() const					{ return bFormulaMode; }
GetInputWindow()232cdf0e10cSrcweir 	ScInputWindow*	GetInputWindow()						{ return pInputWin; }
SetInputWindow(ScInputWindow * pNew)233cdf0e10cSrcweir 	void			SetInputWindow( ScInputWindow* pNew )	{ pInputWin = pNew; }
234cdf0e10cSrcweir 	void			StopInputWinEngine( sal_Bool bAll );
235cdf0e10cSrcweir 
IsInEnterHandler() const236cdf0e10cSrcweir 	sal_Bool			IsInEnterHandler() const				{ return bInEnterHandler; }
IsInOwnChange() const237cdf0e10cSrcweir 	sal_Bool			IsInOwnChange() const					{ return bInOwnChange; }
238cdf0e10cSrcweir 
239cdf0e10cSrcweir 	sal_Bool			IsModalMode( SfxObjectShell* pDocSh );
240cdf0e10cSrcweir 
241cdf0e10cSrcweir 	void			ForgetLastPattern();
242cdf0e10cSrcweir 
243cdf0e10cSrcweir 	void			UpdateSpellSettings( sal_Bool bFromStartTab = sal_False );
244cdf0e10cSrcweir 
245cdf0e10cSrcweir 	void			FormulaPreview();
246cdf0e10cSrcweir 
247cdf0e10cSrcweir 	Size			GetTextSize();		// in 1/100mm
248cdf0e10cSrcweir 
249cdf0e10cSrcweir 					// eigentlich private, fuer SID_INPUT_SUM public
250cdf0e10cSrcweir 	void			InitRangeFinder( const String& rFormula );
251cdf0e10cSrcweir 
SetAutoComplete(sal_Bool bSet)252cdf0e10cSrcweir 	static void		SetAutoComplete(sal_Bool bSet)	{ bAutoComplete = bSet; }
253cdf0e10cSrcweir };
254cdf0e10cSrcweir 
255cdf0e10cSrcweir //========================================================================
256cdf0e10cSrcweir //	ScInputHdlState
257cdf0e10cSrcweir //========================================================================
258cdf0e10cSrcweir class ScInputHdlState
259cdf0e10cSrcweir {
260cdf0e10cSrcweir 	friend class ScInputHandler;
261cdf0e10cSrcweir 
262cdf0e10cSrcweir public:
263cdf0e10cSrcweir 		ScInputHdlState( const ScAddress& rCurPos,
264cdf0e10cSrcweir 						 const ScAddress& rStartPos,
265cdf0e10cSrcweir 						 const ScAddress& rEndPos,
266cdf0e10cSrcweir 						 const String& rString,
267cdf0e10cSrcweir 						 const EditTextObject* pData );
268cdf0e10cSrcweir 		ScInputHdlState( const ScInputHdlState& rCpy );
269cdf0e10cSrcweir 		~ScInputHdlState();
270cdf0e10cSrcweir 
271cdf0e10cSrcweir 	ScInputHdlState&	operator= ( const ScInputHdlState& r );
272cdf0e10cSrcweir 	int					operator==( const ScInputHdlState& r ) const;
operator !=(const ScInputHdlState & r) const273cdf0e10cSrcweir 	int					operator!=( const ScInputHdlState& r ) const
274cdf0e10cSrcweir 							{ return !operator==( r ); }
275cdf0e10cSrcweir 
GetPos() const276cdf0e10cSrcweir 	const ScAddress&		GetPos() const 			{ return aCursorPos; }
GetStartPos() const277cdf0e10cSrcweir 	const ScAddress&		GetStartPos() const 	{ return aStartPos; }
GetEndPos() const278cdf0e10cSrcweir 	const ScAddress& 		GetEndPos() const 		{ return aEndPos; }
GetString() const279cdf0e10cSrcweir 	const String&			GetString() const		{ return aString; }
GetEditData() const280cdf0e10cSrcweir 	const EditTextObject*	GetEditData() const		{ return pEditData; }
281cdf0e10cSrcweir 
282cdf0e10cSrcweir private:
283cdf0e10cSrcweir 	ScAddress		aCursorPos;
284cdf0e10cSrcweir 	ScAddress		aStartPos;
285cdf0e10cSrcweir 	ScAddress		aEndPos;
286cdf0e10cSrcweir 	String			aString;
287cdf0e10cSrcweir 	EditTextObject* pEditData;
288cdf0e10cSrcweir };
289cdf0e10cSrcweir 
290cdf0e10cSrcweir 
291cdf0e10cSrcweir 
292cdf0e10cSrcweir #endif
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 
295