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 .
22 #include <controls/table/tablemodel.hxx>
23 #include <controls/table/tablesort.hxx>
24 #include <tools/color.hxx>
26 #include <com/sun/star/awt/grid/GridDataEvent.hpp>
27 #include <com/sun/star/awt/grid/XGridColumnModel.hpp>
28 #include <com/sun/star/awt/grid/XGridDataModel.hpp>
29 #include <com/sun/star/awt/grid/XGridColumn.hpp>
30 #include <com/sun/star/awt/grid/XGridColumn.hpp>
31 #include <com/sun/star/style/VerticalAlignment.hpp>
32 #include <cppuhelper/weakref.hxx>
39 //= UnoControlTableModel
41 class UnoGridColumnFacade
;
42 class UnoControlTableModel
: public ITableModel
, public ITableDataSort
45 UnoControlTableModel();
46 virtual ~UnoControlTableModel() override
;
49 // ITableModel overridables
50 virtual TableSize
getColumnCount() const override
;
51 virtual TableSize
getRowCount() const override
;
52 virtual bool hasColumnHeaders() const override
;
53 virtual bool hasRowHeaders() const override
;
54 virtual PColumnModel
getColumnModel( ColPos column
) override
;
55 virtual PTableRenderer
getRenderer() const override
;
56 virtual PTableInputHandler
getInputHandler() const override
;
57 virtual TableMetrics
getRowHeight() const override
;
58 virtual TableMetrics
getColumnHeaderHeight() const override
;
59 virtual TableMetrics
getRowHeaderWidth() const override
;
60 virtual ScrollbarVisibility
getVerticalScrollbarVisibility() const override
;
61 virtual ScrollbarVisibility
getHorizontalScrollbarVisibility() const override
;
62 virtual void addTableModelListener( const PTableModelListener
& i_listener
) override
;
63 virtual void removeTableModelListener( const PTableModelListener
& i_listener
) override
;
64 virtual void getCellContent( ColPos
const i_col
, RowPos
const i_row
, css::uno::Any
& o_cellContent
) override
;
65 virtual void getCellToolTip( ColPos
const i_col
, RowPos
const i_row
, css::uno::Any
& o_cellToolTip
) override
;
66 virtual css::uno::Any
getRowHeading( RowPos
const i_rowPos
) const override
;
67 virtual ::std::optional
< ::Color
> getLineColor() const override
;
68 virtual ::std::optional
< ::Color
> getHeaderBackgroundColor() const override
;
69 virtual ::std::optional
< ::Color
> getHeaderTextColor() const override
;
70 virtual ::std::optional
< ::Color
> getActiveSelectionBackColor() const override
;
71 virtual ::std::optional
< ::Color
> getInactiveSelectionBackColor() const override
;
72 virtual ::std::optional
< ::Color
> getActiveSelectionTextColor() const override
;
73 virtual ::std::optional
< ::Color
> getInactiveSelectionTextColor() const override
;
74 virtual ::std::optional
< ::Color
> getTextColor() const override
;
75 virtual ::std::optional
< ::Color
> getTextLineColor() const override
;
76 virtual ::std::optional
< ::std::vector
< ::Color
> >
77 getRowBackgroundColors() const override
;
78 virtual css::style::VerticalAlignment
79 getVerticalAlign() const override
;
80 virtual ITableDataSort
* getSortAdapter() override
;
81 virtual bool isEnabled() const override
;
83 // ITableDataSort overridables
84 virtual void sortByColumn( ColPos
const i_column
, ColumnSortDirection
const i_sortDirection
) override
;
85 virtual ColumnSort
getCurrentSortOrder() const override
;
87 // column write access
88 void appendColumn( css::uno::Reference
< css::awt::grid::XGridColumn
> const & i_column
);
89 void insertColumn( ColPos
const i_position
, css::uno::Reference
< css::awt::grid::XGridColumn
> const & i_column
);
90 void removeColumn( ColPos
const i_position
);
91 void removeAllColumns();
94 void setVerticalScrollbarVisibility( ScrollbarVisibility
const i_visibility
);
95 void setHorizontalScrollbarVisibility( ScrollbarVisibility
const i_visibility
);
97 void setDataModel( css::uno::Reference
< css::awt::grid::XGridDataModel
> const & i_gridDataModel
);
98 bool hasDataModel() const;
99 css::uno::Reference
< css::awt::grid::XGridDataModel
>
100 getDataModel() const;
101 void setColumnModel( css::uno::Reference
< css::awt::grid::XGridColumnModel
> const & i_gridColumnModel
);
102 bool hasColumnModel() const;
103 css::uno::Reference
< css::awt::grid::XGridColumnModel
>
104 getColumnModel() const;
106 void setRowHeaders(bool _bRowHeaders
);
107 void setColumnHeaders(bool _bColumnHeaders
);
109 void setRowHeight( TableMetrics _nHeight
);
110 void setRowHeaderWidth( TableMetrics _nWidth
);
111 void setColumnHeaderHeight( TableMetrics _nHeight
);
113 void setLineColor( css::uno::Any
const & i_color
);
114 void setHeaderBackgroundColor( css::uno::Any
const & i_color
);
115 void setHeaderTextColor( css::uno::Any
const & i_color
);
116 void setActiveSelectionBackColor( css::uno::Any
const & i_color
);
117 void setInactiveSelectionBackColor( css::uno::Any
const & i_color
);
118 void setActiveSelectionTextColor( css::uno::Any
const & i_color
);
119 void setInactiveSelectionTextColor( css::uno::Any
const & i_color
);
120 void setTextColor( css::uno::Any
const & i_color
);
121 void setTextLineColor( css::uno::Any
const & i_color
);
122 void setRowBackgroundColors( css::uno::Any
const & i_APIValue
);
124 void setVerticalAlign(css::style::VerticalAlignment _rAlign
);
125 void setEnabled( bool _bEnabled
);
127 // multiplexing of XGridDataListener events
128 void notifyRowsInserted( css::awt::grid::GridDataEvent
const & i_event
) const;
129 void notifyRowsRemoved( css::awt::grid::GridDataEvent
const & i_event
) const;
130 void notifyDataChanged( css::awt::grid::GridDataEvent
const & i_event
) const;
132 /// retrieves the index of a column within the model
133 ColPos
getColumnPos( UnoGridColumnFacade
const & i_column
) const;
135 /// notifies a change in a column belonging to the model
136 void notifyColumnChange( ColPos
const i_columnPos
, ColumnAttributeGroup
const i_attributeGroup
) const;
138 /** notifies a change in all data represented by the model. To be used if you cannot specified the changed data
141 void notifyAllDataChanged() const;
144 void impl_notifyTableMetricsChanged() const;
146 typedef ::std::vector
< PTableModelListener
> ModellListeners
;
147 typedef ::std::vector
< PColumnModel
> ColumnModels
;
149 ColumnModels aColumns
;
150 bool bHasColumnHeaders
;
152 ScrollbarVisibility eVScrollMode
;
153 ScrollbarVisibility eHScrollMode
;
154 PTableRenderer pRenderer
;
155 PTableInputHandler pInputHandler
;
156 TableMetrics nRowHeight
;
157 TableMetrics nColumnHeaderHeight
;
158 TableMetrics nRowHeaderWidth
;
159 ::std::optional
< ::Color
> m_aGridLineColor
;
160 ::std::optional
< ::Color
> m_aHeaderBackgroundColor
;
161 ::std::optional
< ::Color
> m_aHeaderTextColor
;
162 ::std::optional
< ::Color
> m_aActiveSelectionBackColor
;
163 ::std::optional
< ::Color
> m_aInactiveSelectionBackColor
;
164 ::std::optional
< ::Color
> m_aActiveSelectionTextColor
;
165 ::std::optional
< ::Color
> m_aInactiveSelectionTextColor
;
166 ::std::optional
< ::Color
> m_aTextColor
;
167 ::std::optional
< ::Color
> m_aTextLineColor
;
168 ::std::optional
< ::std::vector
< ::Color
> > m_aRowColors
;
169 css::style::VerticalAlignment m_eVerticalAlign
;
171 ModellListeners m_aListeners
;
172 css::uno::WeakReference
< css::awt::grid::XGridDataModel
> m_aDataModel
;
173 css::uno::WeakReference
< css::awt::grid::XGridColumnModel
> m_aColumnModel
;
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */