xref: /AOO41X/main/toolkit/inc/toolkit/awt/vclxaccessiblecomponent.hxx (revision 50e6b0721ed882c1c74690abd9bee6b3a8da8cfd)
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 _TOOLKIT_AWT_VCLXACCESSIBLECOMPONENT_HXX_
25 #define _TOOLKIT_AWT_VCLXACCESSIBLECOMPONENT_HXX_
26 
27 #include <toolkit/dllapi.h>
28 #include <com/sun/star/accessibility/XAccessible.hpp>
29 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
30 #include <com/sun/star/accessibility/XAccessibleExtendedComponent.hpp>
31 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
32 #include <com/sun/star/awt/XWindow.hpp>
33 #include <com/sun/star/lang/XServiceInfo.hpp>
34 #include <cppuhelper/compbase3.hxx>
35 #include <cppuhelper/implbase1.hxx>
36 #include <comphelper/accimplaccess.hxx>
37 #include <comphelper/accessiblecomponenthelper.hxx>
38 
39 #include <tools/gen.hxx>    // Size
40 #include <tools/link.hxx>   // Size
41 
42 class Window;
43 class VCLXWindow;
44 class VclSimpleEvent;
45 class VclWindowEvent;
46 
47 namespace utl {
48 class AccessibleRelationSetHelper;
49 class AccessibleStateSetHelper;
50 }
51 
52 
53 //  ----------------------------------------------------
54 //  class VCLXAccessibleComponent
55 //  ----------------------------------------------------
56 
57 typedef ::comphelper::OAccessibleExtendedComponentHelper    AccessibleExtendedComponentHelper_BASE;
58 
59 typedef ::cppu::ImplHelper1<
60     ::com::sun::star::lang::XServiceInfo > VCLXAccessibleComponent_BASE;
61 
62 class VCLExternalSolarLock;
63 
64 class TOOLKIT_DLLPUBLIC VCLXAccessibleComponent
65         :public AccessibleExtendedComponentHelper_BASE
66         ,public ::comphelper::OAccessibleImplementationAccess
67         ,public VCLXAccessibleComponent_BASE
68 {
69 private:
70     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow> mxWindow;
71     VCLXWindow*                         mpVCLXindow;
72 
73     sal_uLong                           nDummy1;
74     sal_uLong                           nDummy2;
75     void*                           pDummy1;
76     VCLExternalSolarLock*           m_pSolarLock;
77 
78 protected:
79      DECL_LINK( WindowEventListener, VclSimpleEvent* );
80      DECL_LINK( WindowChildEventListener, VclSimpleEvent* );
81 
82     virtual void    ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent );
83     virtual void    ProcessWindowChildEvent( const VclWindowEvent& rVclWindowEvent );
84     virtual void    FillAccessibleRelationSet( utl::AccessibleRelationSetHelper& rRelationSet );
85     virtual void    FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet );
86 
87     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > GetChildAccessible( const VclWindowEvent& rVclWindowEvent );
88 
89 public:
90     VCLXAccessibleComponent( VCLXWindow* pVCLXindow );
91     ~VCLXAccessibleComponent();
92 
GetVCLXWindow() const93     VCLXWindow*    GetVCLXWindow() const { return mpVCLXindow; }
94     Window*        GetWindow() const;
95 
96     virtual void SAL_CALL disposing();
97 
98     // ::com::sun::star::uno::XInterface
99     DECLARE_XINTERFACE()
100     // ::com::sun::star::lang::XTypeProvider
101     DECLARE_XTYPEPROVIDER()
102 
103     // XServiceInfo
104     virtual ::rtl::OUString SAL_CALL getImplementationName() throw (::com::sun::star::uno::RuntimeException);
105     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& rServiceName ) throw (::com::sun::star::uno::RuntimeException);
106     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw (::com::sun::star::uno::RuntimeException);
107 
108     // ::com::sun::star::accessibility::XAccessibleContext
109     sal_Int32 SAL_CALL getAccessibleChildCount(  ) throw (::com::sun::star::uno::RuntimeException);
110     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
111     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent(  ) throw (::com::sun::star::uno::RuntimeException);
112     sal_Int32 SAL_CALL getAccessibleIndexInParent(  ) throw (::com::sun::star::uno::RuntimeException);
113     sal_Int16 SAL_CALL getAccessibleRole(  ) throw (::com::sun::star::uno::RuntimeException);
114     ::rtl::OUString SAL_CALL getAccessibleDescription(  ) throw (::com::sun::star::uno::RuntimeException);
115     ::rtl::OUString SAL_CALL getAccessibleName(  ) throw (::com::sun::star::uno::RuntimeException);
116     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet(  ) throw (::com::sun::star::uno::RuntimeException);
117     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet(  ) throw (::com::sun::star::uno::RuntimeException);
118     ::com::sun::star::lang::Locale SAL_CALL getLocale(  ) throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException);
119 
120     // ::com::sun::star::accessibility::XAccessibleComponent
121     ::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);
122     ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen(  ) throw (::com::sun::star::uno::RuntimeException);
123     void SAL_CALL grabFocus(  ) throw (::com::sun::star::uno::RuntimeException);
124     virtual sal_Int32 SAL_CALL getForeground(  ) throw (::com::sun::star::uno::RuntimeException);
125     virtual sal_Int32 SAL_CALL getBackground(  ) throw (::com::sun::star::uno::RuntimeException);
126 
127     // ::com::sun::star::accessibility::XAccessibleExtendedComponent
128     virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont > SAL_CALL getFont(  ) throw (::com::sun::star::uno::RuntimeException);
129     virtual ::rtl::OUString SAL_CALL getTitledBorderText(  ) throw (::com::sun::star::uno::RuntimeException);
130     virtual ::rtl::OUString SAL_CALL getToolTipText(  ) throw (::com::sun::star::uno::RuntimeException);
131 
132 protected:
133     // base class overridables
134     ::com::sun::star::awt::Rectangle SAL_CALL implGetBounds(  ) throw (::com::sun::star::uno::RuntimeException);
135 
136 private:
137     /** we may be reparented (if external components use OAccessibleImplementationAccess base class),
138         so this method here returns the parent in the VCL world, in opposite to the parent
139         an external component gave us
140     @precond
141         the caller must ensure thread safety, i.e. our mutex must be locked
142     */
143     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
144             getVclParent() const;
145 };
146 
147 /* ----------------------------------------------------------
148   Accessibility only for the Window hierarchy!
149   Maybe derived classes must overwrite these Accessibility interfaces:
150 
151     // XAccessibleContext:
152     sal_Int16 getAccessibleRole() => VCL Window::GetAccessibleRole()
153     OUString getAccessibleDescription() => VCL Window::GetAccessibleDescription
154     OUString getAccessibleName() => VCL Window::GetAccessibleText() => Most windows return Window::GetText()
155     Reference< XAccessibleRelationSet > getAccessibleRelationSet()
156     Reference< XAccessibleStateSet > getAccessibleStateSet() => overload FillAccessibleStateSet( ... )
157 
158 ---------------------------------------------------------- */
159 
160 
161 #endif // _TOOLKIT_AWT_VCLXACCESSIBLECOMPONENT_HXX_
162 
163