/src/libreoffice/toolkit/source/controls/grid/gridcontrol.hxx
Line | Count | Source |
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 <com/sun/star/awt/grid/XGridControl.hpp> |
23 | | #include <com/sun/star/awt/grid/XGridRowSelection.hpp> |
24 | | |
25 | | #include <toolkit/controls/unocontrolbase.hxx> |
26 | | #include <toolkit/controls/unocontrolmodel.hxx> |
27 | | #include <cppuhelper/implbase2.hxx> |
28 | | #include <toolkit/helper/listenermultiplexer.hxx> |
29 | | |
30 | | #include <memory> |
31 | | |
32 | | namespace toolkit |
33 | | { |
34 | | |
35 | | class GridEventForwarder; |
36 | | |
37 | | |
38 | | // = UnoGridModel |
39 | | |
40 | | class UnoGridModel : public UnoControlModel |
41 | | { |
42 | | protected: |
43 | | css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override; |
44 | | ::cppu::IPropertyArrayHelper& getInfoHelper() override; |
45 | | |
46 | | public: |
47 | | explicit UnoGridModel( const css::uno::Reference< css::uno::XComponentContext >& i_factory ); |
48 | | UnoGridModel( const UnoGridModel& rModel ); |
49 | | |
50 | | rtl::Reference<UnoControlModel> Clone() const override; |
51 | | |
52 | | // css::lang::XComponent |
53 | | void SAL_CALL dispose( ) override; |
54 | | |
55 | | // css::beans::XMultiPropertySet |
56 | | css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; |
57 | | |
58 | | // css::io::XPersistObject |
59 | | OUString SAL_CALL getServiceName() override; |
60 | | |
61 | | // OPropertySetHelper |
62 | | void setFastPropertyValue_NoBroadcast( std::unique_lock<std::mutex>& rGuard, sal_Int32 nHandle, const css::uno::Any& rValue ) override; |
63 | | |
64 | | // XServiceInfo |
65 | | OUString SAL_CALL getImplementationName() override |
66 | 0 | { return u"stardiv.Toolkit.GridControlModel"_ustr; } |
67 | | |
68 | | css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override |
69 | 0 | { |
70 | 0 | auto s(UnoControlModel::getSupportedServiceNames()); |
71 | 0 | s.realloc(s.getLength() + 1); |
72 | 0 | s.getArray()[s.getLength() - 1] = "com.sun.star.awt.grid.UnoControlGridModel"; |
73 | 0 | return s; |
74 | 0 | } |
75 | | }; |
76 | | |
77 | | |
78 | | // = UnoGridControl |
79 | | |
80 | | typedef ::cppu::AggImplInheritanceHelper2 < UnoControlBase |
81 | | , css::awt::grid::XGridControl |
82 | | , css::awt::grid::XGridRowSelection |
83 | | > UnoGridControl_Base; |
84 | | class UnoGridControl : public UnoGridControl_Base |
85 | | { |
86 | | public: |
87 | | UnoGridControl(); |
88 | | OUString GetComponentServiceName() const override; |
89 | | |
90 | | // css::lang::XComponent |
91 | | void SAL_CALL dispose( ) override; |
92 | | |
93 | | // css::awt::XControl |
94 | | void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit >& Toolkit, const css::uno::Reference< css::awt::XWindowPeer >& Parent ) override; |
95 | | sal_Bool SAL_CALL setModel( const css::uno::Reference< css::awt::XControlModel >& rxModel ) override; |
96 | | |
97 | | // css::awt::grid::XGridControl |
98 | | virtual ::sal_Int32 SAL_CALL getColumnAtPoint(::sal_Int32 x, ::sal_Int32 y) override; |
99 | | virtual ::sal_Int32 SAL_CALL getRowAtPoint(::sal_Int32 x, ::sal_Int32 y) override; |
100 | | virtual ::sal_Int32 SAL_CALL getCurrentColumn( ) override; |
101 | | virtual ::sal_Int32 SAL_CALL getCurrentRow( ) override; |
102 | | virtual void SAL_CALL goToCell( ::sal_Int32 i_columnIndex, ::sal_Int32 i_rowIndex ) override; |
103 | | |
104 | | // css::awt::grid::XGridRowSelection |
105 | | virtual void SAL_CALL selectRow( ::sal_Int32 i_rowIndex ) override; |
106 | | virtual void SAL_CALL selectAllRows() override; |
107 | | virtual void SAL_CALL deselectRow( ::sal_Int32 i_rowIndex ) override; |
108 | | virtual void SAL_CALL deselectAllRows() override; |
109 | | virtual css::uno::Sequence< ::sal_Int32 > SAL_CALL getSelectedRows() override; |
110 | | virtual sal_Bool SAL_CALL hasSelectedRows() override; |
111 | | virtual sal_Bool SAL_CALL isRowSelected(::sal_Int32 index) override; |
112 | | virtual void SAL_CALL addSelectionListener(const css::uno::Reference< css::awt::grid::XGridSelectionListener > & listener) override; |
113 | | virtual void SAL_CALL removeSelectionListener(const css::uno::Reference< css::awt::grid::XGridSelectionListener > & listener) override; |
114 | | |
115 | | // css::lang::XServiceInfo |
116 | | OUString SAL_CALL getImplementationName() override |
117 | 0 | { return u"stardiv.Toolkit.GridControl"_ustr; } |
118 | | |
119 | | css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override |
120 | 0 | { |
121 | 0 | auto s(UnoControlBase::getSupportedServiceNames()); |
122 | 0 | s.realloc(s.getLength() + 1); |
123 | 0 | s.getArray()[s.getLength() - 1] = "com.sun.star.awt.grid.UnoControlGrid"; |
124 | 0 | return s; |
125 | 0 | } |
126 | | |
127 | | using UnoControl::getPeer; |
128 | | |
129 | | protected: |
130 | | virtual ~UnoGridControl() override; |
131 | | |
132 | | private: |
133 | | SelectionListenerMultiplexer m_aSelectionListeners; |
134 | | std::unique_ptr< GridEventForwarder > m_pEventForwarder; |
135 | | }; |
136 | | |
137 | | } // toolkit |
138 | | |
139 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |