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 #ifndef _SVX_GRIDCTRL_HXX 24 #define _SVX_GRIDCTRL_HXX 25 26 #include <tools/list.hxx> 27 #include <com/sun/star/sdbc/XRowSet.hpp> 28 #include <com/sun/star/sdbc/XRowSetListener.hpp> 29 #include <com/sun/star/sdb/XRowsChangeListener.hpp> 30 #include <com/sun/star/beans/PropertyChangeEvent.hpp> 31 #include <com/sun/star/util/XNumberFormatter.hpp> 32 #include <com/sun/star/util/Date.hpp> 33 #include <com/sun/star/container/XIndexAccess.hpp> 34 #include <vcl/fixed.hxx> 35 #include <vcl/field.hxx> 36 37 #ifndef _SV_BUTTON_HXX //autogen 38 #include <vcl/button.hxx> 39 #endif 40 #include <tools/date.hxx> 41 #include <tools/ref.hxx> 42 #include <svtools/editbrowsebox.hxx> 43 #include <vos/mutex.hxx> 44 #include <comphelper/propmultiplex.hxx> 45 #include <svtools/transfer.hxx> 46 #include "svx/svxdllapi.h" 47 48 class DbGridControl; 49 class CursorWrapper; 50 51 sal_Bool CompareBookmark(const ::com::sun::star::uno::Any& aLeft, const ::com::sun::star::uno::Any& aRight); 52 53 namespace svxform 54 { 55 class DataColumn; 56 } 57 DECLARE_LIST(DbDataColumns, ::svxform::DataColumn*) 58 59 enum GridRowStatus 60 { 61 GRS_CLEAN, 62 GRS_MODIFIED, 63 GRS_DELETED, 64 GRS_INVALID 65 }; 66 67 //================================================================== 68 // DbGridRow, Zeilenbeschreibung 69 //================================================================== 70 71 class DbGridRow : public SvRefBase 72 { 73 ::com::sun::star::uno::Any m_aBookmark; // ::com::sun::star::text::Bookmark der Zeile, kann gesetzt sein 74 DbDataColumns m_aVariants; 75 GridRowStatus m_eStatus; 76 sal_Bool m_bIsNew; 77 // Zeile ist nicht mehr gueltig, 78 // wird bei der naechsten positionierung entfernt 79 public: DbGridRow()80 DbGridRow():m_eStatus(GRS_CLEAN), m_bIsNew(sal_True) { } 81 DbGridRow(CursorWrapper* pCur, sal_Bool bPaintCursor); 82 void SetState(CursorWrapper* pCur, sal_Bool bPaintCursor); 83 84 ~DbGridRow(); 85 86 // da GetField auf Geschwindigkeit getuned ist vorher immer noch hasField verwenden HasField(sal_uInt32 nPos) const87 sal_Bool HasField(sal_uInt32 nPos) const {return nPos < m_aVariants.Count();} GetField(sal_uInt32 nPos) const88 const ::svxform::DataColumn& GetField(sal_uInt32 nPos) const { return *m_aVariants.GetObject(nPos); } 89 SetStatus(GridRowStatus _eStat)90 void SetStatus(GridRowStatus _eStat) { m_eStatus = _eStat; } GetStatus() const91 GridRowStatus GetStatus() const { return m_eStatus; } SetNew(sal_Bool _bNew)92 void SetNew(sal_Bool _bNew) { m_bIsNew = _bNew; } IsNew() const93 sal_Bool IsNew() const { return m_bIsNew; } 94 GetBookmark() const95 const ::com::sun::star::uno::Any& GetBookmark() const { return m_aBookmark; } 96 IsValid() const97 sal_Bool IsValid() const { return m_eStatus == GRS_CLEAN || m_eStatus == GRS_MODIFIED; } IsModified() const98 sal_Bool IsModified() const { return m_eStatus == GRS_MODIFIED; } 99 }; 100 101 SV_DECL_REF(DbGridRow) 102 103 //================================================================== 104 // DbGridControl 105 //================================================================== 106 class DbGridColumn; 107 DECLARE_LIST(DbGridColumns, DbGridColumn*) 108 109 //================================================================== 110 class FmGridListener 111 { 112 public: 113 virtual void selectionChanged() = 0; 114 virtual void columnChanged() = 0; 115 }; 116 117 #define GRID_COLUMN_NOT_FOUND ((sal_uInt16)-1) 118 119 //================================================================== 120 // InitWindowFacet, describing which aspect of a column's Window to (re-)initialize 121 //================================================================== 122 enum InitWindowFacet 123 { 124 InitFont = 0x01, 125 InitForeground = 0x02, 126 InitBackground = 0x04, 127 InitWritingMode = 0x08, 128 InitAll = 0xFF 129 }; 130 131 //================================================================== 132 class FmXGridSourcePropListener; 133 class DisposeListenerGridBridge; 134 typedef ::svt::EditBrowseBox DbGridControl_Base; 135 class SVX_DLLPUBLIC DbGridControl : public DbGridControl_Base 136 { 137 friend class FmXGridSourcePropListener; 138 friend class GridFieldValueListener; 139 friend class DisposeListenerGridBridge; 140 141 public: 142 //================================================================== 143 // NavigationBar 144 //================================================================== 145 class NavigationBar: public Control 146 { 147 class AbsolutePos : public NumericField 148 { 149 public: 150 AbsolutePos(Window* pParent, WinBits nStyle = 0); 151 152 virtual void KeyInput(const KeyEvent& rEvt); 153 virtual void LoseFocus(); 154 }; 155 156 friend class NavigationBar::AbsolutePos; 157 158 // zusaetzliche Controls 159 FixedText m_aRecordText; 160 AbsolutePos m_aAbsolute; // AbsolutePositionierung 161 FixedText m_aRecordOf; 162 FixedText m_aRecordCount; 163 164 ImageButton m_aFirstBtn; // ImageButton fuer 'gehe zum ersten Datensatz' 165 ImageButton m_aPrevBtn; // ImageButton fuer 'gehe zum vorhergehenden Datensatz' 166 ImageButton m_aNextBtn; // ImageButton fuer 'gehe zum naechsten Datensatz' 167 ImageButton m_aLastBtn; // ImageButton fuer 'gehe zum letzten Datensatz' 168 ImageButton m_aNewBtn; // ImageButton fuer 'gehe zum neuen Datensatz' 169 sal_uInt16 m_nDefaultWidth; 170 sal_Int32 m_nCurrentPos; 171 172 sal_Bool m_bPositioning; // protect PositionDataSource against recursion 173 174 public: 175 // StatusIds fuer Controls der Bar 176 // wichtig fuers Invalidieren 177 enum State 178 { 179 RECORD_TEXT = 1, 180 RECORD_ABSOLUTE, 181 RECORD_OF, 182 RECORD_COUNT, 183 RECORD_FIRST, 184 RECORD_NEXT, 185 RECORD_PREV, 186 RECORD_LAST, 187 RECORD_NEW 188 }; 189 190 NavigationBar(Window* pParent, WinBits nStyle = 0); 191 192 // Status Methoden fuer Controls 193 void InvalidateAll(sal_Int32 nCurrentPos = -1, sal_Bool bAll = sal_False); InvalidateState(sal_uInt16 nWhich)194 void InvalidateState(sal_uInt16 nWhich) {SetState(nWhich);} 195 void SetState(sal_uInt16 nWhich); 196 sal_Bool GetState(sal_uInt16 nWhich) const; GetDefaultWidth() const197 sal_uInt16 GetDefaultWidth() const {return m_nDefaultWidth;} 198 199 protected: 200 virtual void Resize(); 201 virtual void Paint(const Rectangle& rRect); 202 virtual void StateChanged( StateChangedType nType ); 203 204 private: 205 DECL_LINK(OnClick, Button*); 206 sal_uInt16 ArrangeControls(); 207 208 void PositionDataSource(sal_Int32 nRecord); 209 }; 210 211 friend class DbGridControl::NavigationBar; 212 213 public: 214 // diese Optionen werden verodert und geben an, welche der einzelnen feature 215 // freigegeben werden koennen, default ist readonly also 0 216 enum Option 217 { 218 OPT_READONLY = 0x00, 219 OPT_INSERT = 0x01, 220 OPT_UPDATE = 0x02, 221 OPT_DELETE = 0x04 222 }; 223 224 private: 225 Font m_aDefaultFont; 226 Link m_aMasterStateProvider; 227 Link m_aMasterSlotExecutor; 228 229 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xFormatter; 230 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceFactory; 231 232 DbGridColumns m_aColumns; // Spaltenbeschreibung 233 NavigationBar m_aBar; 234 DbGridRowRef m_xDataRow; // Zeile die modifiziert werden kann 235 // kommt vom DatenCursor 236 DbGridRowRef m_xSeekRow, // Zeile die von Iterator gesetzt wird 237 // kommt vom DatenCursor 238 239 m_xEmptyRow; // Datensatz zum einfuegen 240 241 sal_uInt32 m_nAsynAdjustEvent; 242 243 // if we modify the row for the new record, we automatically insert a "new new row". 244 // But if somebody else inserts a new record into the data source, we have to do the same. 245 // For that reason we have to listen to some properties of our data source. 246 ::comphelper::OPropertyChangeMultiplexer* m_pDataSourcePropMultiplexer; 247 FmXGridSourcePropListener* m_pDataSourcePropListener; 248 ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowsChangeListener> 249 m_xRowSetListener; // get notification when rows were changed 250 251 void* m_pFieldListeners; 252 // property listeners for field values 253 254 DisposeListenerGridBridge* m_pCursorDisposeListener; 255 // need to know about the diposing of the seek cursor 256 // construct analogous to the data source proplistener/multiplexer above : 257 // DisposeListenerGridBridge is a bridge from FmXDisposeListener which I don't want to be derived from 258 259 FmGridListener* m_pGridListener; 260 261 protected: 262 CursorWrapper* m_pDataCursor; // Cursor fuer Updates 263 CursorWrapper* m_pSeekCursor; // Cursor zum Seeken 264 265 private: 266 // dieses sind Laufvariablen 267 DbGridRowRef m_xCurrentRow; // Row an der aktuellen Zeile 268 DbGridRowRef m_xPaintRow; // Row die gerade drgestellt werden soll 269 sal_Int32 m_nSeekPos; // Position des SeekCursors 270 sal_Int32 m_nTotalCount; // wird gesetzt, wenn der DatenCursor mit dem Z�hlen der 271 // Datens�tze fertig ist 272 // initial Wert ist -1 273 osl::Mutex m_aDestructionSafety; 274 osl::Mutex m_aAdjustSafety; 275 276 com::sun::star::util::Date 277 m_aNullDate; // NullDate of the Numberformatter; 278 279 BrowserMode m_nMode; 280 sal_Int32 m_nCurrentPos; // Aktuelle Position; 281 sal_uInt32 m_nDeleteEvent; // EventId fuer asychrone Loeschen von Zeilen 282 sal_uInt16 m_nOptions; // Was kann das Control (Insert, Update, Delete) 283 // default readonly 284 sal_uInt16 m_nOptionMask; // the mask of options to be enabled in setDataSource 285 // (with respect to the data source capabilities) 286 // defaults to (insert | update | delete) 287 sal_uInt16 m_nLastColId; 288 long m_nLastRowId; 289 290 sal_Bool m_bDesignMode : 1; // default = sal_False 291 sal_Bool m_bRecordCountFinal : 1; 292 sal_Bool m_bMultiSelection : 1; 293 sal_Bool m_bNavigationBar : 1; 294 295 sal_Bool m_bSynchDisplay : 1; 296 sal_Bool m_bForceROController : 1; 297 sal_Bool m_bHandle : 1; 298 sal_Bool m_bFilterMode : 1; 299 sal_Bool m_bWantDestruction : 1; 300 sal_Bool m_bInAdjustDataSource : 1; 301 sal_Bool m_bPendingAdjustRows : 1; // if an async adjust is pending, is it for AdjustRows or AdjustDataSource ? 302 sal_Bool m_bHideScrollbars : 1; 303 304 protected: 305 sal_Bool m_bUpdating : 1; // werden gerade updates durchgefuehrt 306 307 protected: 308 virtual sal_Bool SeekRow(long nRow); 309 virtual void VisibleRowsChanged( long nNewTopRow, sal_uInt16 nNumRows); 310 virtual void PaintStatusCell(OutputDevice& rDev, const Rectangle& rRect) const; 311 virtual void PaintCell(OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColId) const; 312 virtual RowStatus GetRowStatus(long nRow) const; 313 virtual sal_Bool CursorMoving(long nNewRow, sal_uInt16 nNewCol); 314 virtual void CursorMoved(); 315 virtual void ArrangeControls(sal_uInt16& nX, sal_uInt16 nY); 316 virtual sal_uInt32 GetTotalCellWidth(long nRow, sal_uInt16 nColId); 317 virtual void Command(const CommandEvent& rEvt); 318 virtual long PreNotify(NotifyEvent& rEvt); 319 virtual void KeyInput(const KeyEvent& rEvt); 320 virtual void StateChanged( StateChangedType nType ); 321 virtual void DataChanged( const DataChangedEvent& rDCEvt ); 322 virtual void Select(); 323 324 virtual ::svt::CellController* GetController(long nRow, sal_uInt16 nCol); 325 326 virtual void CellModified(); 327 virtual sal_Bool SaveModified(); 328 virtual sal_Bool IsModified() const; 329 330 virtual sal_uInt16 AppendColumn(const String& rName, sal_uInt16 nWidth = 0, sal_uInt16 nPos = HEADERBAR_APPEND, sal_uInt16 nId = (sal_uInt16)-1); 331 virtual void RemoveColumn(sal_uInt16 nId); 332 virtual DbGridColumn* CreateColumn(sal_uInt16 nId) const; 333 virtual void ColumnMoved(sal_uInt16 nId); 334 virtual sal_Bool SaveRow(); 335 virtual sal_Bool IsTabAllowed(sal_Bool bForward) const; 336 337 /// hide a column 338 virtual void HideColumn(sal_uInt16 nId); 339 /// show a column 340 virtual void ShowColumn(sal_uInt16 nId); 341 342 /** This is called before executing a context menu for a row. rMenu contains the initial entries 343 handled by this base class' method (which always has to be called). 344 Derived classes may alter the menu in any way and handle any additional entries in 345 PostExecuteColumnContextMenu. 346 All disabled entries will be removed before executing the menu, so be careful with separators 347 near entries you probably wish to disable ... 348 */ 349 virtual void PreExecuteRowContextMenu(sal_uInt16 nRow, PopupMenu& rMenu); 350 /** After executing the context menu for a row this method is called. 351 */ 352 virtual void PostExecuteRowContextMenu(sal_uInt16 nRow, const PopupMenu& rMenu, sal_uInt16 nExecutionResult); 353 354 virtual void DataSourcePropertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException); 355 356 virtual void FieldValueChanged(sal_uInt16 _nId, const ::com::sun::star::beans::PropertyChangeEvent& _evt); 357 virtual void FieldListenerDisposing(sal_uInt16 _nId); 358 359 virtual void disposing(sal_uInt16 _nId, const ::com::sun::star::lang::EventObject& _rEvt); 360 361 // own overridables 362 /// called when the current row changed 363 virtual void onRowChange(); 364 /// called when the current column changed 365 virtual void onColumnChange(); 366 367 // DragSourceHelper overridables 368 virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ); 369 370 void executeRowContextMenu( long _nRow, const Point& _rPreferredPos ); 371 372 public: 373 DbGridControl( 374 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >, 375 Window* pParent, 376 WinBits nBits = WB_BORDER); 377 378 virtual ~DbGridControl(); 379 380 virtual void Init(); 381 virtual void InitColumnsByFields(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xFields) = 0; 382 virtual void RemoveRows(); 383 384 /** GetCellText returns the text at the given position 385 @param _nRow 386 the number of the row 387 @param _nColId 388 the ID of the column 389 @return 390 the text out of the cell 391 */ 392 virtual String GetCellText(long _nRow, sal_uInt16 _nColId) const; 393 394 void RemoveRows(sal_Bool bNewCursor); 395 396 void InvalidateStatus(); 397 getNumberFormatter() const398 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& getNumberFormatter() const {return m_xFormatter;} 399 400 // die Datenquelle 401 // die Optionen koennen die Updatefaehigkeiten noch einschraenken, nicht erweitern 402 virtual void setDataSource(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& rCursor, 403 sal_uInt16 nOpts = OPT_INSERT | OPT_UPDATE | OPT_DELETE); 404 virtual void Dispatch(sal_uInt16 nId); 405 getDataSource() const406 CursorWrapper* getDataSource() const {return m_pDataCursor;} GetColumns() const407 const DbGridColumns& GetColumns() const {return m_aColumns;} 408 409 void EnableHandle(sal_Bool bEnable); HasHandle() const410 sal_Bool HasHandle() const {return m_bHandle;} 411 void InsertHandleColumn(); 412 413 /// welche Position hat die Spalte mit der Id in der ::com::sun::star::sdbcx::View, die Handle-Column zahelt nicht mit GetViewColumnPos(sal_uInt16 nId) const414 sal_uInt16 GetViewColumnPos( sal_uInt16 nId ) const { sal_uInt16 nPos = GetColumnPos(nId); return (nPos==(sal_uInt16)-1) ? GRID_COLUMN_NOT_FOUND : nPos-1; } 415 416 /** welche Position hat die Spalte mit der Id in m_aColumns, also dem von GetColumns gelieferten ::com::sun::star::sdbcx::Container ? 417 (unterscheidet sich u.U. von der von GetViewColumnPos gelieferten, wenn es versteckt Spalten gibt) 418 */ 419 sal_uInt16 GetModelColumnPos( sal_uInt16 nId ) const; 420 421 /// Anzahl der Spalten im Model GetViewColCount() const422 sal_uInt16 GetViewColCount() const { return ColCount() - 1; } GetModelColCount() const423 sal_uInt16 GetModelColCount() const { return (sal_uInt16)m_aColumns.Count(); } 424 /// umgekehrt zu GetViewColumnPos : Id zu Position, die erste Nicht-Handle-Column hat die Position 0 GetColumnIdFromViewPos(sal_uInt16 nPos) const425 sal_uInt16 GetColumnIdFromViewPos( sal_uInt16 nPos ) const { return GetColumnId(nPos + 1); } 426 sal_uInt16 GetColumnIdFromModelPos( sal_uInt16 nPos ) const; 427 428 virtual void SetDesignMode(sal_Bool bMode); IsDesignMode() const429 sal_Bool IsDesignMode() const {return m_bDesignMode;} IsOpen() const430 sal_Bool IsOpen() const {return m_pSeekCursor != NULL;} 431 432 virtual void SetFilterMode(sal_Bool bMode); IsFilterMode() const433 sal_Bool IsFilterMode() const {return m_bFilterMode;} IsFilterRow(long nRow) const434 sal_Bool IsFilterRow(long nRow) const {return m_bFilterMode && nRow == 0;} 435 436 void EnableNavigationBar(sal_Bool bEnable); HasNavigationBar() const437 sal_Bool HasNavigationBar() const {return m_bNavigationBar;} 438 GetOptions() const439 sal_uInt16 GetOptions() const {return m_nOptions;} GetNavigationBar()440 NavigationBar& GetNavigationBar() {return m_aBar;} 441 sal_uInt16 SetOptions(sal_uInt16 nOpt); 442 // The new options are interpreted with respect to the current data source. If it is unable 443 // to update, to insert or to restore, the according options are ignored. If the grid isn't 444 // connected to a data source, all options except OPT_READONLY are ignored. 445 446 void SetMultiSelection(sal_Bool bMulti); GetMultiSelection() const447 sal_Bool GetMultiSelection() const {return m_bMultiSelection;} 448 getNullDate() const449 const com::sun::star::util::Date& getNullDate() const {return m_aNullDate;} 450 451 // Positionierung 452 void MoveToPosition(sal_uInt32 nPos); 453 void MoveToFirst(); 454 void MoveToNext(); 455 void MoveToPrev(); 456 void MoveToLast(); 457 void AppendNew(); 458 459 // Abgleich der Cursor falls von au�en der DatenCursor verschoben wurde 460 // Flag bedeutet ob ein Abgleich es Rowcounts vorgenommen werden soll 461 void AdjustDataSource(sal_Bool bFull = sal_False); 462 void Undo(); 463 464 virtual void BeginCursorAction(); 465 virtual void EndCursorAction(); 466 467 // wird die aktuelle Zeile neu gesetzt IsUpdating() const468 sal_Bool IsUpdating() const {return m_bUpdating;} 469 470 virtual void RowRemoved( long nRow, long nNumRows = 1, sal_Bool bDoPaint = sal_True ); 471 virtual void RowInserted( long nRow, long nNumRows = 1, sal_Bool bDoPaint = sal_True, sal_Bool bKeepSelection = sal_False ); 472 virtual void RowModified( long nRow, sal_uInt16 nColId = USHRT_MAX ); 473 474 void resetCurrentRow(); 475 getDisplaySynchron() const476 sal_Bool getDisplaySynchron() const { return m_bSynchDisplay; } 477 void setDisplaySynchron(sal_Bool bSync); 478 void forceSyncDisplay(); 479 // wenn das auf sal_False gesetzt wird, laeuft die Anzeige nicht mehr mit der aktuellen Cursor-Position synchron 480 // (soll heissen, in AdjustDataSource wird nicht in die zur CursorPosition gehoerenden Zeile gesprungen) 481 // wer das benutzt, sollte bitte wissen, was er tut, da zum Beispiel die Eingabe von Daten in einer Zeile auf der Anzeige, 482 // die gar nicht mit der Position des Cursors synchron ist, ziemlich kritisch sein koennte 483 isForcedROController() const484 sal_Bool isForcedROController() const { return m_bForceROController; } 485 void forceROController(sal_Bool bForce); 486 // Setzt man das auf sal_True, hat das GridControl immer einen ::com::sun::star::frame::Controller, der allerdings read-only ist. Ausserdem 487 // wird die Edit-Zeile des Controllers so eingestellt, dass sie ihre Selektion bei Fokus-Verlust weiterhin anzeigt. 488 GetCurrentRow() const489 const DbGridRowRef& GetCurrentRow() const {return m_xCurrentRow;} 490 SetStateProvider(const Link & rProvider)491 void SetStateProvider(const Link& rProvider) { m_aMasterStateProvider = rProvider; } 492 // if this link is set the given provider will be asked for the state of my items. 493 // the return values are interpreted as follows : 494 // <0 -> not specified (use default mechanism to determine the state) 495 // ==0 -> the item is disabled 496 // >0 -> the item is enabled SetSlotExecutor(const Link & rExecutor)497 void SetSlotExecutor(const Link& rExecutor) { m_aMasterSlotExecutor = rExecutor; } 498 // analogous : if this link is set, all nav-bar slots will be routed through it when executed 499 // if the handler returns nonzero, no further handling of the slot occurs 500 501 void EnablePermanentCursor(sal_Bool bEnable); 502 sal_Bool IsPermanentCursorEnabled() const; 503 504 /** forces both scrollbars to be hidden 505 506 For the horizontal srollbar, this is overruled by enabling the navigation bar: A navigation 507 bar <b>always</b> implies a horizontal scroll bar 508 @seealso EnableNavigationBar 509 */ 510 void ForceHideScrollbars( sal_Bool _bForce ); 511 sal_Bool IsForceHideScrollbars() const; 512 513 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getServiceManager() const514 getServiceManager() const { return m_xServiceFactory; } 515 516 /// returns <TRUE/> if the text of the given cell can be copied into the clipboard 517 sal_Bool canCopyCellText(sal_Int32 _nRow, sal_Int16 _nColId); 518 /// copies the text of the given cell into the clipboard 519 void copyCellText(sal_Int32 _nRow, sal_Int16 _nColId); 520 521 // selectin listener handling getGridListener() const522 FmGridListener* getGridListener() const { return m_pGridListener; } setGridListener(FmGridListener * _pListener)523 void setGridListener( FmGridListener* _pListener ) { m_pGridListener = _pListener; } 524 525 // helper class to grant access to selected methods from within the DbCellControl class 526 struct GrantControlAccess 527 { 528 friend class DbCellControl; 529 friend class RowSetEventListener; 530 protected: GrantControlAccessDbGridControl::GrantControlAccess531 GrantControlAccess() { } 532 }; 533 534 /// called when a controller needs to be re-initialized 535 void refreshController(sal_uInt16 _nColId, GrantControlAccess _aAccess); 536 GetSeekCursor(GrantControlAccess) const537 CursorWrapper* GetSeekCursor(GrantControlAccess /*_aAccess*/) const { return m_pSeekCursor; } GetSeekRow(GrantControlAccess) const538 const DbGridRowRef& GetSeekRow(GrantControlAccess /*_aAccess*/) const { return m_xSeekRow; } SetSeekPos(sal_Int32 nPos,GrantControlAccess)539 void SetSeekPos(sal_Int32 nPos,GrantControlAccess /*_aAccess*/) {m_nSeekPos = nPos;} 540 541 /** 542 @return 543 The count of additional controls of the control area. 544 */ 545 virtual sal_Int32 GetAccessibleControlCount() const; 546 547 /** Creates the accessible object of an additional control. 548 @param _nIndex 549 The 0-based index of the control. 550 @return 551 The XAccessible interface of the specified control. 552 */ 553 virtual ::com::sun::star::uno::Reference< 554 ::com::sun::star::accessibility::XAccessible > 555 CreateAccessibleControl( sal_Int32 _nIndex ); 556 557 // IAccessibleTableProvider 558 /** Creates the accessible object of a data table cell. 559 @param nRow The row index of the cell. 560 @param nColumnId The column ID of the cell. 561 @return The XAccessible interface of the specified cell. */ 562 virtual ::com::sun::star::uno::Reference< 563 ::com::sun::star::accessibility::XAccessible > 564 CreateAccessibleCell( sal_Int32 nRow, sal_uInt16 nColumnId ); 565 566 protected: 567 void RecalcRows(long nNewTopRow, sal_uInt16 nLinesOnScreen, sal_Bool bUpdateCursor); 568 sal_Bool SeekCursor(long nRow, sal_Bool bAbsolute = sal_False); 569 void RemoveColumns(); // aufraeumen eigener strukturen 570 void AdjustRows(); 571 sal_Int32 AlignSeekCursor(); 572 sal_Bool SetCurrent(long nNewRow); 573 574 String GetCurrentRowCellText(DbGridColumn* pCol,const DbGridRowRef& _rRow) const; 575 virtual void DeleteSelectedRows(); IsValid(const DbGridRowRef & _xRow) const576 sal_Bool IsValid(const DbGridRowRef& _xRow) const {return _xRow && _xRow->IsValid();} 577 578 // Zeile an der gerade eingefuegt wird 579 sal_Bool IsCurrentAppending() const; 580 581 // Leerzeile zum Einfuegen 582 sal_Bool IsInsertionRow(long nRow) const; 583 SetSeekPos(sal_Int32 nPos)584 void SetSeekPos(sal_Int32 nPos) {m_nSeekPos = nPos;} GetCurrentPos() const585 sal_Int32 GetCurrentPos() const {return m_nCurrentPos;} GetSeekPos() const586 sal_Int32 GetSeekPos() const {return m_nSeekPos;} GetTotalCount() const587 sal_Int32 GetTotalCount() const {return m_nTotalCount;} 588 GetEmptyRow() const589 const DbGridRowRef& GetEmptyRow() const { return m_xEmptyRow; } GetSeekRow() const590 const DbGridRowRef& GetSeekRow() const { return m_xSeekRow; } GetPaintRow() const591 const DbGridRowRef& GetPaintRow() const { return m_xPaintRow; } GetSeekCursor() const592 CursorWrapper* GetSeekCursor() const { return m_pSeekCursor; } 593 594 595 void ConnectToFields(); 596 void DisconnectFromFields(); 597 598 void implAdjustInSolarThread(sal_Bool _bRows); 599 // calls AdjustRows or AdjustDataSource, synchron if the caller is running in the solar thread, else asynchron 600 601 protected: 602 virtual void InitController(::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol); 603 void Construct(); 604 void ImplInitWindow( const InitWindowFacet _eInitWhat ); 605 DECL_LINK(OnDelete, void*); 606 607 DECL_LINK(OnAsyncAdjust, void*); 608 // if the param is != NULL, AdjustRows will be called, else AdjustDataSource 609 610 private: 611 using BrowseBox::InsertHandleColumn; 612 }; 613 614 615 SV_IMPL_REF(DbGridRow); 616 617 618 #endif // _SVX_GRIDCTRL_HXX 619 620