1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
{ namespace sun
{ namespace star
{ namespace accessibility
{ class XAccessible
; } } } }
35 namespace vcl
{ class Window
; }
40 class AccessibleRelationSetHelper
;
41 class AccessibleStateSetHelper
;
45 // class VCLXAccessibleComponent
47 typedef ::cppu::ImplHelper1
<
48 css::lang::XServiceInfo
> VCLXAccessibleComponent_BASE
;
50 class TOOLKIT_DLLPUBLIC VCLXAccessibleComponent
51 :public comphelper::OAccessibleExtendedComponentHelper
52 ,public ::comphelper::OAccessibleImplementationAccess
53 ,public VCLXAccessibleComponent_BASE
56 rtl::Reference
<VCLXWindow
> m_xVCLXWindow
;
57 VclPtr
<vcl::Window
> m_xEventSource
;
59 DECL_LINK( WindowEventListener
, VclWindowEvent
&, void );
60 DECL_LINK( WindowChildEventListener
, VclWindowEvent
&, void );
61 void DisconnectEvents();
64 virtual void ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
);
65 virtual void ProcessWindowChildEvent( const VclWindowEvent
& rVclWindowEvent
);
66 virtual void FillAccessibleRelationSet( utl::AccessibleRelationSetHelper
& rRelationSet
);
67 virtual void FillAccessibleStateSet( utl::AccessibleStateSetHelper
& rStateSet
);
69 virtual css::uno::Reference
< css::accessibility::XAccessible
> GetChildAccessible( const VclWindowEvent
& rVclWindowEvent
);
72 VCLXAccessibleComponent( VCLXWindow
* pVCLXWindow
);
73 virtual ~VCLXAccessibleComponent() override
;
75 VCLXWindow
* GetVCLXWindow() const;
76 VclPtr
<vcl::Window
> GetWindow() const;
77 template< class derived_type
> VclPtr
< derived_type
> GetAs() const {
78 return VclPtr
< derived_type
>( static_cast< derived_type
* >( GetWindow().get() ) ); }
79 template< class derived_type
> VclPtr
< derived_type
> GetAsDynamic() const {
80 return VclPtr
< derived_type
>( dynamic_cast< derived_type
* >( GetWindow().get() ) ); }
82 virtual void SAL_CALL
disposing() override
;
84 // css::uno::XInterface
86 // css::lang::XTypeProvider
87 DECLARE_XTYPEPROVIDER()
90 virtual OUString SAL_CALL
getImplementationName() override
;
91 virtual sal_Bool SAL_CALL
supportsService( const OUString
& rServiceName
) override
;
92 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
94 // css::accessibility::XAccessibleContext
95 sal_Int32 SAL_CALL
getAccessibleChildCount( ) override
;
96 css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleChild( sal_Int32 i
) override
;
97 css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleParent( ) override
;
98 sal_Int32 SAL_CALL
getAccessibleIndexInParent( ) override
;
99 sal_Int16 SAL_CALL
getAccessibleRole( ) override
;
100 OUString SAL_CALL
getAccessibleDescription( ) override
;
101 OUString SAL_CALL
getAccessibleName( ) override
;
102 OUString SAL_CALL
getAccessibleId( ) override
;
103 css::uno::Reference
< css::accessibility::XAccessibleRelationSet
> SAL_CALL
getAccessibleRelationSet( ) override
;
104 css::uno::Reference
< css::accessibility::XAccessibleStateSet
> SAL_CALL
getAccessibleStateSet( ) override
;
105 css::lang::Locale SAL_CALL
getLocale( ) override
;
107 // css::accessibility::XAccessibleComponent
108 css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleAtPoint( const css::awt::Point
& aPoint
) override
;
109 css::awt::Point SAL_CALL
getLocationOnScreen( ) override
;
110 void SAL_CALL
grabFocus( ) override
;
111 virtual sal_Int32 SAL_CALL
getForeground( ) override
;
112 virtual sal_Int32 SAL_CALL
getBackground( ) override
;
114 // css::accessibility::XAccessibleExtendedComponent
115 virtual css::uno::Reference
< css::awt::XFont
> SAL_CALL
getFont( ) override
;
116 virtual OUString SAL_CALL
getTitledBorderText( ) override
;
117 virtual OUString SAL_CALL
getToolTipText( ) override
;
120 // base class overridables
121 css::awt::Rectangle
implGetBounds( ) override
;
124 /** we may be reparented (if external components use OAccessibleImplementationAccess base class),
125 so this method here returns the parent in the VCL world, in opposite to the parent
126 an external component gave us
128 the caller must ensure thread safety, i.e. our mutex must be locked
130 css::uno::Reference
< css::accessibility::XAccessible
>
131 getVclParent() const;
134 /* ----------------------------------------------------------
135 Accessibility only for the Window hierarchy!
136 Maybe derived classes must overwrite these Accessibility interfaces:
138 // XAccessibleContext:
139 sal_Int16 getAccessibleRole() => VCL Window::GetAccessibleRole()
140 OUString getAccessibleDescription() => VCL Window::GetAccessibleDescription
141 OUString getAccessibleName() => VCL Window::GetAccessibleText() => Most windows return Window::GetText()
142 OUString getAccessibleId() => VCL Window::get_id()
143 Reference< XAccessibleRelationSet > getAccessibleRelationSet()
144 Reference< XAccessibleStateSet > getAccessibleStateSet() => override FillAccessibleStateSet( ... )
146 ---------------------------------------------------------- */
149 #endif // INCLUDED_TOOLKIT_AWT_VCLXACCESSIBLECOMPONENT_HXX
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */