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