101aa44aaSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
301aa44aaSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
401aa44aaSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
501aa44aaSAndrew Rist  * distributed with this work for additional information
601aa44aaSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
701aa44aaSAndrew Rist  * to you under the Apache License, Version 2.0 (the
801aa44aaSAndrew Rist  * "License"); you may not use this file except in compliance
901aa44aaSAndrew Rist  * with the License.  You may obtain a copy of the License at
1001aa44aaSAndrew Rist  *
1101aa44aaSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
1201aa44aaSAndrew Rist  *
1301aa44aaSAndrew Rist  * Unless required by applicable law or agreed to in writing,
1401aa44aaSAndrew Rist  * software distributed under the License is distributed on an
1501aa44aaSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1601aa44aaSAndrew Rist  * KIND, either express or implied.  See the License for the
1701aa44aaSAndrew Rist  * specific language governing permissions and limitations
1801aa44aaSAndrew Rist  * under the License.
1901aa44aaSAndrew Rist  *
2001aa44aaSAndrew Rist  *************************************************************/
2101aa44aaSAndrew Rist 
2201aa44aaSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SVTOOLS_TABLECONTROL_IMPL_HXX
25cdf0e10cSrcweir #define SVTOOLS_TABLECONTROL_IMPL_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "svtools/table/tablemodel.hxx"
28cdf0e10cSrcweir #include "svtools/table/tablecontrolinterface.hxx"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include "svtaccessiblefactory.hxx"
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <vcl/seleng.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include <vector>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include <boost/scoped_ptr.hpp>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir class ScrollBar;
39cdf0e10cSrcweir class ScrollBarBox;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir //........................................................................
42cdf0e10cSrcweir namespace svt { namespace table
43cdf0e10cSrcweir {
44cdf0e10cSrcweir //........................................................................
45cdf0e10cSrcweir 
46cdf0e10cSrcweir     struct MutableColumnMetrics : protected ColumnMetrics
47cdf0e10cSrcweir     {
MutableColumnMetricssvt::table::MutableColumnMetrics48cdf0e10cSrcweir         MutableColumnMetrics()
49cdf0e10cSrcweir             :ColumnMetrics()
50cdf0e10cSrcweir         {
51cdf0e10cSrcweir         }
52cdf0e10cSrcweir 
MutableColumnMetricssvt::table::MutableColumnMetrics53cdf0e10cSrcweir         MutableColumnMetrics( long const i_startPixel, long const i_endPixel )
54cdf0e10cSrcweir             :ColumnMetrics( i_startPixel, i_endPixel )
55cdf0e10cSrcweir         {
56cdf0e10cSrcweir         }
57cdf0e10cSrcweir 
getStartsvt::table::MutableColumnMetrics58cdf0e10cSrcweir         long getStart() const { return nStartPixel; }
getEndsvt::table::MutableColumnMetrics59cdf0e10cSrcweir         long getEnd() const { return nEndPixel; }
60cdf0e10cSrcweir 
setEndsvt::table::MutableColumnMetrics61cdf0e10cSrcweir         void setEnd( long const i_end ) { nEndPixel = i_end; }
movesvt::table::MutableColumnMetrics62cdf0e10cSrcweir         void move( long const i_offset ) { nStartPixel += i_offset; nEndPixel += i_offset; }
63cdf0e10cSrcweir 
getWidthsvt::table::MutableColumnMetrics64cdf0e10cSrcweir         long getWidth() const { return nEndPixel - nStartPixel; }
65cdf0e10cSrcweir 
operator ()svt::table::MutableColumnMetrics66cdf0e10cSrcweir         ColumnMetrics const & operator()() { return *this; }
67cdf0e10cSrcweir     };
68cdf0e10cSrcweir 
69cdf0e10cSrcweir     struct ColumnInfoPositionLess
70cdf0e10cSrcweir     {
operator ()svt::table::ColumnInfoPositionLess71cdf0e10cSrcweir         bool operator()( MutableColumnMetrics const& i_colInfo, long const i_position )
72cdf0e10cSrcweir         {
73cdf0e10cSrcweir             return i_colInfo.getEnd() < i_position;
74cdf0e10cSrcweir         }
operator ()svt::table::ColumnInfoPositionLess75cdf0e10cSrcweir         bool operator()( long const i_position, MutableColumnMetrics const& i_colInfo )
76cdf0e10cSrcweir         {
77cdf0e10cSrcweir             return i_position < i_colInfo.getStart();
78cdf0e10cSrcweir         }
79cdf0e10cSrcweir     };
80cdf0e10cSrcweir 
81cdf0e10cSrcweir     typedef ::std::vector< MutableColumnMetrics >    ColumnPositions;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir     class TableControl;
84cdf0e10cSrcweir     class TableDataWindow;
85cdf0e10cSrcweir     class TableFunctionSet;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     //====================================================================
88cdf0e10cSrcweir 	//= TableControl_Impl
89cdf0e10cSrcweir 	//====================================================================
90cdf0e10cSrcweir     class TableControl_Impl :public ITableControl
91cdf0e10cSrcweir                             ,public ITableModelListener
92cdf0e10cSrcweir     {
93cdf0e10cSrcweir         friend class TableGeometry;
94cdf0e10cSrcweir         friend class TableRowGeometry;
95cdf0e10cSrcweir         friend class TableColumnGeometry;
96cdf0e10cSrcweir         friend class SuspendInvariants;
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     private:
99cdf0e10cSrcweir         /// the control whose impl-instance we implemnt
100cdf0e10cSrcweir         TableControl&       	m_rAntiImpl;
101cdf0e10cSrcweir         /// the model of the table control
102cdf0e10cSrcweir         PTableModel         	m_pModel;
103cdf0e10cSrcweir         /// the input handler to use, usually the input handler as provided by ->m_pModel
104cdf0e10cSrcweir         PTableInputHandler  	m_pInputHandler;
105cdf0e10cSrcweir         /// info about the widths of our columns
106cdf0e10cSrcweir         ColumnPositions         m_aColumnWidths;
107cdf0e10cSrcweir 
108cdf0e10cSrcweir         /// the height of a single row in the table, measured in pixels
109cdf0e10cSrcweir         long                	m_nRowHeightPixel;
110cdf0e10cSrcweir         /// the height of the column header row in the table, measured in pixels
111cdf0e10cSrcweir         long                	m_nColHeaderHeightPixel;
112cdf0e10cSrcweir         /// the width of the row header column in the table, measured in pixels
113cdf0e10cSrcweir         long                	m_nRowHeaderWidthPixel;
114cdf0e10cSrcweir 
115cdf0e10cSrcweir         /// the number of columns in the table control. Cached model value.
116cdf0e10cSrcweir         TableSize           	m_nColumnCount;
117cdf0e10cSrcweir 
118cdf0e10cSrcweir         /// the number of rows in the table control. Cached model value.
119cdf0e10cSrcweir         TableSize           	m_nRowCount;
120cdf0e10cSrcweir 
121cdf0e10cSrcweir         /// denotes whether or not the columns fitted into the available width, last time we checked
122cdf0e10cSrcweir         long                    m_bColumnsFit;
123cdf0e10cSrcweir 
124cdf0e10cSrcweir         ColPos              	m_nCurColumn;
125cdf0e10cSrcweir         RowPos              	m_nCurRow;
126cdf0e10cSrcweir         ColPos              	m_nLeftColumn;
127cdf0e10cSrcweir         RowPos              	m_nTopRow;
128cdf0e10cSrcweir 
129cdf0e10cSrcweir         sal_Int32           	m_nCursorHidden;
130cdf0e10cSrcweir 
131cdf0e10cSrcweir         /** the window to contain all data content, including header bars
132cdf0e10cSrcweir 
133cdf0e10cSrcweir             The window's upper left corner is at position (0,0), relative to the
134cdf0e10cSrcweir             table control, which is the direct parent of the data window.
135cdf0e10cSrcweir         */
136cdf0e10cSrcweir         ::boost::scoped_ptr< TableDataWindow >
137cdf0e10cSrcweir                                 m_pDataWindow;
138cdf0e10cSrcweir         /// the vertical scrollbar, if any
139cdf0e10cSrcweir         ScrollBar*          	m_pVScroll;
140cdf0e10cSrcweir         /// the horizontal scrollbar, if any
141cdf0e10cSrcweir         ScrollBar*              m_pHScroll;
142cdf0e10cSrcweir         ScrollBarBox*       	m_pScrollCorner;
143cdf0e10cSrcweir 	    //selection engine - for determining selection range, e.g. single, multiple
144cdf0e10cSrcweir 	    SelectionEngine*    	m_pSelEngine;
145cdf0e10cSrcweir 	    //vector which contains the selected rows
146cdf0e10cSrcweir 	    std::vector<RowPos> 	m_aSelectedRows;
147cdf0e10cSrcweir 	    //part of selection engine
148cdf0e10cSrcweir 	    TableFunctionSet*   	m_pTableFunctionSet;
149cdf0e10cSrcweir 	    //part of selection engine
150cdf0e10cSrcweir 	    RowPos		    	    m_nAnchor;
151cdf0e10cSrcweir         bool                    m_bUpdatingColWidths;
152cdf0e10cSrcweir 
153cdf0e10cSrcweir     	Link                    m_aSelectHdl;
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 	    AccessibleFactoryAccess     m_aFactoryAccess;
156cdf0e10cSrcweir 	    IAccessibleTableControl*    m_pAccessibleTable;
157cdf0e10cSrcweir 
158cdf0e10cSrcweir #if DBG_UTIL
159cdf0e10cSrcweir     #define INV_SCROLL_POSITION     1
160cdf0e10cSrcweir         /** represents a bitmask of invariants to check
161cdf0e10cSrcweir 
162cdf0e10cSrcweir             Actually, impl_checkInvariants checks more invariants than denoted in this
163cdf0e10cSrcweir             bit mask, but only those present here can be disabled temporarily.
164cdf0e10cSrcweir         */
165cdf0e10cSrcweir         sal_Int32           m_nRequiredInvariants;
166cdf0e10cSrcweir #endif
167cdf0e10cSrcweir 
168cdf0e10cSrcweir     public:
169cdf0e10cSrcweir         void        setModel( PTableModel _pModel );
170cdf0e10cSrcweir 
getInputHandler() const171cdf0e10cSrcweir         inline  const PTableInputHandler&   getInputHandler() const { return m_pInputHandler; }
172cdf0e10cSrcweir 
getCurRow() const173cdf0e10cSrcweir 		inline	RowPos  getCurRow() const           { return m_nCurRow; }
setCurRow(RowPos i_curRow)174cdf0e10cSrcweir 		inline	void	setCurRow( RowPos i_curRow ){ m_nCurRow = i_curRow; }
175cdf0e10cSrcweir 
getAnchor() const176cdf0e10cSrcweir         RowPos  getAnchor() const { return m_nAnchor; }
setAnchor(RowPos const i_anchor)177cdf0e10cSrcweir         void    setAnchor( RowPos const i_anchor ) { m_nAnchor = i_anchor; }
178cdf0e10cSrcweir 
getTopRow() const179cdf0e10cSrcweir         inline  RowPos  getTopRow() const       { return m_nTopRow; }
getLeftColumn() const180cdf0e10cSrcweir         inline  ColPos  getLeftColumn() const { return m_nLeftColumn; }
181cdf0e10cSrcweir 
getAntiImpl() const182cdf0e10cSrcweir         inline  const TableControl&   getAntiImpl() const { return m_rAntiImpl; }
getAntiImpl()183cdf0e10cSrcweir         inline        TableControl&   getAntiImpl()       { return m_rAntiImpl; }
184cdf0e10cSrcweir 
185cdf0e10cSrcweir     public:
186cdf0e10cSrcweir         TableControl_Impl( TableControl& _rAntiImpl );
187cdf0e10cSrcweir         ~TableControl_Impl();
188cdf0e10cSrcweir 
189cdf0e10cSrcweir #if DBG_UTIL
190cdf0e10cSrcweir         const sal_Char* impl_checkInvariants() const;
191cdf0e10cSrcweir #endif
192cdf0e10cSrcweir         /** to be called when the anti-impl instance has been resized
193cdf0e10cSrcweir         */
194cdf0e10cSrcweir         void    onResize();
195cdf0e10cSrcweir 
196cdf0e10cSrcweir         /** paints the table control content which intersects with the given rectangle
197cdf0e10cSrcweir         */
198cdf0e10cSrcweir         void    doPaintContent( const Rectangle& _rUpdateRect );
199cdf0e10cSrcweir 
200cdf0e10cSrcweir         /** moves the cursor to the cell with the given coordinates
201cdf0e10cSrcweir 
202cdf0e10cSrcweir             To ease the caller's code, the coordinates must not necessarily denote a
203cdf0e10cSrcweir             valid position. If they don't, <FALSE/> will be returned.
204cdf0e10cSrcweir         */
205cdf0e10cSrcweir         bool    goTo( ColPos _nColumn, RowPos _nRow );
206cdf0e10cSrcweir 
207cdf0e10cSrcweir         /** ensures that the given coordinate is visible
208cdf0e10cSrcweir             @param _nColumn
209cdf0e10cSrcweir                 the column position which should be visible. Must be non-negative, and smaller
210cdf0e10cSrcweir                 than the column count.
211cdf0e10cSrcweir             @param _nRow
212cdf0e10cSrcweir                 the row position which should be visibleMust be non-negative, and smaller
213cdf0e10cSrcweir                 than the row count.
214cdf0e10cSrcweir             @param _bAcceptPartialVisibility
215cdf0e10cSrcweir                 <TRUE/> if it's okay that the given cooordinate is only partially visible
216cdf0e10cSrcweir         */
217cdf0e10cSrcweir         void    ensureVisible( ColPos _nColumn, RowPos _nRow, bool _bAcceptPartialVisibility );
218cdf0e10cSrcweir 
219cdf0e10cSrcweir         /** retrieves the content of the given cell, converted to a string
220cdf0e10cSrcweir         */
221cdf0e10cSrcweir         ::rtl::OUString getCellContentAsString( RowPos const i_row, ColPos const i_col );
222cdf0e10cSrcweir 
223cdf0e10cSrcweir         /** returns the position of the current row in the selection vector */
224cdf0e10cSrcweir 	    int	getRowSelectedNumber(const ::std::vector<RowPos>& selectedRows, RowPos current);
225cdf0e10cSrcweir 
226cdf0e10cSrcweir         /** ??? */
227cdf0e10cSrcweir 	    void    invalidateSelectedRegion( RowPos _nPrevRow, RowPos _nCurRow );
228cdf0e10cSrcweir 
229cdf0e10cSrcweir         /** invalidates the part of the data window which is covered by the given rows
230cdf0e10cSrcweir             @param i_firstRow
231cdf0e10cSrcweir                 the index of the first row to include in the invalidation
232cdf0e10cSrcweir             @param i_lastRow
233cdf0e10cSrcweir                 the index of the last row to include in the invalidation, or ROW_INVALID if the invalidation
234cdf0e10cSrcweir                 should happen down to the bottom of the data window.
235cdf0e10cSrcweir         */
236cdf0e10cSrcweir         void    invalidateRowRange( RowPos const i_firstRow, RowPos const i_lastRow );
237cdf0e10cSrcweir 
238cdf0e10cSrcweir         /** invalidates the part of the data window which is covered by the given row
239cdf0e10cSrcweir         */
invalidateRow(RowPos const i_row)240cdf0e10cSrcweir         void    invalidateRow( RowPos const i_row ) { invalidateRowRange( i_row, i_row ); }
241cdf0e10cSrcweir 
242cdf0e10cSrcweir         /** invalidates all selected rows
243cdf0e10cSrcweir         */
244cdf0e10cSrcweir         void    invalidateSelectedRows();
245cdf0e10cSrcweir 
246cdf0e10cSrcweir 	    void    checkCursorPosition();
247cdf0e10cSrcweir 
hasRowSelection() const248cdf0e10cSrcweir         bool    hasRowSelection() const { return !m_aSelectedRows.empty(); }
getSelectedRowCount() const249cdf0e10cSrcweir         size_t  getSelectedRowCount() const { return m_aSelectedRows.size(); }
250cdf0e10cSrcweir         RowPos  getSelectedRowIndex( size_t const i_selectionIndex ) const;
251cdf0e10cSrcweir 
252cdf0e10cSrcweir         /** removes the given row index from m_aSelectedRows
253cdf0e10cSrcweir 
254cdf0e10cSrcweir             @return
255cdf0e10cSrcweir                 <TRUE/> if and only if the row was previously marked as selected
256cdf0e10cSrcweir         */
257cdf0e10cSrcweir         bool        markRowAsDeselected( RowPos const i_rowIndex );
258cdf0e10cSrcweir 
259cdf0e10cSrcweir         /** marks the given row as selectged, by putting it into m_aSelectedRows
260cdf0e10cSrcweir             @return
261cdf0e10cSrcweir                 <TRUE/> if and only if the row was previously <em>not</em> marked as selected
262cdf0e10cSrcweir         */
263cdf0e10cSrcweir         bool        markRowAsSelected( RowPos const i_rowIndex );
264cdf0e10cSrcweir 
265cdf0e10cSrcweir         /** marks all rows as deselected
266cdf0e10cSrcweir             @return
267cdf0e10cSrcweir                 <TRUE/> if and only if the selection actually changed by this operation
268cdf0e10cSrcweir         */
269cdf0e10cSrcweir         bool        markAllRowsAsDeselected();
270cdf0e10cSrcweir 
271cdf0e10cSrcweir         /** marks all rows as selected
272cdf0e10cSrcweir             @return
273cdf0e10cSrcweir                 <FALSE/> if and only if all rows were selected already.
274cdf0e10cSrcweir         */
275cdf0e10cSrcweir         bool        markAllRowsAsSelected();
276cdf0e10cSrcweir 
setSelectHandler(Link const & i_selectHandler)277cdf0e10cSrcweir         void        setSelectHandler( Link const & i_selectHandler ) { m_aSelectHdl = i_selectHandler; }
getSelectHandler() const278cdf0e10cSrcweir         Link const& getSelectHandler() const { return m_aSelectHdl; }
279cdf0e10cSrcweir 
280cdf0e10cSrcweir         void commitAccessibleEvent( sal_Int16 const i_eventID, const com::sun::star::uno::Any& i_newValue, const com::sun::star::uno::Any& i_oldValue );
281cdf0e10cSrcweir         void commitCellEvent( sal_Int16 const i_eventID, const com::sun::star::uno::Any& i_newValue, const com::sun::star::uno::Any& i_oldValue );
282cdf0e10cSrcweir         void commitTableEvent( sal_Int16 const i_eventID, const com::sun::star::uno::Any& i_newValue, const com::sun::star::uno::Any& i_oldValue );
283cdf0e10cSrcweir 
284cdf0e10cSrcweir         // ITableControl
285cdf0e10cSrcweir         virtual void                hideCursor();
286cdf0e10cSrcweir         virtual void                showCursor();
287cdf0e10cSrcweir         virtual bool                dispatchAction( TableControlAction _eAction );
288cdf0e10cSrcweir 	    virtual SelectionEngine*    getSelEngine();
289cdf0e10cSrcweir         virtual PTableModel         getModel() const;
290cdf0e10cSrcweir         virtual ColPos              getCurrentColumn() const;
291cdf0e10cSrcweir         virtual RowPos              getCurrentRow() const;
292cdf0e10cSrcweir         virtual bool                activateCell( ColPos const i_col, RowPos const i_row );
293cdf0e10cSrcweir         virtual ::Size              getTableSizePixel() const;
294cdf0e10cSrcweir         virtual void                setPointer( Pointer const & i_pointer );
295cdf0e10cSrcweir         virtual void                captureMouse();
296cdf0e10cSrcweir         virtual void                releaseMouse();
297cdf0e10cSrcweir         virtual void                invalidate( TableArea const i_what );
298cdf0e10cSrcweir         virtual long                pixelWidthToAppFont( long const i_pixels ) const;
299cdf0e10cSrcweir         virtual void                hideTracking();
300cdf0e10cSrcweir         virtual void                showTracking( Rectangle const & i_location, sal_uInt16 const i_flags );
301cdf0e10cSrcweir 	    virtual RowPos	            getRowAtPoint( const Point& rPoint ) const;
302cdf0e10cSrcweir         virtual ColPos              getColAtPoint( const Point& rPoint ) const;
303cdf0e10cSrcweir         virtual TableCell           hitTest( const Point& rPoint ) const;
304cdf0e10cSrcweir         virtual ColumnMetrics       getColumnMetrics( ColPos const i_column ) const;
305cdf0e10cSrcweir 	    virtual bool                isRowSelected( RowPos i_row ) const;
306cdf0e10cSrcweir 
307cdf0e10cSrcweir 
308cdf0e10cSrcweir         long                        appFontWidthToPixel( long const i_appFontUnits ) const;
309cdf0e10cSrcweir 
getDataWindow()310cdf0e10cSrcweir         TableDataWindow&        getDataWindow()       { return *m_pDataWindow; }
getDataWindow() const311cdf0e10cSrcweir         const TableDataWindow&  getDataWindow() const { return *m_pDataWindow; }
312cdf0e10cSrcweir 	    ScrollBar* getHorzScrollbar();
313cdf0e10cSrcweir 	    ScrollBar* getVertScrollbar();
314cdf0e10cSrcweir 
315cdf0e10cSrcweir 	    Rectangle calcHeaderRect( bool bColHeader );
316cdf0e10cSrcweir         Rectangle calcHeaderCellRect( bool bColHeader, sal_Int32 nPos );
317cdf0e10cSrcweir 	    Rectangle calcTableRect();
318cdf0e10cSrcweir         Rectangle calcCellRect( sal_Int32 nRow, sal_Int32 nCol );
319cdf0e10cSrcweir 
320cdf0e10cSrcweir         // A11Y
321cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
322cdf0e10cSrcweir                         getAccessible( Window& i_parentWindow );
323cdf0e10cSrcweir         void            disposeAccessible();
324cdf0e10cSrcweir 
isAccessibleAlive() const325cdf0e10cSrcweir         inline bool     isAccessibleAlive() const { return impl_isAccessibleAlive(); }
326cdf0e10cSrcweir 
327cdf0e10cSrcweir         // ITableModelListener
328cdf0e10cSrcweir         virtual void    rowsInserted( RowPos first, RowPos last );
329cdf0e10cSrcweir         virtual void    rowsRemoved( RowPos first, RowPos last );
330cdf0e10cSrcweir         virtual void    columnInserted( ColPos const i_colIndex );
331cdf0e10cSrcweir         virtual void    columnRemoved( ColPos const i_colIndex );
332cdf0e10cSrcweir         virtual void    allColumnsRemoved();
333cdf0e10cSrcweir         virtual void    cellsUpdated( ColPos const i_firstCol, ColPos i_lastCol, RowPos const i_firstRow, RowPos const i_lastRow );
334cdf0e10cSrcweir         virtual void    columnChanged( ColPos const i_column, ColumnAttributeGroup const i_attributeGroup );
335cdf0e10cSrcweir         virtual void    tableMetricsChanged();
336cdf0e10cSrcweir 
337cdf0e10cSrcweir     private:
338cdf0e10cSrcweir         bool            impl_isAccessibleAlive() const;
339cdf0e10cSrcweir         void            impl_commitAccessibleEvent(
340cdf0e10cSrcweir                             sal_Int16 const i_eventID,
341cdf0e10cSrcweir                             ::com::sun::star::uno::Any const & i_newValue,
342cdf0e10cSrcweir                             ::com::sun::star::uno::Any const & i_oldValue
343cdf0e10cSrcweir                         );
344cdf0e10cSrcweir 
345cdf0e10cSrcweir         /** toggles the cursor visibility
346cdf0e10cSrcweir 
347cdf0e10cSrcweir             The method is not bound to the classes public invariants, as it's used in
348cdf0e10cSrcweir             situations where the they must not necessarily be fullfilled.
349cdf0e10cSrcweir         */
350cdf0e10cSrcweir         void        impl_ni_doSwitchCursor( bool _bOn );
351cdf0e10cSrcweir 
352cdf0e10cSrcweir         /** returns the number of visible rows.
353cdf0e10cSrcweir 
354cdf0e10cSrcweir             @param _bAcceptPartialRow
355cdf0e10cSrcweir                 specifies whether a possible only partially visible last row is
356cdf0e10cSrcweir                 counted, too.
357cdf0e10cSrcweir         */
358cdf0e10cSrcweir         TableSize   impl_getVisibleRows( bool _bAcceptPartialRow ) const;
359cdf0e10cSrcweir 
360cdf0e10cSrcweir         /** returns the number of visible columns
361cdf0e10cSrcweir 
362cdf0e10cSrcweir             The value may change with different horizontal scroll positions, as
363cdf0e10cSrcweir             different columns have different widths. For instance, if your control is
364cdf0e10cSrcweir             100 pixels wide, and has three columns of width 50, 50, 100, respectively,
365cdf0e10cSrcweir             then this method will return either "2" or "1", depending on which column
366cdf0e10cSrcweir             is the first visible one.
367cdf0e10cSrcweir 
368cdf0e10cSrcweir             @param _bAcceptPartialRow
369cdf0e10cSrcweir                 specifies whether a possible only partially visible last row is
370cdf0e10cSrcweir                 counted, too.
371cdf0e10cSrcweir         */
372cdf0e10cSrcweir         TableSize   impl_getVisibleColumns( bool _bAcceptPartialCol ) const;
373cdf0e10cSrcweir 
374cdf0e10cSrcweir         /** determines the rectangle occupied by the given cell
375cdf0e10cSrcweir         */
376cdf0e10cSrcweir         void        impl_getCellRect( ColPos _nColumn, RowPos _nRow, Rectangle& _rCellRect ) const;
377cdf0e10cSrcweir 
378cdf0e10cSrcweir         /** updates all cached model values
379cdf0e10cSrcweir 
380cdf0e10cSrcweir             The method is not bound to the classes public invariants, as it's used in
381cdf0e10cSrcweir             situations where the they must not necessarily be fullfilled.
382cdf0e10cSrcweir         */
383cdf0e10cSrcweir         void        impl_ni_updateCachedModelValues();
384cdf0e10cSrcweir 
385cdf0e10cSrcweir         /** updates the cached table metrics (row height etc.)
386cdf0e10cSrcweir         */
387cdf0e10cSrcweir         void        impl_ni_updateCachedTableMetrics();
388cdf0e10cSrcweir 
389cdf0e10cSrcweir         /** does a relayout of the table control
390cdf0e10cSrcweir 
391cdf0e10cSrcweir             Column widths, and consequently the availability of the vertical and horizontal scrollbar, are updated
392cdf0e10cSrcweir             with a call to this method.
393cdf0e10cSrcweir 
394cdf0e10cSrcweir             @param i_assumeInflexibleColumnsUpToIncluding
395cdf0e10cSrcweir                 the index of a column up to which all columns should be considered as inflexible, or
396cdf0e10cSrcweir                 <code>COL_INVALID</code>.
397cdf0e10cSrcweir         */
398cdf0e10cSrcweir         void        impl_ni_relayout( ColPos const i_assumeInflexibleColumnsUpToIncluding = COL_INVALID );
399cdf0e10cSrcweir 
400cdf0e10cSrcweir         /** calculates the new width of our columns, taking into account their min and max widths, and their relative
401cdf0e10cSrcweir             flexibility.
402cdf0e10cSrcweir 
403cdf0e10cSrcweir             @param i_assumeInflexibleColumnsUpToIncluding
404cdf0e10cSrcweir                 the index of a column up to which all columns should be considered as inflexible, or
405cdf0e10cSrcweir                 <code>COL_INVALID</code>.
406cdf0e10cSrcweir 
407cdf0e10cSrcweir             @param i_assumeVerticalScrollbar
408cdf0e10cSrcweir                 controls whether or not we should assume the presence of a vertical scrollbar. If <true/>, and
409cdf0e10cSrcweir                 if the model has a VerticalScrollbarVisibility != ScrollbarShowNever, the method will leave
410cdf0e10cSrcweir                 space for a vertical scrollbar.
411cdf0e10cSrcweir 
412cdf0e10cSrcweir             @return
413cdf0e10cSrcweir                 the overall width of the grid, which is available for columns
414cdf0e10cSrcweir         */
415cdf0e10cSrcweir         long        impl_ni_calculateColumnWidths(
416cdf0e10cSrcweir                         ColPos const i_assumeInflexibleColumnsUpToIncluding,
417cdf0e10cSrcweir                         bool const i_assumeVerticalScrollbar,
418cdf0e10cSrcweir                         ::std::vector< long >& o_newColWidthsPixel
419cdf0e10cSrcweir                     ) const;
420cdf0e10cSrcweir 
421cdf0e10cSrcweir         /** positions all child windows, e.g. the both scrollbars, the corner window, and the data window
422cdf0e10cSrcweir         */
423cdf0e10cSrcweir         void        impl_ni_positionChildWindows(
424cdf0e10cSrcweir                         Rectangle const & i_dataCellPlayground,
425cdf0e10cSrcweir                         bool const i_verticalScrollbar,
426cdf0e10cSrcweir                         bool const i_horizontalScrollbar
427cdf0e10cSrcweir                     );
428cdf0e10cSrcweir 
429cdf0e10cSrcweir         /** scrolls the view by the given number of rows
430cdf0e10cSrcweir 
431cdf0e10cSrcweir             The method is not bound to the classes public invariants, as it's used in
432cdf0e10cSrcweir             situations where the they must not necessarily be fullfilled.
433cdf0e10cSrcweir 
434cdf0e10cSrcweir             @return
435cdf0e10cSrcweir                 the number of rows by which the viewport was scrolled. This may differ
436cdf0e10cSrcweir                 from the given numbers to scroll in case the begin or the end of the
437cdf0e10cSrcweir                 row range were reached.
438cdf0e10cSrcweir         */
439cdf0e10cSrcweir         TableSize   impl_ni_ScrollRows( TableSize _nRowDelta );
440cdf0e10cSrcweir 
441cdf0e10cSrcweir         /** equivalent to impl_ni_ScrollRows, but checks the instances invariants beforehand (in a non-product build only)
442cdf0e10cSrcweir         */
443cdf0e10cSrcweir         TableSize   impl_scrollRows( TableSize const i_rowDelta );
444cdf0e10cSrcweir 
445cdf0e10cSrcweir         /** scrolls the view by the given number of columns
446cdf0e10cSrcweir 
447cdf0e10cSrcweir             The method is not bound to the classes public invariants, as it's used in
448cdf0e10cSrcweir             situations where the they must not necessarily be fullfilled.
449cdf0e10cSrcweir 
450cdf0e10cSrcweir             @return
451cdf0e10cSrcweir                 the number of columns by which the viewport was scrolled. This may differ
452cdf0e10cSrcweir                 from the given numbers to scroll in case the begin or the end of the
453cdf0e10cSrcweir                 column range were reached.
454cdf0e10cSrcweir         */
455cdf0e10cSrcweir         TableSize   impl_ni_ScrollColumns( TableSize _nColumnDelta );
456cdf0e10cSrcweir 
457cdf0e10cSrcweir         /** equivalent to impl_ni_ScrollColumns, but checks the instances invariants beforehand (in a non-product build only)
458cdf0e10cSrcweir         */
459cdf0e10cSrcweir         TableSize   impl_scrollColumns( TableSize const i_columnDelta );
460cdf0e10cSrcweir 
461cdf0e10cSrcweir         /** retrieves the area occupied by the totality of (at least partially) visible cells
462cdf0e10cSrcweir 
463cdf0e10cSrcweir             The returned area includes row and column headers. Also, it takes into
464*fb0b81f5Smseidel             account the fact that there might be less columns than would normally
465cdf0e10cSrcweir             find room in the control.
466cdf0e10cSrcweir 
467cdf0e10cSrcweir             As a result of respecting the partial visibility of rows and columns,
468cdf0e10cSrcweir             the returned area might be larger than the data window's output size.
469cdf0e10cSrcweir         */
470cdf0e10cSrcweir         Rectangle   impl_getAllVisibleCellsArea() const;
471cdf0e10cSrcweir 
472cdf0e10cSrcweir         /** retrieves the area occupied by all (at least partially) visible data cells.
473cdf0e10cSrcweir 
474cdf0e10cSrcweir             Effectively, the returned area is the same as returned by ->impl_getAllVisibleCellsArea,
475cdf0e10cSrcweir             minus the row and column header areas.
476cdf0e10cSrcweir         */
477cdf0e10cSrcweir         Rectangle   impl_getAllVisibleDataCellArea() const;
478cdf0e10cSrcweir 
479cdf0e10cSrcweir         /** retrieves the column which covers the given ordinate
480cdf0e10cSrcweir         */
481cdf0e10cSrcweir         ColPos      impl_getColumnForOrdinate( long const i_ordinate ) const;
482cdf0e10cSrcweir 
483cdf0e10cSrcweir         /** retrieves the row which covers the given abscissa
484cdf0e10cSrcweir         */
485cdf0e10cSrcweir         RowPos      impl_getRowForAbscissa( long const i_abscissa ) const;
486cdf0e10cSrcweir 
487cdf0e10cSrcweir         /// invalidates the window area occupied by the given column
488cdf0e10cSrcweir         void        impl_invalidateColumn( ColPos const i_column );
489cdf0e10cSrcweir 
490cdf0e10cSrcweir         DECL_LINK( OnScroll, ScrollBar* );
491cdf0e10cSrcweir         DECL_LINK( OnUpdateScrollbars, void* );
492cdf0e10cSrcweir     };
493cdf0e10cSrcweir 
494cdf0e10cSrcweir 	//see seleng.hxx, seleng.cxx, FunctionSet overridables, part of selection engine
495cdf0e10cSrcweir 	class TableFunctionSet : public FunctionSet
496cdf0e10cSrcweir 	{
497cdf0e10cSrcweir 	private:
498cdf0e10cSrcweir 		TableControl_Impl*  m_pTableControl;
499cdf0e10cSrcweir 		RowPos              m_nCurrentRow;
500cdf0e10cSrcweir 
501cdf0e10cSrcweir 	public:
502cdf0e10cSrcweir 		TableFunctionSet(TableControl_Impl* _pTableControl);
503cdf0e10cSrcweir 		virtual ~TableFunctionSet();
504cdf0e10cSrcweir 
505cdf0e10cSrcweir 	   virtual void BeginDrag();
506cdf0e10cSrcweir 	   virtual void CreateAnchor();
507cdf0e10cSrcweir 	   virtual void DestroyAnchor();
508cdf0e10cSrcweir 	   virtual sal_Bool SetCursorAtPoint(const Point& rPoint, sal_Bool bDontSelectAtCursor);
509cdf0e10cSrcweir 	   virtual sal_Bool IsSelectionAtPoint( const Point& rPoint );
510cdf0e10cSrcweir 	   virtual void DeselectAtPoint( const Point& rPoint );
511cdf0e10cSrcweir 	   virtual void DeselectAll();
512cdf0e10cSrcweir 	};
513cdf0e10cSrcweir 
514cdf0e10cSrcweir 
515cdf0e10cSrcweir //........................................................................
516cdf0e10cSrcweir } } // namespace svt::table
517cdf0e10cSrcweir //........................................................................
518cdf0e10cSrcweir 
519cdf0e10cSrcweir #endif // SVTOOLS_TABLECONTROL_IMPL_HXX
520