1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _UNOCONTROL_TABLEMODEL_HXX_ 25 #define _UNOCONTROL_TABLEMODEL_HXX_ 26 27 #include "svtools/table/tablemodel.hxx" 28 #include "svtools/table/tablecontrol.hxx" 29 30 /** === begin UNO includes === **/ 31 #include <com/sun/star/awt/grid/XGridControl.hpp> 32 #include <com/sun/star/awt/grid/GridDataEvent.hpp> 33 #include <com/sun/star/awt/grid/XGridColumnModel.hpp> 34 #include <com/sun/star/awt/grid/XGridDataModel.hpp> 35 #include <com/sun/star/awt/grid/XGridSelectionListener.hpp> 36 #include <com/sun/star/awt/grid/XGridColumn.hpp> 37 #include <com/sun/star/util/Color.hpp> 38 #include <com/sun/star/style/VerticalAlignment.hpp> 39 /** === end UNO includes === **/ 40 41 #include <cppuhelper/implbase2.hxx> 42 #include <rtl/ref.hxx> 43 44 #include <boost/noncopyable.hpp> 45 46 // ..................................................................................................................... 47 namespace svt { namespace table 48 { 49 // ..................................................................................................................... 50 51 //================================================================================================================== 52 //= UnoControlTableModel 53 //================================================================================================================== 54 class UnoGridColumnFacade; 55 struct UnoControlTableModel_Impl; 56 class UnoControlTableModel : public ITableModel, public ITableDataSort 57 { 58 private: 59 UnoControlTableModel_Impl* m_pImpl; 60 61 public: 62 UnoControlTableModel(); 63 ~UnoControlTableModel(); 64 65 public: 66 // ITableModel overridables 67 virtual TableSize getColumnCount() const; 68 virtual TableSize getRowCount() const; 69 virtual bool hasColumnHeaders() const; 70 virtual bool hasRowHeaders() const; 71 virtual bool isCellEditable( ColPos col, RowPos row ) const; 72 virtual PColumnModel getColumnModel( ColPos column ); 73 virtual PTableRenderer getRenderer() const; 74 virtual PTableInputHandler getInputHandler() const; 75 virtual TableMetrics getRowHeight() const; 76 virtual TableMetrics getColumnHeaderHeight() const; 77 virtual TableMetrics getRowHeaderWidth() const; 78 virtual ScrollbarVisibility getVerticalScrollbarVisibility() const; 79 virtual ScrollbarVisibility getHorizontalScrollbarVisibility() const; 80 virtual void addTableModelListener( const PTableModelListener& i_listener ); 81 virtual void removeTableModelListener( const PTableModelListener& i_listener ); 82 virtual void getCellContent( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any& o_cellContent ); 83 virtual void getCellToolTip( ColPos const i_col, RowPos const i_row, ::com::sun::star::uno::Any & o_cellToolTip ); 84 virtual ::com::sun::star::uno::Any getRowHeading( RowPos const i_rowPos ) const; 85 virtual ::boost::optional< ::Color > getLineColor() const; 86 virtual ::boost::optional< ::Color > getHeaderBackgroundColor() const; 87 virtual ::boost::optional< ::Color > getHeaderTextColor() const; 88 virtual ::boost::optional< ::Color > getActiveSelectionBackColor() const; 89 virtual ::boost::optional< ::Color > getInactiveSelectionBackColor() const; 90 virtual ::boost::optional< ::Color > getActiveSelectionTextColor() const; 91 virtual ::boost::optional< ::Color > getInactiveSelectionTextColor() const; 92 virtual ::boost::optional< ::Color > getTextColor() const; 93 virtual ::boost::optional< ::Color > getTextLineColor() const; 94 virtual ::boost::optional< ::std::vector< ::Color > > 95 getRowBackgroundColors() const; 96 virtual ::com::sun::star::style::VerticalAlignment 97 getVerticalAlign() const; 98 virtual ITableDataSort* getSortAdapter(); 99 virtual bool isEnabled() const; 100 101 // ITableDataSort overridables 102 virtual void sortByColumn( ColPos const i_column, ColumnSortDirection const i_sortDirection ); 103 virtual ColumnSort getCurrentSortOrder() const; 104 105 // column write access 106 void appendColumn( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > const & i_column ); 107 void insertColumn( ColPos const i_position, ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > const & i_column ); 108 void removeColumn( ColPos const i_position ); 109 void removeAllColumns(); 110 111 // other operations 112 void setVerticalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const; 113 void setHorizontalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const; 114 115 void setDataModel( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > const & i_gridDataModel ); 116 bool hasDataModel() const; 117 ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > 118 getDataModel() const; 119 void setColumnModel( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > const & i_gridColumnModel ); 120 bool hasColumnModel() const; 121 ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > 122 getColumnModel() const; 123 124 void setRowHeaders(bool _bRowHeaders); 125 void setColumnHeaders(bool _bColumnHeaders); 126 127 void setRowHeight( TableMetrics _nHeight ); 128 void setRowHeaderWidth( TableMetrics _nWidth ); 129 void setColumnHeaderHeight( TableMetrics _nHeight ); 130 131 void setLineColor( ::com::sun::star::uno::Any const & i_color ); 132 void setHeaderBackgroundColor( ::com::sun::star::uno::Any const & i_color ); 133 void setHeaderTextColor( ::com::sun::star::uno::Any const & i_color ); 134 void setActiveSelectionBackColor( ::com::sun::star::uno::Any const & i_color ); 135 void setInactiveSelectionBackColor( ::com::sun::star::uno::Any const & i_color ); 136 void setActiveSelectionTextColor( ::com::sun::star::uno::Any const & i_color ); 137 void setInactiveSelectionTextColor( ::com::sun::star::uno::Any const & i_color ); 138 void setTextColor( ::com::sun::star::uno::Any const & i_color ); 139 void setTextLineColor( ::com::sun::star::uno::Any const & i_color ); 140 void setRowBackgroundColors( ::com::sun::star::uno::Any const & i_APIValue ); 141 142 void setVerticalAlign(::com::sun::star::style::VerticalAlignment _rAlign); 143 void setEnabled( bool _bEnabled ); 144 145 // multiplexing of XGridDataListener events 146 void notifyRowsInserted( ::com::sun::star::awt::grid::GridDataEvent const & i_event ) const; 147 void notifyRowsRemoved( ::com::sun::star::awt::grid::GridDataEvent const & i_event ) const; 148 void notifyDataChanged( ::com::sun::star::awt::grid::GridDataEvent const & i_event ) const; 149 150 /// retrieves the index of a column within the model 151 ColPos getColumnPos( UnoGridColumnFacade const & i_column ) const; 152 153 /// notifies a change in a column belonging to the model 154 void notifyColumnChange( ColPos const i_columnPos, ColumnAttributeGroup const i_attributeGroup ) const; 155 156 /** notifies a change in all data represented by the model. To be used if you cannot specified the changed data 157 in more detail. 158 */ 159 void notifyAllDataChanged() const; 160 161 #ifdef DBG_UTIL 162 const char* checkInvariants() const; 163 #endif 164 165 private: 166 void impl_notifyTableMetricsChanged() const; 167 }; 168 169 // ..................................................................................................................... 170 } } // svt::table 171 // ..................................................................................................................... 172 173 #endif // _UNOCONTROL_TABLEMODEL_HXX_ 174