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