Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _SVX_GRIDCTRL_HXX
29 : : #define _SVX_GRIDCTRL_HXX
30 : :
31 : : #include <com/sun/star/sdbc/XRowSet.hpp>
32 : : #include <com/sun/star/sdbc/XRowSetListener.hpp>
33 : : #include <com/sun/star/sdb/XRowsChangeListener.hpp>
34 : : #include <com/sun/star/beans/PropertyChangeEvent.hpp>
35 : : #include <com/sun/star/util/XNumberFormatter.hpp>
36 : : #include <com/sun/star/util/Date.hpp>
37 : : #include <com/sun/star/container/XIndexAccess.hpp>
38 : : #include <vcl/fixed.hxx>
39 : : #include <vcl/field.hxx>
40 : :
41 : : #include <vcl/button.hxx>
42 : : #include <tools/ref.hxx>
43 : : #include <svtools/editbrowsebox.hxx>
44 : : #include <osl/mutex.hxx>
45 : : #include <comphelper/propmultiplex.hxx>
46 : : #include <svtools/transfer.hxx>
47 : : #include "svx/svxdllapi.h"
48 : : #include <vector>
49 : :
50 : : class DbGridControl;
51 : : class CursorWrapper;
52 : :
53 : : sal_Bool CompareBookmark(const ::com::sun::star::uno::Any& aLeft, const ::com::sun::star::uno::Any& aRight);
54 : :
55 : : namespace svxform
56 : : {
57 : : class DataColumn;
58 : : }
59 : : typedef ::std::vector< ::svxform::DataColumn* > DbDataColumns;
60 : :
61 : : enum GridRowStatus
62 : : {
63 : : GRS_CLEAN,
64 : : GRS_MODIFIED,
65 : : GRS_DELETED,
66 : : GRS_INVALID
67 : : };
68 : :
69 : : //==================================================================
70 : : // DbGridRow, description of rows
71 : : //==================================================================
72 : :
73 : : class DbGridRow : public SvRefBase
74 : : {
75 : : ::com::sun::star::uno::Any m_aBookmark; // ::com::sun::star::text::Bookmark of the row, can be set
76 : : DbDataColumns m_aVariants;
77 : : GridRowStatus m_eStatus;
78 : : sal_Bool m_bIsNew;
79 : : // row is no longer valid
80 : : // is removed on the next positioning
81 : : public:
82 : : DbGridRow():m_eStatus(GRS_CLEAN), m_bIsNew(sal_True) { }
83 : : DbGridRow(CursorWrapper* pCur, sal_Bool bPaintCursor);
84 : : void SetState(CursorWrapper* pCur, sal_Bool bPaintCursor);
85 : :
86 : : ~DbGridRow();
87 : :
88 : : sal_Bool HasField(sal_uInt32 nPos) const { return nPos < m_aVariants.size(); }
89 : : const ::svxform::DataColumn& GetField(sal_uInt32 nPos) const { return *m_aVariants[ nPos ]; }
90 : :
91 : : void SetStatus(GridRowStatus _eStat) { m_eStatus = _eStat; }
92 : : GridRowStatus GetStatus() const { return m_eStatus; }
93 : : void SetNew(sal_Bool _bNew) { m_bIsNew = _bNew; }
94 : : sal_Bool IsNew() const { return m_bIsNew; }
95 : :
96 : : const ::com::sun::star::uno::Any& GetBookmark() const { return m_aBookmark; }
97 : :
98 : : sal_Bool IsValid() const { return m_eStatus == GRS_CLEAN || m_eStatus == GRS_MODIFIED; }
99 : 0 : sal_Bool IsModified() const { return m_eStatus == GRS_MODIFIED; }
100 : : };
101 : :
102 : 0 : SV_DECL_REF(DbGridRow)
103 : :
104 : : //==================================================================
105 : : // DbGridControl
106 : : //==================================================================
107 : : class DbGridColumn;
108 : : typedef ::std::vector< DbGridColumn* > DbGridColumns;
109 : :
110 : : //==================================================================
111 : : class FmGridListener
112 : : {
113 : : public:
114 : : virtual void selectionChanged() = 0;
115 : : virtual void columnChanged() = 0;
116 : :
117 : : protected:
118 : : ~FmGridListener() {}
119 : : };
120 : :
121 : : #define GRID_COLUMN_NOT_FOUND SAL_MAX_UINT16
122 : :
123 : : //==================================================================
124 : : // InitWindowFacet, describing which aspect of a column's Window to (re-)initialize
125 : : //==================================================================
126 : : enum InitWindowFacet
127 : : {
128 : : InitFont = 0x01,
129 : : InitForeground = 0x02,
130 : : InitBackground = 0x04,
131 : : InitWritingMode = 0x08,
132 : : InitAll = 0xFF
133 : : };
134 : :
135 : : //==================================================================
136 : : class FmXGridSourcePropListener;
137 : : class DisposeListenerGridBridge;
138 : : typedef ::svt::EditBrowseBox DbGridControl_Base;
139 : : class SVX_DLLPUBLIC DbGridControl : public DbGridControl_Base
140 : : {
141 : : friend class FmXGridSourcePropListener;
142 : : friend class GridFieldValueListener;
143 : : friend class DisposeListenerGridBridge;
144 : :
145 : : public:
146 : : //==================================================================
147 : : // NavigationBar
148 : : //==================================================================
149 : : class NavigationBar: public Control
150 : : {
151 : : class AbsolutePos : public NumericField
152 : : {
153 : : public:
154 : : AbsolutePos(Window* pParent, WinBits nStyle = 0);
155 : :
156 : : virtual void KeyInput(const KeyEvent& rEvt);
157 : : virtual void LoseFocus();
158 : : };
159 : :
160 : : friend class NavigationBar::AbsolutePos;
161 : :
162 : : // zusaetzliche Controls
163 : : FixedText m_aRecordText;
164 : : AbsolutePos m_aAbsolute; // absolute positioning
165 : : FixedText m_aRecordOf;
166 : : FixedText m_aRecordCount;
167 : :
168 : : ImageButton m_aFirstBtn; // ImageButton for 'go to the first record'
169 : : ImageButton m_aPrevBtn; // ImageButton for 'go to the previous record'
170 : : ImageButton m_aNextBtn; // ImageButton for 'go to the next record'
171 : : ImageButton m_aLastBtn; // ImageButton for 'go to the last record'
172 : : ImageButton m_aNewBtn; // ImageButton for 'go to a new record'
173 : : sal_uInt16 m_nDefaultWidth;
174 : : sal_Int32 m_nCurrentPos;
175 : :
176 : : sal_Bool m_bPositioning; // protect PositionDataSource against recursion
177 : :
178 : : public:
179 : : // StatusIds for Controls of the Bar
180 : : // important for invalidation
181 : : enum State
182 : : {
183 : : RECORD_TEXT = 1,
184 : : RECORD_ABSOLUTE,
185 : : RECORD_OF,
186 : : RECORD_COUNT,
187 : : RECORD_FIRST,
188 : : RECORD_NEXT,
189 : : RECORD_PREV,
190 : : RECORD_LAST,
191 : : RECORD_NEW
192 : : };
193 : :
194 : : NavigationBar(Window* pParent, WinBits nStyle = 0);
195 : :
196 : : // Status methods for Controls
197 : : void InvalidateAll(sal_Int32 nCurrentPos = -1, sal_Bool bAll = sal_False);
198 : : void InvalidateState(sal_uInt16 nWhich) {SetState(nWhich);}
199 : : void SetState(sal_uInt16 nWhich);
200 : : sal_Bool GetState(sal_uInt16 nWhich) const;
201 : : sal_uInt16 GetDefaultWidth() const {return m_nDefaultWidth;}
202 : :
203 : : protected:
204 : : virtual void Resize();
205 : : virtual void Paint(const Rectangle& rRect);
206 : : virtual void StateChanged( StateChangedType nType );
207 : :
208 : : private:
209 : : DECL_LINK(OnClick, Button*);
210 : : sal_uInt16 ArrangeControls();
211 : :
212 : : void PositionDataSource(sal_Int32 nRecord);
213 : : };
214 : :
215 : : friend class DbGridControl::NavigationBar;
216 : :
217 : : public:
218 : : // these options are or'ed and indicate, which of the single
219 : : // features can be released, default is readonly which means 0
220 : : enum Option
221 : : {
222 : : OPT_READONLY = 0x00,
223 : : OPT_INSERT = 0x01,
224 : : OPT_UPDATE = 0x02,
225 : : OPT_DELETE = 0x04
226 : : };
227 : :
228 : : private:
229 : : Font m_aDefaultFont;
230 : : Link m_aMasterStateProvider;
231 : : Link m_aMasterSlotExecutor;
232 : :
233 : : ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xFormatter;
234 : : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceFactory;
235 : :
236 : : DbGridColumns m_aColumns; // Column description
237 : : NavigationBar m_aBar;
238 : : DbGridRowRef m_xDataRow; // Row which can be modified
239 : : // comes from the data cursor
240 : : DbGridRowRef m_xSeekRow, // Row to which the iterator can set
241 : : // comes from the data cursor
242 : :
243 : : m_xEmptyRow; // record set to insert
244 : :
245 : : sal_uInt32 m_nAsynAdjustEvent;
246 : :
247 : : // if we modify the row for the new record, we automatically insert a "new new row".
248 : : // But if somebody else inserts a new record into the data source, we have to do the same.
249 : : // For that reason we have to listen to some properties of our data source.
250 : : ::comphelper::OPropertyChangeMultiplexer* m_pDataSourcePropMultiplexer;
251 : : FmXGridSourcePropListener* m_pDataSourcePropListener;
252 : : ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowsChangeListener>
253 : : m_xRowSetListener; // get notification when rows were changed
254 : :
255 : : void* m_pFieldListeners;
256 : : // property listeners for field values
257 : :
258 : : DisposeListenerGridBridge* m_pCursorDisposeListener;
259 : : // need to know about the diposing of the seek cursor
260 : : // construct analogous to the data source proplistener/multiplexer above :
261 : : // DisposeListenerGridBridge is a bridge from FmXDisposeListener which I don't want to be derived from
262 : :
263 : : FmGridListener* m_pGridListener;
264 : :
265 : : protected:
266 : : CursorWrapper* m_pDataCursor; // Cursor for Updates
267 : : CursorWrapper* m_pSeekCursor; // Cursor for Seeking
268 : :
269 : : private:
270 : : // iteration variables
271 : : DbGridRowRef m_xCurrentRow;
272 : : DbGridRowRef m_xPaintRow; // Row to be displayed
273 : : sal_Int32 m_nSeekPos; // Position of the SeekCursor
274 : : sal_Int32 m_nTotalCount; // is set when the data cursor finished counting the
275 : : // records. Initial value is -1
276 : : osl::Mutex m_aDestructionSafety;
277 : : osl::Mutex m_aAdjustSafety;
278 : :
279 : : com::sun::star::util::Date
280 : : m_aNullDate; // NullDate of the Numberformatter;
281 : :
282 : : BrowserMode m_nMode;
283 : : sal_Int32 m_nCurrentPos; // Current position;
284 : : sal_uInt32 m_nDeleteEvent; // EventId for asychronous deletion of rows
285 : : sal_uInt16 m_nOptions; // What is the able to do (Insert, Update, Delete)
286 : : // default readonly
287 : : sal_uInt16 m_nOptionMask; // the mask of options to be enabled in setDataSource
288 : : // (with respect to the data source capabilities)
289 : : // defaults to (insert | update | delete)
290 : : sal_uInt16 m_nLastColId;
291 : : long m_nLastRowId;
292 : :
293 : : sal_Bool m_bDesignMode : 1; // default = sal_False
294 : : sal_Bool m_bRecordCountFinal : 1;
295 : : sal_Bool m_bMultiSelection : 1;
296 : : sal_Bool m_bNavigationBar : 1;
297 : :
298 : : sal_Bool m_bSynchDisplay : 1;
299 : : sal_Bool m_bForceROController : 1;
300 : : sal_Bool m_bHandle : 1;
301 : : sal_Bool m_bFilterMode : 1;
302 : : sal_Bool m_bWantDestruction : 1;
303 : : sal_Bool m_bInAdjustDataSource : 1;
304 : : sal_Bool m_bPendingAdjustRows : 1; // if an async adjust is pending, is it for AdjustRows or AdjustDataSource ?
305 : : sal_Bool m_bHideScrollbars : 1;
306 : :
307 : : protected:
308 : : sal_Bool m_bUpdating : 1; // are any updates being executed right now?
309 : :
310 : : protected:
311 : : virtual sal_Bool SeekRow(long nRow);
312 : : virtual void VisibleRowsChanged( long nNewTopRow, sal_uInt16 nNumRows);
313 : : virtual void PaintStatusCell(OutputDevice& rDev, const Rectangle& rRect) const;
314 : : virtual void PaintCell(OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColId) const;
315 : : virtual RowStatus GetRowStatus(long nRow) const;
316 : : virtual sal_Bool CursorMoving(long nNewRow, sal_uInt16 nNewCol);
317 : : virtual void CursorMoved();
318 : : virtual void ArrangeControls(sal_uInt16& nX, sal_uInt16 nY);
319 : : virtual sal_uInt32 GetTotalCellWidth(long nRow, sal_uInt16 nColId);
320 : : virtual void Command(const CommandEvent& rEvt);
321 : : virtual long PreNotify(NotifyEvent& rEvt);
322 : : virtual void KeyInput(const KeyEvent& rEvt);
323 : : virtual void StateChanged( StateChangedType nType );
324 : : virtual void DataChanged( const DataChangedEvent& rDCEvt );
325 : : virtual void Select();
326 : :
327 : : virtual ::svt::CellController* GetController(long nRow, sal_uInt16 nCol);
328 : :
329 : : virtual void CellModified();
330 : : virtual sal_Bool SaveModified();
331 : : virtual sal_Bool IsModified() const;
332 : :
333 : : virtual sal_uInt16 AppendColumn(const String& rName, sal_uInt16 nWidth = 0, sal_uInt16 nPos = HEADERBAR_APPEND, sal_uInt16 nId = (sal_uInt16)-1);
334 : : virtual void RemoveColumn(sal_uInt16 nId);
335 : : virtual DbGridColumn* CreateColumn(sal_uInt16 nId) const;
336 : : virtual void ColumnMoved(sal_uInt16 nId);
337 : : virtual sal_Bool SaveRow();
338 : : virtual sal_Bool IsTabAllowed(sal_Bool bForward) const;
339 : :
340 : : /// hide a column
341 : : virtual void HideColumn(sal_uInt16 nId);
342 : : /// show a column
343 : : virtual void ShowColumn(sal_uInt16 nId);
344 : :
345 : : /** This is called before executing a context menu for a row. rMenu contains the initial entries
346 : : handled by this base class' method (which always has to be called).
347 : : Derived classes may alter the menu in any way and handle any additional entries in
348 : : PostExecuteColumnContextMenu.
349 : : All disabled entries will be removed before executing the menu, so be careful with separators
350 : : near entries you probably wish to disable ...
351 : : */
352 : : virtual void PreExecuteRowContextMenu(sal_uInt16 nRow, PopupMenu& rMenu);
353 : : /** After executing the context menu for a row this method is called.
354 : : */
355 : : virtual void PostExecuteRowContextMenu(sal_uInt16 nRow, const PopupMenu& rMenu, sal_uInt16 nExecutionResult);
356 : :
357 : : virtual void DataSourcePropertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException);
358 : :
359 : : virtual void FieldValueChanged(sal_uInt16 _nId, const ::com::sun::star::beans::PropertyChangeEvent& _evt);
360 : : virtual void FieldListenerDisposing(sal_uInt16 _nId);
361 : :
362 : : virtual void disposing(sal_uInt16 _nId, const ::com::sun::star::lang::EventObject& _rEvt);
363 : :
364 : : // own overridables
365 : : /// called when the current row changed
366 : : virtual void onRowChange();
367 : : /// called when the current column changed
368 : : virtual void onColumnChange();
369 : :
370 : : // DragSourceHelper overridables
371 : : virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
372 : :
373 : : void executeRowContextMenu( long _nRow, const Point& _rPreferredPos );
374 : :
375 : : public:
376 : : DbGridControl(
377 : : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >,
378 : : Window* pParent,
379 : : WinBits nBits = WB_BORDER);
380 : :
381 : : virtual ~DbGridControl();
382 : :
383 : : virtual void Init();
384 : : virtual void InitColumnsByFields(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xFields) = 0;
385 : : virtual void RemoveRows();
386 : :
387 : : /** GetCellText returns the text at the given position
388 : : @param _nRow
389 : : the number of the row
390 : : @param _nColId
391 : : the ID of the column
392 : : @return
393 : : the text out of the cell
394 : : */
395 : : virtual String GetCellText(long _nRow, sal_uInt16 _nColId) const;
396 : :
397 : : void RemoveRows(sal_Bool bNewCursor);
398 : :
399 : : void InvalidateStatus();
400 : :
401 : : const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& getNumberFormatter() const {return m_xFormatter;}
402 : :
403 : : // the data source
404 : : // the options can restrict but not extend the update abilities
405 : : virtual void setDataSource(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& rCursor,
406 : : sal_uInt16 nOpts = OPT_INSERT | OPT_UPDATE | OPT_DELETE);
407 : : virtual void Dispatch(sal_uInt16 nId);
408 : :
409 : : CursorWrapper* getDataSource() const {return m_pDataCursor;}
410 : : const DbGridColumns& GetColumns() const {return m_aColumns;}
411 : :
412 : : void EnableHandle(sal_Bool bEnable);
413 : : sal_Bool HasHandle() const {return m_bHandle;}
414 : : void InsertHandleColumn();
415 : :
416 : : // which position does the column with the id in the ::com::sun::star::sdbcx::View have, the handle column doesn't count
417 [ # # ]: 0 : sal_uInt16 GetViewColumnPos( sal_uInt16 nId ) const { sal_uInt16 nPos = GetColumnPos(nId); return (nPos==BROWSER_INVALIDID) ? GRID_COLUMN_NOT_FOUND : nPos-1; }
418 : :
419 : : // which position does the column with the id in m_aColumns have, that means the ::com::sun::star::sdbcx::Container
420 : : // returned from the GetColumns (may be different from the position returned by GetViewColumnPos
421 : : // if there are hidden columns)
422 : : sal_uInt16 GetModelColumnPos( sal_uInt16 nId ) const;
423 : :
424 : : // the number of columns in the model
425 : 0 : sal_uInt16 GetViewColCount() const { return ColCount() - 1; }
426 : : sal_uInt16 GetModelColCount() const { return (sal_uInt16)m_aColumns.size(); }
427 : : // reverse to GetViewColumnPos: Id of position, the first non-handle column has position 0
428 : 15 : sal_uInt16 GetColumnIdFromViewPos( sal_uInt16 nPos ) const { return GetColumnId(nPos + 1); }
429 : : sal_uInt16 GetColumnIdFromModelPos( sal_uInt16 nPos ) const;
430 : :
431 : : virtual void SetDesignMode(sal_Bool bMode);
432 : : sal_Bool IsDesignMode() const {return m_bDesignMode;}
433 : : sal_Bool IsOpen() const {return m_pSeekCursor != NULL;}
434 : :
435 : : virtual void SetFilterMode(sal_Bool bMode);
436 : : sal_Bool IsFilterMode() const {return m_bFilterMode;}
437 : : sal_Bool IsFilterRow(long nRow) const {return m_bFilterMode && nRow == 0;}
438 : :
439 : : void EnableNavigationBar(sal_Bool bEnable);
440 : : sal_Bool HasNavigationBar() const {return m_bNavigationBar;}
441 : :
442 : 4 : sal_uInt16 GetOptions() const {return m_nOptions;}
443 : : NavigationBar& GetNavigationBar() {return m_aBar;}
444 : : sal_uInt16 SetOptions(sal_uInt16 nOpt);
445 : : // The new options are interpreted with respect to the current data source. If it is unable
446 : : // to update, to insert or to restore, the according options are ignored. If the grid isn't
447 : : // connected to a data source, all options except OPT_READONLY are ignored.
448 : :
449 : : const com::sun::star::util::Date& getNullDate() const {return m_aNullDate;}
450 : :
451 : : // positioning
452 : : void MoveToPosition(sal_uInt32 nPos);
453 : : void MoveToFirst();
454 : : void MoveToNext();
455 : : void MoveToPrev();
456 : : void MoveToLast();
457 : : void AppendNew();
458 : :
459 : : // adjustment of the cursors in case the data cursor has been
460 : : // moved from the outside.
461 : : // the flag indicates if an adjustment of the row count should be
462 : : // done as well
463 : : void AdjustDataSource(sal_Bool bFull = sal_False);
464 : : void Undo();
465 : :
466 : : virtual void BeginCursorAction();
467 : : virtual void EndCursorAction();
468 : :
469 : : // is the current line being updated
470 : : sal_Bool IsUpdating() const {return m_bUpdating;}
471 : :
472 : : virtual void RowRemoved( long nRow, long nNumRows = 1, sal_Bool bDoPaint = sal_True );
473 : : virtual void RowInserted( long nRow, long nNumRows = 1, sal_Bool bDoPaint = sal_True, sal_Bool bKeepSelection = sal_False );
474 : : virtual void RowModified( long nRow, sal_uInt16 nColId = USHRT_MAX );
475 : :
476 : : void resetCurrentRow();
477 : :
478 : : sal_Bool getDisplaySynchron() const { return m_bSynchDisplay; }
479 : : void setDisplaySynchron(sal_Bool bSync);
480 : : // when set to sal_False, the display is no longer in sync with the current cursor position
481 : : // (means that in AdjustDataSource we are jumping to a row not belonging to CursorPosition)
482 : : // when using this, you should know what you are doing, because for example entering data
483 : : // in a row in the display that is not in sync with the position of the cursor can be very critical
484 : :
485 : 0 : const DbGridRowRef& GetCurrentRow() const {return m_xCurrentRow;}
486 : :
487 : : void SetStateProvider(const Link& rProvider) { m_aMasterStateProvider = rProvider; }
488 : : // if this link is set the given provider will be asked for the state of my items.
489 : : // the return values are interpreted as follows :
490 : : // <0 -> not specified (use default mechanism to determine the state)
491 : : // ==0 -> the item is disabled
492 : : // >0 -> the item is enabled
493 : : void SetSlotExecutor(const Link& rExecutor) { m_aMasterSlotExecutor = rExecutor; }
494 : : // analogous : if this link is set, all nav-bar slots will be routed through it when executed
495 : : // if the handler returns nonzero, no further handling of the slot occurs
496 : :
497 : : void EnablePermanentCursor(sal_Bool bEnable);
498 : : sal_Bool IsPermanentCursorEnabled() const;
499 : :
500 : : /** forces both scrollbars to be hidden
501 : :
502 : : For the horizontal srollbar, this is overruled by enabling the navigation bar: A navigation
503 : : bar <b>always</b> implies a horizontal scroll bar
504 : : @seealso EnableNavigationBar
505 : : */
506 : : void ForceHideScrollbars( sal_Bool _bForce );
507 : :
508 : : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
509 : 0 : getServiceManager() const { return m_xServiceFactory; }
510 : :
511 : : /// returns <TRUE/> if the text of the given cell can be copied into the clipboard
512 : : sal_Bool canCopyCellText(sal_Int32 _nRow, sal_Int16 _nColId);
513 : : /// copies the text of the given cell into the clipboard
514 : : void copyCellText(sal_Int32 _nRow, sal_Int16 _nColId);
515 : :
516 : : // selectin listener handling
517 : : FmGridListener* getGridListener() const { return m_pGridListener; }
518 : : void setGridListener( FmGridListener* _pListener ) { m_pGridListener = _pListener; }
519 : :
520 : : // helper class to grant access to selected methods from within the DbCellControl class
521 : : struct GrantControlAccess
522 : : {
523 : : friend class DbCellControl;
524 : : friend class RowSetEventListener;
525 : : protected:
526 : : GrantControlAccess() { }
527 : : };
528 : :
529 : : /// called when a controller needs to be re-initialized
530 : : void refreshController(sal_uInt16 _nColId, GrantControlAccess _aAccess);
531 : :
532 : : CursorWrapper* GetSeekCursor(GrantControlAccess /*_aAccess*/) const { return m_pSeekCursor; }
533 : : const DbGridRowRef& GetSeekRow(GrantControlAccess /*_aAccess*/) const { return m_xSeekRow; }
534 : : void SetSeekPos(sal_Int32 nPos,GrantControlAccess /*_aAccess*/) {m_nSeekPos = nPos;}
535 : :
536 : : /**
537 : : @return
538 : : The count of additional controls of the control area.
539 : : */
540 : : virtual sal_Int32 GetAccessibleControlCount() const;
541 : :
542 : : /** Creates the accessible object of an additional control.
543 : : @param _nIndex
544 : : The 0-based index of the control.
545 : : @return
546 : : The XAccessible interface of the specified control.
547 : : */
548 : : virtual ::com::sun::star::uno::Reference<
549 : : ::com::sun::star::accessibility::XAccessible >
550 : : CreateAccessibleControl( sal_Int32 _nIndex );
551 : :
552 : : // IAccessibleTableProvider
553 : : /** Creates the accessible object of a data table cell.
554 : : @param nRow The row index of the cell.
555 : : @param nColumnId The column ID of the cell.
556 : : @return The XAccessible interface of the specified cell. */
557 : : virtual ::com::sun::star::uno::Reference<
558 : : ::com::sun::star::accessibility::XAccessible >
559 : : CreateAccessibleCell( sal_Int32 nRow, sal_uInt16 nColumnId );
560 : :
561 : : protected:
562 : : void RecalcRows(long nNewTopRow, sal_uInt16 nLinesOnScreen, sal_Bool bUpdateCursor);
563 : : sal_Bool SeekCursor(long nRow, sal_Bool bAbsolute = sal_False);
564 : : void RemoveColumns(); // cleaning of own structures
565 : : void AdjustRows();
566 : : sal_Int32 AlignSeekCursor();
567 : : sal_Bool SetCurrent(long nNewRow);
568 : :
569 : : String GetCurrentRowCellText(DbGridColumn* pCol,const DbGridRowRef& _rRow) const;
570 : : virtual void DeleteSelectedRows();
571 : : sal_Bool IsValid(const DbGridRowRef& _xRow) const {return _xRow && _xRow->IsValid();}
572 : :
573 : : // row which is currently being appended
574 : : sal_Bool IsCurrentAppending() const;
575 : :
576 : : // empty row for insertion
577 : : sal_Bool IsInsertionRow(long nRow) const;
578 : :
579 : : void SetSeekPos(sal_Int32 nPos) {m_nSeekPos = nPos;}
580 : 0 : sal_Int32 GetCurrentPos() const {return m_nCurrentPos;}
581 : : sal_Int32 GetSeekPos() const {return m_nSeekPos;}
582 : : sal_Int32 GetTotalCount() const {return m_nTotalCount;}
583 : :
584 : 0 : const DbGridRowRef& GetEmptyRow() const { return m_xEmptyRow; }
585 : : const DbGridRowRef& GetSeekRow() const { return m_xSeekRow; }
586 : : const DbGridRowRef& GetPaintRow() const { return m_xPaintRow; }
587 : : CursorWrapper* GetSeekCursor() const { return m_pSeekCursor; }
588 : :
589 : :
590 : : void ConnectToFields();
591 : : void DisconnectFromFields();
592 : :
593 : : void implAdjustInSolarThread(sal_Bool _bRows);
594 : : // calls AdjustRows or AdjustDataSource, synchron if the caller is running in the solar thread, else asynchron
595 : :
596 : : protected:
597 : : virtual void InitController(::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol);
598 : : void Construct();
599 : : void ImplInitWindow( const InitWindowFacet _eInitWhat );
600 : : DECL_LINK(OnDelete, void*);
601 : :
602 : : DECL_LINK(OnAsyncAdjust, void*);
603 : : // if the param is != NULL, AdjustRows will be called, else AdjustDataSource
604 : :
605 : : private:
606 : : using BrowseBox::InsertHandleColumn;
607 : : };
608 : :
609 : :
610 : : SV_IMPL_REF(DbGridRow);
611 : :
612 : :
613 : : #endif // _SVX_GRIDCTRL_HXX
614 : :
615 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|