Avoid potential negative array index access to cached text.
[LibreOffice.git] / accessibility / inc / standard / vclxaccessiblelistitem.hxx
blob260c132bbfa1de9e526e934d52a1ae94e6f61af8
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/XAccessibleText.hpp>
27 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <cppuhelper/compbase.hxx>
30 #include <cppuhelper/basemutex.hxx>
31 #include <comphelper/accessibletexthelper.hxx>
32 #include <standard/vclxaccessiblelist.hxx>
34 // forward ---------------------------------------------------------------
36 namespace com::sun::star::awt {
37 struct Point;
38 struct Rectangle;
39 struct Size;
40 class XFocusListener;
43 // class VCLXAccessibleListItem ------------------------------------------
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::lang::XServiceInfo > VCLXAccessibleListItem_BASE;
52 /** the class OAccessibleListBoxEntry represents the base class for an accessible object of a listbox entry
54 class VCLXAccessibleListItem final : public ::cppu::BaseMutex,
55 public ::comphelper::OCommonAccessibleText,
56 public VCLXAccessibleListItem_BASE
58 private:
59 OUString m_sEntryText;
60 sal_Int32 m_nIndexInParent;
61 bool m_bSelected;
62 bool m_bVisible;
64 /// client id in the AccessibleEventNotifier queue
65 sal_uInt32 m_nClientId;
67 rtl::Reference< VCLXAccessibleList > m_xParent;
69 virtual ~VCLXAccessibleListItem() override = default;
70 /** this function is called upon disposing the component
72 virtual void SAL_CALL disposing() override;
74 // OCommonAccessibleText
75 virtual OUString implGetText() override;
76 virtual css::lang::Locale implGetLocale() override;
77 virtual void implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) override;
79 public:
80 /** OAccessibleBase needs a valid view
81 @param _nIndexInParent
82 is the position of the entry inside the listbox
83 @param _xParent
84 is our parent accessible object
86 VCLXAccessibleListItem(sal_Int32 _nIndexInParent,
87 rtl::Reference< VCLXAccessibleList > _xParent);
89 void NotifyAccessibleEvent( sal_Int16 _nEventId, const css::uno::Any& _aOldValue, const css::uno::Any& _aNewValue );
91 bool IsSelected() const { return m_bSelected; }
92 void SetSelected( bool _bSelected );
93 void SetVisible( bool _bVisible );
95 // XTypeProvider
96 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
98 // XServiceInfo
99 virtual OUString SAL_CALL getImplementationName() override;
100 virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) override;
101 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
103 // XAccessible
104 virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override;
106 // XAccessibleContext
107 virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override;
108 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override;
109 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override;
110 virtual sal_Int64 SAL_CALL getAccessibleIndexInParent( ) override;
111 virtual sal_Int16 SAL_CALL getAccessibleRole( ) override;
112 virtual OUString SAL_CALL getAccessibleDescription( ) override;
113 virtual OUString SAL_CALL getAccessibleName( ) override;
114 virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override;
115 virtual sal_Int64 SAL_CALL getAccessibleStateSet( ) override;
116 virtual css::lang::Locale SAL_CALL getLocale( ) override;
118 // XAccessibleComponent
119 virtual sal_Bool SAL_CALL containsPoint( const css::awt::Point& aPoint ) override;
120 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override;
121 virtual css::awt::Rectangle SAL_CALL getBounds( ) override;
122 virtual css::awt::Point SAL_CALL getLocation( ) override;
123 virtual css::awt::Point SAL_CALL getLocationOnScreen( ) override;
124 virtual css::awt::Size SAL_CALL getSize( ) override;
125 virtual void SAL_CALL grabFocus( ) override;
126 virtual sal_Int32 SAL_CALL getForeground() override;
127 virtual sal_Int32 SAL_CALL getBackground() override;
129 // XAccessibleText
130 virtual sal_Int32 SAL_CALL getCaretPosition() override;
131 virtual sal_Bool SAL_CALL setCaretPosition( sal_Int32 nIndex ) override;
132 virtual sal_Unicode SAL_CALL getCharacter( sal_Int32 nIndex ) override;
133 virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCharacterAttributes( sal_Int32 nIndex, const css::uno::Sequence< OUString >& aRequestedAttributes ) override;
134 virtual css::awt::Rectangle SAL_CALL getCharacterBounds( sal_Int32 nIndex ) override;
135 virtual sal_Int32 SAL_CALL getCharacterCount() override;
136 virtual sal_Int32 SAL_CALL getIndexAtPoint( const css::awt::Point& aPoint ) override;
137 virtual OUString SAL_CALL getSelectedText() override;
138 virtual sal_Int32 SAL_CALL getSelectionStart() override;
139 virtual sal_Int32 SAL_CALL getSelectionEnd() override;
140 virtual sal_Bool SAL_CALL setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override;
141 virtual OUString SAL_CALL getText() override;
142 virtual OUString SAL_CALL getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override;
143 virtual css::accessibility::TextSegment SAL_CALL getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override;
144 virtual css::accessibility::TextSegment SAL_CALL getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override;
145 virtual css::accessibility::TextSegment SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override;
146 virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override;
147 virtual sal_Bool SAL_CALL scrollSubstringTo( sal_Int32 nStartIndex, sal_Int32 nEndIndex, css::accessibility::AccessibleScrollType aScrollType) override;
149 // XAccessibleEventBroadcaster
150 virtual void SAL_CALL addAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override;
151 virtual void SAL_CALL removeAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override;
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */