Avoid potential negative array index access to cached text.
[LibreOffice.git] / accessibility / inc / extended / accessibleiconchoicectrlentry.hxx
blobb2430481e58ca7a0e20b00fdc85e53b3341fae50
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 #pragma once
22 #include <com/sun/star/accessibility/AccessibleScrollType.hpp>
23 #include <com/sun/star/accessibility/XAccessible.hpp>
24 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
25 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
26 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
27 #include <com/sun/star/accessibility/XAccessibleAction.hpp>
28 #include <com/sun/star/lang/XEventListener.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <cppuhelper/compbase.hxx>
31 #include <cppuhelper/basemutex.hxx>
32 #include <comphelper/accessibletexthelper.hxx>
33 #include <tools/gen.hxx>
34 #include <vcl/vclptr.hxx>
36 // forward
38 class SvxIconChoiceCtrlEntry;
39 class SvtIconChoiceCtrl;
41 namespace accessibility
45 typedef ::cppu::WeakComponentImplHelper< css::accessibility::XAccessible
46 , css::accessibility::XAccessibleContext
47 , css::accessibility::XAccessibleComponent
48 , css::accessibility::XAccessibleEventBroadcaster
49 , css::accessibility::XAccessibleText
50 , css::accessibility::XAccessibleAction
51 , css::lang::XServiceInfo
52 , css::lang::XEventListener > AccessibleIconChoiceCtrlEntry_BASE;
54 /** the class AccessibleListBoxEntry represents the class for an accessible object of a listbox entry */
55 class AccessibleIconChoiceCtrlEntry final : public ::cppu::BaseMutex,
56 public AccessibleIconChoiceCtrlEntry_BASE,
57 public ::comphelper::OCommonAccessibleText
59 /** The treelistbox control */
60 VclPtr<SvtIconChoiceCtrl> m_pIconCtrl;
61 sal_Int32 m_nIndex;
63 /// client id in the AccessibleEventNotifier queue
64 sal_uInt32 m_nClientId;
66 css::uno::Reference< css::accessibility::XAccessible > m_xParent;
68 tools::Rectangle GetBoundingBox_Impl() const;
69 AbsoluteScreenPixelRectangle GetBoundingBoxOnScreen_Impl() const;
70 bool IsAlive_Impl() const;
71 bool IsShowing_Impl() const;
73 /// @throws css::lang::DisposedException
74 /// @throws css::uno::RuntimeException
75 tools::Rectangle GetBoundingBox();
76 /// @throws css::lang::DisposedException
77 /// @throws css::uno::RuntimeException
78 AbsoluteScreenPixelRectangle GetBoundingBoxOnScreen();
79 /// @throws css::lang::DisposedException
80 void EnsureIsAlive() const;
82 virtual ~AccessibleIconChoiceCtrlEntry() override;
83 /** this function is called upon disposing the component
85 virtual void SAL_CALL disposing() override;
87 // OCommonAccessibleText
88 virtual OUString implGetText() override;
89 virtual css::lang::Locale implGetLocale() override;
90 virtual void implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) override final;
92 public:
93 /** Ctor()
94 @param _rIconCtrl
95 the icon control
96 @param _nPos
97 the entry number
98 @param _xParent
99 is our parent accessible object
101 AccessibleIconChoiceCtrlEntry( SvtIconChoiceCtrl& _rIconCtrl,
102 sal_Int32 _nPos,
103 const css::uno::Reference< css::accessibility::XAccessible >& _xParent );
105 // XTypeProvider
106 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
108 // XServiceInfo
109 virtual OUString SAL_CALL getImplementationName() override;
110 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
111 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
113 // XEventListener
114 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
116 // XAccessible
117 virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override;
119 // XAccessibleContext
120 virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override;
121 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override;
122 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override;
123 virtual sal_Int64 SAL_CALL getAccessibleIndexInParent( ) override;
124 virtual sal_Int16 SAL_CALL getAccessibleRole( ) override;
125 virtual OUString SAL_CALL getAccessibleDescription( ) override;
126 virtual OUString SAL_CALL getAccessibleName( ) override;
127 virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override;
128 virtual sal_Int64 SAL_CALL getAccessibleStateSet( ) override;
129 virtual css::lang::Locale SAL_CALL getLocale( ) override;
131 // XAccessibleComponent
132 virtual sal_Bool SAL_CALL containsPoint( const css::awt::Point& aPoint ) override;
133 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override;
134 virtual css::awt::Rectangle SAL_CALL getBounds( ) override;
135 virtual css::awt::Point SAL_CALL getLocation( ) override;
136 virtual css::awt::Point SAL_CALL getLocationOnScreen( ) override;
137 virtual css::awt::Size SAL_CALL getSize( ) override;
138 virtual void SAL_CALL grabFocus( ) override;
139 virtual sal_Int32 SAL_CALL getForeground( ) override;
140 virtual sal_Int32 SAL_CALL getBackground( ) override;
142 // XAccessibleText
143 virtual sal_Int32 SAL_CALL getCaretPosition() override;
144 virtual sal_Bool SAL_CALL setCaretPosition( sal_Int32 nIndex ) override;
145 virtual sal_Unicode SAL_CALL getCharacter( sal_Int32 nIndex ) override;
146 virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCharacterAttributes( sal_Int32 nIndex, const css::uno::Sequence< OUString >& aRequestedAttributes ) override;
147 virtual css::awt::Rectangle SAL_CALL getCharacterBounds( sal_Int32 nIndex ) override;
148 virtual sal_Int32 SAL_CALL getCharacterCount() override;
149 virtual sal_Int32 SAL_CALL getIndexAtPoint( const css::awt::Point& aPoint ) override;
150 virtual OUString SAL_CALL getSelectedText() override;
151 virtual sal_Int32 SAL_CALL getSelectionStart() override;
152 virtual sal_Int32 SAL_CALL getSelectionEnd() override;
153 virtual sal_Bool SAL_CALL setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override;
154 virtual OUString SAL_CALL getText() override;
155 virtual OUString SAL_CALL getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override;
156 virtual css::accessibility::TextSegment SAL_CALL getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override;
157 virtual css::accessibility::TextSegment SAL_CALL getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override;
158 virtual css::accessibility::TextSegment SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override;
159 virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override;
160 virtual sal_Bool SAL_CALL scrollSubstringTo( sal_Int32 nStartIndex, sal_Int32 nEndIndex, css::accessibility::AccessibleScrollType aScrollType) override;
162 // XAccessibleEventBroadcaster
163 virtual void SAL_CALL addAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override;
164 virtual void SAL_CALL removeAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override;
166 // XAccessibleAction
167 virtual sal_Int32 SAL_CALL getAccessibleActionCount( ) override;
168 virtual sal_Bool SAL_CALL doAccessibleAction( sal_Int32 nIndex ) override;
169 virtual OUString SAL_CALL getAccessibleActionDescription( sal_Int32 nIndex ) override;
170 virtual css::uno::Reference< css::accessibility::XAccessibleKeyBinding > SAL_CALL getAccessibleActionKeyBinding( sal_Int32 nIndex ) override;
174 }// namespace accessibility
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */