From b9337e22ce1dbf2eba0e8c8db294ae99f4111f91 Mon Sep 17 00:00:00 2001 From: Bjoern Michaelsen Date: Thu, 18 Apr 2013 18:26:28 +0200 Subject: execute move of global headers see https://gerrit.libreoffice.org/#/c/3367/ and Change-Id: I00c96fa77d04b33a6f8c8cd3490dfcd9bdc9e84a for details Change-Id: I199a75bc4042af20817265d5ef85b1134a96ff5a --- include/svtools/table/defaultinputhandler.hxx | 65 +++ include/svtools/table/gridtablerenderer.hxx | 121 ++++++ include/svtools/table/tablecontrol.hxx | 218 ++++++++++ include/svtools/table/tablecontrolinterface.hxx | 257 +++++++++++ include/svtools/table/tableinputhandler.hxx | 73 ++++ include/svtools/table/tablemodel.hxx | 539 ++++++++++++++++++++++++ include/svtools/table/tablerenderer.hxx | 285 +++++++++++++ include/svtools/table/tablesort.hxx | 89 ++++ include/svtools/table/tabletypes.hxx | 64 +++ 9 files changed, 1711 insertions(+) create mode 100644 include/svtools/table/defaultinputhandler.hxx create mode 100644 include/svtools/table/gridtablerenderer.hxx create mode 100644 include/svtools/table/tablecontrol.hxx create mode 100644 include/svtools/table/tablecontrolinterface.hxx create mode 100644 include/svtools/table/tableinputhandler.hxx create mode 100644 include/svtools/table/tablemodel.hxx create mode 100644 include/svtools/table/tablerenderer.hxx create mode 100644 include/svtools/table/tablesort.hxx create mode 100644 include/svtools/table/tabletypes.hxx (limited to 'include/svtools/table') diff --git a/include/svtools/table/defaultinputhandler.hxx b/include/svtools/table/defaultinputhandler.hxx new file mode 100644 index 000000000000..021b523f1bda --- /dev/null +++ b/include/svtools/table/defaultinputhandler.hxx @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef SVTOOLS_INC_TABLE_DEFAULTINPUTHANDLER_HXX +#define SVTOOLS_INC_TABLE_DEFAULTINPUTHANDLER_HXX + +#include "svtools/table/tableinputhandler.hxx" +#include "svtools/table/tabletypes.hxx" + +#include + +//...................................................................................................................... +namespace svt { namespace table +{ +//...................................................................................................................... + + struct DefaultInputHandler_Impl; + + //================================================================================================================== + //= DefaultInputHandler + //================================================================================================================== + class DefaultInputHandler : public ITableInputHandler + { + private: + ::boost::scoped_ptr< DefaultInputHandler_Impl > m_pImpl; + + public: + DefaultInputHandler(); + ~DefaultInputHandler(); + + virtual bool MouseMove ( ITableControl& _rControl, const MouseEvent& rMEvt ); + virtual bool MouseButtonDown ( ITableControl& _rControl, const MouseEvent& rMEvt ); + virtual bool MouseButtonUp ( ITableControl& _rControl, const MouseEvent& rMEvt ); + virtual bool KeyInput ( ITableControl& _rControl, const KeyEvent& rKEvt ); + virtual bool GetFocus ( ITableControl& _rControl ); + virtual bool LoseFocus ( ITableControl& _rControl ); + virtual bool RequestHelp ( ITableControl& _rControl, const HelpEvent& rHEvt ); + virtual bool Command ( ITableControl& _rControl, const CommandEvent& rCEvt ); + virtual bool PreNotify ( ITableControl& _rControl, NotifyEvent& rNEvt ); + virtual bool Notify ( ITableControl& _rControl, NotifyEvent& rNEvt ); + }; + +//...................................................................................................................... +} } // namespace svt::table +//...................................................................................................................... + +#endif // SVTOOLS_INC_TABLE_DEFAULTINPUTHANDLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svtools/table/gridtablerenderer.hxx b/include/svtools/table/gridtablerenderer.hxx new file mode 100644 index 000000000000..21a096268fe1 --- /dev/null +++ b/include/svtools/table/gridtablerenderer.hxx @@ -0,0 +1,121 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef SVTOOLS_INC_TABLE_GRIDTABLERENDERER_HXX +#define SVTOOLS_INC_TABLE_GRIDTABLERENDERER_HXX + +#include + +#include + +//........................................................................ +namespace svt { namespace table +{ +//........................................................................ + + struct GridTableRenderer_Impl; + + //==================================================================== + //= GridTableRenderer + //==================================================================== + /** a default implementation for the ->ITableRenderer interface + + This class is able to paint a table grid, table headers, and cell + backgrounds according to the selected/active state of cells. + */ + class GridTableRenderer : public ITableRenderer + { + private: + ::boost::scoped_ptr< GridTableRenderer_Impl > m_pImpl; + + public: + /** creates a table renderer associated with the given model + + @param _rModel + the model which should be rendered. The caller is responsible + for lifetime control, that is, the model instance must live + at least as long as the renderer instance lives + */ + GridTableRenderer( ITableModel& _rModel ); + ~GridTableRenderer(); + + /** determines whether or not to paint grid lines + */ + bool useGridLines() const; + + /** controls whether or not to paint grid lines + */ + void useGridLines( bool const i_use ); + + public: + // ITableRenderer overridables + virtual void PaintHeaderArea( + OutputDevice& _rDevice, const Rectangle& _rArea, + bool _bIsColHeaderArea, bool _bIsRowHeaderArea, + const StyleSettings& _rStyle ); + virtual void PaintColumnHeader( ColPos _nCol, bool _bActive, bool _bSelected, + OutputDevice& _rDevice, const Rectangle& _rArea, + const StyleSettings& _rStyle ); + virtual void PrepareRow( RowPos _nRow, bool i_hasControlFocus, bool _bSelected, + OutputDevice& _rDevice, const Rectangle& _rRowArea, + const StyleSettings& _rStyle ); + virtual void PaintRowHeader( + bool i_hasControlFocus, bool _bSelected, + OutputDevice& _rDevice, const Rectangle& _rArea, + const StyleSettings& _rStyle ); + virtual void PaintCell( ColPos const i_col, + bool i_hasControlFocus, bool _bSelected, + OutputDevice& _rDevice, const Rectangle& _rArea, + const StyleSettings& _rStyle ); + virtual void ShowCellCursor( Window& _rView, const Rectangle& _rCursorRect); + virtual void HideCellCursor( Window& _rView, const Rectangle& _rCursorRect); + virtual bool FitsIntoCell( + ::com::sun::star::uno::Any const & i_cellContent, + ColPos const i_colPos, RowPos const i_rowPos, + bool const i_active, bool const i_selected, + OutputDevice& i_targetDevice, Rectangle const & i_targetArea + ) const; + virtual bool GetFormattedCellString( + ::com::sun::star::uno::Any const & i_cellValue, + ColPos const i_colPos, RowPos const i_rowPos, + OUString & o_cellString + ) const; + + private: + struct CellRenderContext; + + void impl_paintCellContent( + CellRenderContext const & i_context + ); + void impl_paintCellImage( + CellRenderContext const & i_context, + Image const & i_image + ); + void impl_paintCellText( + CellRenderContext const & i_context, + OUString const & i_text + ); + }; +//........................................................................ +} } // namespace svt::table +//........................................................................ + +#endif // SVTOOLS_INC_TABLE_GRIDTABLERENDERER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svtools/table/tablecontrol.hxx b/include/svtools/table/tablecontrol.hxx new file mode 100644 index 000000000000..a170a38a4648 --- /dev/null +++ b/include/svtools/table/tablecontrol.hxx @@ -0,0 +1,218 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef SVTOOLS_INC_TABLE_TABLECONTROL_HXX +#define SVTOOLS_INC_TABLE_TABLECONTROL_HXX + +#include "svtools/svtdllapi.h" +#include "svtools/table/tablemodel.hxx" +#include "svtools/accessibletable.hxx" +#include "svtools/accessiblefactory.hxx" + +#include +#include + +#include +#include + +//........................................................................ + +namespace svt { namespace table +{ +//........................................................................ + + class TableControl_Impl; + + //==================================================================== + //= TableControl + //==================================================================== + /** a basic control which manages table-like data, i.e. a number of cells + organized in m rows and n columns. + + The control itself does not do any assumptions about the concrete data + it displays, this is encapsulated in an instance supporting the + ->ITableModel interface. + + Also, the control does not do any assumptions about how the model's + content is rendered. This is the responsibility of a component + supporting the ->ITableRenderer interface (the renderer is obtained from + the model). + + The control supports the concept of a current (or active + cell). + The control supports accessibility, this is encapsulated in IAccessibleTable + */ + class SVT_DLLPUBLIC TableControl : public Control, public IAccessibleTable + { + private: + ::boost::shared_ptr< TableControl_Impl > m_pImpl; + + + public: + TableControl( Window* _pParent, WinBits _nStyle ); + ~TableControl(); + + /// sets a new table model + void SetModel( PTableModel _pModel ); + /// retrieves the current table model + PTableModel GetModel() const; + + /** retrieves the current row + + The current row is the one which contains the active cell. + + @return + the row index of the active cell, or ->ROW_INVALID + if there is no active cell, e.g. because the table does + not contain any rows or columns. + */ + sal_Int32 GetCurrentRow() const; + + ITableControl& + getTableControlInterface(); + + /** retrieves the current column + + The current col is the one which contains the active cell. + + @return + the column index of the active cell, or ->COL_INVALID + if there is no active cell, e.g. because the table does + not contain any rows or columns. + */ + sal_Int32 GetCurrentColumn() const; + + /** activates the cell at the given position + + @return + if the move was successful, otherwise. Usual + failure conditions include some other instance vetoing the move, + or impossibility to execute the move at all (for instance because + of invalid coordinates). + */ + bool GoTo( ColPos _nColumnPos, RowPos _nRow); + + /** moves the active cell to the given column, by keeping the active row + + @return + if the move was successful, otherwise. Usual + failure conditions include some other instance vetoing the move, + or impossibility to execute the move at all (for instance because + of invalid coordinates). + */ + inline bool GoToColumn( ColPos _nColumn ) + { + return GoTo( _nColumn, GetCurrentRow() ); + } + + /** moves the active cell to the given row, by keeping the active column + + @return + if the move was successful, otherwise. Usual + failure conditions include some other instance vetoing the move, + or impossibility to execute the move at all (for instance because + of invalid coordinates). + */ + bool GoToRow( RowPos _nRow ) + { + return GoTo( GetCurrentColumn(), _nRow ); + } + + SVT_DLLPRIVATE virtual void Resize(); + virtual void Select(); + + /**after removing a row, updates the vector which contains the selected rows + if the row, which should be removed, is selected, it will be erased from the vector + */ + SelectionEngine* getSelEngine(); + Window& getDataWindow(); + + // Window overridables + virtual void GetFocus(); + virtual void LoseFocus(); + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void StateChanged( StateChangedType i_nStateChange ); + + /** Creates and returns the accessible object of the whole GridControl. */ + SVT_DLLPRIVATE virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible(); + SVT_DLLPRIVATE virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleControl( sal_Int32 _nIndex ); + SVT_DLLPRIVATE virtual OUString GetAccessibleObjectName(AccessibleTableControlObjType eObjType, sal_Int32 _nRow, sal_Int32 _nCol) const; + SVT_DLLPRIVATE virtual sal_Bool GoToCell( sal_Int32 _nColumnPos, sal_Int32 _nRow ); + SVT_DLLPRIVATE virtual OUString GetAccessibleObjectDescription(AccessibleTableControlObjType eObjType, sal_Int32 _nPosition = -1) const; + SVT_DLLPRIVATE virtual void FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& rStateSet, AccessibleTableControlObjType eObjType ) const; + + // temporary methods + // Those do not really belong into the public API - they're intended for firing A11Y-related events. However, + // firing those events should be an implementation internal to the TableControl resp. TableControl_Impl, + // instead of something triggered externally. + void commitCellEventIfAccessibleAlive( sal_Int16 const i_eventID, const css::uno::Any& i_newValue, const css::uno::Any& i_oldValue ); + void commitTableEventIfAccessibleAlive( sal_Int16 const i_eventID, const css::uno::Any& i_newValue, const css::uno::Any& i_oldValue ); + + // ............................................................................................................. + // IAccessibleTable + virtual Rectangle GetWindowExtentsRelative( Window *pRelativeWindow ) const; + virtual void GrabFocus(); + virtual css::uno::Reference< css::accessibility::XAccessible > GetAccessible( sal_Bool bCreate = sal_True ); + virtual Window* GetAccessibleParentWindow() const; + virtual Window* GetWindowInstance(); + virtual sal_Int32 GetAccessibleControlCount() const; + virtual sal_Bool ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint ); + virtual long GetRowCount() const; + virtual long GetColumnCount() const; + virtual sal_Bool HasRowHeader() const; + virtual sal_Bool ConvertPointToCellAddress( sal_Int32& _rnRow, sal_Int32& _rnColPos, const Point& _rPoint ); + virtual Rectangle calcHeaderRect( sal_Bool _bIsColumnBar, sal_Bool _bOnScreen = sal_True ); + virtual Rectangle calcHeaderCellRect( sal_Bool _bIsColumnBar, sal_Int32 nPos); + virtual Rectangle calcTableRect( sal_Bool _bOnScreen = sal_True ); + virtual Rectangle calcCellRect( sal_Int32 _nRowPos, sal_Int32 _nColPos ); + virtual Rectangle GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex); + virtual sal_Int32 GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint); + virtual void FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper& _rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const; + virtual OUString GetRowDescription( sal_Int32 _nRow ) const; + virtual OUString GetRowName(sal_Int32 _nIndex) const; + virtual OUString GetColumnDescription( sal_uInt16 _nColumnPos ) const; + virtual OUString GetColumnName( sal_Int32 _nIndex ) const; + virtual css::uno::Any GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const; + virtual sal_Bool HasRowHeader(); + virtual sal_Bool HasColHeader(); + virtual OUString GetAccessibleCellText(sal_Int32 _nRowPos, sal_Int32 _nColPos) const; + + virtual sal_Int32 GetSelectedRowCount() const; + virtual sal_Int32 GetSelectedRowIndex( sal_Int32 const i_selectionIndex ) const; + virtual bool IsRowSelected( sal_Int32 const i_rowIndex ) const; + virtual void SelectRow( sal_Int32 const i_rowIndex, bool const i_select ); + virtual void SelectAllRows( bool const i_select ); + // ............................................................................................................. + + private: + DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* ); + + private: + TableControl(); // never implemented + TableControl( const TableControl& ); // never implemented + TableControl& operator=( const TableControl& ); // never implemented + }; + +//........................................................................ +} } // namespace svt::table +//........................................................................ + +#endif // SVTOOLS_INC_TABLE_TABLECONTROL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svtools/table/tablecontrolinterface.hxx b/include/svtools/table/tablecontrolinterface.hxx new file mode 100644 index 000000000000..a95cc282985c --- /dev/null +++ b/include/svtools/table/tablecontrolinterface.hxx @@ -0,0 +1,257 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef SVTOOLS_INC_TABLE_ABSTRACTTABLECONTROL_HXX +#define SVTOOLS_INC_TABLE_ABSTRACTTABLECONTROL_HXX + +#include +#include +#include + +#include "svtools/table/tabletypes.hxx" +#include "svtools/table/tablemodel.hxx" + +class Pointer; + +//...................................................................................................................... +namespace svt { namespace table +{ +//...................................................................................................................... + + //================================================================================================================== + //= TableControlAction + //================================================================================================================== + enum TableControlAction + { + /// moves the cursor in the table control one row up, if possible, by keeping the current column + cursorUp, + /// moves the cursor in the table control one row down, if possible, by keeping the current column + cursorDown, + /// moves the cursor in the table control one column to the left, if possible, by keeping the current row + cursorLeft, + /// moves the cursor in the table control one column to the right, if possible, by keeping the current row + cursorRight, + /// moves the cursor to the beginning of the current line + cursorToLineStart, + /// moves the cursor to the end of the current line + cursorToLineEnd, + /// moves the cursor to the first row, keeping the current column + cursorToFirstLine, + /// moves the cursor to the last row, keeping the current column + cursorToLastLine, + /// moves the cursor one page up, keeping the current column + cursorPageUp, + /// moves the cursor one page down, keeping the current column + cursorPageDown, + /// moves the cursor to the top-most, left-most cell + cursorTopLeft, + /// moves the cursor to the bottom-most, right-most cell + cursorBottomRight, + /// selects the row, where the actual cursor is + cursorSelectRow, + /// selects the rows, above the actual cursor is + cursorSelectRowUp, + /// selects the row, beneath the actual cursor is + cursorSelectRowDown, + /// selects the row, from the actual cursor till top + cursorSelectRowAreaTop, + /// selects the row, from the actual cursor till bottom + cursorSelectRowAreaBottom, + + /// invalid and final enumeration value, not to be actually used + invalidTableControlAction + }; + + //================================================================================================================== + //= TableCellArea + //================================================================================================================== + enum TableCellArea + { + CellContent, + ColumnDivider + }; + + //================================================================================================================== + //= TableCell + //================================================================================================================== + struct TableCell + { + ColPos nColumn; + RowPos nRow; + TableCellArea eArea; + + TableCell() + :nColumn( COL_INVALID ) + ,nRow( ROW_INVALID ) + ,eArea( CellContent ) + { + } + + TableCell( ColPos const i_column, RowPos const i_row ) + :nColumn( i_column ) + ,nRow( i_row ) + ,eArea( CellContent ) + { + } + }; + + //================================================================================================================== + //= ColumnMetrics + //================================================================================================================== + struct ColumnMetrics + { + /** the start of the column, in pixels. Might be negative, in case the column is scrolled out of the visible + area. Note: see below. + */ + long nStartPixel; + + /** the end of the column, in pixels, plus 1. Effectively, this is the accumulated width of a all columns + up to the current one. + + Huh? Earlier you said that the nStartPixel of columns + scrolled out (to the left) of the visible area is + negative. Also, where is the promise that there is no gap + between columns? The above claim would be true only if the + first column always started at zero, and there is never a + gap. So these doc comments are inconsistent. How + surprising. + */ + long nEndPixel; + + ColumnMetrics() + :nStartPixel(0) + ,nEndPixel(0) + { + } + + ColumnMetrics( long const i_start, long const i_end ) + :nStartPixel( i_start ) + ,nEndPixel( i_end ) + { + } + }; + + //================================================================================================================== + //= TableArea + //================================================================================================================== + enum TableArea + { + TableAreaColumnHeaders, + TableAreaRowHeaders, + TableAreaDataArea, + TableAreaAll + }; + + //================================================================================================================== + //= ITableControl + //================================================================================================================== + /** defines a callback interface to be implemented by a concrete table control + */ + class SAL_NO_VTABLE ITableControl + { + public: + /** hides the cell cursor + + The method cares for successive calls, that is, for every call to + ->hideCursor(), you need one call to ->showCursor. Only if the number + of both calls matches, the cursor is really shown. + + @see showCursor + */ + virtual void hideCursor() = 0; + + /** shows the cell cursor + + @see hideCursor + */ + virtual void showCursor() = 0; + + /** dispatches an action to the table control + + @return + if the action could be dispatched successfully, otherwise. Usual + failure conditions include some other instance vetoing the action, or impossibility + to execute the action at all (for instance moving up one row when already positioned + on the very first row). + + @see TableControlAction + */ + virtual bool dispatchAction( TableControlAction _eAction ) = 0; + + /** returns selection engine*/ + virtual SelectionEngine* getSelEngine() = 0; + + /** returns the table model + + The returned model is guaranteed to not be . + */ + virtual PTableModel getModel() const = 0; + + /// returns the index of the currently active column + virtual ColPos getCurrentColumn() const = 0; + + /// returns the index of the currently active row + virtual RowPos getCurrentRow() const = 0; + + /// activates the given cell + virtual bool activateCell( ColPos const i_col, RowPos const i_row ) = 0; + + /// retrieves the size of the table window, in pixels + virtual ::Size getTableSizePixel() const = 0; + + /// sets a new mouse pointer for the table window + virtual void setPointer( Pointer const & i_pointer ) = 0; + + /// captures the mouse to the table window + virtual void captureMouse() = 0; + + /// releases the mouse, after it had previously been captured + virtual void releaseMouse() = 0; + + /// invalidates the table window + virtual void invalidate( TableArea const i_what ) = 0; + + /// calculates a width, given in pixels, into a AppFont-based width + virtual long pixelWidthToAppFont( long const i_pixels ) const = 0; + + /// shows a trackign rectangle + virtual void showTracking( Rectangle const & i_location, sal_uInt16 const i_flags ) = 0; + + /// hides a prviously shown tracking rectangle + virtual void hideTracking() = 0; + + /// does a hit test for the given pixel coordinates + virtual TableCell hitTest( const Point& rPoint ) const = 0; + + /// retrieves the metrics for a given column + virtual ColumnMetrics getColumnMetrics( ColPos const i_column ) const = 0; + + /// determines whether a given row is selected + virtual bool isRowSelected( RowPos _nRow ) const = 0; + + virtual ~ITableControl() {}; + }; + +//...................................................................................................................... +} } // namespace svt::table +//...................................................................................................................... + +#endif // SVTOOLS_INC_TABLE_ABSTRACTTABLECONTROL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svtools/table/tableinputhandler.hxx b/include/svtools/table/tableinputhandler.hxx new file mode 100644 index 000000000000..2158d573bb2d --- /dev/null +++ b/include/svtools/table/tableinputhandler.hxx @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef SVTOOLS_INC_TABLE_TABLEINPUTHANDLER_HXX +#define SVTOOLS_INC_TABLE_TABLEINPUTHANDLER_HXX + +#include + +class MouseEvent; +class KeyEvent; +class HelpEvent; +class CommandEvent; +class NotifyEvent; + +//........................................................................ +namespace svt { namespace table +{ +//........................................................................ + + class ITableControl; + + //==================================================================== + //= ITableInputHandler + //==================================================================== + /** interface for components handling input in a ->TableControl + */ + class ITableInputHandler + { + public: + // all those methods have the same semantics as the equal-named methods of ->Window, + // with the additional option to return a boolean value indicating whether + // the event should be further processed by the ->Window implementations (), + // or whether it has been sufficiently handled by the ->ITableInputHandler instance + // (). + + virtual bool MouseMove ( ITableControl& _rControl, const MouseEvent& rMEvt ) = 0; + virtual bool MouseButtonDown ( ITableControl& _rControl, const MouseEvent& rMEvt ) = 0; + virtual bool MouseButtonUp ( ITableControl& _rControl, const MouseEvent& rMEvt ) = 0; + virtual bool KeyInput ( ITableControl& _rControl, const KeyEvent& rKEvt ) = 0; + virtual bool GetFocus ( ITableControl& _rControl ) = 0; + virtual bool LoseFocus ( ITableControl& _rControl ) = 0; + virtual bool RequestHelp ( ITableControl& _rControl, const HelpEvent& rHEvt ) = 0; + virtual bool Command ( ITableControl& _rControl, const CommandEvent& rCEvt ) = 0; + virtual bool PreNotify ( ITableControl& _rControl, NotifyEvent& rNEvt ) = 0; + virtual bool Notify ( ITableControl& _rControl, NotifyEvent& rNEvt ) = 0; + + virtual ~ITableInputHandler() { } + }; + typedef ::boost::shared_ptr< ITableInputHandler > PTableInputHandler; + +//........................................................................ +} } // namespace svt::table +//........................................................................ + +#endif // SVTOOLS_INC_TABLE_TABLEINPUTHANDLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svtools/table/tablemodel.hxx b/include/svtools/table/tablemodel.hxx new file mode 100644 index 000000000000..cae54efb0ef0 --- /dev/null +++ b/include/svtools/table/tablemodel.hxx @@ -0,0 +1,539 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef SVTOOLS_INC_TABLE_TABLEMODEL_HXX +#define SVTOOLS_INC_TABLE_TABLEMODEL_HXX + +#include "svtools/svtdllapi.h" +#include "svtools/table/tabletypes.hxx" +#include "svtools/table/tablerenderer.hxx" +#include "svtools/table/tableinputhandler.hxx" +#include "svtools/table/tablesort.hxx" + +#include +#include +#include + +#include +#include + +#include +#include +#include + +//........................................................................ +namespace svt { namespace table +{ +//........................................................................ + + + //==================================================================== + //= ScrollbarVisibility + //==================================================================== + enum ScrollbarVisibility + { + /** enumeration value denoting that a scrollbar should never be visible, even + if needed normally + */ + ScrollbarShowNever, + /** enumeration value denoting that a scrollbar should be visible when needed only + */ + ScrollbarShowSmart, + /** enumeration value denoting that a scrollbar should always be visible, even + if not needed normally + */ + ScrollbarShowAlways + }; + + //==================================================================== + //= ITableModelListener + //==================================================================== + typedef sal_Int32 ColumnAttributeGroup; + #define COL_ATTRS_NONE (0x00000000) + /// denotes column attributes related to the width of the column + #define COL_ATTRS_WIDTH (0x00000001) + /// denotes column attributes related to the appearance of the column, i.e. those relevant for rendering + #define COL_ATTRS_APPEARANCE (0x00000002) + /// denotes the entirety of column attributes + #define COL_ATTRS_ALL (0x7FFFFFFF) + + //==================================================================== + //= ITableModelListener + //==================================================================== + /** declares an interface to be implemented by components interested in + changes in an ->ITableModel + */ + class SAL_NO_VTABLE ITableModelListener : public ::boost::enable_shared_from_this< ITableModelListener > + { + public: + /** notifies the listener that one or more rows have been inserted into + the table + + @param first + the index of the first newly inserted row + @param last + the index of the last newly inserted row. Must not be smaller + than ->first + */ + virtual void rowsInserted( RowPos first, RowPos last ) = 0; + + /** notifies the listener that one or more rows have been removed from + the table + + @param first + the old index of the first removed row. If this is -1, then all + rows have been removed from the model. + @param last + the old index of the last removed row. Must not be smaller + than ->first + */ + virtual void rowsRemoved( RowPos first, RowPos last ) = 0; + + /** notifies the listener that one or more columns have been inserted into + the table + + @param first + the index of the first newly inserted row + @param last + the index of the last newly inserted row. Must not be smaller + than ->first + */ + virtual void columnInserted( ColPos const i_colIndex ) = 0; + + /** notifies the listener that one or more columns have been removed from + the table + + @param i_colIndex + the old index of the removed column + */ + virtual void columnRemoved( ColPos const i_colIndex ) = 0; + + /** notifies the listener that all columns have been removed form the model + */ + virtual void allColumnsRemoved() = 0; + + /** notifies the listener that a rectangular cell range in the table + has been updated + + Listeners are required to discard any possibly cached information + they have about the cells in question, in particular any possibly + cached cell values. + */ + virtual void cellsUpdated( ColPos const i_firstCol, ColPos i_lastCol, RowPos const i_firstRow, RowPos const i_lastRow ) = 0; + + /** notifies the listener that attributes of a given column changed + + @param i_column + the position of the column whose attributes changed + @param i_attributeGroup + a combination of one or more COL_ATTRS_* flags, denoting the attribute group(s) + in which changes occurred. + */ + virtual void columnChanged( ColPos const i_column, ColumnAttributeGroup const i_attributeGroup ) = 0; + + /** notifies the listener that the metrics of the table changed. + + Metrics here include the column header height, the row header width, the row height, and the presence + of both the row and column header. + */ + virtual void tableMetricsChanged() = 0; + + /// deletes the listener instance + virtual ~ITableModelListener(){}; + }; + typedef ::boost::shared_ptr< ITableModelListener > PTableModelListener; + + //==================================================================== + //= IColumnModel + //==================================================================== + /** interface to be implemented by table column models + */ + class SAL_NO_VTABLE IColumnModel + { + public: + /** retrieves the ID of the column + + The semantics of a column id is not defined. It's up to the + implementor of the ->IColumnModel, respectively the ->ITableModel + which provides the column models, to define such a semantics. + + @return + the ID of the column. May be 0 if the table which the column + belongs to does not need and support column ids. + + @see setID + */ + virtual ::com::sun::star::uno::Any + getID() const = 0; + + /** sets a new column ID + + @return + if setting the new ID was successful. A possible error + conditions is if you try to set an ID which is already used + by another column within the same table. + + @see getID + */ + virtual void setID( const ::com::sun::star::uno::Any& _nID ) = 0; + + /** returns the name of the column + + Column names should be human-readable, but not necessarily unique + within a given table. + + @see setName + */ + virtual String getName() const = 0; + + /** sets a new name for the column + + @see getName + */ + virtual void setName( const String& _rName ) = 0; + + /** retrieves the help text to be displayed for the column. + */ + virtual String getHelpText() const = 0; + + /** sets a new the help text to be displayed for the column. + */ + virtual void setHelpText( const String& i_helpText ) = 0; + + /** determines whether the column can be interactively resized + + @see getMinWidth + @see getMaxWidth + @see getWidth + */ + virtual bool isResizable() const = 0; + + /** declares the column as resizable or fixed in width + + @see getMinWidth + @see getMaxWidth + @see getWidth + */ + virtual void setResizable( bool _bResizable ) = 0; + + /** denotes the relative flexibility of the column + + This flexibility is taken into account when a table control auto-resizes its columns, because the available + space changed. In this case, the columns grow or shrink according to their flexibility. + + A value of 0 means the column is not auto-resized at all. + */ + virtual sal_Int32 getFlexibility() const = 0; + + /** sets a new flexibility value for the column + + @see getFlexibility + */ + virtual void setFlexibility( sal_Int32 const i_flexibility ) = 0; + + /** returns the width of the column, in app-font unitss + + The returned value must be a positive ->TableMetrics value. + + @see setWidth + @see getMinWidth + @see getMaxWidth + */ + virtual TableMetrics getWidth() const = 0; + + /** sets a new width for the column + + @param _nWidth + the new width, app-font units + + @see getWidth + */ + virtual void setWidth( TableMetrics _nWidth ) = 0; + + /** returns the minimum width of the column, in app-font units, or 0 if the column + does not have a minimal width + + @see setMinWidth + @see getMaxWidth + @see getWidth + */ + virtual TableMetrics getMinWidth() const = 0; + + /** sets the minimum width of the column, in app-font units + + @see getMinWidth + @see setMaxWidth + @see setWidth + */ + virtual void setMinWidth( TableMetrics _nMinWidth ) = 0; + + /** returns the maximum width of the column, in app-font units, or 0 if the column + does not have a minimal width + + @see setMaxWidth + @see getMinWidth + @see getWidth + */ + virtual TableMetrics getMaxWidth() const = 0; + + /** sets the maximum width of the column, in app-font units + + @see getMaxWidth + @see setMinWidth + @see setWidth + */ + virtual void setMaxWidth( TableMetrics _nMaxWidth ) = 0; + + /** retrieves the horizontal alignment to be used for content in this cell + */ + virtual ::com::sun::star::style::HorizontalAlignment getHorizontalAlign() = 0; + + /** sets a new the horizontal alignment to be used for content in this cell + */ + virtual void setHorizontalAlign(::com::sun::star::style::HorizontalAlignment _xAlign) = 0; + + /// deletes the column model instance + virtual ~IColumnModel() { } + }; + typedef ::boost::shared_ptr< IColumnModel > PColumnModel; + + //==================================================================== + //= ITableModel + //==================================================================== + /** declares the interface to implement by an abtract table model + */ + class SAL_NO_VTABLE SVT_DLLPUBLIC ITableModel + { + public: + /** returns the number of columns in the table + */ + virtual TableSize getColumnCount() const = 0; + + /** returns the number of rows in the table + */ + virtual TableSize getRowCount() const = 0; + + /** determines whether the table has column headers + + If this method returns , the renderer returned by + ->getRenderer must be able to render column headers. + + @see IColumnRenderer + */ + virtual bool hasColumnHeaders() const = 0; + + /** determines whether the table has row headers + + If this method returns , the renderer returned by + ->getRenderer must be able to render row headers. + + @see IColumnRenderer + */ + virtual bool hasRowHeaders() const = 0; + + /** determines whether the given cell is editable + + @see ICellEditor + @todo + */ + virtual bool isCellEditable( ColPos col, RowPos row ) const = 0; + + /** returns a model for a certain column + + @param column + the index of the column in question. Must be greater than or + equal 0, and smaller than the return value of ->getColumnCount() + + @return + the model of the column in question. Must not be + */ + virtual PColumnModel getColumnModel( ColPos column ) = 0; + + /** returns a renderer which is able to paint the table represented + by this table model + + @return the renderer to use. Must not be + */ + virtual PTableRenderer getRenderer() const = 0; + + /** returns the component handling input in a view associated with the model + */ + virtual PTableInputHandler getInputHandler() const = 0; + + /** determines the height of rows in the table. + + @return + the logical height of rows in the table, in app-font units. The height must be + greater 0. + */ + virtual TableMetrics getRowHeight() const = 0; + + /** determines the height of the column header row + + This method is not to be called if ->hasColumnHeaders() + returned . + + @return + the logical height of the column header row, in app-font units. + Must be greater than 0. + */ + virtual TableMetrics getColumnHeaderHeight() const = 0; + + /** determines the width of the row header column + + This method is not to be called if ->hasRowHeaders() + returned . + + @return + the logical width of the row header column, in app-font units. + Must be greater than 0. + */ + virtual TableMetrics getRowHeaderWidth() const = 0; + + /** returns the visibilit mode of the vertical scrollbar + */ + virtual ScrollbarVisibility getVerticalScrollbarVisibility() const = 0; + + /** returns the visibilit mode of the horizontal scrollbar + */ + virtual ScrollbarVisibility getHorizontalScrollbarVisibility() const = 0; + + /** adds a listener to be notified of changes in the table model + */ + virtual void addTableModelListener( const PTableModelListener& i_listener ) = 0; + + /** remove a listener to be notified of changes in the table model + */ + virtual void removeTableModelListener( const PTableModelListener& i_listener ) = 0; + + /** retrieves the content of the given cell + */ + virtual void getCellContent( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any& o_cellContent ) = 0; + + /** returns an object which should be displayed as tooltip for the given cell + + At the moment, only string-convertible values are supported here. In the future, one might imagine displaying + scaled-down versions of a graphic in a cell, and a larger version of that very graphic as tooltip. + + If no tooltip object is provided, then the cell content is used, and displayed as tooltip for the cell + if and only if it doesn't fit into the cell's space itself. + + @param i_col + The column index of the cell in question. COL_ROW_HEADERS is a valid argument here. + @param i_row + The row index of the cell in question. + @param o_cellToolTip + takes the tooltip object upon return. + */ + virtual void getCellToolTip( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any & o_cellToolTip ) = 0; + + /** retrieves title of a given row + */ + virtual ::com::sun::star::uno::Any getRowHeading( RowPos const i_rowPos ) const = 0; + + /** returns the color to be used for rendering the grid lines. + + If this value is not set, a default color from the style settings will be used. + */ + virtual ::boost::optional< ::Color > getLineColor() const = 0; + + /** returns the color to be used for rendering the header background. + + If this value is not set, a default color from the style settings will be used. + */ + virtual ::boost::optional< ::Color > getHeaderBackgroundColor() const = 0; + + /** returns the color to be used for rendering the header text. + + If this value is not set, a default color from the style settings will be used. + */ + virtual ::boost::optional< ::Color > getHeaderTextColor() const = 0; + + /** returns the color to be used for the background of selected cells, when the control has the focus + + If this value is not set, a default color from the style settings will be used. + */ + virtual ::boost::optional< ::Color > getActiveSelectionBackColor() const = 0; + + /** returns the color to be used for the background of selected cells, when the control does not have the focus + + If this value is not set, a default color from the style settings will be used. + */ + virtual ::boost::optional< ::Color > getInactiveSelectionBackColor() const = 0; + + /** returns the color to be used for the text of selected cells, when the control has the focus + + If this value is not set, a default color from the style settings will be used. + */ + virtual ::boost::optional< ::Color > getActiveSelectionTextColor() const = 0; + + /** returns the color to be used for the text of selected cells, when the control does not have the focus + + If this value is not set, a default color from the style settings will be used. + */ + virtual ::boost::optional< ::Color > getInactiveSelectionTextColor() const = 0; + + /** returns the color to be used for rendering cell texts. + + If this value is not set, a default color from the style settings will be used. + */ + virtual ::boost::optional< ::Color > getTextColor() const = 0; + + /** returns the color to be used for text lines (underline, strikethrough) when rendering cell text. + + If this value is not set, a default color from the style settings will be used. + */ + virtual ::boost::optional< ::Color > getTextLineColor() const = 0; + + /** returns the colors to be used for the row backgrounds. + + If this value is not set, every second row will have a background color derived from the style settings's + selection color, the other rows will not have a special background at all. + + If this value is an empty sequence, the rows will not have a special background at all, instead the + normal background of the complete control will be used. + + If value is a non-empty sequence, then rows will have the background colors as specified in the sequence, + in alternating order. + */ + virtual ::boost::optional< ::std::vector< ::Color > > + getRowBackgroundColors() const = 0; + + /** determines the vertical alignment of content within a cell + */ + virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign() const = 0; + + /** returns an adapter to the sorting functionality of the model + + It is legitimate to return here, in this case, the table model does not support sorting. + */ + virtual ITableDataSort* getSortAdapter() = 0; + + /// destroys the table model instance + virtual ~ITableModel() { } + }; + typedef ::boost::shared_ptr< ITableModel > PTableModel; + +//........................................................................ +} } // namespace svt::table +//........................................................................ + +#endif // SVTOOLS_INC_TABLE_TABLEMODEL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svtools/table/tablerenderer.hxx b/include/svtools/table/tablerenderer.hxx new file mode 100644 index 000000000000..05ee87571c4c --- /dev/null +++ b/include/svtools/table/tablerenderer.hxx @@ -0,0 +1,285 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef SVTOOLS_INC_TABLE_TABLERENDERER_HXX +#define SVTOOLS_INC_TABLE_TABLERENDERER_HXX + +#include + +#include + +#include + +//........................................................................ +namespace svt { namespace table +{ +//........................................................................ + + //==================================================================== + //= ITableRenderer + //==================================================================== + /** interface to implement by components rendering a ->TableControl + */ + class SAL_NO_VTABLE ITableRenderer + { + public: + + /** paints a (part of) header area + + There are two header areas in a table control: +
  • The row containing all column headers, i.e. above all rows containing the data
  • +
  • The column containing all row headers. i.e. left of all columns containing the data
  • +
