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