Avoid potential negative array index access to cached text.
[LibreOffice.git] / toolkit / source / controls / grid / gridcontrol.hxx
blob9b7eae0eaa2572d5c2b4e7d06729ea5aaf156aef
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef INCLUDED_TOOLKIT_SOURCE_CONTROLS_GRID_GRIDCONTROL_HXX
21 #define INCLUDED_TOOLKIT_SOURCE_CONTROLS_GRID_GRIDCONTROL_HXX
23 #include <com/sun/star/awt/grid/XGridControl.hpp>
24 #include <com/sun/star/awt/grid/XGridRowSelection.hpp>
26 #include <toolkit/controls/unocontrolbase.hxx>
27 #include <toolkit/controls/unocontrolmodel.hxx>
28 #include <cppuhelper/implbase2.hxx>
29 #include <toolkit/helper/listenermultiplexer.hxx>
31 #include <memory>
33 namespace toolkit
36 class GridEventForwarder;
39 // = UnoGridModel
41 class UnoGridModel : public UnoControlModel
43 protected:
44 css::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const override;
45 ::cppu::IPropertyArrayHelper& getInfoHelper() override;
47 public:
48 explicit UnoGridModel( const css::uno::Reference< css::uno::XComponentContext >& i_factory );
49 UnoGridModel( const UnoGridModel& rModel );
51 rtl::Reference<UnoControlModel> Clone() const override;
53 // css::lang::XComponent
54 void SAL_CALL dispose( ) override;
56 // css::beans::XMultiPropertySet
57 css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
59 // css::io::XPersistObject
60 OUString SAL_CALL getServiceName() override;
62 // OPropertySetHelper
63 void setFastPropertyValue_NoBroadcast( std::unique_lock<std::mutex>& rGuard, sal_Int32 nHandle, const css::uno::Any& rValue ) override;
65 // XServiceInfo
66 OUString SAL_CALL getImplementationName() override
67 { return "stardiv.Toolkit.GridControlModel"; }
69 css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override
71 auto s(UnoControlModel::getSupportedServiceNames());
72 s.realloc(s.getLength() + 1);
73 s.getArray()[s.getLength() - 1] = "com.sun.star.awt.grid.UnoControlGridModel";
74 return s;
79 // = UnoGridControl
81 typedef ::cppu::AggImplInheritanceHelper2 < UnoControlBase
82 , css::awt::grid::XGridControl
83 , css::awt::grid::XGridRowSelection
84 > UnoGridControl_Base;
85 class UnoGridControl : public UnoGridControl_Base
87 public:
88 UnoGridControl();
89 OUString GetComponentServiceName() const override;
91 // css::lang::XComponent
92 void SAL_CALL dispose( ) override;
94 // css::awt::XControl
95 void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit >& Toolkit, const css::uno::Reference< css::awt::XWindowPeer >& Parent ) override;
96 sal_Bool SAL_CALL setModel( const css::uno::Reference< css::awt::XControlModel >& rxModel ) override;
98 // css::awt::grid::XGridControl
99 virtual ::sal_Int32 SAL_CALL getColumnAtPoint(::sal_Int32 x, ::sal_Int32 y) override;
100 virtual ::sal_Int32 SAL_CALL getRowAtPoint(::sal_Int32 x, ::sal_Int32 y) override;
101 virtual ::sal_Int32 SAL_CALL getCurrentColumn( ) override;
102 virtual ::sal_Int32 SAL_CALL getCurrentRow( ) override;
103 virtual void SAL_CALL goToCell( ::sal_Int32 i_columnIndex, ::sal_Int32 i_rowIndex ) override;
105 // css::awt::grid::XGridRowSelection
106 virtual void SAL_CALL selectRow( ::sal_Int32 i_rowIndex ) override;
107 virtual void SAL_CALL selectAllRows() override;
108 virtual void SAL_CALL deselectRow( ::sal_Int32 i_rowIndex ) override;
109 virtual void SAL_CALL deselectAllRows() override;
110 virtual css::uno::Sequence< ::sal_Int32 > SAL_CALL getSelectedRows() override;
111 virtual sal_Bool SAL_CALL hasSelectedRows() override;
112 virtual sal_Bool SAL_CALL isRowSelected(::sal_Int32 index) override;
113 virtual void SAL_CALL addSelectionListener(const css::uno::Reference< css::awt::grid::XGridSelectionListener > & listener) override;
114 virtual void SAL_CALL removeSelectionListener(const css::uno::Reference< css::awt::grid::XGridSelectionListener > & listener) override;
116 // css::lang::XServiceInfo
117 OUString SAL_CALL getImplementationName() override
118 { return "stardiv.Toolkit.GridControl"; }
120 css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override
122 auto s(UnoControlBase::getSupportedServiceNames());
123 s.realloc(s.getLength() + 1);
124 s.getArray()[s.getLength() - 1] = "com.sun.star.awt.grid.UnoControlGrid";
125 return s;
128 using UnoControl::getPeer;
130 protected:
131 virtual ~UnoGridControl() override;
133 private:
134 SelectionListenerMultiplexer m_aSelectionListeners;
135 std::unique_ptr< GridEventForwarder > m_pEventForwarder;
138 } // toolkit
140 #endif // _TOOLKIT_TREE_CONTROL_HXX
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */