LibreOffice Module toolkit (master) 1
tablemodel.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
22#include <toolkit/dllapi.h>
26
27#include <com/sun/star/style/VerticalAlignment.hpp>
28#include <com/sun/star/style/HorizontalAlignment.hpp>
29
30#include <sal/types.h>
31
32#include <optional>
33#include <memory>
34#include <vector>
36
37namespace svt::table { class ITableDataSort; }
38
39class Color;
40
42{
43 NONE = 0x00,
45 WIDTH = 0x01,
47 APPEARANCE = 0x02,
49 ALL = 0x03,
50};
51namespace o3tl
52{
53 template<> struct typed_flags<ColumnAttributeGroup> : is_typed_flags<ColumnAttributeGroup, 0x03> {};
54}
55
56
57namespace svt::table
58{
59 //= ScrollbarVisibility
61 {
73 };
74
75
76 //= ITableModelListener
77
81 class SAL_NO_VTABLE ITableModelListener : public std::enable_shared_from_this< ITableModelListener >
82 {
83 public:
93 virtual void rowsInserted( RowPos first, RowPos last ) = 0;
94
105 virtual void rowsRemoved( RowPos first, RowPos last ) = 0;
106
110 virtual void columnInserted() = 0;
111
115 virtual void columnRemoved() = 0;
116
119 virtual void allColumnsRemoved() = 0;
120
128 virtual void cellsUpdated( RowPos const i_firstRow, RowPos const i_lastRow ) = 0;
129
138 virtual void columnChanged( ColPos const i_column, ColumnAttributeGroup const i_attributeGroup ) = 0;
139
145 virtual void tableMetricsChanged() = 0;
146
149 };
150 typedef std::shared_ptr< ITableModelListener > PTableModelListener;
151
152
153 //= IColumnModel
154
158 {
159 public:
167 virtual OUString getName() const = 0;
168
171 virtual OUString getHelpText() const = 0;
172
179 virtual bool isResizable() const = 0;
180
188 virtual sal_Int32 getFlexibility() const = 0;
189
198 virtual TableMetrics getWidth() const = 0;
199
207 virtual void setWidth( TableMetrics _nWidth ) = 0;
208
216 virtual TableMetrics getMinWidth() const = 0;
217
225 virtual TableMetrics getMaxWidth() const = 0;
226
229 virtual css::style::HorizontalAlignment getHorizontalAlign() = 0;
230
232 virtual ~IColumnModel() { }
233 };
234 typedef std::shared_ptr< IColumnModel > PColumnModel;
235
236
237 //= ITableModel
238
242 {
243 public:
246 virtual TableSize getColumnCount() const = 0;
247
250 virtual TableSize getRowCount() const = 0;
251
259 virtual bool hasColumnHeaders() const = 0;
260
268 virtual bool hasRowHeaders() const = 0;
269
279 virtual PColumnModel getColumnModel( ColPos column ) = 0;
280
286 virtual PTableRenderer getRenderer() const = 0;
287
291
298 virtual TableMetrics getRowHeight() const = 0;
299
310
320 virtual TableMetrics getRowHeaderWidth() const = 0;
321
325
329
332 virtual void addTableModelListener( const PTableModelListener& i_listener ) = 0;
333
336 virtual void removeTableModelListener( const PTableModelListener& i_listener ) = 0;
337
340 virtual void getCellContent( ColPos const i_col, RowPos const i_row, css::uno::Any& o_cellContent ) = 0;
341
357 virtual void getCellToolTip( ColPos const i_col, RowPos const i_row, css::uno::Any & o_cellToolTip ) = 0;
358
361 virtual css::uno::Any getRowHeading( RowPos const i_rowPos ) const = 0;
362
367 virtual ::std::optional< ::Color > getLineColor() const = 0;
368
373 virtual ::std::optional< ::Color > getHeaderBackgroundColor() const = 0;
374
379 virtual ::std::optional< ::Color > getHeaderTextColor() const = 0;
380
385 virtual ::std::optional< ::Color > getActiveSelectionBackColor() const = 0;
386
391 virtual ::std::optional< ::Color > getInactiveSelectionBackColor() const = 0;
392
397 virtual ::std::optional< ::Color > getActiveSelectionTextColor() const = 0;
398
403 virtual ::std::optional< ::Color > getInactiveSelectionTextColor() const = 0;
404
409 virtual ::std::optional< ::Color > getTextColor() const = 0;
410
415 virtual ::std::optional< ::Color > getTextLineColor() const = 0;
416
428 virtual ::std::optional< ::std::vector< ::Color > >
430
433 virtual css::style::VerticalAlignment getVerticalAlign() const = 0;
434
440
443 virtual bool isEnabled() const = 0;
444
446 virtual ~ITableModel() { }
447 };
448 typedef std::shared_ptr< ITableModel > PTableModel;
449
450
451} // namespace svt::table
452
453
454/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
interface to be implemented by table column models
Definition: tablemodel.hxx:158
virtual css::style::HorizontalAlignment getHorizontalAlign()=0
retrieves the horizontal alignment to be used for content in this cell
virtual TableMetrics getMaxWidth() const =0
returns the maximum width of the column, in app-font units, or 0 if the column does not have a minima...
virtual OUString getName() const =0
returns the name of the column
virtual OUString getHelpText() const =0
retrieves the help text to be displayed for the column.
virtual TableMetrics getMinWidth() const =0
returns the minimum width of the column, in app-font units, or 0 if the column does not have a minima...
virtual bool isResizable() const =0
determines whether the column can be interactively resized
virtual void setWidth(TableMetrics _nWidth)=0
sets a new width for the column
virtual TableMetrics getWidth() const =0
returns the width of the column, in app-font units
virtual ~IColumnModel()
deletes the column model instance
Definition: tablemodel.hxx:232
virtual sal_Int32 getFlexibility() const =0
denotes the relative flexibility of the column
provides sorting functionality for the data underlying an ITableModel
Definition: tablesort.hxx:58
declares an interface to be implemented by components interested in changes in an ->ITableModel
Definition: tablemodel.hxx:82
virtual void cellsUpdated(RowPos const i_firstRow, RowPos const i_lastRow)=0
notifies the listener that a rectangular cell range in the table has been updated
virtual void columnChanged(ColPos const i_column, ColumnAttributeGroup const i_attributeGroup)=0
notifies the listener that attributes of a given column changed
virtual void tableMetricsChanged()=0
notifies the listener that the metrics of the table changed.
virtual void columnRemoved()=0
notifies the listener that one or more columns have been removed from the table
virtual void rowsRemoved(RowPos first, RowPos last)=0
notifies the listener that one or more rows have been removed from the table
virtual void allColumnsRemoved()=0
notifies the listener that all columns have been removed from the model
virtual ~ITableModelListener()
deletes the listener instance
Definition: tablemodel.hxx:148
virtual void columnInserted()=0
notifies the listener that one or more columns have been inserted into the table
virtual void rowsInserted(RowPos first, RowPos last)=0
notifies the listener that one or more rows have been inserted into the table
declares the interface to implement by an abstract table model
Definition: tablemodel.hxx:242
virtual void getCellContent(ColPos const i_col, RowPos const i_row, css::uno::Any &o_cellContent)=0
retrieves the content of the given cell
virtual void addTableModelListener(const PTableModelListener &i_listener)=0
adds a listener to be notified of changes in the table model
virtual ::std::optional< ::Color > getLineColor() const =0
returns the color to be used for rendering the grid lines.
virtual ::std::optional< ::Color > getHeaderTextColor() const =0
returns the color to be used for rendering the header text.
virtual ::std::optional< ::Color > getActiveSelectionTextColor() const =0
returns the color to be used for the text of selected cells, when the control has the focus
virtual bool hasRowHeaders() const =0
determines whether the table has row headers
virtual ::std::optional< ::Color > getInactiveSelectionTextColor() const =0
returns the color to be used for the text of selected cells, when the control does not have the focus
virtual bool isEnabled() const =0
returns enabled state.
virtual TableSize getColumnCount() const =0
returns the number of columns in the table
virtual ::std::optional< ::Color > getActiveSelectionBackColor() const =0
returns the color to be used for the background of selected cells, when the control has the focus
virtual void removeTableModelListener(const PTableModelListener &i_listener)=0
remove a listener to be notified of changes in the table model
virtual TableSize getRowCount() const =0
returns the number of rows in the table
virtual PColumnModel getColumnModel(ColPos column)=0
returns a model for a certain column
virtual PTableInputHandler getInputHandler() const =0
returns the component handling input in a view associated with the model
virtual ::std::optional< ::Color > getTextColor() const =0
returns the color to be used for rendering cell texts.
virtual ::std::optional< ::Color > getHeaderBackgroundColor() const =0
returns the color to be used for rendering the header background.
virtual ::std::optional< ::std::vector< ::Color > > getRowBackgroundColors() const =0
returns the colors to be used for the row backgrounds.
virtual TableMetrics getColumnHeaderHeight() const =0
determines the height of the column header row
virtual bool hasColumnHeaders() const =0
determines whether the table has column headers
virtual ::std::optional< ::Color > getTextLineColor() const =0
returns the color to be used for text lines (underline, strikethrough) when rendering cell text.
virtual ITableDataSort * getSortAdapter()=0
returns an adapter to the sorting functionality of the model
virtual css::style::VerticalAlignment getVerticalAlign() const =0
determines the vertical alignment of content within a cell
virtual ~ITableModel()
destroys the table model instance
Definition: tablemodel.hxx:446
virtual ::std::optional< ::Color > getInactiveSelectionBackColor() const =0
returns the color to be used for the background of selected cells, when the control does not have the...
virtual ScrollbarVisibility getVerticalScrollbarVisibility() const =0
returns the visibility mode of the vertical scrollbar
virtual ScrollbarVisibility getHorizontalScrollbarVisibility() const =0
returns the visibility mode of the horizontal scrollbar
virtual PTableRenderer getRenderer() const =0
returns a renderer which is able to paint the table represented by this table model
virtual void getCellToolTip(ColPos const i_col, RowPos const i_row, css::uno::Any &o_cellToolTip)=0
returns an object which should be displayed as tooltip for the given cell
virtual TableMetrics getRowHeaderWidth() const =0
determines the width of the row header column
virtual css::uno::Any getRowHeading(RowPos const i_rowPos) const =0
retrieves title of a given row
virtual TableMetrics getRowHeight() const =0
determines the height of rows in the table.
#define TOOLKIT_DLLPUBLIC
Definition: dllapi.h:29
void SAL_CALL last(const css::awt::SpinEvent &rEvent) override
void SAL_CALL first(const css::awt::SpinEvent &rEvent) override
NONE
const sal_uInt16 WIDTH
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< ITableModel > PTableModel
Definition: tablemodel.hxx:448
std::shared_ptr< ITableRenderer > PTableRenderer
@ ScrollbarShowNever
enumeration value denoting that a scrollbar should never be visible, even if needed normally
Definition: tablemodel.hxx:65
@ ScrollbarShowSmart
enumeration value denoting that a scrollbar should be visible when needed only
Definition: tablemodel.hxx:68
@ ScrollbarShowAlways
enumeration value denoting that a scrollbar should always be visible, even if not needed normally
Definition: tablemodel.hxx:72
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
@ APPEARANCE
denotes column attributes related to the appearance of the column, i.e. those relevant for rendering
#define SAL_NO_VTABLE