Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_TOOLKIT_AWT_VCLXACCESSIBLECOMPONENT_HXX
21 : #define INCLUDED_TOOLKIT_AWT_VCLXACCESSIBLECOMPONENT_HXX
22 :
23 : #include <toolkit/dllapi.h>
24 : #include <com/sun/star/accessibility/XAccessible.hpp>
25 : #include <com/sun/star/accessibility/XAccessibleContext.hpp>
26 : #include <com/sun/star/accessibility/XAccessibleExtendedComponent.hpp>
27 : #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
28 : #include <com/sun/star/awt/XWindow.hpp>
29 : #include <com/sun/star/lang/XServiceInfo.hpp>
30 : #include <cppuhelper/compbase3.hxx>
31 : #include <cppuhelper/implbase1.hxx>
32 : #include <comphelper/accimplaccess.hxx>
33 : #include <comphelper/accessiblecomponenthelper.hxx>
34 :
35 : #include <tools/link.hxx>
36 : #include <vcl/vclptr.hxx>
37 :
38 : namespace vcl { class Window; }
39 : class VCLXWindow;
40 : class VclSimpleEvent;
41 : class VclWindowEvent;
42 :
43 : namespace utl {
44 : class AccessibleRelationSetHelper;
45 : class AccessibleStateSetHelper;
46 : }
47 :
48 :
49 :
50 : // class VCLXAccessibleComponent
51 :
52 :
53 : typedef ::comphelper::OAccessibleExtendedComponentHelper AccessibleExtendedComponentHelper_BASE;
54 :
55 : typedef ::cppu::ImplHelper1<
56 : ::com::sun::star::lang::XServiceInfo > VCLXAccessibleComponent_BASE;
57 :
58 : class VCLExternalSolarLock;
59 :
60 : class TOOLKIT_DLLPUBLIC VCLXAccessibleComponent
61 : :public AccessibleExtendedComponentHelper_BASE
62 : ,public ::comphelper::OAccessibleImplementationAccess
63 : ,public VCLXAccessibleComponent_BASE
64 : {
65 : private:
66 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow> mxWindow;
67 : VCLXWindow* mpVCLXindow;
68 :
69 : VCLExternalSolarLock* m_pSolarLock;
70 :
71 : protected:
72 : DECL_LINK( WindowEventListener, VclSimpleEvent* );
73 : DECL_LINK( WindowChildEventListener, VclSimpleEvent* );
74 :
75 : virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent );
76 : virtual void ProcessWindowChildEvent( const VclWindowEvent& rVclWindowEvent );
77 : virtual void FillAccessibleRelationSet( utl::AccessibleRelationSetHelper& rRelationSet );
78 : virtual void FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet );
79 :
80 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > GetChildAccessible( const VclWindowEvent& rVclWindowEvent );
81 :
82 : public:
83 : VCLXAccessibleComponent( VCLXWindow* pVCLXindow );
84 : virtual ~VCLXAccessibleComponent();
85 :
86 48941 : VCLXWindow* GetVCLXWindow() const { return mpVCLXindow; }
87 : VclPtr<vcl::Window> GetWindow() const;
88 2161 : template< class derived_type > VclPtr< derived_type > GetAs() const {
89 2161 : return VclPtr< derived_type >( static_cast< derived_type * >( GetWindow().get() ) ); }
90 0 : template< class derived_type > VclPtr< derived_type > GetAsDynamic() const {
91 0 : return VclPtr< derived_type >( dynamic_cast< derived_type * >( GetWindow().get() ) ); }
92 :
93 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
94 :
95 : // ::com::sun::star::uno::XInterface
96 : DECLARE_XINTERFACE()
97 : // ::com::sun::star::lang::XTypeProvider
98 : DECLARE_XTYPEPROVIDER()
99 :
100 : // XServiceInfo
101 : virtual OUString SAL_CALL getImplementationName() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
102 : virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
103 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
104 :
105 : // ::com::sun::star::accessibility::XAccessibleContext
106 : sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
107 : ::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, std::exception) SAL_OVERRIDE;
108 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
109 : sal_Int32 SAL_CALL getAccessibleIndexInParent( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
110 : sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
111 : OUString SAL_CALL getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
112 : OUString SAL_CALL getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
113 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
114 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
115 : ::com::sun::star::lang::Locale SAL_CALL getLocale( ) throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
116 :
117 : // ::com::sun::star::accessibility::XAccessibleComponent
118 : ::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, std::exception) SAL_OVERRIDE;
119 : ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
120 : void SAL_CALL grabFocus( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
121 : virtual sal_Int32 SAL_CALL getForeground( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
122 : virtual sal_Int32 SAL_CALL getBackground( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
123 :
124 : // ::com::sun::star::accessibility::XAccessibleExtendedComponent
125 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont > SAL_CALL getFont( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
126 : virtual OUString SAL_CALL getTitledBorderText( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
127 : virtual OUString SAL_CALL getToolTipText( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
128 :
129 : protected:
130 : // base class overridables
131 : ::com::sun::star::awt::Rectangle implGetBounds( ) throw (::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
132 :
133 : private:
134 : /** we may be reparented (if external components use OAccessibleImplementationAccess base class),
135 : so this method here returns the parent in the VCL world, in opposite to the parent
136 : an external component gave us
137 : @precond
138 : the caller must ensure thread safety, i.e. our mutex must be locked
139 : */
140 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
141 : getVclParent() const;
142 : };
143 :
144 : /* ----------------------------------------------------------
145 : Accessibility only for the Window hierarchy!
146 : Maybe derived classes must overwrite these Accessibility interfaces:
147 :
148 : // XAccessibleContext:
149 : sal_Int16 getAccessibleRole() => VCL Window::GetAccessibleRole()
150 : OUString getAccessibleDescription() => VCL Window::GetAccessibleDescription
151 : OUString getAccessibleName() => VCL Window::GetAccessibleText() => Most windows return Window::GetText()
152 : Reference< XAccessibleRelationSet > getAccessibleRelationSet()
153 : Reference< XAccessibleStateSet > getAccessibleStateSet() => override FillAccessibleStateSet( ... )
154 :
155 : ---------------------------------------------------------- */
156 :
157 :
158 : #endif // INCLUDED_TOOLKIT_AWT_VCLXACCESSIBLECOMPONENT_HXX
159 :
160 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|