1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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
35 #include "address.hxx"
36 #include <tools/fract.hxx>
37 #include <tools/gen.hxx>
38 #include <svx/svxenum.hxx>
46 class ScEditEngineDefaulter
;
49 class ScInputHdlState
;
50 class TypedScStrCollection
;
51 class ScRangeFindList
;
58 //========================================================================
60 //========================================================================
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
;
79 BOOL bUseTab
; // Blaettern moeglich
81 BOOL bTextValid
; // Text noch nicht in Edit-Engine
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
96 BOOL bParenthesisShown
;
97 BOOL bCreatingFuncView
;
99 BOOL bCommandErrorShown
;
103 BOOL bCellHasPercentFormat
;
105 SvxCellHorJustify eAttrAdjust
;
107 Fraction aScaleX
; // fuer Ref-MapMode
110 ScTabViewShell
* pRefViewSh
;
111 ScTabViewShell
* pActiveViewSh
;
113 const ScPatternAttr
* pLastPattern
;
114 SfxItemSet
* pEditDefaults
;
117 ScInputHdlState
* pLastState
;
120 ScRangeFindList
* pRangeFindList
;
122 static BOOL bAutoComplete
; // aus App-Optionen
123 static BOOL bOptLoaded
;
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
* );
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();
146 void RemoveRangeFinder();
147 void DeleteRangeFinder();
148 void UpdateParenthesis();
149 void UpdateAutoCorrFlag();
152 BOOL
CursorAtClosingPar();
153 void SkipClosingPar();
154 DECL_LINK( ModifyHdl
, void* );
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
);
178 BOOL
InputCommand( const CommandEvent
& rCEvt
, BOOL bForce
);
180 void InsertFunction( const String
& rFuncName
, BOOL bAddPar
= TRUE
);
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
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
; }
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 //========================================================================
258 //========================================================================
259 class ScInputHdlState
261 friend class ScInputHandler
;
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
);
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
; }
284 ScAddress aCursorPos
;
288 EditTextObject
* pEditData
;