summaryrefslogtreecommitdiffstats
path: root/svtools/source/uno/unocontroltablemodel.hxx
blob: 53aa832657a87ec955035afdfc5fe21ae7752cbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#pragma once

#include <table/tablemodel.hxx>
#include <table/tablesort.hxx>

#include <com/sun/star/awt/grid/GridDataEvent.hpp>
#include <com/sun/star/awt/grid/XGridColumnModel.hpp>
#include <com/sun/star/awt/grid/XGridDataModel.hpp>
#include <com/sun/star/awt/grid/XGridColumn.hpp>
#include <com/sun/star/style/VerticalAlignment.hpp>

#include <memory>


namespace svt::table
{


    //= UnoControlTableModel

    class UnoGridColumnFacade;
    struct UnoControlTableModel_Impl;
    class UnoControlTableModel : public ITableModel, public ITableDataSort
    {
    private:
        std::unique_ptr<UnoControlTableModel_Impl>  m_pImpl;

    public:
        UnoControlTableModel();
        virtual ~UnoControlTableModel() override;

    public:
        // ITableModel overridables
        virtual TableSize                       getColumnCount() const override;
        virtual TableSize                       getRowCount() const override;
        virtual bool                            hasColumnHeaders() const override;
        virtual bool                            hasRowHeaders() const override;
        virtual PColumnModel                    getColumnModel( ColPos column ) override;
        virtual PTableRenderer                  getRenderer() const override;
        virtual PTableInputHandler              getInputHandler() const override;
        virtual TableMetrics                    getRowHeight() const override;
        virtual TableMetrics                    getColumnHeaderHeight() const override;
        virtual TableMetrics                    getRowHeaderWidth() const override;
        virtual ScrollbarVisibility             getVerticalScrollbarVisibility() const override;
        virtual ScrollbarVisibility             getHorizontalScrollbarVisibility() const override;
        virtual void                            addTableModelListener( const PTableModelListener& i_listener ) override;
        virtual void                            removeTableModelListener( const PTableModelListener& i_listener ) override;
        virtual void                            getCellContent( ColPos const i_col, RowPos const i_row, css::uno::Any& o_cellContent ) override;
        virtual void                            getCellToolTip( ColPos const i_col, RowPos const i_row, css::uno::Any & o_cellToolTip ) override;
        virtual css::uno::Any      getRowHeading( RowPos const i_rowPos ) const override;
        virtual ::std::optional< ::Color >    getLineColor() const override;
        virtual ::std::optional< ::Color >    getHeaderBackgroundColor() const override;
        virtual ::std::optional< ::Color >    getHeaderTextColor() const override;
        virtual ::std::optional< ::Color >    getActiveSelectionBackColor() const override;
        virtual ::std::optional< ::Color >    getInactiveSelectionBackColor() const override;
        virtual ::std::optional< ::Color >    getActiveSelectionTextColor() const override;
        virtual ::std::optional< ::Color >    getInactiveSelectionTextColor() const override;
        virtual ::std::optional< ::Color >    getTextColor() const override;
        virtual ::std::optional< ::Color >    getTextLineColor() const override;
        virtual ::std::optional< ::std::vector< ::Color > >
                                                getRowBackgroundColors() const override;
        virtual css::style::VerticalAlignment
                                                getVerticalAlign() const override;
        virtual ITableDataSort*                 getSortAdapter() override;
        virtual bool                            isEnabled() const override;

        // ITableDataSort overridables
        virtual void        sortByColumn( ColPos const i_column, ColumnSortDirection const i_sortDirection ) override;
        virtual ColumnSort  getCurrentSortOrder() const override;

        // column write access
        void    appendColumn( css::uno::Reference< css::awt::grid::XGridColumn > const & i_column );
        void    insertColumn( ColPos const i_position, css::uno::Reference< css::awt::grid::XGridColumn > const & i_column );
        void    removeColumn( ColPos const i_position );
        void    removeAllColumns();

        // other operations
        void    setVerticalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const;
        void    setHorizontalScrollbarVisibility( ScrollbarVisibility const i_visibility ) const;

        void    setDataModel( css::uno::Reference< css::awt::grid::XGridDataModel > const & i_gridDataModel );
        bool    hasDataModel() const;
        css::uno::Reference< css::awt::grid::XGridDataModel >
                getDataModel() const;
        void    setColumnModel( css::uno::Reference< css::awt::grid::XGridColumnModel > const & i_gridColumnModel );
        bool    hasColumnModel() const;
        css::uno::Reference< css::awt::grid::XGridColumnModel >
                getColumnModel() const;

        void    setRowHeaders(bool _bRowHeaders);
        void    setColumnHeaders(bool _bColumnHeaders);

        void    setRowHeight( TableMetrics _nHeight );
        void    setRowHeaderWidth( TableMetrics _nWidth );
        void    setColumnHeaderHeight( TableMetrics _nHeight );

        void    setLineColor( css::uno::Any const & i_color );
        void    setHeaderBackgroundColor( css::uno::Any const & i_color );
        void    setHeaderTextColor( css::uno::Any const & i_color );
        void    setActiveSelectionBackColor( css::uno::Any const & i_color );
        void    setInactiveSelectionBackColor( css::uno::Any const & i_color );
        void    setActiveSelectionTextColor( css::uno::Any const & i_color );
        void    setInactiveSelectionTextColor( css::uno::Any const & i_color );
        void    setTextColor( css::uno::Any const & i_color );
        void    setTextLineColor( css::uno::Any const & i_color );
        void    setRowBackgroundColors( css::uno::Any const & i_APIValue );

        void    setVerticalAlign(css::style::VerticalAlignment _rAlign);
        void    setEnabled( bool _bEnabled );

        // multiplexing of XGridDataListener events
        void    notifyRowsInserted( css::awt::grid::GridDataEvent const & i_event ) const;
        void    notifyRowsRemoved( css::awt::grid::GridDataEvent const & i_event ) const;
        void    notifyDataChanged( css::awt::grid::GridDataEvent const & i_event ) const;

        /// retrieves the index of a column within the model
        ColPos getColumnPos( UnoGridColumnFacade const & i_column ) const;

        /// notifies a change in a column belonging to the model
        void    notifyColumnChange( ColPos const i_columnPos, ColumnAttributeGroup const i_attributeGroup ) const;

        /** notifies a change in all data represented by the model. To be used if you cannot specified the changed data
            in more detail.
        */
        void    notifyAllDataChanged() const;

    private:
        void    impl_notifyTableMetricsChanged() const;
    };


} // svt::table



/* vim:set shiftwidth=4 softtabstop=4 expandtab: */