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