xref: /aoo42x/main/svx/source/inc/gridcell.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _SVX_GRIDCELL_HXX
29 #define _SVX_GRIDCELL_HXX
30 
31 #include <svx/gridctrl.hxx>
32 
33 #include "sqlparserclient.hxx"
34 #include "typeconversionclient.hxx"
35 
36 /** === begin UNO includes === **/
37 #include <com/sun/star/sdb/XColumn.hpp>
38 #include <com/sun/star/form/XBoundControl.hpp>
39 #include <com/sun/star/awt/XTextComponent.hpp>
40 #include <com/sun/star/awt/XListBox.hpp>
41 #include <com/sun/star/awt/XComboBox.hpp>
42 #include <com/sun/star/awt/TextAlign.hpp>
43 #include <com/sun/star/awt/XControlModel.hpp>
44 #include <com/sun/star/awt/XControl.hpp>
45 #include <com/sun/star/awt/XCheckBox.hpp>
46 #include <com/sun/star/awt/XButton.hpp>
47 #include <com/sun/star/beans/XFastPropertySet.hpp>
48 #include <com/sun/star/lang/XUnoTunnel.hpp>
49 #include <com/sun/star/form/XChangeBroadcaster.hpp>
50 #include <com/sun/star/awt/XWindow.hpp>
51 /** === end UNO includes === **/
52 
53 #include <comphelper/propmultiplex.hxx>
54 #include <comphelper/componentcontext.hxx>
55 #include <cppuhelper/component.hxx>
56 #include <cppuhelper/implbase1.hxx>
57 #include <cppuhelper/implbase2.hxx>
58 #include <tools/diagnose_ex.h>
59 #include <tools/rtti.hxx>
60 
61 class DbCellControl;
62 class Edit;
63 class FmXGridCell;
64 
65 //==================================================================
66 // FmMutexHelper
67 //==================================================================
68 class FmMutexHelper
69 {
70 protected:
71 	::osl::Mutex	m_aMutex;
72 };
73 
74 //==================================================================
75 // DbGridColumn, Spaltenbeschreibung
76 //==================================================================
77 class DbGridColumn
78 {
79 	friend class DbGridControl;
80 
81 	::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >		m_xModel;
82 	::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >		m_xField;		// Verbindung zum Datenbankfeld
83 	::svt::CellControllerRef m_xController; // Struktur zum Verwalten der Controls fuer eine Spalte
84 										// diese wird von der DbBrowseBox auf die jeweiligen Zellen
85 										// einer Spalte positioniert
86 	FmXGridCell*				m_pCell;
87 
88 protected:
89 	DbGridControl&		m_rParent;
90 
91 private:
92 	sal_Int32				m_nLastVisibleWidth;	// nur gueltig, wenn m_bHidden == sal_True
93 	sal_Int32				m_nFormatKey;
94 	sal_Int16				m_nFieldType;
95 	sal_Int16				m_nTypeId;
96 	sal_uInt16				m_nId;
97 	sal_Int16				m_nFieldPos;
98 	sal_Int16				m_nAlign;						// wird mit TXT_ALIGN_LEFT .... angegeben
99 	sal_Bool				m_bReadOnly : 1;
100 	sal_Bool				m_bAutoValue : 1;
101 	sal_Bool				m_bInSave : 1;
102 	sal_Bool				m_bNumeric : 1;
103 	sal_Bool				m_bObject : 1;	// Verweist die Column auf ein Object Datentyp?
104 	sal_Bool				m_bHidden : 1;
105 	sal_Bool				m_bLocked : 1;
106 	sal_Bool				m_bDateTime : 1;
107 
108 	static ::svt::CellControllerRef s_xEmptyController;
109 		// used by locked columns
110 public:
111 	DbGridColumn(sal_uInt16 _nId, DbGridControl& rParent)
112         :m_pCell(NULL)
113         ,m_rParent(rParent)
114         ,m_nLastVisibleWidth(-1)
115         ,m_nFormatKey(0)
116         ,m_nFieldType(0)
117         ,m_nTypeId(0)
118         ,m_nId(_nId)
119         ,m_nFieldPos(-1)
120         ,m_nAlign(::com::sun::star::awt::TextAlign::LEFT)
121         ,m_bReadOnly(sal_False)
122         ,m_bAutoValue(sal_False)
123         ,m_bInSave(sal_False)
124         ,m_bNumeric(sal_False)
125         ,m_bObject(sal_False)
126         ,m_bHidden(sal_False)
127         ,m_bLocked(sal_False)
128 		,m_bDateTime(sal_False)
129 	{
130 	}
131 
132 	~DbGridColumn();
133 
134 	const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& getModel() const { return m_xModel; }
135 	void  setModel(::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >  _xModel);
136 
137 
138 	sal_uInt16	GetId() const {return m_nId;}
139 	sal_Bool	IsReadOnly() const {return m_bReadOnly;}
140 	sal_Bool	IsAutoValue() const {return m_bAutoValue;}
141 	sal_Bool	IsUpdating() const {return m_bInSave;}
142 	sal_Int16	GetAlignment() const {return m_nAlign;}
143 	sal_Int16	GetType() const {return m_nFieldType;}
144 	sal_Int16	GetFieldPos() const {return m_nFieldPos; }
145 	sal_Bool	IsNumeric() const {return m_bNumeric;}
146 	sal_Bool	IsDateTime() const {return m_bDateTime;}
147 	sal_Bool	IsObject() const {return m_bObject;}
148 	sal_Bool	IsHidden() const {return m_bHidden;}
149 	sal_Int32	GetKey() const {return m_nFormatKey;}
150 	const	::svt::CellControllerRef& GetController() const {return m_bLocked ? s_xEmptyController : m_xController;}
151 	const	::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& GetField() const {return m_xField;}
152 	DbGridControl& GetParent() const {return m_rParent;}
153 	FmXGridCell* GetCell() const {return m_pCell;}
154 
155 	::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >	GetCurrentFieldValue() const;
156 
157 	//		Zeichnen eines Feldes an einer Position, ist ein ::com::sun::star::sdbcx::View gesetzt
158 	//		uebernimmt dieser das Zeichnen, z.B. fuer CheckBoxen
159 	void	Paint(OutputDevice& rDev,
160 				  const Rectangle& rRect,
161 				  const DbGridRow* pRow,
162 				  const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
163 
164 
165 	//		Inititialierung im alive mode
166 	//		Ist kein ColumnController gesetzt, wird eine DefaultInitialisierung
167 	//		vorgenommen
168 	void	CreateControl(sal_Int32 _nFieldPos, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xField, sal_Int32 nTypeId);
169 	void	UpdateControl()
170 			{
171 				::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >  xField(m_xField);
172 				CreateControl(m_nFieldPos, xField, m_nTypeId);
173 			}
174 
175 	//		Editieren einer Zelle
176 	void	UpdateFromField(const DbGridRow* pRow, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
177 	sal_Bool	Commit();
178 
179 	//		freigeben aller Daten, die fuer den AliveMode noetig sind
180 	void	Clear();
181 
182 	XubString  GetCellText(const DbGridRow* pRow, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter) const;
183 	XubString  GetCellText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& xField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter) const;
184 
185 	void	SetReadOnly(sal_Bool bRead){m_bReadOnly = bRead;}
186 	void	SetObject(sal_Int16 nPos) {m_bObject = m_bReadOnly = sal_True; m_nFieldPos = nPos;}
187 
188 	void	ImplInitWindow( Window& rParent, const InitWindowFacet _eInitWhat );
189 
190 	// Properties, die auf den ::com::sun::star::frame::Controller durchschlagen koennen
191 	sal_Int16	SetAlignment(sal_Int16 _nAlign);
192 		// if _nAlign is -1, the alignment is calculated from the type of the field we are bound to
193 		// the value really set is returned
194 	sal_Int16	SetAlignmentFromModel(sal_Int16 nStandardAlign);
195 		// set the alignment according to the "Align"-property of m_xModel, use the given standard
196 		// alignment if the property if void, return the really set alignment
197 
198 	// column locking
199 	sal_Bool	isLocked() const { return m_bLocked; }
200 	void	setLock(sal_Bool _bLock);
201 
202 private:
203     /** attaches or detaches our cell object to the SctriptEventAttacherManager implemented
204         by our model's parent
205     */
206     void    impl_toggleScriptManager_nothrow( bool _bAttach );
207 };
208 
209 //==================================================================
210 // DbCellControl, liefert die Daten fuer einen CellController
211 // wird in der Regel nur f�r komplexe Controls wie z.B ComboBoxen
212 // benoetigt
213 //==================================================================
214 class DbCellControl
215 		:public ::svxform::OTypeConversionClient
216 		,public ::svxform::OStaticDataAccessTools
217 		,public FmMutexHelper			// _before_ the listener, so the listener is to be destroyed first!
218 		,public ::comphelper::OPropertyChangeListener
219 {
220 private:
221 	::comphelper::OPropertyChangeMultiplexer*	m_pModelChangeBroadcaster;
222     ::comphelper::OPropertyChangeMultiplexer*	m_pFieldChangeBroadcaster;
223 
224 private:
225 	sal_Bool					m_bTransparent : 1;
226 	sal_Bool					m_bAlignedController : 1;
227 	sal_Bool					m_bAccessingValueProperty : 1;
228 
229     ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >
230                                 m_xCursor;
231 
232 protected:
233 	DbGridColumn&				m_rColumn;
234 	Window* 					m_pPainter;
235 	Window* 					m_pWindow;
236 
237 protected:
238     // attribute access
239     const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& getCursor() const { return m_xCursor; }
240 
241 	// control transparency
242 	inline	sal_Bool	isTransparent( ) const { return m_bTransparent; }
243 	inline	void		setTransparent( sal_Bool _bSet ) { m_bTransparent = _bSet; }
244 
245 	// control alignment
246 	inline	void		setAlignedController( sal_Bool _bAlign = sal_True ) { m_bAlignedController = _bAlign; }
247 
248 
249 	/** determined whether or not the value property is locked
250 	@see lockValueProperty
251 	*/
252 	inline	sal_Bool	isValuePropertyLocked() const;
253 
254 	/** locks the listening at the value property.
255 		<p>This means that every subsequent change now done on the value property of the model ("Text", or "Value",
256 		or whatever) is then ignored.<br/>
257 		This base class uses this setting in <method>Commit</method>.</p>
258 	@precond
259 		Value locking can't be nested
260 	@see unlockValueProperty
261 	*/
262 	inline	void		lockValueProperty();
263 	/** unlocks the listening at the value property
264 	@see lockValueProperty
265 	*/
266 	inline	void		unlockValueProperty();
267 
268 protected:
269 	// adds the given property to the list of properties which we listen for
270 	void	doPropertyListening( const ::rtl::OUString& _rPropertyName );
271 
272 	// called whenever a property which affects field settings in general is called
273 	// you should overwrite this method for every property you add yourself as listener to
274 	// with doPropertyListening
275 	virtual void	implAdjustGenericFieldSetting( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel );
276 
277 	// called by _propertyChanged if a property which denotes the column value has changed
278 	void	implValuePropertyChanged( );
279 
280 
281 public:
282     TYPEINFO();
283 	DbCellControl(DbGridColumn& _rColumn, sal_Bool _bText = sal_True);
284 	virtual ~DbCellControl();
285 
286 
287 	Window& GetWindow() const
288     {
289         ENSURE_OR_THROW( m_pWindow, "no window" );
290         return *m_pWindow;
291     }
292 
293 	// control alignment
294 	inline	sal_Bool	isAlignedController() const { return m_bAlignedController; }
295 			void		AlignControl(sal_Int16 nAlignment);
296 
297 	void SetTextLineColor();
298 	void SetTextLineColor(const Color& _rColor);
299 
300 	// Initialisieren bevor ein Control angezeigt wird
301 	virtual void Init( Window& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& xCursor );
302 	virtual ::svt::CellControllerRef CreateController() const = 0;
303 
304 	// Schreiben des Wertes in das Model
305 	sal_Bool Commit();
306 
307 	// Formatting the field data to output text
308 	virtual XubString GetFormatText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter, Color** ppColor = NULL) = 0;
309 
310 	virtual void Update(){}
311 	// Refresh the control by the field data
312 	virtual void UpdateFromField(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter) = 0;
313 
314 	// Painten eines Zellinhalts im vorgegeben Rechteck
315 	virtual void PaintFieldToCell( OutputDevice& rDev, const Rectangle& rRect, const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
316     virtual void PaintCell( OutputDevice& _rDev, const Rectangle& _rRect );
317 
318 	void  ImplInitWindow( Window& rParent, const InitWindowFacet _eInitWhat );
319 
320 	double GetValue(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter) const;
321 
322 protected:
323 	void	invalidatedController();
324 
325 	/** commits the content of the control (e.g. the text of an edit field) into the column model
326 		(e.g. the "Text" property of the model).
327 		<p>To be overwritten in derived classes.</p>
328 	@see updateFromModel
329 	*/
330 	virtual sal_Bool commitControl( ) = 0;
331 
332 	/** updates the current content of the control (e.g. the text of an edit field) from the column model
333 		(e.g. the "Text" property of the model).
334 		<p>To be overwritten in derived classes.</p>
335 	@precond
336 		NULL != _rxModel
337 	@precond
338 		NULL != m_pWindow
339 
340 	@see commitControl
341 	*/
342 	virtual void	updateFromModel( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxModel ) = 0;
343 
344 protected:
345 // OPropertyChangeListener
346 	virtual void _propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException);
347 
348 private:
349 	void implDoPropertyListening( const ::rtl::OUString& _rPropertyName, sal_Bool _bWarnIfNotExistent = sal_True );
350 
351 	/// updates the "readonly" setting on m_pWindow, according to the respective property value in the given model
352 	void implAdjustReadOnly( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel,bool i_bReadOnly );
353 
354 	/// updates the "enabled" setting on m_pWindow, according to the respective property value in the given model
355 	void implAdjustEnabled( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel );
356 };
357 
358 //==================================================================
359 //------------------------------------------------------------------
360 inline	sal_Bool	DbCellControl::isValuePropertyLocked() const
361 {
362 	return m_bAccessingValueProperty;
363 }
364 
365 //------------------------------------------------------------------
366 inline	void		DbCellControl::lockValueProperty()
367 {
368 	OSL_ENSURE( !isValuePropertyLocked(), "DbCellControl::lockValueProperty: not to be nested!" );
369 	m_bAccessingValueProperty = sal_True;
370 }
371 
372 //------------------------------------------------------------------
373 inline	void		DbCellControl::unlockValueProperty()
374 {
375 	OSL_ENSURE( isValuePropertyLocked(), "DbCellControl::lockValueProperty: not locked so far!" );
376 	m_bAccessingValueProperty = sal_False;
377 }
378 
379 //==================================================================
380 /** a field which is bound to a column which supports the MaxTextLen property
381 */
382 class DbLimitedLengthField : public DbCellControl
383 {
384 public:
385     TYPEINFO();
386 
387 protected:
388 	DbLimitedLengthField( DbGridColumn& _rColumn );
389 
390 protected:
391 	// DbCellControl
392 	virtual void implAdjustGenericFieldSetting( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel );
393 
394 protected:
395     inline void implSetMaxTextLen( sal_Int16 _nMaxLen )
396     {
397         implSetEffectiveMaxTextLen( _nMaxLen ? _nMaxLen : EDIT_NOLIMIT );
398     }
399     virtual void implSetEffectiveMaxTextLen( sal_Int16 _nMaxLen );
400 };
401 
402 //==================================================================
403 class DbTextField : public DbLimitedLengthField
404 {
405     ::svt::IEditImplementation* m_pEdit;
406     ::svt::IEditImplementation* m_pPainterImplementation;
407 	sal_Int16		            m_nKeyType;
408     sal_Bool                    m_bIsSimpleEdit;
409 
410 protected:
411 	~DbTextField( );
412 
413 public:
414     TYPEINFO();
415 	DbTextField(DbGridColumn& _rColumn);
416 
417     ::svt::IEditImplementation* GetEditImplementation() { return m_pEdit; }
418     sal_Bool                    IsSimpleEdit() const { return m_bIsSimpleEdit; }
419 
420     virtual void Init( Window& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& xCursor );
421 	virtual XubString GetFormatText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter, Color** ppColor = NULL);
422 	virtual void UpdateFromField(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
423 	virtual ::svt::CellControllerRef CreateController() const;
424     virtual void PaintFieldToCell( OutputDevice& _rDev, const Rectangle& _rRect,
425                         const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField,
426                         const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter );
427 
428 protected:
429 	// DbCellControl
430 	virtual sal_Bool	commitControl( );
431 	virtual void		updateFromModel( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxModel );
432     // DbLimitedLengthField
433     virtual void        implSetEffectiveMaxTextLen( sal_Int16 _nMaxLen );
434 };
435 
436 //==================================================================
437 class DbFormattedField : public DbLimitedLengthField
438 {
439 protected:
440 	::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >	m_xSupplier;
441 	sal_Int16						m_nKeyType;
442 
443 
444 public:
445     TYPEINFO();
446 	DbFormattedField(DbGridColumn& _rColumn);
447 	virtual ~DbFormattedField();
448 
449 
450 	virtual void Init( Window& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& xCursor );
451 	virtual XubString GetFormatText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter, Color** ppColor = NULL);
452 	virtual void UpdateFromField(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
453 	virtual ::svt::CellControllerRef CreateController() const;
454 
455 protected:
456 	// DbCellControl
457 	virtual sal_Bool	commitControl( );
458 	virtual void		updateFromModel( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxModel );
459 
460 	// OPropertyChangeListener
461 	virtual void _propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException);
462 };
463 
464 //==================================================================
465 class DbCheckBox : public DbCellControl
466 {
467 public:
468     TYPEINFO();
469 	DbCheckBox(DbGridColumn& _rColumn);
470 
471     virtual void Init( Window& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& xCursor );
472 	virtual void UpdateFromField(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
473 	virtual ::svt::CellControllerRef CreateController() const;
474 	virtual void PaintFieldToCell(OutputDevice& rDev, const Rectangle& rRect,
475 						  const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField,
476 						  const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
477     virtual XubString GetFormatText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter, Color** ppColor = NULL);
478 
479 protected:
480 	// DbCellControl
481 	virtual sal_Bool	commitControl( );
482 	virtual void		updateFromModel( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxModel );
483 };
484 
485 //==================================================================
486 class DbComboBox : public DbCellControl
487 {
488 	sal_Int16		  m_nKeyType;
489 
490 public:
491     TYPEINFO();
492 	DbComboBox(DbGridColumn& _rColumn);
493 
494 	virtual void Init( Window& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& xCursor );
495 	virtual XubString GetFormatText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter, Color** ppColor = NULL);
496 	virtual void UpdateFromField(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
497 	virtual ::svt::CellControllerRef CreateController() const;
498 
499 	void SetList(const ::com::sun::star::uno::Any& rItems);
500 
501 protected:
502 	// DbCellControl
503 	virtual sal_Bool	commitControl( );
504 	virtual void		updateFromModel( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxModel );
505 
506 	virtual void		implAdjustGenericFieldSetting( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel );
507 
508 	// OPropertyChangeListener
509 	virtual void _propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException);
510 };
511 
512 //==================================================================
513 class DbListBox 	:public DbCellControl
514 {
515 	sal_Bool			  m_bBound	: 1;
516 	::com::sun::star::uno::Sequence< ::rtl::OUString > m_aValueList;
517 
518 public:
519     TYPEINFO();
520 	DbListBox(DbGridColumn& _rColumn);
521 
522 	virtual void Init( Window& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& xCursor );
523 	virtual XubString GetFormatText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter, Color** ppColor = NULL);
524 	virtual void UpdateFromField(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
525 	virtual ::svt::CellControllerRef CreateController() const;
526 
527 	void SetList(const ::com::sun::star::uno::Any& rItems);
528 
529 protected:
530 	// DbCellControl
531 	virtual sal_Bool	commitControl( );
532 	virtual void		updateFromModel( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxModel );
533 
534 	virtual void		implAdjustGenericFieldSetting( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel );
535 
536 	// OPropertyChangeListener
537 	virtual void _propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException);
538 };
539 
540 //==================================================================
541 class DbPatternField : public DbCellControl
542 {
543 public:
544     TYPEINFO();
545     DbPatternField( DbGridColumn& _rColumn, const ::comphelper::ComponentContext& _rContext );
546 	virtual void Init( Window& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& xCursor );
547 	virtual XubString GetFormatText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter, Color** ppColor = NULL);
548 	virtual void UpdateFromField(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
549 	virtual ::svt::CellControllerRef CreateController() const;
550 
551 protected:
552 	/// DbCellControl
553 	virtual sal_Bool	commitControl( );
554 	virtual void		updateFromModel( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxModel );
555 
556 	virtual void		implAdjustGenericFieldSetting( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel );
557 
558 private:
559     String  impl_formatText( const String& _rText );
560 
561 private:
562     ::std::auto_ptr< ::dbtools::FormattedColumnValue >  m_pValueFormatter;
563     ::std::auto_ptr< ::dbtools::FormattedColumnValue >  m_pPaintFormatter;
564     ::comphelper::ComponentContext                      m_aContext;
565 };
566 
567 //==================================================================
568 class DbSpinField : public DbCellControl
569 {
570 private:
571 	sal_Int16	m_nStandardAlign;
572 
573 public:
574     TYPEINFO();
575 
576 protected:
577 	DbSpinField( DbGridColumn& _rColumn, sal_Int16 _nStandardAlign = com::sun::star::awt::TextAlign::RIGHT );
578 
579 public:
580 	virtual void						Init( Window& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& _rxCursor );
581 	virtual ::svt::CellControllerRef	CreateController() const;
582 
583 protected:
584 	virtual SpinField*	createField(
585 							Window* _pParent,
586 							WinBits _nFieldStyle,
587 							const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel
588 						) = 0;
589 };
590 
591 //==================================================================
592 class DbDateField : public DbSpinField
593 {
594 public:
595     TYPEINFO();
596 	DbDateField(DbGridColumn& _rColumn);
597 	virtual XubString GetFormatText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter, Color** ppColor = NULL);
598 	virtual void UpdateFromField(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
599 
600 protected:
601 	// DbCellControl
602 	virtual sal_Bool	commitControl( );
603 	virtual void		updateFromModel( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxModel );
604 
605 	// DbSpinField
606 	virtual SpinField*	createField(
607 							Window* _pParent,
608 							WinBits _nFieldStyle,
609 							const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel
610 						);
611 
612 	/// initializes everything which relates to the properties describing the numeric behaviour
613 	virtual void	implAdjustGenericFieldSetting( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel );
614 };
615 
616 //==================================================================
617 class DbTimeField : public DbSpinField
618 {
619 public:
620     TYPEINFO();
621 	DbTimeField(DbGridColumn& _rColumn);
622 	virtual XubString GetFormatText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter, Color** ppColor = NULL);
623 	virtual void UpdateFromField(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
624 
625 protected:
626 	// DbCellControl
627 	virtual sal_Bool	commitControl( );
628 	virtual void		updateFromModel( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxModel );
629 
630 	// DbSpinField
631 	virtual SpinField*	createField(
632 							Window* _pParent,
633 							WinBits _nFieldStyle,
634 							const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel
635 						);
636 
637 	/// initializes everything which relates to the properties describing the numeric behaviour
638 	virtual void	implAdjustGenericFieldSetting( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel );
639 };
640 
641 //==================================================================
642 class DbCurrencyField : public DbSpinField
643 {
644 	sal_Int16  m_nScale;
645 
646 public:
647     TYPEINFO();
648 	DbCurrencyField(DbGridColumn& _rColumn);
649 	virtual XubString GetFormatText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter, Color** ppColor = NULL);
650 	virtual void UpdateFromField(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
651 
652 	double GetCurrency(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter) const;
653 
654 protected:
655 	// DbCellControl
656 	virtual sal_Bool	commitControl( );
657 	virtual void		updateFromModel( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxModel );
658 
659 	// DbSpinField
660 	virtual SpinField*	createField(
661 							Window* _pParent,
662 							WinBits _nFieldStyle,
663 							const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel
664 						);
665 
666 	/// initializes everything which relates to the properties describing the numeric behaviour
667 	virtual void	implAdjustGenericFieldSetting( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel );
668 };
669 
670 //==================================================================
671 class DbNumericField : public DbSpinField
672 {
673 public:
674     TYPEINFO();
675 	DbNumericField(DbGridColumn& _rColumn);
676 	virtual XubString GetFormatText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter, Color** ppColor = NULL);
677 	virtual void UpdateFromField(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
678 
679 protected:
680 	// DbCellControl
681 	virtual sal_Bool	commitControl( );
682 	virtual void		updateFromModel( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxModel );
683 
684 	// DbSpinField
685 	virtual SpinField*	createField(
686 							Window* _pParent,
687 							WinBits _nFieldStyle,
688 							const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel
689 						);
690 
691 	/// initializes everything which relates to the properties describing the numeric behaviour
692 	void	implAdjustGenericFieldSetting( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel );
693 };
694 
695 //==================================================================
696 class DbFilterField
697 		:public DbCellControl
698 		,public ::svxform::OSQLParserClient
699 {
700 	::com::sun::star::uno::Sequence< ::rtl::OUString >	m_aValueList;
701 	XubString	m_aText;
702 	Link	m_aCommitLink;
703 	sal_Int16	m_nControlClass;
704 	sal_Bool	m_bFilterList : 1;
705 	sal_Bool	m_bFilterListFilled : 1;
706 	sal_Bool	m_bBound : 1;
707 
708 public:
709     TYPEINFO();
710 	DbFilterField(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,DbGridColumn& _rColumn);
711 	virtual ~DbFilterField();
712 
713 	virtual void Init( Window& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& xCursor );
714 	virtual ::svt::CellControllerRef CreateController() const;
715 	virtual void PaintCell(OutputDevice& rDev, const Rectangle& rRect);
716 	virtual void Update();
717     virtual XubString GetFormatText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter, Color** ppColor = NULL);
718     virtual void UpdateFromField(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
719 
720 	const XubString& GetText() const {return m_aText;}
721 	void SetText(const XubString& rText);
722 
723 	void SetCommitHdl( const Link& rLink ) { m_aCommitLink = rLink; }
724 	const Link& GetCommitHdl() const { return m_aCommitLink; }
725 
726 protected:
727 
728 	// DbCellControl
729 	virtual sal_Bool	commitControl( );
730 	virtual void		updateFromModel( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxModel );
731 
732 protected:
733 	void SetList(const ::com::sun::star::uno::Any& rItems, sal_Bool bComboBox);
734 	void CreateControl(Window* pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xModel);
735 	DECL_LINK( OnClick, void* );
736 };
737 
738 //==================================================================
739 // Base class providing the access to a grid cell
740 //==================================================================
741 typedef ::cppu::ImplHelper2 <   ::com::sun::star::awt::XControl
742                             ,   ::com::sun::star::form::XBoundControl
743                             >   FmXGridCell_Base;
744 typedef ::cppu::ImplHelper1 <   ::com::sun::star::awt::XWindow
745                             >   FmXGridCell_WindowBase;
746 class FmXGridCell   :public ::cppu::OComponentHelper
747                     ,public FmXGridCell_Base
748                     ,public FmXGridCell_WindowBase
749 {
750 protected:
751     ::osl::Mutex        m_aMutex;
752     DbGridColumn*       m_pColumn;
753     DbCellControl*      m_pCellControl;
754 
755 private:
756 	::cppu::OInterfaceContainerHelper	m_aWindowListeners;
757 	::cppu::OInterfaceContainerHelper	m_aFocusListeners;
758 	::cppu::OInterfaceContainerHelper	m_aKeyListeners;
759 	::cppu::OInterfaceContainerHelper	m_aMouseListeners;
760 	::cppu::OInterfaceContainerHelper	m_aMouseMotionListeners;
761 
762 protected:
763 	virtual ~FmXGridCell();
764 
765 public:
766 	TYPEINFO();
767 	FmXGridCell( DbGridColumn* pColumn, DbCellControl* pControl );
768     void init();
769 
770 	DECLARE_UNO3_AGG_DEFAULTS(FmXGridCell, OComponentHelper);
771 	virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(::com::sun::star::uno::RuntimeException);
772 
773 	void SetTextLineColor();
774 	void SetTextLineColor(const Color& _rColor);
775 
776 // XTypeProvider
777     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw (::com::sun::star::uno::RuntimeException);
778 	virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
779 
780 // OComponentHelper
781 	virtual void SAL_CALL disposing();
782 
783 // ::com::sun::star::lang::XComponent
784 	virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException){OComponentHelper::dispose();}
785 	virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener)throw(::com::sun::star::uno::RuntimeException)		{ OComponentHelper::addEventListener(aListener);}
786 	virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener)throw(::com::sun::star::uno::RuntimeException)		{ OComponentHelper::removeEventListener(aListener);}
787 
788 // ::com::sun::star::awt::XControl
789 	virtual void SAL_CALL setContext(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& /*Context*/) throw(::com::sun::star::uno::RuntimeException){}
790 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >  SAL_CALL getContext() throw(::com::sun::star::uno::RuntimeException);
791 	virtual void SAL_CALL createPeer(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit >& /*Toolkit*/, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& /*Parent*/) throw(::com::sun::star::uno::RuntimeException){}
792 
793 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > SAL_CALL getPeer() throw (::com::sun::star::uno::RuntimeException) {return ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > ();}
794 	virtual sal_Bool SAL_CALL setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& /*Model*/) throw (::com::sun::star::uno::RuntimeException) {return sal_False;}
795 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > SAL_CALL getModel() throw (::com::sun::star::uno::RuntimeException);
796 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XView > SAL_CALL getView() throw (::com::sun::star::uno::RuntimeException) {return ::com::sun::star::uno::Reference< ::com::sun::star::awt::XView > ();}
797 	virtual void SAL_CALL setDesignMode(sal_Bool /*bOn*/) throw (::com::sun::star::uno::RuntimeException) {}
798 	virtual sal_Bool SAL_CALL isDesignMode() throw (::com::sun::star::uno::RuntimeException) {return sal_False;}
799 	virtual sal_Bool SAL_CALL isTransparent() throw (::com::sun::star::uno::RuntimeException) {return sal_False;}
800 
801 // ::com::sun::star::form::XBoundControl
802 	virtual sal_Bool SAL_CALL getLock() throw(::com::sun::star::uno::RuntimeException);
803 	virtual void SAL_CALL setLock(sal_Bool _bLock) throw(::com::sun::star::uno::RuntimeException);
804 
805     // XWindow
806     virtual void SAL_CALL setPosSize( ::sal_Int32 X, ::sal_Int32 Y, ::sal_Int32 Width, ::sal_Int32 Height, ::sal_Int16 Flags ) throw (::com::sun::star::uno::RuntimeException);
807     virtual ::com::sun::star::awt::Rectangle SAL_CALL getPosSize(  ) throw (::com::sun::star::uno::RuntimeException);
808     virtual void SAL_CALL setVisible( ::sal_Bool Visible ) throw (::com::sun::star::uno::RuntimeException);
809     virtual void SAL_CALL setEnable( ::sal_Bool Enable ) throw (::com::sun::star::uno::RuntimeException);
810     virtual void SAL_CALL setFocus(  ) throw (::com::sun::star::uno::RuntimeException);
811     virtual void SAL_CALL addWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
812     virtual void SAL_CALL removeWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
813     virtual void SAL_CALL addFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
814     virtual void SAL_CALL removeFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
815     virtual void SAL_CALL addKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
816     virtual void SAL_CALL removeKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
817     virtual void SAL_CALL addMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
818     virtual void SAL_CALL removeMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
819     virtual void SAL_CALL addMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
820     virtual void SAL_CALL removeMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
821     virtual void SAL_CALL addPaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
822     virtual void SAL_CALL removePaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
823 
824 	sal_Bool Commit() {return m_pCellControl->Commit();}
825 	void ImplInitWindow( Window& rParent, const InitWindowFacet _eInitWhat )
826 		{ m_pCellControl->ImplInitWindow( rParent, _eInitWhat ); }
827 
828 	sal_Bool isAlignedController() const { return m_pCellControl->isAlignedController(); }
829 	void AlignControl(sal_Int16 nAlignment)
830 		{ m_pCellControl->AlignControl(nAlignment);}
831 
832 protected:
833     virtual Window* getEventWindow() const;
834     virtual void onWindowEvent( const sal_uLong _nEventId, const Window& _rWindow, const void* _pEventData );
835 
836     // default implementations call our focus listeners, don't forget to call them if you override this
837     virtual void onFocusGained( const ::com::sun::star::awt::FocusEvent& _rEvent );
838     virtual void onFocusLost( const ::com::sun::star::awt::FocusEvent& _rEvent );
839 
840 private:
841 	DECL_LINK( OnWindowEvent, VclWindowEvent* );
842 };
843 
844 //==================================================================
845 class FmXDataCell : public FmXGridCell
846 {
847 public:
848 	TYPEINFO();
849 	FmXDataCell( DbGridColumn* pColumn, DbCellControl& _rControl )
850         :FmXGridCell( pColumn, &_rControl )
851     {
852     }
853 
854 	virtual void PaintFieldToCell(OutputDevice& rDev,
855 			   const Rectangle& rRect,
856 			   const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& xField,
857 			   const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
858 
859 	void UpdateFromField(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& xField,
860 						 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter)
861 				{ m_pCellControl->UpdateFromField(xField, xFormatter); }
862 
863 protected:
864 	void UpdateFromColumn();
865 };
866 
867 //==================================================================
868 class FmXTextCell : public FmXDataCell
869 {
870 protected:
871     /** determines whether the text of this cell can be painted directly, without
872         using the painter control
873 
874         If this is <TRUE/>, the <member>PaintCell</member> method will simply use the text as returned
875         by <member>GetText</member>, and draw it onto the device passed to <member>PaintFieldToCell</member>,
876         while respecting the current alignment settings.
877 
878         If this is <FALSE/>, the <member>PaintFieldToCell</member> request will be forwarded to the painter
879         control (<member>m_pPainter</member>). This is more expensive, but the only option
880         if your painting involves more that a simple DrawText.
881 
882         This member is <TRUE/> by default, and can be modified by derived classes.
883     */
884     sal_Bool    m_bFastPaint;
885 
886 public:
887 	TYPEINFO();
888 	FmXTextCell( DbGridColumn* pColumn, DbCellControl& _rControl );
889 
890 	virtual void PaintFieldToCell(OutputDevice& rDev,
891 			   const Rectangle& rRect,
892 			   const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& xField,
893 			   const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
894 
895 	XubString GetText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField,
896 				   const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter,
897 				   Color** ppColor = NULL)
898 			{return m_pCellControl->GetFormatText(_rxField, xFormatter, ppColor);}
899 };
900 
901 //==================================================================
902 typedef ::cppu::ImplHelper2 <   ::com::sun::star::awt::XTextComponent
903                             ,   ::com::sun::star::form::XChangeBroadcaster
904                             >   FmXEditCell_Base;
905 class FmXEditCell : public FmXTextCell,
906 					public FmXEditCell_Base
907 {
908 private:
909     ::rtl::OUString                     m_sValueOnEnter;
910 
911 protected:
912 	::cppu::OInterfaceContainerHelper	m_aTextListeners;
913 	::cppu::OInterfaceContainerHelper	m_aChangeListeners;
914     ::svt::IEditImplementation*         m_pEditImplementation;
915     bool                                m_bOwnEditImplementation;
916 
917 	virtual ~FmXEditCell();
918 public:
919 	FmXEditCell( DbGridColumn* pColumn, DbCellControl& _rControl );
920 
921 	DECLARE_UNO3_AGG_DEFAULTS(FmXEditCell, FmXTextCell);
922 	virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(::com::sun::star::uno::RuntimeException);
923 
924 // XTypeProvider
925 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);
926 	virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
927 
928 // OComponentHelper
929 	virtual void SAL_CALL disposing();
930 
931 // ::com::sun::star::awt::XTextComponent
932 	virtual void SAL_CALL addTextListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener >& l) throw(::com::sun::star::uno::RuntimeException);
933 	virtual void SAL_CALL removeTextListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener >& l) throw(::com::sun::star::uno::RuntimeException);
934 	virtual void SAL_CALL setText(const ::rtl::OUString& aText) throw(::com::sun::star::uno::RuntimeException);
935 	virtual void SAL_CALL insertText(const ::com::sun::star::awt::Selection& Sel, const ::rtl::OUString& Text) throw(::com::sun::star::uno::RuntimeException);
936 	virtual ::rtl::OUString SAL_CALL getText() throw(::com::sun::star::uno::RuntimeException);
937 	virtual ::rtl::OUString SAL_CALL getSelectedText() throw(::com::sun::star::uno::RuntimeException);
938 	virtual void SAL_CALL setSelection(const ::com::sun::star::awt::Selection& aSelection) throw(::com::sun::star::uno::RuntimeException);
939 	virtual ::com::sun::star::awt::Selection SAL_CALL getSelection() throw(::com::sun::star::uno::RuntimeException);
940 	virtual sal_Bool SAL_CALL isEditable() throw(::com::sun::star::uno::RuntimeException);
941 	virtual void SAL_CALL setEditable(sal_Bool bEditable) throw(::com::sun::star::uno::RuntimeException);
942 	virtual void SAL_CALL setMaxTextLen(sal_Int16 nLen) throw(::com::sun::star::uno::RuntimeException);
943 	virtual sal_Int16 SAL_CALL getMaxTextLen() throw(::com::sun::star::uno::RuntimeException);
944 
945     // XChangeBroadcaster
946     virtual void SAL_CALL addChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XChangeListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
947     virtual void SAL_CALL removeChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XChangeListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
948 
949 protected:
950     virtual void onWindowEvent( const sal_uLong _nEventId, const Window& _rWindow, const void* _pEventData );
951 
952     virtual void onFocusGained( const ::com::sun::star::awt::FocusEvent& _rEvent );
953     virtual void onFocusLost( const ::com::sun::star::awt::FocusEvent& _rEvent );
954 
955 private:
956     void onTextChanged();
957 };
958 
959 //==================================================================
960 typedef ::cppu::ImplHelper2 <   ::com::sun::star::awt::XCheckBox
961                             ,   ::com::sun::star::awt::XButton
962                             >   FmXCheckBoxCell_Base;
963 class FmXCheckBoxCell : public FmXDataCell,
964 						public FmXCheckBoxCell_Base
965 {
966 	::cppu::OInterfaceContainerHelper	m_aItemListeners;
967 	::cppu::OInterfaceContainerHelper	m_aActionListeners;
968     ::rtl::OUString                     m_aActionCommand;
969 	CheckBox*							m_pBox;
970 
971 protected:
972 	virtual ~FmXCheckBoxCell();
973 
974 public:
975 	FmXCheckBoxCell( DbGridColumn* pColumn, DbCellControl& _rControl );
976 
977 // UNO
978 	DECLARE_UNO3_AGG_DEFAULTS(FmXCheckBoxCell, FmXDataCell);
979 	virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(::com::sun::star::uno::RuntimeException);
980 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);
981 	virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
982 
983 // OComponentHelper
984 	virtual void SAL_CALL disposing();
985 
986 // ::com::sun::star::awt::XCheckBox
987 	virtual void SAL_CALL addItemListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener >& l) throw(::com::sun::star::uno::RuntimeException);
988 	virtual void SAL_CALL removeItemListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener >& l) throw(::com::sun::star::uno::RuntimeException);
989 	virtual sal_Int16 SAL_CALL getState() throw(::com::sun::star::uno::RuntimeException);
990 	virtual void SAL_CALL setState(sal_Int16 n) throw(::com::sun::star::uno::RuntimeException);
991 	virtual void SAL_CALL setLabel(const ::rtl::OUString& Label) throw(::com::sun::star::uno::RuntimeException);
992 	virtual void SAL_CALL enableTriState(sal_Bool b) throw(::com::sun::star::uno::RuntimeException);
993 
994     // XButton
995     virtual void SAL_CALL addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& l ) throw (::com::sun::star::uno::RuntimeException);
996     virtual void SAL_CALL removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& l ) throw (::com::sun::star::uno::RuntimeException);
997     //virtual void SAL_CALL setLabel( const ::rtl::OUString& Label ) throw (::com::sun::star::uno::RuntimeException);
998     virtual void SAL_CALL setActionCommand( const ::rtl::OUString& Command ) throw (::com::sun::star::uno::RuntimeException);
999 
1000 protected:
1001     virtual Window* getEventWindow() const;
1002     virtual void onWindowEvent( const sal_uLong _nEventId, const Window& _rWindow, const void* _pEventData );
1003 };
1004 
1005 //==================================================================
1006 typedef ::cppu::ImplHelper1 <   ::com::sun::star::awt::XListBox
1007                             >   FmXListBoxCell_Base;
1008 class FmXListBoxCell    :public FmXTextCell
1009                         ,public FmXListBoxCell_Base
1010 {
1011 	::cppu::OInterfaceContainerHelper	m_aItemListeners,
1012 										m_aActionListeners;
1013 	ListBox*							m_pBox;
1014 
1015 protected:
1016 	virtual ~FmXListBoxCell();
1017 
1018 public:
1019 	FmXListBoxCell( DbGridColumn* pColumn, DbCellControl& _rControl );
1020 
1021 	DECLARE_UNO3_AGG_DEFAULTS(FmXListBoxCell, FmXTextCell);
1022 	virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(::com::sun::star::uno::RuntimeException);
1023 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);
1024 	virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
1025 
1026 // OComponentHelper
1027 	virtual void SAL_CALL disposing();
1028 
1029 // ::com::sun::star::awt::XListBox
1030 	virtual void SAL_CALL addItemListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener >& l) throw(::com::sun::star::uno::RuntimeException);
1031 	virtual void SAL_CALL removeItemListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener >& l) throw(::com::sun::star::uno::RuntimeException);
1032 	virtual void SAL_CALL addActionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& l) throw(::com::sun::star::uno::RuntimeException);
1033 	virtual void SAL_CALL removeActionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& l) throw(::com::sun::star::uno::RuntimeException);
1034 	virtual void SAL_CALL addItem(const ::rtl::OUString& aItem, sal_Int16 nPos) throw(::com::sun::star::uno::RuntimeException);
1035 	virtual void SAL_CALL addItems(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aItems, sal_Int16 nPos) throw(::com::sun::star::uno::RuntimeException);
1036 	virtual void SAL_CALL removeItems(sal_Int16 nPos, sal_Int16 nCount) throw(::com::sun::star::uno::RuntimeException);
1037 	virtual sal_Int16 SAL_CALL getItemCount() throw(::com::sun::star::uno::RuntimeException);
1038 	virtual ::rtl::OUString SAL_CALL getItem(sal_Int16 nPos) throw(::com::sun::star::uno::RuntimeException);
1039 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getItems() throw(::com::sun::star::uno::RuntimeException);
1040 	virtual sal_Int16 SAL_CALL getSelectedItemPos() throw(::com::sun::star::uno::RuntimeException);
1041 	virtual ::com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL getSelectedItemsPos() throw(::com::sun::star::uno::RuntimeException);
1042 	virtual ::rtl::OUString SAL_CALL getSelectedItem() throw(::com::sun::star::uno::RuntimeException);
1043 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSelectedItems() throw(::com::sun::star::uno::RuntimeException);
1044 	virtual void SAL_CALL SAL_CALL selectItemPos(sal_Int16 nPos, sal_Bool bSelect) throw(::com::sun::star::uno::RuntimeException);
1045 	virtual void SAL_CALL SAL_CALL selectItemsPos(const ::com::sun::star::uno::Sequence< sal_Int16 >& aPositions, sal_Bool bSelect) throw(::com::sun::star::uno::RuntimeException);
1046 	virtual void SAL_CALL SAL_CALL selectItem(const ::rtl::OUString& aItem, sal_Bool bSelect) throw(::com::sun::star::uno::RuntimeException);
1047 	virtual sal_Bool SAL_CALL isMutipleMode() throw(::com::sun::star::uno::RuntimeException);
1048 	virtual void SAL_CALL SAL_CALL setMultipleMode(sal_Bool bMulti) throw(::com::sun::star::uno::RuntimeException);
1049 	virtual sal_Int16 SAL_CALL getDropDownLineCount() throw(::com::sun::star::uno::RuntimeException);
1050 	virtual void SAL_CALL SAL_CALL setDropDownLineCount(sal_Int16 nLines) throw(::com::sun::star::uno::RuntimeException);
1051 	virtual void SAL_CALL SAL_CALL makeVisible(sal_Int16 nEntry) throw(::com::sun::star::uno::RuntimeException);
1052 
1053 protected:
1054     virtual void onWindowEvent( const sal_uLong _nEventId, const Window& _rWindow, const void* _pEventData );
1055 
1056 	DECL_LINK( OnDoubleClick, void* );
1057 };
1058 
1059 //==================================================================
1060 typedef ::cppu::ImplHelper1 <   ::com::sun::star::awt::XComboBox
1061                             >   FmXComboBoxCell_Base;
1062 class FmXComboBoxCell   :public FmXTextCell
1063                         ,public FmXComboBoxCell_Base
1064 {
1065 private:
1066 	::cppu::OInterfaceContainerHelper	m_aItemListeners,
1067 										m_aActionListeners;
1068     ComboBox*                           m_pComboBox;
1069 
1070 protected:
1071 	virtual ~FmXComboBoxCell();
1072 
1073 public:
1074 	FmXComboBoxCell( DbGridColumn* pColumn, DbCellControl& _rControl );
1075 
1076 	DECLARE_UNO3_AGG_DEFAULTS(FmXListBoxCell, FmXTextCell);
1077 	virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(::com::sun::star::uno::RuntimeException);
1078 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);
1079 	virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
1080 
1081     // OComponentHelper
1082 	virtual void SAL_CALL disposing();
1083 
1084     // XComboBox
1085     virtual void SAL_CALL addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException);
1086     virtual void SAL_CALL removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException);
1087     virtual void SAL_CALL addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException);
1088     virtual void SAL_CALL removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException);
1089     virtual void SAL_CALL addItem( const ::rtl::OUString& _Item, ::sal_Int16 _Pos ) throw (::com::sun::star::uno::RuntimeException);
1090     virtual void SAL_CALL addItems( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _Items, ::sal_Int16 _Pos ) throw (::com::sun::star::uno::RuntimeException);
1091     virtual void SAL_CALL removeItems( ::sal_Int16 nPos, ::sal_Int16 nCount ) throw (::com::sun::star::uno::RuntimeException);
1092     virtual ::sal_Int16 SAL_CALL getItemCount(  ) throw (::com::sun::star::uno::RuntimeException);
1093     virtual ::rtl::OUString SAL_CALL getItem( ::sal_Int16 _Pos ) throw (::com::sun::star::uno::RuntimeException);
1094     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getItems(  ) throw (::com::sun::star::uno::RuntimeException);
1095     virtual ::sal_Int16 SAL_CALL getDropDownLineCount(  ) throw (::com::sun::star::uno::RuntimeException);
1096     virtual void SAL_CALL setDropDownLineCount( ::sal_Int16 _Lines ) throw (::com::sun::star::uno::RuntimeException);
1097 
1098 protected:
1099     virtual void onWindowEvent( const sal_uLong _nEventId, const Window& _rWindow, const void* _pEventData );
1100 };
1101 
1102 //==================================================================
1103 typedef ::cppu::ImplHelper2 <   ::com::sun::star::awt::XTextComponent
1104                             ,   ::com::sun::star::lang::XUnoTunnel
1105                             >   FmXFilterCell_Base;
1106 class FmXFilterCell :public FmXGridCell
1107 					,public FmXFilterCell_Base
1108 {
1109 	::cppu::OInterfaceContainerHelper m_aTextListeners;
1110 protected:
1111 	virtual ~FmXFilterCell();
1112 public:
1113 	TYPEINFO();
1114 	FmXFilterCell(DbGridColumn* pColumn = NULL, DbCellControl* pControl = NULL);
1115 
1116 
1117 	DECLARE_UNO3_AGG_DEFAULTS(FmXFilterCell, FmXGridCell);
1118 	virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(::com::sun::star::uno::RuntimeException);
1119 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);
1120 	virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
1121 
1122 // XUnoTunnel
1123 	virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
1124 
1125 // helpers for XUnoTunnel
1126 	static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
1127 	static FmXFilterCell* getImplementation(
1128 		const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxObject);
1129 
1130 //	painting the filter text
1131 	virtual void PaintCell(OutputDevice& rDev, const Rectangle& rRect);
1132 	void Update(){m_pCellControl->Update();}
1133 
1134 // OComponentHelper
1135 	virtual void SAL_CALL disposing();
1136 
1137 // ::com::sun::star::awt::XTextComponent
1138 	virtual void SAL_CALL addTextListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener >& l) throw(::com::sun::star::uno::RuntimeException);
1139 	virtual void SAL_CALL removeTextListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener >& l) throw(::com::sun::star::uno::RuntimeException);
1140 	virtual void SAL_CALL setText(const ::rtl::OUString& aText) throw(::com::sun::star::uno::RuntimeException);
1141 	virtual void SAL_CALL insertText(const ::com::sun::star::awt::Selection& Sel, const ::rtl::OUString& Text) throw(::com::sun::star::uno::RuntimeException);
1142 	virtual ::rtl::OUString SAL_CALL getText() throw(::com::sun::star::uno::RuntimeException);
1143 	virtual ::rtl::OUString SAL_CALL getSelectedText() throw(::com::sun::star::uno::RuntimeException);
1144 	virtual void SAL_CALL setSelection(const ::com::sun::star::awt::Selection& aSelection) throw(::com::sun::star::uno::RuntimeException);
1145 	virtual ::com::sun::star::awt::Selection SAL_CALL getSelection() throw(::com::sun::star::uno::RuntimeException);
1146 	virtual sal_Bool SAL_CALL isEditable() throw(::com::sun::star::uno::RuntimeException);
1147 	virtual void SAL_CALL setEditable(sal_Bool bEditable) throw(::com::sun::star::uno::RuntimeException);
1148 	virtual void SAL_CALL setMaxTextLen(sal_Int16 nLen) throw(::com::sun::star::uno::RuntimeException);
1149 	virtual sal_Int16 SAL_CALL getMaxTextLen() throw(::com::sun::star::uno::RuntimeException);
1150 
1151 protected:
1152 	DECL_LINK( OnCommit, void* );
1153 };
1154 
1155 #endif // _SVX_GRIDCELL_HXX
1156 
1157