1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _UNOCONTROL_TABLEMODEL_HXX_ 29 #define _UNOCONTROL_TABLEMODEL_HXX_ 30 31 #include "svtools/table/tablemodel.hxx" 32 #include "svtools/table/tablecontrol.hxx" 33 34 /** === begin UNO includes === **/ 35 #include <com/sun/star/awt/grid/XGridControl.hpp> 36 #include <com/sun/star/awt/grid/GridDataEvent.hpp> 37 #include <com/sun/star/awt/grid/XGridColumnModel.hpp> 38 #include <com/sun/star/awt/grid/XGridDataModel.hpp> 39 #include <com/sun/star/awt/grid/XGridSelectionListener.hpp> 40 #include <com/sun/star/awt/grid/XGridColumn.hpp> 41 #include <com/sun/star/util/Color.hpp> 42 #include <com/sun/star/style/VerticalAlignment.hpp> 43 /** === end UNO includes === **/ 44 45 #include <cppuhelper/implbase2.hxx> 46 #include <rtl/ref.hxx> 47 48 #include <boost/noncopyable.hpp> 49 50 // ..................................................................................................................... 51 namespace svt { namespace table 52 { 53 // ..................................................................................................................... 54 55 //================================================================================================================== 56 //= UnoControlTableModel 57 //================================================================================================================== 58 class UnoGridColumnFacade; 59 struct UnoControlTableModel_Impl; 60 class UnoControlTableModel : public ITableModel, public ITableDataSort 61 { 62 private: 63 UnoControlTableModel_Impl* m_pImpl; 64 65 public: 66 UnoControlTableModel(); 67 ~UnoControlTableModel(); 68 69 public: 70 // ITableModel overridables 71 virtual TableSize getColumnCount() const; 72 virtual TableSize getRowCount() const; 73 virtual bool hasColumnHeaders() const; 74 virtual bool hasRowHeaders() const; 75 virtual bool isCellEditable( ColPos col, RowPos row ) const; 76 virtual PColumnModel getColumnModel( ColPos column ); 77 virtual PTableRenderer getRenderer() const; 78 virtual PTableInputHandler getInputHandler() const; 79 virtual TableMetrics getRowHeight() const; 80 virtual TableMetrics getColumnHeaderHeight() const; 81 virtual TableMetrics getRowHeaderWidth() const; 82 virtual ScrollbarVisibility getVerticalScrollbarVisibility() const; 83 virtual ScrollbarVisibility getHorizontalScrollbarVisibility() const; 84 virtual void addTableModelListener( const PTableModelListener& i_listener ); 85 virtual void removeTableModelListener( const PTableModelListener& i_listener ); 86 virtual void getCellContent( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any& o_cellContent ); 87 virtual void getCellToolTip( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any & o_cellToolTip ); 88 virtual ::com::sun::star::uno::Any getRowHeading( RowPos const i_rowPos ) const; 89 virtual ::boost::optional< ::Color > getLineColor() const; 90 virtual ::boost::optional< ::Color > getHeaderBackgroundColor() const; 91 virtual ::boost::optional< ::Color > getHeaderTextColor() const; 92 virtual ::boost::optional< ::Color > getActiveSelectionBackColor() const; 93 virtual ::boost::optional< ::Color > getInactiveSelectionBackColor() const; 94 virtual ::boost::optional< ::Color > getActiveSelectionTextColor() const; 95 virtual ::boost::optional< ::Color > getInactiveSelectionTextColor() const; 96 virtual ::boost::optional< ::Color > getTextColor() const; 97 virtual ::boost::optional< ::Color > getTextLineColor() const; 98 virtual ::boost::optional< ::std::vector< ::Color > > 99 getRowBackgroundColors() const; 100 virtual ::com::sun::star::style::VerticalAlignment 101 getVerticalAlign() const; 102 virtual ITableDataSort* getSortAdapter(); 103 104 // ITableDataSort overridables 105 virtual void sortByColumn( ColPos const i_column, ColumnSortDirection const i_sortDirection ); 106 virtual ColumnSort getCurrentSortOrder() const; 107 108 // column write access 109 void appendColumn( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > const & i_column ); 110 void insertColumn( ColPos const i_position, ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > const & i_column ); 111 void removeColumn( ColPos const i_position ); 112 void removeAllColumns(); 113 114 // other operations 115 void setVerticalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const; 116 void setHorizontalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const; 117 118 void setDataModel( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > const & i_gridDataModel ); 119 bool hasDataModel() const; 120 ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > 121 getDataModel() const; 122 void setColumnModel( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > const & i_gridColumnModel ); 123 bool hasColumnModel() const; 124 ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > 125 getColumnModel() const; 126 127 void setRowHeaders(bool _bRowHeaders); 128 void setColumnHeaders(bool _bColumnHeaders); 129 130 void setRowHeight( TableMetrics _nHeight ); 131 void setRowHeaderWidth( TableMetrics _nWidth ); 132 void setColumnHeaderHeight( TableMetrics _nHeight ); 133 134 void setLineColor( ::com::sun::star::uno::Any const & i_color ); 135 void setHeaderBackgroundColor( ::com::sun::star::uno::Any const & i_color ); 136 void setHeaderTextColor( ::com::sun::star::uno::Any const & i_color ); 137 void setActiveSelectionBackColor( ::com::sun::star::uno::Any const & i_color ); 138 void setInactiveSelectionBackColor( ::com::sun::star::uno::Any const & i_color ); 139 void setActiveSelectionTextColor( ::com::sun::star::uno::Any const & i_color ); 140 void setInactiveSelectionTextColor( ::com::sun::star::uno::Any const & i_color ); 141 void setTextColor( ::com::sun::star::uno::Any const & i_color ); 142 void setTextLineColor( ::com::sun::star::uno::Any const & i_color ); 143 void setRowBackgroundColors( ::com::sun::star::uno::Any const & i_APIValue ); 144 145 void setVerticalAlign(::com::sun::star::style::VerticalAlignment _rAlign); 146 147 // multiplexing of XGridDataListener events 148 void notifyRowsInserted( ::com::sun::star::awt::grid::GridDataEvent const & i_event ) const; 149 void notifyRowsRemoved( ::com::sun::star::awt::grid::GridDataEvent const & i_event ) const; 150 void notifyDataChanged( ::com::sun::star::awt::grid::GridDataEvent const & i_event ) const; 151 152 /// retrieves the index of a column within the model 153 ColPos getColumnPos( UnoGridColumnFacade const & i_column ) const; 154 155 /// notifies a change in a column belonging to the model 156 void notifyColumnChange( ColPos const i_columnPos, ColumnAttributeGroup const i_attributeGroup ) const; 157 158 /** notifies a change in all data represented by the model. To be used if you cannot specified the changed data 159 in more detail. 160 */ 161 void notifyAllDataChanged() const; 162 163 #ifdef DBG_UTIL 164 const char* checkInvariants() const; 165 #endif 166 167 private: 168 void impl_notifyTableMetricsChanged() const; 169 }; 170 171 // ..................................................................................................................... 172 } } // svt::table 173 // ..................................................................................................................... 174 175 #endif // _UNOCONTROL_TABLEMODEL_HXX_ 176