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 100 // ITableDataSort overridables 101 virtual void sortByColumn( ColPos const i_column, ColumnSortDirection const i_sortDirection ); 102 virtual ColumnSort getCurrentSortOrder() const; 103 104 // column write access 105 void appendColumn( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > const & i_column ); 106 void insertColumn( ColPos const i_position, ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > const & i_column ); 107 void removeColumn( ColPos const i_position ); 108 void removeAllColumns(); 109 110 // other operations 111 void setVerticalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const; 112 void setHorizontalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const; 113 114 void setDataModel( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > const & i_gridDataModel ); 115 bool hasDataModel() const; 116 ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridDataModel > 117 getDataModel() const; 118 void setColumnModel( ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > const & i_gridColumnModel ); 119 bool hasColumnModel() const; 120 ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnModel > 121 getColumnModel() const; 122 123 void setRowHeaders(bool _bRowHeaders); 124 void setColumnHeaders(bool _bColumnHeaders); 125 126 void setRowHeight( TableMetrics _nHeight ); 127 void setRowHeaderWidth( TableMetrics _nWidth ); 128 void setColumnHeaderHeight( TableMetrics _nHeight ); 129 130 void setLineColor( ::com::sun::star::uno::Any const & i_color ); 131 void setHeaderBackgroundColor( ::com::sun::star::uno::Any const & i_color ); 132 void setHeaderTextColor( ::com::sun::star::uno::Any const & i_color ); 133 void setActiveSelectionBackColor( ::com::sun::star::uno::Any const & i_color ); 134 void setInactiveSelectionBackColor( ::com::sun::star::uno::Any const & i_color ); 135 void setActiveSelectionTextColor( ::com::sun::star::uno::Any const & i_color ); 136 void setInactiveSelectionTextColor( ::com::sun::star::uno::Any const & i_color ); 137 void setTextColor( ::com::sun::star::uno::Any const & i_color ); 138 void setTextLineColor( ::com::sun::star::uno::Any const & i_color ); 139 void setRowBackgroundColors( ::com::sun::star::uno::Any const & i_APIValue ); 140 141 void setVerticalAlign(::com::sun::star::style::VerticalAlignment _rAlign); 142 143 // multiplexing of XGridDataListener events 144 void notifyRowsInserted( ::com::sun::star::awt::grid::GridDataEvent const & i_event ) const; 145 void notifyRowsRemoved( ::com::sun::star::awt::grid::GridDataEvent const & i_event ) const; 146 void notifyDataChanged( ::com::sun::star::awt::grid::GridDataEvent const & i_event ) const; 147 148 /// retrieves the index of a column within the model 149 ColPos getColumnPos( UnoGridColumnFacade const & i_column ) const; 150 151 /// notifies a change in a column belonging to the model 152 void notifyColumnChange( ColPos const i_columnPos, ColumnAttributeGroup const i_attributeGroup ) const; 153 154 /** notifies a change in all data represented by the model. To be used if you cannot specified the changed data 155 in more detail. 156 */ 157 void notifyAllDataChanged() const; 158 159 #ifdef DBG_UTIL 160 const char* checkInvariants() const; 161 #endif 162 163 private: 164 void impl_notifyTableMetricsChanged() const; 165 }; 166 167 // ..................................................................................................................... 168 } } // svt::table 169 // ..................................................................................................................... 170 171 #endif // _UNOCONTROL_TABLEMODEL_HXX_ 172