xref: /AOO42X/main/accessibility/inc/accessibility/standard/vclxaccessiblelistitem.hxx (revision 9bce9b0d387299c68bd81d539e1478357a103de5)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef ACCESSIBILITY_STANDARD_VCLXACCESSIBLELISTITEM_HXX
25 #define ACCESSIBILITY_STANDARD_VCLXACCESSIBLELISTITEM_HXX
26 
27 #include <com/sun/star/accessibility/XAccessible.hpp>
28 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
29 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
30 #include <com/sun/star/accessibility/XAccessibleStateSet.hpp>
31 #include <com/sun/star/accessibility/XAccessibleText.hpp>
32 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
33 #include <com/sun/star/lang/XServiceInfo.hpp>
34 #ifndef _CPPUHELPER_COMPBASE6_HXX
35 #include <cppuhelper/compbase6.hxx>
36 #endif
37 #ifndef _COMPHELPER_BROADCASTHELPER_HXX
38 #include <comphelper/broadcasthelper.hxx>
39 #endif
40 #include <comphelper/accessibletexthelper.hxx>
41 
42 // forward ---------------------------------------------------------------
43 
44 namespace com { namespace sun { namespace star { namespace awt {
45     struct Point;
46     struct Rectangle;
47     struct Size;
48     class XFocusListener;
49 } } } }
50 
51 namespace accessibility
52 {
53     class IComboListBoxHelper;
54 }
55 
56 // class VCLXAccessibleListItem ------------------------------------------
57 
58 typedef ::cppu::WeakAggComponentImplHelper6< ::com::sun::star::accessibility::XAccessible
59                                             , ::com::sun::star::accessibility::XAccessibleContext
60                                             , ::com::sun::star::accessibility::XAccessibleComponent
61                                             , ::com::sun::star::accessibility::XAccessibleEventBroadcaster
62                                             , ::com::sun::star::accessibility::XAccessibleText
63                                             , ::com::sun::star::lang::XServiceInfo > VCLXAccessibleListItem_BASE;
64 
65 /** the class OAccessibleListBoxEntry represents the base class for an accessible object of a listbox entry
66 */
67 class VCLXAccessibleListItem : public ::comphelper::OBaseMutex,
68                                public ::comphelper::OCommonAccessibleText,
69                                public VCLXAccessibleListItem_BASE
70 {
71 private:
72     ::rtl::OUString                     m_sEntryText;
73     sal_Int32                           m_nIndexInParent;
74     sal_Bool                            m_bSelected;
75     sal_Bool                            m_bVisible;
76 
77 protected:
78     /// client id in the AccessibleEventNotifier queue
79     sal_uInt32                          m_nClientId;
80     ::accessibility::IComboListBoxHelper*       m_pListBoxHelper;
81 
82     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >        m_xParent;
83     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > m_xParentContext;
84 
85 private:
86     /** notifies all listeners that this object has changed
87         @param  _nEventId
88             is the event id
89         @param  _aOldValue
90             is the old value
91         @param  _aNewValue
92             is the new value
93     */
94     /*void                  NotifyAccessibleEvent(  sal_Int16 _nEventId,
95                                                     const ::com::sun::star::uno::Any& _aOldValue,
96                                                     const ::com::sun::star::uno::Any& _aNewValue );*/
97 
98 protected:
99     virtual ~VCLXAccessibleListItem();
100     /** this function is called upon disposing the component
101     */
102     virtual void SAL_CALL   disposing();
103 
104     // OCommonAccessibleText
105     virtual ::rtl::OUString                 implGetText();
106     virtual ::com::sun::star::lang::Locale  implGetLocale();
107     virtual void                            implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex );
108 
109 public:
110     /** OAccessibleBase needs a valid view
111         @param  _pListBoxHelper
112             is the list- or combobox for which we implement an accessible object
113         @param  _nIndexInParent
114             is the position of the entry inside the listbox
115         @param  _xParent
116             is our parent accessible object
117     */
118     VCLXAccessibleListItem( ::accessibility::IComboListBoxHelper* _pListBoxHelper,
119                             sal_Int32 _nIndexInParent,
120                             const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _xParent );
121 
122     void                    NotifyAccessibleEvent(  sal_Int16 _nEventId, const ::com::sun::star::uno::Any& _aOldValue, const ::com::sun::star::uno::Any& _aNewValue );
123 
IsSelected() const124     inline sal_Bool         IsSelected() const { return m_bSelected; }
125     void                    SetSelected( sal_Bool _bSelected );
126     void                    SetVisible( sal_Bool _bVisible );
DecrementIndexInParent()127     inline bool             DecrementIndexInParent() { OSL_ENSURE(m_nIndexInParent != 0,"Invalid call!");--m_nIndexInParent; return true;}
IncrementIndexInParent()128     inline bool             IncrementIndexInParent() { ++m_nIndexInParent; return true;}
129 
130     // XInterface
131     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException);
132     virtual void SAL_CALL acquire(  ) throw();
133     virtual void SAL_CALL release(  ) throw();
134 
135     // XTypeProvider
136     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw (::com::sun::star::uno::RuntimeException);
137     virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException);
138 
139     // XServiceInfo
140     virtual ::rtl::OUString SAL_CALL getImplementationName() throw (::com::sun::star::uno::RuntimeException);
141     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& rServiceName ) throw (::com::sun::star::uno::RuntimeException);
142     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw (::com::sun::star::uno::RuntimeException);
143 
144     // XAccessible
145     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext(  ) throw (::com::sun::star::uno::RuntimeException);
146 
147     // XAccessibleContext
148     virtual sal_Int32 SAL_CALL getAccessibleChildCount(  ) throw (::com::sun::star::uno::RuntimeException);
149     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::uno::RuntimeException);
150     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent(  ) throw (::com::sun::star::uno::RuntimeException);
151     virtual sal_Int32 SAL_CALL getAccessibleIndexInParent(  ) throw (::com::sun::star::uno::RuntimeException);
152     virtual sal_Int16 SAL_CALL getAccessibleRole(  ) throw (::com::sun::star::uno::RuntimeException);
153     virtual ::rtl::OUString SAL_CALL getAccessibleDescription(  ) throw (::com::sun::star::uno::RuntimeException);
154     virtual ::rtl::OUString SAL_CALL getAccessibleName(  ) throw (::com::sun::star::uno::RuntimeException);
155     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet(  ) throw (::com::sun::star::uno::RuntimeException);
156     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet(  ) throw (::com::sun::star::uno::RuntimeException);
157     virtual ::com::sun::star::lang::Locale SAL_CALL getLocale(  ) throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException);
158 
159     // XAccessibleComponent
160     virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
161     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
162     virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds(  ) throw (::com::sun::star::uno::RuntimeException);
163     virtual ::com::sun::star::awt::Point SAL_CALL getLocation(  ) throw (::com::sun::star::uno::RuntimeException);
164     virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen(  ) throw (::com::sun::star::uno::RuntimeException);
165     virtual ::com::sun::star::awt::Size SAL_CALL getSize(  ) throw (::com::sun::star::uno::RuntimeException);
166     virtual void SAL_CALL grabFocus(  ) throw (::com::sun::star::uno::RuntimeException);
167     virtual sal_Int32 SAL_CALL getForeground (void) throw (::com::sun::star::uno::RuntimeException);
168     virtual sal_Int32 SAL_CALL getBackground (void) throw (::com::sun::star::uno::RuntimeException);
169 
170     // XAccessibleText
171     virtual sal_Int32 SAL_CALL getCaretPosition() throw (::com::sun::star::uno::RuntimeException);
172     virtual sal_Bool SAL_CALL setCaretPosition( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
173     virtual sal_Unicode SAL_CALL getCharacter( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
174     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aRequestedAttributes ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
175     virtual ::com::sun::star::awt::Rectangle SAL_CALL getCharacterBounds( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
176     virtual sal_Int32 SAL_CALL getCharacterCount() throw (::com::sun::star::uno::RuntimeException);
177     virtual sal_Int32 SAL_CALL getIndexAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
178     virtual ::rtl::OUString SAL_CALL getSelectedText() throw (::com::sun::star::uno::RuntimeException);
179     virtual sal_Int32 SAL_CALL getSelectionStart() throw (::com::sun::star::uno::RuntimeException);
180     virtual sal_Int32 SAL_CALL getSelectionEnd() throw (::com::sun::star::uno::RuntimeException);
181     virtual sal_Bool SAL_CALL setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
182     virtual ::rtl::OUString SAL_CALL getText() throw (::com::sun::star::uno::RuntimeException);
183     virtual ::rtl::OUString SAL_CALL getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
184     virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
185     virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
186     virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
187     virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
188 
189     // XAccessibleEventBroadcaster
190     using cppu::WeakAggComponentImplHelperBase::addEventListener;
191     using cppu::WeakAggComponentImplHelperBase::removeEventListener;
192     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
193     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
194 };
195 
196 #endif // ACCESSIBILITY_STANDARD_ACCESSIBLELISTBOXENTRY_HXX
197