Update ooo320-m1
[ooovba.git] / sc / source / ui / inc / inputhdl.hxx
blob94dfb2ed6b707cb637b07dcce7618a2f85c884ff
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: inputhdl.hxx,v $
10 * $Revision: 1.15.32.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_INPUTHDL_HXX
32 #define SC_INPUTHDL_HXX
34 #include "global.hxx"
35 #include "address.hxx"
36 #include <tools/fract.hxx>
37 #include <tools/gen.hxx>
38 #include <svx/svxenum.hxx>
40 class ScDocument;
41 class ScTabView;
42 class ScTabViewShell;
43 class ScInputWindow;
44 class ScPatternAttr;
45 class EditEngine;
46 class ScEditEngineDefaulter;
47 class EditView;
48 class EditTextObject;
49 class ScInputHdlState;
50 class TypedScStrCollection;
51 class ScRangeFindList;
52 class Timer;
53 class KeyEvent;
54 class CommandEvent;
56 struct ESelection;
58 //========================================================================
59 // ScInputHandler
60 //========================================================================
62 class ScInputHandler
64 private:
65 ScInputWindow* pInputWin;
67 ScEditEngineDefaulter* pEngine; // editierte Daten in der Tabelle
68 EditView* pTableView; // aktive EditView dazu
69 EditView* pTopView; // EditView in der Eingabezeile
71 TypedScStrCollection* pColumnData;
72 TypedScStrCollection* pFormulaData;
73 TypedScStrCollection* pFormulaDataPara;
74 ULONG nTipVisible;
75 ULONG nTipVisibleSec;
76 String aManualTip;
77 String aAutoSearch;
78 USHORT nAutoPos;
79 BOOL bUseTab; // Blaettern moeglich
81 BOOL bTextValid; // Text noch nicht in Edit-Engine
82 String aCurrentText;
84 String aFormText; // fuer Funktions-Autopilot
85 xub_StrLen nFormSelStart; // Selektion fuer Funktions-Autopilot
86 xub_StrLen nFormSelEnd;
88 USHORT nAutoPar; // autom.parentheses than can be overwritten
90 ScAddress aCursorPos;
91 ScInputMode eMode;
92 BOOL bModified;
93 BOOL bSelIsRef;
94 BOOL bFormulaMode;
95 BOOL bInRangeUpdate;
96 BOOL bParenthesisShown;
97 BOOL bCreatingFuncView;
98 BOOL bInEnterHandler;
99 BOOL bCommandErrorShown;
100 BOOL bInOwnChange;
102 BOOL bProtected;
103 BOOL bCellHasPercentFormat;
104 ULONG nValidation;
105 SvxCellHorJustify eAttrAdjust;
107 Fraction aScaleX; // fuer Ref-MapMode
108 Fraction aScaleY;
110 ScTabViewShell* pRefViewSh;
111 ScTabViewShell* pActiveViewSh;
113 const ScPatternAttr* pLastPattern;
114 SfxItemSet* pEditDefaults;
115 BOOL bLastIsSymbol;
117 ScInputHdlState* pLastState;
118 Timer* pDelayTimer;
120 ScRangeFindList* pRangeFindList;
122 static BOOL bAutoComplete; // aus App-Optionen
123 static BOOL bOptLoaded;
125 #ifdef _INPUTHDL_CXX
126 private:
127 void UpdateActiveView();
128 void SyncViews( EditView* pSourceView = NULL );
129 BOOL StartTable( sal_Unicode cTyped, BOOL bFromCommand );
130 void RemoveSelection();
131 void UpdateFormulaMode();
132 void InvalidateAttribs();
133 void ImplCreateEditEngine();
134 DECL_LINK( DelayTimer, Timer* );
135 void GetColData();
136 void UseColData();
137 void NextAutoEntry( BOOL bBack );
138 void UpdateAdjust( sal_Unicode cTyped );
139 void GetFormulaData();
140 void UseFormulaData();
141 void NextFormulaEntry( BOOL bBack );
142 void PasteFunctionData();
143 void PasteManualTip();
144 EditView* GetFuncEditView();
145 void RemoveAdjust();
146 void RemoveRangeFinder();
147 void DeleteRangeFinder();
148 void UpdateParenthesis();
149 void UpdateAutoCorrFlag();
150 void ResetAutoPar();
151 void AutoParAdded();
152 BOOL CursorAtClosingPar();
153 void SkipClosingPar();
154 DECL_LINK( ModifyHdl, void* );
155 #endif
157 public:
158 ScInputHandler();
159 virtual ~ScInputHandler();
161 void SetMode( ScInputMode eNewMode );
162 BOOL IsInputMode() const { return (eMode != SC_INPUT_NONE); }
163 BOOL IsEditMode() const { return (eMode != SC_INPUT_NONE &&
164 eMode != SC_INPUT_TYPE); }
165 BOOL IsTopMode() const { return (eMode == SC_INPUT_TOP); }
167 const String& GetEditString();
168 const String& GetFormString() const { return aFormText; }
170 BOOL GetTextAndFields( ScEditEngineDefaulter& rDestEngine );
172 BOOL KeyInput( const KeyEvent& rKEvt, BOOL bStartEdit = FALSE );
173 void EnterHandler( BYTE nBlockMode = 0 );
174 void CancelHandler();
175 void SetReference( const ScRange& rRef, ScDocument* pDoc );
176 void AddRefEntry();
178 BOOL InputCommand( const CommandEvent& rCEvt, BOOL bForce );
180 void InsertFunction( const String& rFuncName, BOOL bAddPar = TRUE );
181 void ClearText();
183 void InputSelection( EditView* pView );
184 void InputChanged( EditView* pView, BOOL bFromNotify = FALSE );
186 void ViewShellGone(ScTabViewShell* pViewSh);
187 void SetRefViewShell(ScTabViewShell* pRefVsh) {pRefViewSh=pRefVsh;}
190 void NotifyChange( const ScInputHdlState* pState, BOOL bForce = FALSE,
191 ScTabViewShell* pSourceSh = NULL,
192 BOOL bStopEditing = TRUE);
193 void UpdateCellAdjust( SvxCellHorJustify eJust );
195 void ResetDelayTimer(); //BugId 54702
197 void HideTip();
198 void HideTipBelow();
199 void ShowTipCursor();
200 void ShowTip( const String& rText ); // am Cursor
201 void ShowTipBelow( const String& rText );
203 void SetRefScale( const Fraction& rX, const Fraction& rY );
204 void UpdateRefDevice();
206 EditView* GetActiveView();
207 EditView* GetTableView() { return pTableView; }
208 EditView* GetTopView() { return pTopView; }
210 BOOL DataChanging( sal_Unicode cTyped = 0, BOOL bFromCommand = FALSE );
211 void DataChanged( BOOL bFromTopNotify = FALSE );
213 BOOL TakesReturn() const { return ( nTipVisible != 0 ); }
215 void SetModified() { bModified = TRUE; }
217 BOOL GetSelIsRef() const { return bSelIsRef; }
218 void SetSelIsRef(BOOL bSet) { bSelIsRef = bSet; }
220 void ShowRefFrame();
222 ScRangeFindList* GetRangeFindList() { return pRangeFindList; }
224 void UpdateRange( USHORT nIndex, const ScRange& rNew );
226 // Kommunikation mit Funktionsautopilot
227 void InputGetSelection ( xub_StrLen& rStart, xub_StrLen& rEnd );
228 void InputSetSelection ( xub_StrLen nStart, xub_StrLen nEnd );
229 void InputReplaceSelection ( const String& rStr );
230 String InputGetFormulaStr ();
232 BOOL IsFormulaMode() const { return bFormulaMode; }
233 ScInputWindow* GetInputWindow() { return pInputWin; }
234 void SetInputWindow( ScInputWindow* pNew ) { pInputWin = pNew; }
235 void StopInputWinEngine( BOOL bAll );
237 BOOL IsInEnterHandler() const { return bInEnterHandler; }
238 BOOL IsInOwnChange() const { return bInOwnChange; }
240 BOOL IsModalMode( SfxObjectShell* pDocSh );
242 void ForgetLastPattern();
244 void UpdateSpellSettings( BOOL bFromStartTab = FALSE );
246 void FormulaPreview();
248 Size GetTextSize(); // in 1/100mm
250 // eigentlich private, fuer SID_INPUT_SUM public
251 void InitRangeFinder( const String& rFormula );
253 static void SetAutoComplete(BOOL bSet) { bAutoComplete = bSet; }
256 //========================================================================
257 // ScInputHdlState
258 //========================================================================
259 class ScInputHdlState
261 friend class ScInputHandler;
263 public:
264 ScInputHdlState( const ScAddress& rCurPos,
265 const ScAddress& rStartPos,
266 const ScAddress& rEndPos,
267 const String& rString,
268 const EditTextObject* pData );
269 ScInputHdlState( const ScInputHdlState& rCpy );
270 ~ScInputHdlState();
272 ScInputHdlState& operator= ( const ScInputHdlState& r );
273 int operator==( const ScInputHdlState& r ) const;
274 int operator!=( const ScInputHdlState& r ) const
275 { return !operator==( r ); }
277 const ScAddress& GetPos() const { return aCursorPos; }
278 const ScAddress& GetStartPos() const { return aStartPos; }
279 const ScAddress& GetEndPos() const { return aEndPos; }
280 const String& GetString() const { return aString; }
281 const EditTextObject* GetEditData() const { return pEditData; }
283 private:
284 ScAddress aCursorPos;
285 ScAddress aStartPos;
286 ScAddress aEndPos;
287 String aString;
288 EditTextObject* pEditData;
293 #endif