1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SVTOOLS_SOURCE_UNO_UNOCONTROLTABLEMODEL_HXX
21 #define INCLUDED_SVTOOLS_SOURCE_UNO_UNOCONTROLTABLEMODEL_HXX
23 #include "svtools/table/tablemodel.hxx"
24 #include "svtools/table/tablecontrol.hxx"
26 #include <com/sun/star/awt/grid/XGridControl.hpp>
27 #include <com/sun/star/awt/grid/GridDataEvent.hpp>
28 #include <com/sun/star/awt/grid/XGridColumnModel.hpp>
29 #include <com/sun/star/awt/grid/XGridDataModel.hpp>
30 #include <com/sun/star/awt/grid/XGridSelectionListener.hpp>
31 #include <com/sun/star/awt/grid/XGridColumn.hpp>
32 #include <com/sun/star/util/Color.hpp>
33 #include <com/sun/star/style/VerticalAlignment.hpp>
35 #include <cppuhelper/implbase2.hxx>
36 #include <rtl/ref.hxx>
38 #include <boost/noncopyable.hpp>
40 // .....................................................................................................................
41 namespace svt
{ namespace table
43 // .....................................................................................................................
45 //==================================================================================================================
46 //= UnoControlTableModel
47 //==================================================================================================================
48 class UnoGridColumnFacade
;
49 struct UnoControlTableModel_Impl
;
50 class UnoControlTableModel
: public ITableModel
, public ITableDataSort
53 UnoControlTableModel_Impl
* m_pImpl
;
56 UnoControlTableModel();
57 ~UnoControlTableModel();
60 // ITableModel overridables
61 virtual TableSize
getColumnCount() const;
62 virtual TableSize
getRowCount() const;
63 virtual bool hasColumnHeaders() const;
64 virtual bool hasRowHeaders() const;
65 virtual bool isCellEditable( ColPos col
, RowPos row
) const;
66 virtual PColumnModel
getColumnModel( ColPos column
);
67 virtual PTableRenderer
getRenderer() const;
68 virtual PTableInputHandler
getInputHandler() const;
69 virtual TableMetrics
getRowHeight() const;
70 virtual TableMetrics
getColumnHeaderHeight() const;
71 virtual TableMetrics
getRowHeaderWidth() const;
72 virtual ScrollbarVisibility
getVerticalScrollbarVisibility() const;
73 virtual ScrollbarVisibility
getHorizontalScrollbarVisibility() const;
74 virtual void addTableModelListener( const PTableModelListener
& i_listener
);
75 virtual void removeTableModelListener( const PTableModelListener
& i_listener
);
76 virtual void getCellContent( ColPos
const i_col
, RowPos
const i_row
, ::com::sun::star::uno::Any
& o_cellContent
);
77 virtual void getCellToolTip( ColPos
const i_col
, RowPos
const i_row
, ::com::sun::star::uno::Any
& o_cellToolTip
);
78 virtual ::com::sun::star::uno::Any
getRowHeading( RowPos
const i_rowPos
) const;
79 virtual ::boost::optional
< ::Color
> getLineColor() const;
80 virtual ::boost::optional
< ::Color
> getHeaderBackgroundColor() const;
81 virtual ::boost::optional
< ::Color
> getHeaderTextColor() const;
82 virtual ::boost::optional
< ::Color
> getActiveSelectionBackColor() const;
83 virtual ::boost::optional
< ::Color
> getInactiveSelectionBackColor() const;
84 virtual ::boost::optional
< ::Color
> getActiveSelectionTextColor() const;
85 virtual ::boost::optional
< ::Color
> getInactiveSelectionTextColor() const;
86 virtual ::boost::optional
< ::Color
> getTextColor() const;
87 virtual ::boost::optional
< ::Color
> getTextLineColor() const;
88 virtual ::boost::optional
< ::std::vector
< ::Color
> >
89 getRowBackgroundColors() const;
90 virtual ::com::sun::star::style::VerticalAlignment
91 getVerticalAlign() const;
92 virtual ITableDataSort
* getSortAdapter();
94 // ITableDataSort overridables
95 virtual void sortByColumn( ColPos
const i_column
, ColumnSortDirection
const i_sortDirection
);
96 virtual ColumnSort
getCurrentSortOrder() const;
98 // column write access
99 void appendColumn( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::grid::XGridColumn
> const & i_column
);
100 void insertColumn( ColPos
const i_position
, ::com::sun::star::uno::Reference
< ::com::sun::star::awt::grid::XGridColumn
> const & i_column
);
101 void removeColumn( ColPos
const i_position
);
102 void removeAllColumns();
105 void setVerticalScrollbarVisibility( ScrollbarVisibility
const i_visibility
) const;
106 void setHorizontalScrollbarVisibility( ScrollbarVisibility
const i_visibility
) const;
108 void setDataModel( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::grid::XGridDataModel
> const & i_gridDataModel
);
109 bool hasDataModel() const;
110 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::grid::XGridDataModel
>
111 getDataModel() const;
112 void setColumnModel( ::com::sun::star::uno::Reference
< ::com::sun::star::awt::grid::XGridColumnModel
> const & i_gridColumnModel
);
113 bool hasColumnModel() const;
114 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::grid::XGridColumnModel
>
115 getColumnModel() const;
117 void setRowHeaders(bool _bRowHeaders
);
118 void setColumnHeaders(bool _bColumnHeaders
);
120 void setRowHeight( TableMetrics _nHeight
);
121 void setRowHeaderWidth( TableMetrics _nWidth
);
122 void setColumnHeaderHeight( TableMetrics _nHeight
);
124 void setLineColor( ::com::sun::star::uno::Any
const & i_color
);
125 void setHeaderBackgroundColor( ::com::sun::star::uno::Any
const & i_color
);
126 void setHeaderTextColor( ::com::sun::star::uno::Any
const & i_color
);
127 void setActiveSelectionBackColor( ::com::sun::star::uno::Any
const & i_color
);
128 void setInactiveSelectionBackColor( ::com::sun::star::uno::Any
const & i_color
);
129 void setActiveSelectionTextColor( ::com::sun::star::uno::Any
const & i_color
);
130 void setInactiveSelectionTextColor( ::com::sun::star::uno::Any
const & i_color
);
131 void setTextColor( ::com::sun::star::uno::Any
const & i_color
);
132 void setTextLineColor( ::com::sun::star::uno::Any
const & i_color
);
133 void setRowBackgroundColors( ::com::sun::star::uno::Any
const & i_APIValue
);
135 void setVerticalAlign(::com::sun::star::style::VerticalAlignment _rAlign
);
137 // multiplexing of XGridDataListener events
138 void notifyRowsInserted( ::com::sun::star::awt::grid::GridDataEvent
const & i_event
) const;
139 void notifyRowsRemoved( ::com::sun::star::awt::grid::GridDataEvent
const & i_event
) const;
140 void notifyDataChanged( ::com::sun::star::awt::grid::GridDataEvent
const & i_event
) const;
142 /// retrieves the index of a column within the model
143 ColPos
getColumnPos( UnoGridColumnFacade
const & i_column
) const;
145 /// notifies a change in a column belonging to the model
146 void notifyColumnChange( ColPos
const i_columnPos
, ColumnAttributeGroup
const i_attributeGroup
) const;
148 /** notifies a change in all data represented by the model. To be used if you cannot specified the changed data
151 void notifyAllDataChanged() const;
154 const char* checkInvariants() const;
158 void impl_notifyTableMetricsChanged() const;
161 // .....................................................................................................................
163 // .....................................................................................................................
165 #endif // INCLUDED_SVTOOLS_SOURCE_UNO_UNOCONTROLTABLEMODEL_HXX
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */