LibreOffice Module toolkit (master) 1
unocontroltablemodel.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
24#include <tools/color.hxx>
25
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>
33
34
35namespace svt::table
36{
37
38
39 //= UnoControlTableModel
40
41 class UnoGridColumnFacade;
43 {
44 public:
46 virtual ~UnoControlTableModel() override;
47
48 public:
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;
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;
82
83 // ITableDataSort overridables
84 virtual void sortByColumn( ColPos const i_column, ColumnSortDirection const i_sortDirection ) override;
85 virtual ColumnSort getCurrentSortOrder() const override;
86
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();
92
93 // other operations
94 void setVerticalScrollbarVisibility( ScrollbarVisibility const i_visibility );
96
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;
105
106 void setRowHeaders(bool _bRowHeaders);
107 void setColumnHeaders(bool _bColumnHeaders);
108
109 void setRowHeight( TableMetrics _nHeight );
110 void setRowHeaderWidth( TableMetrics _nWidth );
111 void setColumnHeaderHeight( TableMetrics _nHeight );
112
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 );
123
124 void setVerticalAlign(css::style::VerticalAlignment _rAlign);
125 void setEnabled( bool _bEnabled );
126
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;
131
133 ColPos getColumnPos( UnoGridColumnFacade const & i_column ) const;
134
136 void notifyColumnChange( ColPos const i_columnPos, ColumnAttributeGroup const i_attributeGroup ) const;
137
141 void notifyAllDataChanged() const;
142
143 private:
145
146 typedef ::std::vector< PTableModelListener > ModellListeners;
147 typedef ::std::vector< PColumnModel > ColumnModels;
148
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;
172 css::uno::WeakReference< css::awt::grid::XGridDataModel > m_aDataModel;
173 css::uno::WeakReference< css::awt::grid::XGridColumnModel > m_aColumnModel;
174 };
175
176
177} // svt::table
178
179
180
181/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
provides sorting functionality for the data underlying an ITableModel
Definition: tablesort.hxx:58
declares the interface to implement by an abstract table model
Definition: tablemodel.hxx:242
virtual PTableInputHandler getInputHandler() const override
returns the component handling input in a view associated with the model
void notifyRowsInserted(css::awt::grid::GridDataEvent const &i_event) const
::std::optional< ::std::vector< ::Color > > m_aRowColors
virtual ScrollbarVisibility getVerticalScrollbarVisibility() const override
returns the visibility mode of the vertical scrollbar
void setActiveSelectionTextColor(css::uno::Any const &i_color)
virtual TableMetrics getRowHeight() const override
determines the height of rows in the table.
virtual void addTableModelListener(const PTableModelListener &i_listener) override
adds a listener to be notified of changes in the table model
virtual ::std::optional< ::Color > getHeaderBackgroundColor() const override
returns the color to be used for rendering the header background.
virtual bool hasColumnHeaders() const override
determines whether the table has column headers
void setVerticalAlign(css::style::VerticalAlignment _rAlign)
virtual ::std::optional< ::Color > getActiveSelectionTextColor() const override
returns the color to be used for the text of selected cells, when the control has the focus
::std::optional< ::Color > m_aActiveSelectionTextColor
virtual ::std::optional< ::std::vector< ::Color > > getRowBackgroundColors() const override
returns the colors to be used for the row backgrounds.
::std::optional< ::Color > m_aGridLineColor
virtual TableSize getColumnCount() const override
returns the number of columns in the table
void setVerticalScrollbarVisibility(ScrollbarVisibility const i_visibility)
void notifyRowsRemoved(css::awt::grid::GridDataEvent const &i_event) const
void setTextColor(css::uno::Any const &i_color)
void setTextLineColor(css::uno::Any const &i_color)
virtual TableSize getRowCount() const override
returns the number of rows in the table
::std::optional< ::Color > m_aHeaderBackgroundColor
void setHeaderBackgroundColor(css::uno::Any const &i_color)
virtual void removeTableModelListener(const PTableModelListener &i_listener) override
remove a listener to be notified of changes in the table model
virtual void getCellToolTip(ColPos const i_col, RowPos const i_row, css::uno::Any &o_cellToolTip) override
returns an object which should be displayed as tooltip for the given cell
virtual css::uno::Any getRowHeading(RowPos const i_rowPos) const override
retrieves title of a given row
virtual ::std::optional< ::Color > getInactiveSelectionBackColor() const override
returns the color to be used for the background of selected cells, when the control does not have the...
::std::optional< ::Color > m_aHeaderTextColor
virtual ::std::optional< ::Color > getHeaderTextColor() const override
returns the color to be used for rendering the header text.
void setRowHeaderWidth(TableMetrics _nWidth)
virtual TableMetrics getColumnHeaderHeight() const override
determines the height of the column header row
ColPos getColumnPos(UnoGridColumnFacade const &i_column) const
retrieves the index of a column within the model
::std::optional< ::Color > m_aInactiveSelectionBackColor
void setColumnHeaderHeight(TableMetrics _nHeight)
void setDataModel(css::uno::Reference< css::awt::grid::XGridDataModel > const &i_gridDataModel)
void setInactiveSelectionBackColor(css::uno::Any const &i_color)
virtual TableMetrics getRowHeaderWidth() const override
determines the width of the row header column
void notifyAllDataChanged() const
notifies a change in all data represented by the model.
virtual ::std::optional< ::Color > getActiveSelectionBackColor() const override
returns the color to be used for the background of selected cells, when the control has the focus
virtual css::style::VerticalAlignment getVerticalAlign() const override
determines the vertical alignment of content within a cell
void setHeaderTextColor(css::uno::Any const &i_color)
::std::optional< ::Color > m_aInactiveSelectionTextColor
css::uno::Reference< css::awt::grid::XGridColumnModel > getColumnModel() const
::std::optional< ::Color > m_aActiveSelectionBackColor
void setRowHeight(TableMetrics _nHeight)
::std::optional< ::Color > m_aTextLineColor
virtual ::std::optional< ::Color > getInactiveSelectionTextColor() const override
returns the color to be used for the text of selected cells, when the control does not have the focus
::std::optional< ::Color > m_aTextColor
css::style::VerticalAlignment m_eVerticalAlign
::std::vector< PTableModelListener > ModellListeners
void setColumnModel(css::uno::Reference< css::awt::grid::XGridColumnModel > const &i_gridColumnModel)
void setActiveSelectionBackColor(css::uno::Any const &i_color)
virtual ScrollbarVisibility getHorizontalScrollbarVisibility() const override
returns the visibility mode of the horizontal scrollbar
css::uno::WeakReference< css::awt::grid::XGridDataModel > m_aDataModel
void insertColumn(ColPos const i_position, css::uno::Reference< css::awt::grid::XGridColumn > const &i_column)
::std::vector< PColumnModel > ColumnModels
void setInactiveSelectionTextColor(css::uno::Any const &i_color)
void setRowBackgroundColors(css::uno::Any const &i_APIValue)
void setHorizontalScrollbarVisibility(ScrollbarVisibility const i_visibility)
css::uno::Reference< css::awt::grid::XGridDataModel > getDataModel() const
virtual ::std::optional< ::Color > getLineColor() const override
returns the color to be used for rendering the grid lines.
virtual ::std::optional< ::Color > getTextLineColor() const override
returns the color to be used for text lines (underline, strikethrough) when rendering cell text.
void setLineColor(css::uno::Any const &i_color)
virtual void sortByColumn(ColPos const i_column, ColumnSortDirection const i_sortDirection) override
sorts the rows in the model by the given column's data, in the given direction.
virtual PTableRenderer getRenderer() const override
returns a renderer which is able to paint the table represented by this table model
void notifyDataChanged(css::awt::grid::GridDataEvent const &i_event) const
virtual ColumnSort getCurrentSortOrder() const override
retrieves the current sort order of the data
virtual ITableDataSort * getSortAdapter() override
returns an adapter to the sorting functionality of the model
virtual ::std::optional< ::Color > getTextColor() const override
returns the color to be used for rendering cell texts.
virtual bool isEnabled() const override
returns enabled state.
css::uno::WeakReference< css::awt::grid::XGridColumnModel > m_aColumnModel
void appendColumn(css::uno::Reference< css::awt::grid::XGridColumn > const &i_column)
virtual bool hasRowHeaders() const override
determines whether the table has row headers
void removeColumn(ColPos const i_position)
void setColumnHeaders(bool _bColumnHeaders)
void notifyColumnChange(ColPos const i_columnPos, ColumnAttributeGroup const i_attributeGroup) const
notifies a change in a column belonging to the model
virtual void getCellContent(ColPos const i_col, RowPos const i_row, css::uno::Any &o_cellContent) override
retrieves the content of the given cell
sal_Int32 TableSize
a value denoting the size of a table
Definition: tabletypes.hxx:29
sal_Int32 RowPos
a value denoting a row position within a table
Definition: tabletypes.hxx:34
std::shared_ptr< ITableRenderer > PTableRenderer
sal_Int32 ColPos
a value denoting a column position within a table
Definition: tabletypes.hxx:32
std::shared_ptr< ITableInputHandler > PTableInputHandler
sal_Int32 TableMetrics
Definition: tabletypes.hxx:36
std::shared_ptr< IColumnModel > PColumnModel
Definition: tablemodel.hxx:234
std::shared_ptr< ITableModelListener > PTableModelListener
Definition: tablemodel.hxx:150
ColumnAttributeGroup
Definition: tablemodel.hxx:42