+ + A header area is more than the union of the single column/row headers. + + First, there might be less columns than fit into the view - in this case, right + beside the right-most column, there's still room which belongs to the column header + area, but is not occupied by any particular column header.
+ An equivalent statement holds for the row header area, if there are less rows than + fit into the view. + + Second, if the table control has both a row header and a column header, + the intersection between those both belongs to both the column header area and the + row header area, but not to any particular column or row header. + + There are two flags specifying whether the to-be-painted area is part of the column + and/or row header area. +
  • If both are , the intersection of both areas is to be painted.
  • +
  • If ->_bIsColHeaderArea is and ->_bIsRowHeaderArea is , + then ->_rArea denotes the column header area excluding the + intersection between row and column header area.
  • +
  • Equivalently for ->_bIsColHeaderArea being and ->_bIsRowHeaderArea + being
  • +
+ Note that it's not possible for both ->_bIsColHeaderArea and ->_bIsRowHeaderArea + to be at the same time. + + @param _rDevice + the device to paint onto + @param _rArea + the area to paint into + @param _bIsColHeaderArea + if and only if ->_rArea is part of the column header area. + @param _bIsRowHeaderArea + if and only if ->_rArea is part of the row header area. + @param _rStyle + the style to be used for drawing + */ + virtual void PaintHeaderArea( + OutputDevice& _rDevice, const Rectangle& _rArea, + bool _bIsColHeaderArea, bool _bIsRowHeaderArea, + const StyleSettings& _rStyle ) = 0; + + /** paints the header for a given column + + @param _nCol + the index of the column to paint + @param _bActive + if and only if the column whose column is to be painted + contains the active cell. + @param _bSelected + if and only if the column whose column is to be painted + is selected currently. + @param _rDevice + denotes the device to paint onto + @param _rArea + the are into which the column header should be painted + @param _rStyle + the style to be used for drawing + */ + virtual void PaintColumnHeader( ColPos _nCol, bool _bActive, bool _bSelected, + OutputDevice& _rDevice, const Rectangle& _rArea, + const StyleSettings& _rStyle ) = 0; + + /** prepares a row for painting + + Painting a table means painting rows as necessary, in an increasing + order. The assumption is that retrieving data for two different rows + is (potentially) more expensive than retrieving data for two different + columns. Thus, the renderer will get the chance to "seek" to a certain + row, and then has to render all cells in this row, before another + row is going to be painted. + + @param _nRow + the row which is going to be painted. The renderer should + at least remember this row, since subsequent calls to + ->PaintRowHeader(), ->PaintCell(), and ->FinishRow() will + not pass this parameter again. + + However, the renderer is also allowed to render any + cell-independent content of this row. + + @param i_hasControlFocus + if and only if the table control currently has the focus + @param _bSelected + if and only if the row to be prepared is + selected currently. + @param _rDevice + denotes the device to paint onto + @param _rRowArea + the are into which the row should be painted. This excludes + the row header area, if applicable. + @param _rStyle + the style to be used for drawing + */ + virtual void PrepareRow( RowPos _nRow, bool i_hasControlFocus, bool _bSelected, + OutputDevice& _rDevice, const Rectangle& _rRowArea, + const StyleSettings& _rStyle ) = 0; + + /** paints the header of a row + + The row to be painted is denoted by the most recent call to + ->PrepareRow. + + @param i_hasControlFocus + if and only if the table control currently has the focus +
+ Note that this flag is equal to the respective flag in the + previous ->PrepareRow call, it's passed here for convinience + only. + @param _bSelected + if and only if the row whose header cell is to be + painted is selected currently. +
+ Note that this flag is equal to the respective flag in the + previous ->PrepareRow call, it's passed here for convinience + only. + @param _rDevice + denotes the device to paint onto + @param _rArea + the are into which the row header should be painted + @param _rStyle + the style to be used for drawing + */ + virtual void PaintRowHeader( bool i_hasControlFocus, bool _bSelected, + OutputDevice& _rDevice, Rectangle const & _rArea, + StyleSettings const & _rStyle ) = 0; + + /** paints a certain cell + + The row to be painted is denoted by the most recent call to + ->PrepareRow. + + @param _bSelected + if and only if the cell to be painted is + selected currently. This is the case if either + the row or the column of the cell is currently selected. +
+ Note that this flag is equal to the respective flag in the + previous ->PrepareRow call, it's passed here for convinience + only. + @param i_hasControlFocus + if and only if the table control currently has the focus +
+ Note that this flag is equal to the respective flag in the + previous ->PrepareRow call, it's passed here for convinience + only. + @param _rDevice + denotes the device to paint onto + @param _rArea + the are into which the cell should be painted + @param _rStyle + the style to be used for drawing + */ + virtual void PaintCell( ColPos const i_col, + bool i_hasControlFocus, bool _bSelected, + OutputDevice& _rDevice, const Rectangle& _rArea, + const StyleSettings& _rStyle ) = 0; + + /** draws a cell cursor in the given rectangle + + The cell cursor is used to indicate the active/current cell + of a table control. + */ + virtual void ShowCellCursor( Window& _rView, const Rectangle& _rCursorRect) = 0; + + /** hides the cell cursor previously drawn into the given rectangle + + The cell cursor is used to indicate the active/current cell + of a table control. + */ + virtual void HideCellCursor( Window& _rView, const Rectangle& _rCursorRect) = 0; + + /** checks whether a given cell content fits into a given target area on a given device. + + @param i_colPos + denotes the column which the cell content would be painted into. Your renderer implementation + would only need this parameter if rendering is done differently for different columns. + + @param i_rowPos + denotes the row which the cell content would be painted into. Your renderer implementation + would only need this parameter if rendering is done differently for different rows. + + @param i_active + is if and only if the renderer should assume the cell content would be painted for the active + cell. + + @param i_selected + is if and only if the renderer should assume the cell content would be painted for a selected + cell. + + @param i_targetDevice + denotes the target device for the assumed rendering operation + + @param i_targetArea + denotes the area within the target device for the assumed rendering operation. + + @return + if and only if the given cell content could be rendered into the given device and the + given area. + */ + virtual bool FitsIntoCell( + ::com::sun::star::uno::Any const & i_cellContent, + ColPos const i_colPos, RowPos const i_rowPos, + bool const i_active, bool const i_selected, + OutputDevice& i_targetDevice, Rectangle const & i_targetArea + ) const = 0; + + /** attempts to format the content of the given cell as string + + @param i_cellValue + the value for which an attempt for a string conversion should be made + @param i_colPos + the column position of the cell in question + @param i_rowPos + the row position of the cell in question + @param o_cellString + the cell content, formatted as string + @return + if and only if the content could be formatted as string + */ + virtual bool GetFormattedCellString( + ::com::sun::star::uno::Any const & i_cellValue, + ColPos const i_colPos, RowPos const i_rowPos, + OUString & o_cellString + ) const = 0; + + /// deletes the renderer instance + virtual ~ITableRenderer() { } + }; + typedef ::boost::shared_ptr< ITableRenderer > PTableRenderer; + +//........................................................................ +} } // namespace svt::table +//........................................................................ + +#endif // SVTOOLS_INC_TABLE_TABLERENDERER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svtools/table/tablesort.hxx b/include/svtools/table/tablesort.hxx new file mode 100644 index 000000000000..072e088cb3ee --- /dev/null +++ b/include/svtools/table/tablesort.hxx @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef SVTOOLS_TABLESORT_HXX +#define SVTOOLS_TABLESORT_HXX + +#include "svtools/table/tabletypes.hxx" + +//...................................................................................................................... +namespace svt { namespace table +{ +//...................................................................................................................... + + //================================================================================================================== + //= ColumnSortDirection + //================================================================================================================== + enum ColumnSortDirection + { + ColumnSortAscending, + ColumnSortDescending + }; + + //================================================================================================================== + //= ColumnSort + //================================================================================================================== + struct ColumnSort + { + ColPos nColumnPos; + ColumnSortDirection eSortDirection; + + ColumnSort() + :nColumnPos( COL_INVALID ) + ,eSortDirection( ColumnSortAscending ) + { + } + + ColumnSort( ColPos const i_columnPos, ColumnSortDirection const i_sortDirection ) + :nColumnPos( i_columnPos ) + ,eSortDirection( i_sortDirection ) + { + } + }; + + //================================================================================================================== + //= ITableDataSort + //================================================================================================================== + /** provides sorting functionality for the datta underlying an ITableModel + */ + class SAL_NO_VTABLE ITableDataSort + { + public: + /** sorts the rows in the model by the given column's data, in the given direction. + */ + virtual void sortByColumn( ColPos const i_column, ColumnSortDirection const i_sortDirection ) = 0; + + /** retrieves the current sort order of the data + + If the nColumnIndex member of the returned srtructure is COL_INVALID, then + the data is currently not sorted. + */ + virtual ColumnSort getCurrentSortOrder() const = 0; + + protected: + ~ITableDataSort() {} + }; + +//...................................................................................................................... +} } // namespace svt::table +//...................................................................................................................... + +#endif // SVTOOLS_TABLESORT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svtools/table/tabletypes.hxx b/include/svtools/table/tabletypes.hxx new file mode 100644 index 000000000000..f0333a9a49d7 --- /dev/null +++ b/include/svtools/table/tabletypes.hxx @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef SVTOOLS_INC_TABLE_TABLETYPES_HXX +#define SVTOOLS_INC_TABLE_TABLETYPES_HXX + +#include + +//........................................................................ +namespace svt { namespace table +{ +//........................................................................ + /// a value denoting the size of a table + typedef sal_Int32 TableSize; + + /// a value denoting a column position within a table + typedef sal_Int32 ColPos; + /// a value denoting a row position within a table + typedef sal_Int32 RowPos; + + /** a value denoting an arbitrary coordinate value of a position within + a table + + Values of this type are guaranteed to be large enough to hold column + positions as well as row positions. + */ + typedef sal_Int32 AnyPos; + + typedef sal_Int32 TableMetrics; + +/// denotes the column containing the row headers +#define COL_ROW_HEADERS ((::svt::table::ColPos)-1) +/// denotes the row containing the column headers +#define ROW_COL_HEADERS ((::svt::table::RowPos)-1) + +/// denotes an invalid column index +#define COL_INVALID ((::svt::table::ColPos)-2) +/// denotes an invalid row index +#define ROW_INVALID ((::svt::table::RowPos)-2) + + +//........................................................................ +} } // namespace svt::table +//........................................................................ + +#endif // SVTOOLS_INC_TABLE_TABLETYPES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit