Bump version to 21.06.18.1
[LibreOffice.git] / include / toolkit / awt / vclxaccessiblecomponent.hxx
blobb9cf5ec6bacc919d3d261d6a988c239f3d19e55f
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 #ifndef INCLUDED_TOOLKIT_AWT_VCLXACCESSIBLECOMPONENT_HXX
21 #define INCLUDED_TOOLKIT_AWT_VCLXACCESSIBLECOMPONENT_HXX
23 #include <toolkit/dllapi.h>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <cppuhelper/implbase1.hxx>
26 #include <comphelper/accimplaccess.hxx>
27 #include <comphelper/accessiblecomponenthelper.hxx>
30 #include <tools/link.hxx>
31 #include <vcl/vclptr.hxx>
33 namespace com::sun::star::accessibility { class XAccessible; }
35 namespace vcl { class Window; }
36 class VCLXWindow;
37 class VclWindowEvent;
39 namespace utl {
40 class AccessibleRelationSetHelper;
41 class AccessibleStateSetHelper;
46 typedef ::cppu::ImplHelper1<
47 css::lang::XServiceInfo > VCLXAccessibleComponent_BASE;
49 class TOOLKIT_DLLPUBLIC VCLXAccessibleComponent
50 :public comphelper::OAccessibleExtendedComponentHelper
51 ,public ::comphelper::OAccessibleImplementationAccess
52 ,public VCLXAccessibleComponent_BASE
54 private:
55 rtl::Reference<VCLXWindow> m_xVCLXWindow;
56 VclPtr<vcl::Window> m_xEventSource;
58 DECL_LINK( WindowEventListener, VclWindowEvent&, void );
59 DECL_LINK( WindowChildEventListener, VclWindowEvent&, void );
60 void DisconnectEvents();
62 protected:
63 virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent );
64 virtual void ProcessWindowChildEvent( const VclWindowEvent& rVclWindowEvent );
65 virtual void FillAccessibleRelationSet( utl::AccessibleRelationSetHelper& rRelationSet );
66 virtual void FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet );
68 virtual css::uno::Reference< css::accessibility::XAccessible > GetChildAccessible( const VclWindowEvent& rVclWindowEvent );
70 public:
71 VCLXAccessibleComponent( VCLXWindow* pVCLXWindow );
72 virtual ~VCLXAccessibleComponent() override;
74 VCLXWindow* GetVCLXWindow() const;
75 VclPtr<vcl::Window> GetWindow() const;
76 template< class derived_type > VclPtr< derived_type > GetAs() const {
77 return VclPtr< derived_type >( static_cast< derived_type * >( GetWindow().get() ) ); }
78 template< class derived_type > VclPtr< derived_type > GetAsDynamic() const {
79 return VclPtr< derived_type >( dynamic_cast< derived_type * >( GetWindow().get() ) ); }
81 virtual void SAL_CALL disposing() override;
83 // css::uno::XInterface
84 DECLARE_XINTERFACE()
85 // css::lang::XTypeProvider
86 DECLARE_XTYPEPROVIDER()
88 // XServiceInfo
89 virtual OUString SAL_CALL getImplementationName() override;
90 virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) override;
91 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
93 // css::accessibility::XAccessibleContext
94 sal_Int32 SAL_CALL getAccessibleChildCount( ) override;
95 css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) override;
96 css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override;
97 sal_Int32 SAL_CALL getAccessibleIndexInParent( ) override;
98 sal_Int16 SAL_CALL getAccessibleRole( ) override;
99 OUString SAL_CALL getAccessibleDescription( ) override;
100 OUString SAL_CALL getAccessibleName( ) override;
101 OUString SAL_CALL getAccessibleId( ) override;
102 css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override;
103 css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) override;
104 css::lang::Locale SAL_CALL getLocale( ) override;
106 // css::accessibility::XAccessibleComponent
107 css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override;
108 css::awt::Point SAL_CALL getLocationOnScreen( ) override;
109 void SAL_CALL grabFocus( ) override;
110 virtual sal_Int32 SAL_CALL getForeground( ) override;
111 virtual sal_Int32 SAL_CALL getBackground( ) override;
113 // css::accessibility::XAccessibleExtendedComponent
114 virtual css::uno::Reference< css::awt::XFont > SAL_CALL getFont( ) override;
115 virtual OUString SAL_CALL getTitledBorderText( ) override;
116 virtual OUString SAL_CALL getToolTipText( ) override;
118 protected:
119 // base class overridables
120 css::awt::Rectangle implGetBounds( ) override;
122 private:
123 /** we may be reparented (if external components use OAccessibleImplementationAccess base class),
124 so this method here returns the parent in the VCL world, in opposite to the parent
125 an external component gave us
126 @precond
127 the caller must ensure thread safety, i.e. our mutex must be locked
129 css::uno::Reference< css::accessibility::XAccessible >
130 getVclParent() const;
133 /* ----------------------------------------------------------
134 Accessibility only for the Window hierarchy!
135 Maybe derived classes must overwrite these Accessibility interfaces:
137 // XAccessibleContext:
138 sal_Int16 getAccessibleRole() => VCL Window::GetAccessibleRole()
139 OUString getAccessibleDescription() => VCL Window::GetAccessibleDescription
140 OUString getAccessibleName() => VCL Window::GetAccessibleText() => Most windows return Window::GetText()
141 OUString getAccessibleId() => VCL Window::get_id()
142 Reference< XAccessibleRelationSet > getAccessibleRelationSet()
143 Reference< XAccessibleStateSet > getAccessibleStateSet() => override FillAccessibleStateSet( ... )
145 ---------------------------------------------------------- */
148 #endif // INCLUDED_TOOLKIT_AWT_VCLXACCESSIBLECOMPONENT_HXX
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */