diff options
Diffstat (limited to 'svtools/inc/svtools/table')
-rw-r--r-- | svtools/inc/svtools/table/abstracttablecontrol.hxx | 134 | ||||
-rw-r--r-- | svtools/inc/svtools/table/defaultinputhandler.hxx | 69 | ||||
-rw-r--r-- | svtools/inc/svtools/table/gridtablerenderer.hxx | 108 | ||||
-rw-r--r-- | svtools/inc/svtools/table/tablecontrol.hxx | 243 | ||||
-rw-r--r-- | svtools/inc/svtools/table/tabledatawindow.hxx | 86 | ||||
-rw-r--r-- | svtools/inc/svtools/table/tableinputhandler.hxx | 78 | ||||
-rw-r--r-- | svtools/inc/svtools/table/tablemodel.hxx | 483 | ||||
-rw-r--r-- | svtools/inc/svtools/table/tablerenderer.hxx | 274 | ||||
-rw-r--r-- | svtools/inc/svtools/table/tabletypes.hxx | 76 |
9 files changed, 1551 insertions, 0 deletions
diff --git a/svtools/inc/svtools/table/abstracttablecontrol.hxx b/svtools/inc/svtools/table/abstracttablecontrol.hxx new file mode 100644 index 000000000000..9206f20ecbcb --- /dev/null +++ b/svtools/inc/svtools/table/abstracttablecontrol.hxx @@ -0,0 +1,134 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef SVTOOLS_INC_TABLE_ABSTRACTTABLECONTROL_HXX +#define SVTOOLS_INC_TABLE_ABSTRACTTABLECONTROL_HXX + +#include <sal/types.h> +#include <vcl/event.hxx> +#include <vcl/seleng.hxx> +#include "tabletypes.hxx" +//........................................................................ +namespace svt { namespace table +{ +//........................................................................ + + 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 + }; + + //==================================================================== + //= IAbstractTableControl + //==================================================================== + /** defines a callback interface to be implemented by a concrete table control + */ + class SAL_NO_VTABLE IAbstractTableControl + { + 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 + <TRUE/> if the action could be dispatched successfully, <FALSE/> 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; + virtual void setCursorAtCurrentCell(const Point& rPoint) = 0; + virtual bool isTooltipActive() = 0; + virtual rtl::OUString& setTooltip(const Point& rPoint ) = 0; + virtual RowPos getCurrentRow(const Point& rPoint ) = 0; + virtual void resizeColumn(const Point& rPoint ) = 0; + virtual bool startResizeColumn(const Point& rPoint) = 0; + virtual bool endResizeColumn(const Point& rPoint) = 0; + virtual bool isRowSelected(RowPos _nRow) = 0; + + virtual ~IAbstractTableControl() {}; + }; + +//........................................................................ +} } // namespace svt::table +//........................................................................ + +#endif // SVTOOLS_INC_TABLE_ABSTRACTTABLECONTROL_HXX diff --git a/svtools/inc/svtools/table/defaultinputhandler.hxx b/svtools/inc/svtools/table/defaultinputhandler.hxx new file mode 100644 index 000000000000..ca760896d539 --- /dev/null +++ b/svtools/inc/svtools/table/defaultinputhandler.hxx @@ -0,0 +1,69 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef SVTOOLS_INC_TABLE_DEFAULTINPUTHANDLER_HXX +#define SVTOOLS_INC_TABLE_DEFAULTINPUTHANDLER_HXX + +#include <svtools/table/tableinputhandler.hxx> + +//........................................................................ +namespace svt { namespace table +{ +//........................................................................ + + struct DefaultInputHandler_Impl; + + //==================================================================== + //= DefaultInputHandler + //==================================================================== + class DefaultInputHandler : public ITableInputHandler + { + friend class TableDataWindow; + private: + DefaultInputHandler_Impl* m_pImpl; + bool m_bResize; + + public: + DefaultInputHandler(); + ~DefaultInputHandler(); + + virtual bool MouseMove ( IAbstractTableControl& _rControl, const MouseEvent& rMEvt ); + virtual bool MouseButtonDown ( IAbstractTableControl& _rControl, const MouseEvent& rMEvt ); + virtual bool MouseButtonUp ( IAbstractTableControl& _rControl, const MouseEvent& rMEvt ); + virtual bool KeyInput ( IAbstractTableControl& _rControl, const KeyEvent& rKEvt ); + virtual bool GetFocus ( IAbstractTableControl& _rControl ); + virtual bool LoseFocus ( IAbstractTableControl& _rControl ); + virtual bool RequestHelp ( IAbstractTableControl& _rControl, const HelpEvent& rHEvt ); + virtual bool Command ( IAbstractTableControl& _rControl, const CommandEvent& rCEvt ); + virtual bool PreNotify ( IAbstractTableControl& _rControl, NotifyEvent& rNEvt ); + virtual bool Notify ( IAbstractTableControl& _rControl, NotifyEvent& rNEvt ); + }; + +//........................................................................ +} } // namespace svt::table +//........................................................................ + +#endif // SVTOOLS_INC_TABLE_DEFAULTINPUTHANDLER_HXX diff --git a/svtools/inc/svtools/table/gridtablerenderer.hxx b/svtools/inc/svtools/table/gridtablerenderer.hxx new file mode 100644 index 000000000000..e474306c0423 --- /dev/null +++ b/svtools/inc/svtools/table/gridtablerenderer.hxx @@ -0,0 +1,108 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef SVTOOLS_INC_TABLE_GRIDTABLERENDERER_HXX +#define SVTOOLS_INC_TABLE_GRIDTABLERENDERER_HXX + +#include <svtools/table/tablemodel.hxx> + +//........................................................................ +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. + + TODO update the documentation when it's decided whether this renderer + also does value handling + */ + class GridTableRenderer : public ITableRenderer + { + private: + 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(); + + /** returns the index of the row currently being painted + + According to the ->ITableRenderer interface, one call is made + to the renderer with a row to prepare (->PrepareRow()), and subsequent + calls do not carry the row index anymore, but are relative to the + row which has previously been prepared. + + This method returns the index of the last row which has been prepared + */ + RowPos getCurrentRow(); + + protected: + // 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 _bActive, bool _bSelected, + OutputDevice& _rDevice, const Rectangle& _rRowArea, + const StyleSettings& _rStyle ); + virtual void PaintRowHeader( + bool _bActive, bool _bSelected, + OutputDevice& _rDevice, const Rectangle& _rArea, + const StyleSettings& _rStyle, rtl::OUString& _rText ); + virtual void PaintCellImage( ColPos _nColumn, + bool _bActive, bool _bSelected, + OutputDevice& _rDevice, const Rectangle& _rArea, + const StyleSettings& _rStyle, Image* _pCellData ); + virtual void PaintCellString( ColPos _nColumn, + bool _bActive, bool _bSelected, + OutputDevice& _rDevice, const Rectangle& _rArea, + const StyleSettings& _rStyle, rtl::OUString& _rText ); + virtual void ShowCellCursor( Window& _rView, const Rectangle& _rCursorRect); + virtual void HideCellCursor( Window& _rView, const Rectangle& _rCursorRect); + }; +//........................................................................ +} } // namespace svt::table +//........................................................................ + +#endif // SVTOOLS_INC_TABLE_GRIDTABLERENDERER_HXX diff --git a/svtools/inc/svtools/table/tablecontrol.hxx b/svtools/inc/svtools/table/tablecontrol.hxx new file mode 100644 index 000000000000..f3b7ed88b565 --- /dev/null +++ b/svtools/inc/svtools/table/tablecontrol.hxx @@ -0,0 +1,243 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef SVTOOLS_INC_TABLE_TABLECONTROL_HXX +#define SVTOOLS_INC_TABLE_TABLECONTROL_HXX + +#include "svtools/svtdllapi.h" +#include <svtools/table/tablemodel.hxx> +#include <vcl/ctrl.hxx> +#include <vcl/seleng.hxx> +#include <svtools/table/tabledatawindow.hxx> +#include <svtools/accessibletable.hxx> +#include <com/sun/star/util/Color.hpp> +#include <svtools/accessiblefactory.hxx> +//........................................................................ + +namespace svt { namespace table +{ +//........................................................................ + + class TableControl_Impl; + class TableDataWindow; + class AccessibleTableControl_Impl; + + //==================================================================== + //= TableControl + //==================================================================== + /** a basic control which manages table-like data, i.e. a number of cells + organized in <code>m</code> rows and <code>n</code> 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 <em>current</em> (or <em>active</em> + cell). + The control supports accessibility, this is encapsulated in IAccessibleTable + + // TODO: scrolling? + */ + class SVT_DLLPUBLIC TableControl : public Control, public IAccessibleTable + { + private: + DECL_DLLPRIVATE_LINK( ImplMouseButtonDownHdl, MouseEvent* ); + DECL_DLLPRIVATE_LINK( ImplMouseButtonUpHdl, MouseEvent* ); + + DECL_DLLPRIVATE_LINK( ImplSelectHdl, void* ); + + TableControl_Impl* m_pImpl; + ::com::sun::star::uno::Sequence< sal_Int32 > m_nCols; + ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aText; + Link m_aSelectHdl; + bool m_bSelectionChanged; + bool m_bTooltip; + public: + ::std::auto_ptr< AccessibleTableControl_Impl > m_pAccessTable; + + TableControl( Window* _pParent, WinBits _nStyle ); + ~TableControl(); + + /// sets a new table model + SVT_DLLPRIVATE void SetModel( PTableModel _pModel ); + /// retrieves the current table model + PTableModel GetModel() const; + + /// returns the top row, i.e. the first visible row + RowPos GetTopRow() const; + /// sets a new top row. The top row is the first visible row in the control + void SetTopRow( RowPos _nRow ); + + /** 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; + + /** returns the row, which contains the input point*/ + + ColPos GetCurrentRow (const Point& rPoint); + + /** 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 + <TRUE/> if the move was successful, <FALSE/> 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 + <TRUE/> if the move was successful, <FALSE/> 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 + <TRUE/> if the move was successful, <FALSE/> 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(); + SVT_DLLPRIVATE void SetSelectHdl( const Link& rLink ) { m_aSelectHdl = rLink; } + const Link& GetSelectHdl() const { return m_aSelectHdl; } + + /**invalidates the table if table has been changed e.g. new row added + */ + void InvalidateDataWindow(RowPos _nRowStart, RowPos _nRowEnd, bool _bRemoved); + /**gets the vector, which contains the selected rows + */ + std::vector<sal_Int32>& GetSelectedRows(); + /**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(); + TableDataWindow* 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 XACC CreateAccessible(); + SVT_DLLPRIVATE virtual XACC CreateAccessibleControl( sal_Int32 _nIndex ); + SVT_DLLPRIVATE virtual ::rtl::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 ::rtl::OUString GetAccessibleObjectDescription(AccessibleTableControlObjType eObjType, sal_Int32 _nPosition = -1) const; + virtual void FillAccessibleStateSet( + ::utl::AccessibleStateSetHelper& rStateSet, + AccessibleTableControlObjType eObjType ) const; + //// Window + virtual Rectangle GetWindowExtentsRelative( Window *pRelativeWindow ) const; + virtual void GrabFocus(); + virtual XACC GetAccessible( BOOL bCreate = 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_Int32 GetSelectedRowCount() const; + virtual bool IsRowSelected( long _nRow ) const; + virtual sal_Bool ConvertPointToCellAddress( sal_Int32& _rnRow, sal_Int32& _rnColPos, const Point& _rPoint ); + virtual Rectangle calcHeaderRect( sal_Bool _bIsColumnBar, BOOL _bOnScreen = TRUE ); + virtual Rectangle calcTableRect( BOOL _bOnScreen = TRUE ); + 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 ::rtl::OUString GetRowDescription( sal_Int32 _nRow ) const; + virtual ::rtl::OUString GetRowName(sal_Int32 _nIndex) const; + virtual ::rtl::OUString GetColumnDescription( sal_uInt16 _nColumnPos ) const; + virtual ::rtl::OUString GetColumnName( sal_Int32 _nIndex ) const; + virtual ::com::sun::star::uno::Any GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos) const; + virtual sal_Bool HasRowHeader(); + virtual sal_Bool HasColHeader(); + virtual sal_Bool isAccessibleAlive( ) const; + virtual void commitGridControlEvent( sal_Int16 _nEventId, const com::sun::star::uno::Any& _rNewValue, const com::sun::star::uno::Any& _rOldValue ); + virtual void RemoveSelectedRow(RowPos _nRowPos); + virtual ::rtl::OUString GetAccessibleCellText(sal_Int32 _nRowPos, sal_Int32 _nColPos) const; + ::com::sun::star::uno::Sequence< sal_Int32 >& getColumnsForTooltip(); + ::com::sun::star::uno::Sequence< ::rtl::OUString >& getTextForTooltip(); + void setTooltip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aText, const ::com::sun::star::uno::Sequence< sal_Int32 >& nCols); + void clearSelection(); + void selectionChanged(bool _bChanged); + bool isTooltip(); + + protected: + /// retrieves the XAccessible implementation associated with the GridControl instance + ::svt::IAccessibleFactory& getAccessibleFactory(); + + private: + TableControl(); // never implemented + TableControl( const TableControl& ); // never implemented + TableControl& operator=( const TableControl& ); // never implemented + }; + +//........................................................................ +} } // namespace svt::table +//........................................................................ + +#endif // SVTOOLS_INC_TABLE_TABLECONTROL_HXX diff --git a/svtools/inc/svtools/table/tabledatawindow.hxx b/svtools/inc/svtools/table/tabledatawindow.hxx new file mode 100644 index 000000000000..829feecd5836 --- /dev/null +++ b/svtools/inc/svtools/table/tabledatawindow.hxx @@ -0,0 +1,86 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef SVTOOLS_SOURCE_TABLE_TABLEDATAWINDOW_HXX +#define SVTOOLS_SOURCE_TABLE_TABLEDATAWINDOW_HXX + +#ifndef _SV_WINDOW_HXX +#include <vcl/window.hxx> +#endif +#include <vcl/seleng.hxx> + +//........................................................................ +namespace svt { namespace table +{ +//........................................................................ + + class TableControl_Impl; + class TableFunctionSet; + + + //==================================================================== + //= TableDataWindow + //==================================================================== + /** the window containing the content area (including headers) of + a table control + */ + class TableDataWindow : public Window + { + friend class TableFunctionSet; + private: + TableControl_Impl& m_rTableControl; + Link m_aMouseButtonDownHdl; + Link m_aMouseButtonUpHdl; + Link m_aSelectHdl; + public: + TableDataWindow( TableControl_Impl& _rTableControl ); + inline void SetMouseButtonDownHdl( const Link& rLink ) { m_aMouseButtonDownHdl = rLink; } + inline const Link& GetMouseButtonDownHdl() const { return m_aMouseButtonDownHdl; } + inline void SetMouseButtonUpHdl( const Link& rLink ) { m_aMouseButtonUpHdl = rLink; } + inline const Link& GetMouseButtonUpHdl() const { return m_aMouseButtonUpHdl; } + inline void SetSelectHdl( const Link& rLink ) { m_aSelectHdl = rLink; } + inline const Link& GetSelectHdl() const { return m_aSelectHdl; } + + // Window overridables + virtual void Paint( const Rectangle& rRect ); + virtual void MouseMove( const MouseEvent& rMEvt); + virtual void MouseButtonDown( const MouseEvent& rMEvt); + virtual void MouseButtonUp( const MouseEvent& rMEvt); + virtual void SetPointer( const Pointer& rPointer ); + virtual void CaptureMouse(); + virtual void ReleaseMouse(); + virtual long Notify(NotifyEvent& rNEvt); + virtual void SetControlBackground(const Color& rColor); + virtual void SetControlBackground(); + + void SetBackground(const Wallpaper& rColor); + void SetBackground(); + }; +//........................................................................ +} } // namespace svt::table +//........................................................................ + +#endif // SVTOOLS_SOURCE_TABLE_TABLEDATAWINDOW_HXX diff --git a/svtools/inc/svtools/table/tableinputhandler.hxx b/svtools/inc/svtools/table/tableinputhandler.hxx new file mode 100644 index 000000000000..6d6af9f641bb --- /dev/null +++ b/svtools/inc/svtools/table/tableinputhandler.hxx @@ -0,0 +1,78 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef SVTOOLS_INC_TABLE_TABLEINPUTHANDLER_HXX +#define SVTOOLS_INC_TABLE_TABLEINPUTHANDLER_HXX + +#include <boost/shared_ptr.hpp> + +class MouseEvent; +class KeyEvent; +class HelpEvent; +class CommandEvent; +class NotifyEvent; + +//........................................................................ +namespace svt { namespace table +{ +//........................................................................ + + class IAbstractTableControl; + + //==================================================================== + //= 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 (<FALSE/>), + // or whether it has been sufficiently handled by the ->ITableInputHandler instance + // (<FALSE/>). + + virtual bool MouseMove ( IAbstractTableControl& _rControl, const MouseEvent& rMEvt ) = 0; + virtual bool MouseButtonDown ( IAbstractTableControl& _rControl, const MouseEvent& rMEvt ) = 0; + virtual bool MouseButtonUp ( IAbstractTableControl& _rControl, const MouseEvent& rMEvt ) = 0; + virtual bool KeyInput ( IAbstractTableControl& _rControl, const KeyEvent& rKEvt ) = 0; + virtual bool GetFocus ( IAbstractTableControl& _rControl ) = 0; + virtual bool LoseFocus ( IAbstractTableControl& _rControl ) = 0; + virtual bool RequestHelp ( IAbstractTableControl& _rControl, const HelpEvent& rHEvt ) = 0; + virtual bool Command ( IAbstractTableControl& _rControl, const CommandEvent& rCEvt ) = 0; + virtual bool PreNotify ( IAbstractTableControl& _rControl, NotifyEvent& rNEvt ) = 0; + virtual bool Notify ( IAbstractTableControl& _rControl, NotifyEvent& rNEvt ) = 0; + + virtual ~ITableInputHandler() { } + }; + typedef ::boost::shared_ptr< ITableInputHandler > PTableInputHandler; + +//........................................................................ +} } // namespace svt::table +//........................................................................ + +#endif // SVTOOLS_INC_TABLE_TABLEINPUTHANDLER_HXX diff --git a/svtools/inc/svtools/table/tablemodel.hxx b/svtools/inc/svtools/table/tablemodel.hxx new file mode 100644 index 000000000000..3da396d9d86c --- /dev/null +++ b/svtools/inc/svtools/table/tablemodel.hxx @@ -0,0 +1,483 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#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 <rtl/ref.hxx> +#include <sal/types.h> +#include <com/sun/star/util/Color.hpp> +#include <boost/shared_ptr.hpp> +#include <com/sun/star/style/VerticalAlignment.hpp> +#include <com/sun/star/style/HorizontalAlignment.hpp> + +//........................................................................ +namespace svt { namespace table +{ +//........................................................................ + + + //==================================================================== + //= cell data + //==================================================================== + struct TableContentType + { + ::rtl::OUString sContent; + Image* pImage; + TableContentType() : + sContent(), + pImage( ) + { + } + }; + //==================================================================== + //= 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 + //==================================================================== + /** declares an interface to be implemented by components interested in + changes in an ->ITableModel + */ + class SAL_NO_VTABLE ITableModelListener + { + public: + //virtual void onTableModelChanged(PTableModel pTableModel) = 0; + /** 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 + @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 columnsInserted( ColPos first, ColPos last ) = 0; + + /** notifies the listener that one or more columns have been removed from + the table + + @param first + the old index of the first removed row + @param last + the old index of the last removed row. Must not be smaller + than ->first + */ + virtual void columnsRemoved( ColPos first, ColPos last ) = 0; + + /** notifies the listener that a column in the table has moved + + @param oldIndex + the old index of the column within the model + @param newIndex + the new index of the column within the model + */ + virtual void columnMoved( ColPos oldIndex, ColPos newIndex ) = 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 firstCol, ColPos lastCol, RowPos firstRow, RowPos lastRow ) = 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 ColumnID getID() const = 0; + + /** sets a new column ID + + @return + <TRUE/> if setting the new ID was successfull. 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 bool setID( const ColumnID _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; + + /** determines whether the column can be 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; + + /** returns the width of the column, in 1/100 millimeters + + The returned value must be a positive ->TableMetrics value. + + It can also be COLWIDTH_FIT_TO_VIEW, to indicate that the width of the column + should automatically be adjusted to completely fit the view. For instance, a + model's last column could return this value, to indicate that it is to occupy + all horizontal space remaining in the view, after all other columns have been + layouted. + + If there is more than one column with width COLWIDTH_FIT_TO_VIEW in a model, + they're all layouted equal-width. + + If the columns with a read width (i.e. other than COLWIDTH_FIT_TO_VIEW) are, + in sum, wider than the view, then the view is free to choose a real width for any + columns which return COLWIDTH_FIT_TO_VIEW here. + + @see setWidth + @see getMinWidth + @see getMaxWidth + @see COLWIDTH_FIT_TO_VIEW + */ + virtual TableMetrics getWidth() const = 0; + + /** sets a new width for the column + + @param _nWidth + the new width, in 1/100 millimeters + + @see getWidth + */ + virtual void setWidth( TableMetrics _nWidth ) = 0; + + /** returns the minimum width of the column, in 1/100 millimeters, 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 1/100 millimeters + + @see getMinWidth + @see setMaxWidth + @see setWidth + */ + virtual void setMinWidth( TableMetrics _nMinWidth ) = 0; + + /** returns the maximum width of the column, in 1/100 millimeters, 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 1/100 millimeters + + @see getMaxWidth + @see setMinWidth + @see setWidth + */ + virtual void setMaxWidth( TableMetrics _nMaxWidth ) = 0; + + /** returns the preferred width of the column, or 0 if the column + does not have a preferred width. + + @see setMaxWidth + @see getMinWidth + @see getWidth + */ + virtual TableMetrics getPreferredWidth() const = 0; + /** sets the preferred width of the column, to be used when user resizes column + + @see getMaxWidth + @see setMinWidth + @see setWidth + */ + virtual void setPreferredWidth( TableMetrics _nPrefWidth ) = 0; + + virtual ::com::sun::star::style::HorizontalAlignment getHorizontalAlign() = 0; + 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; + + SVT_DLLPRIVATE virtual void setColumnCount(TableSize _nColCount) = 0; + SVT_DLLPRIVATE virtual void setRowCount(TableSize _nRowCount) = 0; + + /** determines whether the table has column headers + + If this method returns <TRUE/>, the renderer returned by + ->getRenderer must be able to render column headers. + + @see IColumnRenderer + */ + virtual bool hasColumnHeaders() const = 0; + /** sets whether the table should have row headers + @see IColumnRenderer + */ + SVT_DLLPRIVATE virtual void setRowHeaders( bool rowHeaders) = 0; + + /** sets whether the table should have column headers + @see IColumnRenderer + */ + SVT_DLLPRIVATE virtual void setColumnHeaders( bool columnHeaders) = 0; + + /** determines whether the table has row headers + + If this method returns <TRUE/>, 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; + + /** adds the given listener to the list of ->ITableModelListener's + */ + SVT_DLLPRIVATE virtual void addTableModelListener( const PTableModelListener& listener ) = 0; + + /** revokes the given listener from the list of ->ITableModelListener's + */ + SVT_DLLPRIVATE virtual void removeTableModelListener( const PTableModelListener& listener ) = 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 <NULL/> + + @see getColumnModelByID + */ + virtual PColumnModel getColumnModel( ColPos column ) = 0; + + /** finds a column model by ID + + @param id + the id of the column which is to be looked up + @return + the column model with the given ID, or <NULL/> if there is + no such column + */ + virtual PColumnModel getColumnModelByID( ColumnID id ) = 0; + + /** returns a renderer which is able to paint the table represented + by this table model + + @return the renderer to use. Must not be <NULL/> + */ + SVT_DLLPRIVATE 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 1/100 millimeters. The height must be + greater 0. + */ + SVT_DLLPRIVATE virtual TableMetrics getRowHeight() const = 0; + + SVT_DLLPRIVATE virtual void setRowHeight(TableMetrics _nRowHeight) = 0; + + /** determines the height of the column header row + + This method is not to be called if ->hasColumnHeaders() + returned <FALSE/>. + + @return + the logical height of the column header row, in 1/100 millimeters. + Must be greater than 0. + */ + SVT_DLLPRIVATE virtual TableMetrics getColumnHeaderHeight() const = 0; + + /** determines the width of the row header column + + This method is not to be called if ->hasRowHeaders() + returned <FALSE/>. + + @return + the logical width of the row header column, in 1/100 millimeters. + Must be greater than 0. + */ + SVT_DLLPRIVATE virtual TableMetrics getRowHeaderWidth() const = 0; + + /** determines the visibility of the vertical scrollbar of the table control + @param overAllHeight the height of the table with all rows + @param actHeight the given height of the table + */ + virtual ScrollbarVisibility getVerticalScrollbarVisibility(int overAllHeight,int actHeight) const = 0; + + /** determines the visibility of the horizontal scrollbar of the table control + @param overAllWidth the width of the table with all columns + @param actWidth the given width of the table + */ + virtual ScrollbarVisibility getHorizontalScrollbarVisibility(int overAllWidth, int actWidth) const = 0; + virtual bool hasVerticalScrollbar() =0; + virtual bool hasHorizontalScrollbar() = 0; + /** fills cells with content + */ + virtual void setCellContent(const std::vector< std::vector< ::com::sun::star::uno::Any > >& cellContent)=0; + /** gets the content of the cells + */ + virtual std::vector< std::vector< ::com::sun::star::uno::Any > >& getCellContent() = 0; + /**sets title of header rows + */ + SVT_DLLPRIVATE virtual void setRowHeaderName(const std::vector<rtl::OUString>& cellColumnContent)=0; + /** gets title of header rows + */ + virtual std::vector<rtl::OUString>& getRowHeaderName() = 0; + SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getLineColor() = 0; + SVT_DLLPRIVATE virtual void setLineColor(::com::sun::star::util::Color _rColor) = 0; + SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getHeaderBackgroundColor() = 0; + SVT_DLLPRIVATE virtual void setHeaderBackgroundColor(::com::sun::star::util::Color _rColor) = 0; + SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getTextColor() = 0; + SVT_DLLPRIVATE virtual void setTextColor(::com::sun::star::util::Color _rColor) = 0; + SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getOddRowBackgroundColor() = 0; + SVT_DLLPRIVATE virtual void setOddRowBackgroundColor(::com::sun::star::util::Color _rColor) = 0; + SVT_DLLPRIVATE virtual ::com::sun::star::util::Color getEvenRowBackgroundColor() = 0; + SVT_DLLPRIVATE virtual void setEvenRowBackgroundColor(::com::sun::star::util::Color _rColor) = 0; + SVT_DLLPRIVATE virtual ::com::sun::star::style::VerticalAlignment getVerticalAlign() = 0; + SVT_DLLPRIVATE virtual void setVerticalAlign(::com::sun::star::style::VerticalAlignment _xAlign) = 0; + + /// destroys the table model instance + virtual ~ITableModel() { } + }; + typedef ::boost::shared_ptr< ITableModel > PTableModel; + +//........................................................................ +} } // namespace svt::table +//........................................................................ + +#endif // SVTOOLS_INC_TABLE_TABLEMODEL_HXX diff --git a/svtools/inc/svtools/table/tablerenderer.hxx b/svtools/inc/svtools/table/tablerenderer.hxx new file mode 100644 index 000000000000..f81771dd22e6 --- /dev/null +++ b/svtools/inc/svtools/table/tablerenderer.hxx @@ -0,0 +1,274 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef SVTOOLS_INC_TABLE_TABLERENDERER_HXX +#define SVTOOLS_INC_TABLE_TABLERENDERER_HXX + +#include <svtools/table/tabletypes.hxx> + +#include <vcl/outdev.hxx> + +#include <boost/shared_ptr.hpp> + +//........................................................................ +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: + <ul><li>The row containing all column headers, i.e. <em>above</em> all rows containing the data</li> + <li>The column containing all row headers. i.e. <em>left of</em> all columns containing the data</li> + </ul> + + 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.<br/> + 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. + <ul><li>If both are <TRUE/>, the intersection of both areas is to be painted.</li> + <li>If ->_bIsColHeaderArea is <TRUE/> and ->_bIsRowHeaderArea is <FALSE/>, + then ->_rArea denotes the column header area <em>excluding</em> the + intersection between row and column header area.</li> + <li>Equivalently for ->_bIsColHeaderArea being <FALSE/> and ->_bIsRowHeaderArea + being <TRUE/></li> + </ul> + Note that it's not possible for both ->_bIsColHeaderArea and ->_bIsRowHeaderArea + to be <FALSE/> at the same time. + + @param _rDevice + the device to paint onto + @param _rArea + the area to paint into + @param _bIsColHeaderArea + <TRUE/> if and only if ->_rArea is part of the column header area. + @param _bIsRowHeaderArea + <TRUE/> 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 + <TRUE/> if and only if the column whose column is to be painted + contains the active cell. + @param _bSelected + <TRUE/> 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 _bActive + <TRUE/> if and only if the row to be painted contains the + currently active cell. + @param _bSelected + <TRUE/> 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 _bActive, 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 _bActive + <TRUE/> if and only if the row to be painted contains the + currently active cell. + <br/> + Note that this flag is equal to the respective flag in the + previous ->PrepareRow call, it's passed here for convinience + only. + @param _bSelected + <TRUE/> if and only if the row whose header cell is to be + painted is selected currently. + <br/> + 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 + @param _rText + the title of the header row + */ + virtual void PaintRowHeader( bool _bActive, bool _bSelected, + OutputDevice& _rDevice, const Rectangle& _rArea, + const StyleSettings& _rStyle, rtl::OUString& _rText ) = 0; + + /** paints a certain cell + + The row to be painted is denoted by the most recent call to + ->PrepareRow. + + @param _bSelected + <TRUE/> 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. + <br/> + Note that this flag is equal to the respective flag in the + previous ->PrepareRow call, it's passed here for convinience + only. + @param _bActive + <TRUE/> if the cell is currently active. + <br/> + 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 + @param _pCellData + the content of the cell + */ + virtual void PaintCellImage( ColPos _nColumn, + bool _bActive, bool _bSelected, + OutputDevice& _rDevice, const Rectangle& _rArea, + const StyleSettings& _rStyle, Image* _pCellData ) = 0; + + /** paints a certain cell + + The row to be painted is denoted by the most recent call to + ->PrepareRow. + + @param _bSelected + <TRUE/> 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. + <br/> + Note that this flag is equal to the respective flag in the + previous ->PrepareRow call, it's passed here for convinience + only. + @param _bActive + <TRUE/> if the cell is currently active. + <br/> + 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 + @param _rText + the content of the cell + */ + virtual void PaintCellString( ColPos _nColumn, + bool _bActive, bool _bSelected, + OutputDevice& _rDevice, const Rectangle& _rArea, + const StyleSettings& _rStyle, rtl::OUString& _rText ) = 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; + + /// deletes the renderer instance + virtual ~ITableRenderer() { } + }; + typedef ::boost::shared_ptr< ITableRenderer > PTableRenderer; + +//........................................................................ +} } // namespace svt::table +//........................................................................ + +#endif // SVTOOLS_INC_TABLE_TABLERENDERER_HXX diff --git a/svtools/inc/svtools/table/tabletypes.hxx b/svtools/inc/svtools/table/tabletypes.hxx new file mode 100644 index 000000000000..645120e30d4b --- /dev/null +++ b/svtools/inc/svtools/table/tabletypes.hxx @@ -0,0 +1,76 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef SVTOOLS_INC_TABLE_TABLETYPES_HXX +#define SVTOOLS_INC_TABLE_TABLETYPES_HXX + +#include <sal/types.h> + +//........................................................................ +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; + + /// the ID of a column in a table + typedef sal_Int32 ColumnID; + + typedef sal_Int32 TableMetrics; +/** special column width value which indicates that the column should be + automatically resized to fit the view +*/ +#define COLWIDTH_FIT_TO_VIEW ((::svt::table::TableMetrics)-1) + +/// 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 |