Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef SC_INPUTWIN_HXX
30 : : #define SC_INPUTWIN_HXX
31 : :
32 : : #include <vector>
33 : : #include <vcl/toolbox.hxx>
34 : : #include <sfx2/childwin.hxx>
35 : : #include <svl/lstner.hxx>
36 : : #include <vcl/button.hxx>
37 : : #include <vcl/combobox.hxx>
38 : : #include <vcl/scrbar.hxx>
39 : : #include <vcl/window.hxx>
40 : : #include <svtools/transfer.hxx>
41 : :
42 : : class ScEditEngineDefaulter;
43 : : class EditView;
44 : : struct ESelection;
45 : : class ScInputHandler;
46 : : class ScAccessibleEditLineTextData;
47 : : struct EENotify;
48 : : class ScRangeList;
49 : : class ScTabViewShell;
50 : :
51 : : //========================================================================
52 : :
53 [ - + ]: 450 : class ScTextWndBase : public Window
54 : : {
55 : : public:
56 : : ScTextWndBase( Window* pParent, WinBits nStyle );
57 : : virtual void InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData ) = 0;
58 : : virtual void RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData ) = 0;
59 : : virtual void SetTextString( const String& rString ) = 0;
60 : : virtual const String& GetTextString() const = 0;
61 : : virtual void StartEditEngine() = 0;
62 : : virtual void StopEditEngine( sal_Bool bAll ) = 0;
63 : : virtual EditView* GetEditView() = 0;
64 : : virtual void MakeDialogEditView() = 0;
65 : : virtual void SetFormulaMode( sal_Bool bSet ) = 0;
66 : : virtual sal_Bool IsInputActive() = 0;
67 : : virtual void TextGrabFocus() = 0;
68 : : };
69 : :
70 : : class ScTextWnd : public ScTextWndBase, public DragSourceHelper // edit window
71 : : {
72 : : public:
73 : : ScTextWnd( Window* pParent, ScTabViewShell* pViewSh );
74 : : virtual ~ScTextWnd();
75 : :
76 : : virtual void SetTextString( const String& rString );
77 : : virtual const String& GetTextString() const;
78 : :
79 : : sal_Bool IsInputActive();
80 : : virtual EditView* GetEditView();
81 : :
82 : : // for function autopilots
83 : : virtual void MakeDialogEditView();
84 : :
85 : : virtual void StartEditEngine();
86 : : virtual void StopEditEngine( sal_Bool bAll );
87 : :
88 : : virtual void TextGrabFocus();
89 : :
90 : : virtual void DataChanged( const DataChangedEvent& rDCEvt );
91 : :
92 : : virtual void SetFormulaMode( sal_Bool bSet );
93 : :
94 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
95 : :
96 : : virtual void InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData );
97 : : virtual void RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData );
98 : :
99 : : DECL_LINK( NotifyHdl, void* );
100 : :
101 : : protected:
102 : : virtual void Paint( const Rectangle& rRec );
103 : : virtual void Resize();
104 : :
105 : : virtual void MouseMove( const MouseEvent& rMEvt );
106 : : virtual void MouseButtonDown( const MouseEvent& rMEvt );
107 : : virtual void MouseButtonUp( const MouseEvent& rMEvt );
108 : : virtual void Command( const CommandEvent& rCEvt );
109 : : virtual void KeyInput(const KeyEvent& rKEvt);
110 : : virtual void GetFocus();
111 : : virtual void LoseFocus();
112 : :
113 : : virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
114 : :
115 : : virtual String GetText() const;
116 : :
117 : : void ImplInitSettings();
118 : : void UpdateAutoCorrFlag();
119 : :
120 : : ScTabViewShell* GetViewShell();
121 : :
122 : : typedef ::std::vector< ScAccessibleEditLineTextData* > AccTextDataVector;
123 : :
124 : : String aString;
125 : : Font aTextFont;
126 : : ScEditEngineDefaulter* pEditEngine; // only created when needed
127 : : EditView* pEditView;
128 : : AccTextDataVector maAccTextDatas; // #i105267# text datas may be cloned, remember all copies
129 : : sal_Bool bIsRTL;
130 : : sal_Bool bIsInsertMode;
131 : : sal_Bool bFormulaMode;
132 : :
133 : : // #102710#; this flag should be true if a key input or a command is handled
134 : : // it prevents the call of InputChanged in the ModifyHandler of the EditEngine
135 : : sal_Bool bInputMode;
136 : :
137 : : private:
138 : : ScTabViewShell* mpViewShell;
139 : : };
140 : :
141 : : //========================================================================
142 : :
143 : : class ScPosWnd : public ComboBox, public SfxListener // Display position
144 : : {
145 : : private:
146 : : String aPosStr;
147 : : Accelerator* pAccel;
148 : : sal_uLong nTipVisible;
149 : : sal_Bool bFormulaMode;
150 : : sal_Bool bTopHadFocus;
151 : :
152 : : public:
153 : : ScPosWnd( Window* pParent );
154 : : virtual ~ScPosWnd();
155 : :
156 : : void SetPos( const String& rPosStr ); // Displayed Text
157 : : void SetFormulaMode( sal_Bool bSet );
158 : :
159 : : protected:
160 : : virtual void Select();
161 : : virtual void Modify();
162 : :
163 : : virtual long Notify( NotifyEvent& rNEvt );
164 : :
165 : : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
166 : :
167 : : private:
168 : : void FillRangeNames();
169 : : void FillFunctions();
170 : : void DoEnter();
171 : : void HideTip();
172 : :
173 : : void ReleaseFocus_Impl();
174 : : };
175 : :
176 : : //========================================================================
177 : : class ScInputBarGroup;
178 : :
179 : : class ScMultiTextWnd : public ScTextWnd
180 : : {
181 : : public:
182 : : ScMultiTextWnd( ScInputBarGroup* pParent, ScTabViewShell* pViewSh );
183 : : virtual ~ScMultiTextWnd();
184 : : virtual void StartEditEngine();
185 : : virtual void StopEditEngine( sal_Bool bAll );
186 : : virtual void Resize();
187 : : virtual EditView* GetEditView();
188 : : long GetPixelHeightForLines( long nLines );
189 : : long GetEditEngTxtHeight();
190 : :
191 : : void DoScroll();
192 : : virtual void SetTextString( const String& rString );
193 : : void SetNumLines( long nLines );
194 : 3829 : long GetNumLines() { return mnLines; }
195 : 0 : long GetLastNumExpandedLines() { return mnLastExpandedLines; }
196 : : protected:
197 : : void SetScrollBarRange();
198 : : void InitEditEngine();
199 : :
200 : : virtual void Paint( const Rectangle& rRec );
201 : : DECL_LINK( NotifyHdl, EENotify* );
202 : : DECL_LINK( ModifyHdl, EENotify* );
203 : : private:
204 : : long GetPixelTextHeight();
205 : : ScInputBarGroup& mrGroupBar;
206 : : long mnLines;
207 : : long mnLastExpandedLines;
208 : : long mnBorderHeight;
209 : : bool mbInvalidate;
210 : : };
211 : :
212 : : class ScInputBarGroup : public ScTextWndBase
213 : : {
214 : :
215 : : public:
216 : : ScInputBarGroup( Window* Parent, ScTabViewShell* pViewSh );
217 : : virtual ~ScInputBarGroup();
218 : : virtual void InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData );
219 : : virtual void RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData );
220 : : // virtual void Paint(const Rectangle& rRec );
221 : : void SetTextString( const String& rString );
222 : : void StartEditEngine();
223 : : EditView* GetEditView();
224 : : void SetSize(Size aSize);
225 : : virtual void Resize();
226 : : virtual const String& GetTextString() const;
227 : : virtual void StopEditEngine( sal_Bool bAll );
228 : : virtual void TextGrabFocus();
229 : : void InitEditEngine(SfxObjectShell* pObjSh);
230 : : void SetFormulaMode( sal_Bool bSet );
231 : : bool IsFocus();
232 : : void MakeDialogEditView();
233 : : sal_Bool IsInputActive();
234 : 422 : ScrollBar& GetScrollBar() { return aScrollBar; }
235 : : void IncrementVerticalSize();
236 : : void DecrementVerticalSize();
237 : 1374 : long GetNumLines() { return aMultiTextWnd.GetNumLines(); }
238 : 0 : long GetVertOffset() { return nVertOffset; }
239 : : private:
240 : : void TriggerToolboxLayout();
241 : : ScMultiTextWnd aMultiTextWnd;
242 : : ImageButton aButton;
243 : : ScrollBar aScrollBar;
244 : : long nVertOffset;
245 : : DECL_LINK( ClickHdl, void* );
246 : : DECL_LINK( Impl_ScrollHdl, void* );
247 : :
248 : : };
249 : :
250 : :
251 : : class ScInputWindow : public ToolBox // Parent toolbox
252 : : {
253 : : public:
254 : : ScInputWindow( Window* pParent, SfxBindings* pBind );
255 : : virtual ~ScInputWindow();
256 : :
257 : : virtual void Paint( const Rectangle& rRect );
258 : : virtual void Resize();
259 : : virtual void Select();
260 : :
261 : : void SetFuncString( const String& rString, sal_Bool bDoEdit = sal_True );
262 : : void SetPosString( const String& rStr );
263 : : void SetTextString( const String& rString );
264 : :
265 : : void SetOkCancelMode();
266 : : void SetSumAssignMode();
267 : : void EnableButtons( sal_Bool bEnable = sal_True );
268 : :
269 : : void SetFormulaMode( sal_Bool bSet );
270 : :
271 : : virtual sal_Bool IsInputActive();
272 : : EditView* GetEditView();
273 : :
274 : : void TextGrabFocus();
275 : : void TextInvalidate();
276 : : void SwitchToTextWin();
277 : :
278 : : void PosGrabFocus();
279 : :
280 : : // For function autopilots
281 : : void MakeDialogEditView();
282 : :
283 : : void StopEditEngine( sal_Bool bAll );
284 : :
285 : : void SetInputHandler( ScInputHandler* pNew );
286 : :
287 : 32 : ScInputHandler* GetInputHandler(){ return pInputHdl;}
288 : :
289 : : void StateChanged( StateChangedType nType );
290 : : virtual void DataChanged( const DataChangedEvent& rDCEvt );
291 : : virtual void MouseButtonUp( const MouseEvent& rMEvt );
292 : : virtual void MouseButtonDown( const MouseEvent& rMEvt );
293 : : virtual void MouseMove( const MouseEvent& rMEvt );
294 : 28 : bool IsMultiLineInput() { return mbIsMultiLine; }
295 : : protected:
296 : : virtual void SetText( const String& rString );
297 : : virtual String GetText() const;
298 : :
299 : : bool UseSubTotal( ScRangeList* pRangeList ) const;
300 : : bool IsPointerAtResizePos();
301 : : private:
302 : : ScPosWnd aWndPos;
303 : : std::auto_ptr<ScTextWndBase> pRuntimeWindow;
304 : : ScTextWndBase& aTextWindow;
305 : : ScInputHandler* pInputHdl;
306 : : SfxBindings* pBindings;
307 : : String aTextOk;
308 : : String aTextCancel;
309 : : String aTextSum;
310 : : String aTextEqual;
311 : : long mnMaxY;
312 : : sal_Bool bIsOkCancelMode;
313 : : bool bIsMultiLine;
314 : : bool bInResize;
315 : : bool mbIsMultiLine;
316 : : };
317 : :
318 : : //==================================================================
319 : :
320 [ - + ]: 450 : class ScInputWindowWrapper : public SfxChildWindow
321 : : {
322 : : public:
323 : : ScInputWindowWrapper( Window* pParent,
324 : : sal_uInt16 nId,
325 : : SfxBindings* pBindings,
326 : : SfxChildWinInfo* pInfo );
327 : :
328 : : SFX_DECL_CHILDWINDOW_WITHID(ScInputWindowWrapper);
329 : : };
330 : :
331 : :
332 : : #endif
333 : :
334 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|