xref: /aoo4110/main/sc/source/ui/inc/inputwin.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_INPUTWIN_HXX
25 #define SC_INPUTWIN_HXX
26 
27 #include <vector>
28 #include <vcl/toolbox.hxx>
29 #include <sfx2/childwin.hxx>
30 #include <svl/lstner.hxx>
31 #include <vcl/combobox.hxx>
32 #include <vcl/window.hxx>
33 #include <svtools/transfer.hxx>
34 
35 class ScEditEngineDefaulter;
36 class EditView;
37 struct ESelection;
38 class ScInputHandler;
39 class ScAccessibleEditLineTextData;
40 struct EENotify;
41 class ScRangeList;
42 
43 //========================================================================
44 
45 class ScTextWnd : public Window, public DragSourceHelper		// edit window
46 {
47 public:
48 					ScTextWnd( Window* pParent );
49 	virtual			~ScTextWnd();
50 
51 	void			SetTextString( const String& rString );
52 	const String&	GetTextString() const;
53 
54 	sal_Bool			IsInputActive();
55 	EditView*		GetEditView();
56 
57 						// fuer FunktionsAutopiloten
58 	void			MakeDialogEditView();
59 
60 	void			StartEditEngine();
61 	void			StopEditEngine( sal_Bool bAll );
62 
63 	virtual void	DataChanged( const DataChangedEvent& rDCEvt );
64 
65 	void			SetFormulaMode( sal_Bool bSet );
66 
67 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
68 
69     void            InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData );
70     void            RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData );
71 
72 	DECL_LINK( NotifyHdl, EENotify* );
73 
74 protected:
75 	virtual void	Paint( const Rectangle& rRec );
76 	virtual void	Resize();
77 
78 	virtual void	MouseMove( const MouseEvent& rMEvt );
79 	virtual void	MouseButtonDown( const MouseEvent& rMEvt );
80 	virtual void	MouseButtonUp( const MouseEvent& rMEvt );
81 	virtual void	Command( const CommandEvent& rCEvt );
82 	virtual void	KeyInput(const KeyEvent& rKEvt);
83 	virtual void	GetFocus();
84 	virtual void	LoseFocus();
85 
86 	virtual void	StartDrag( sal_Int8 nAction, const Point& rPosPixel );
87 
88 	virtual String	GetText() const;
89 
90 private:
91 	void			ImplInitSettings();
92 	void			UpdateAutoCorrFlag();
93 
94 private:
95     typedef ::std::vector< ScAccessibleEditLineTextData* > AccTextDataVector;
96 
97 	String		aString;
98 	Font		aTextFont;
99 	ScEditEngineDefaulter*	pEditEngine;			// erst bei Bedarf angelegt
100 	EditView*	pEditView;
101     AccTextDataVector maAccTextDatas;   // #i105267# text datas may be cloned, remember all copies
102     sal_Bool		bIsRTL;
103 	sal_Bool		bIsInsertMode;
104 	sal_Bool		bFormulaMode;
105 
106     // #102710#; this flag should be true if a key input or a command is handled
107     // it prevents the call of InputChanged in the ModifyHandler of the EditEngine
108     sal_Bool        bInputMode;
109 };
110 
111 //========================================================================
112 
113 class ScPosWnd : public ComboBox, public SfxListener		// Positionsanzeige
114 {
115 private:
116 	String			aPosStr;
117 	Accelerator*	pAccel;
118     sal_uLong           nTipVisible;
119 	sal_Bool			bFormulaMode;
120 	sal_Bool			bTopHadFocus;
121 
122 public:
123 					ScPosWnd( Window* pParent );
124 	virtual			~ScPosWnd();
125 
126 	void			SetPos( const String& rPosStr );		// angezeigter Text
127 	void			SetFormulaMode( sal_Bool bSet );
128 
129 protected:
130 	virtual void	Select();
131     virtual void    Modify();
132 
133 	virtual long	Notify( NotifyEvent& rNEvt );
134 
135 	virtual void 	Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
136 
137 private:
138 	void			FillRangeNames();
139 	void			FillFunctions();
140 	void			DoEnter();
141     void            HideTip();
142 
143 	void			ReleaseFocus_Impl();
144 };
145 
146 //========================================================================
147 
148 class ScInputWindow : public ToolBox						// Parent-Toolbox
149 {
150 public:
151                     ScInputWindow( Window* pParent, SfxBindings* pBind );
152 	virtual			~ScInputWindow();
153 
154 	virtual void 	Resize();
155 	virtual void    Select();
156 
157 	void			SetFuncString( const String& rString, sal_Bool bDoEdit = sal_True );
158 	void			SetPosString( const String& rStr );
159 	void			SetTextString( const String& rString );
160 
161 	void 			SetOkCancelMode();
162 	void 			SetSumAssignMode();
163 	void			EnableButtons( sal_Bool bEnable = sal_True );
164 
165 	void			SetFormulaMode( sal_Bool bSet );
166 
167 	sal_Bool			IsInputActive();
168 	EditView*		GetEditView();
169 //UNUSED2008-05  EditView*		ActivateEdit( const String&     rText,
170 //UNUSED2008-05                                const ESelection& rSel );
171 
172 	void			TextGrabFocus();
173 	void			TextInvalidate();
174 	void			SwitchToTextWin();
175 
176 	void			PosGrabFocus();
177 
178 	// Fuer FunktionsAutopiloten
179 	void			MakeDialogEditView();
180 
181 	void			StopEditEngine( sal_Bool bAll );
182 
183 	void			SetInputHandler( ScInputHandler* pNew );
184 
GetInputHandler()185 	ScInputHandler*	GetInputHandler(){ return pInputHdl;}
186 
187 	void			StateChanged( StateChangedType nType );
188 	virtual void	DataChanged( const DataChangedEvent& rDCEvt );
189 
190 
191 protected:
192 	virtual void	SetText( const String& rString );
193 	virtual String	GetText() const;
194 
195     sal_Bool        UseSubTotal( ScRangeList* pRangeList ) const;
196 
197 private:
198 	ScPosWnd		aWndPos;
199 	ScTextWnd		aTextWindow;
200 	ScInputHandler*	pInputHdl;
201     SfxBindings*    pBindings;
202 	String			aTextOk;
203 	String			aTextCancel;
204 	String			aTextSum;
205 	String			aTextEqual;
206 	sal_Bool			bIsOkCancelMode;
207 };
208 
209 //==================================================================
210 
211 class ScInputWindowWrapper : public SfxChildWindow
212 {
213 public:
214 			ScInputWindowWrapper( Window*			pParent,
215 								  sal_uInt16			nId,
216 								  SfxBindings*		pBindings,
217 								  SfxChildWinInfo*	pInfo );
218 
219 	SFX_DECL_CHILDWINDOW(ScInputWindowWrapper);
220 };
221 
222 
223 #endif
224 
225