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_CONTROLS_ACCESSIBLECONTROLCONTEXT_HXX
21 #define INCLUDED_TOOLKIT_CONTROLS_ACCESSIBLECONTROLCONTEXT_HXX
23 #include <comphelper/accessiblecomponenthelper.hxx>
24 #include <comphelper/accimplaccess.hxx>
25 #include <comphelper/uno3.hxx>
26 #include <com/sun/star/lang/XEventListener.hpp>
27 #include <vcl/vclptr.hxx>
29 namespace vcl
{ class Window
; }
30 namespace com
{ namespace sun
{ namespace star
{ namespace awt
{ class XWindow
; } } } }
31 namespace com
{ namespace sun
{ namespace star
{ namespace beans
{ class XPropertySet
; } } } }
32 namespace com
{ namespace sun
{ namespace star
{ namespace beans
{ class XPropertySetInfo
; } } } }
38 //= OAccessibleControlContext
41 typedef ::comphelper::OAccessibleComponentHelper OAccessibleControlContext_Base
;
42 typedef ::cppu::ImplHelper1
< css::lang::XEventListener
43 > OAccessibleControlContext_IBase
;
45 /** class implementing the AccessibleContext for a UNO control - to be used in design mode of the control.
46 <p><b>life time control<b/><br/>
47 This control should be held weak by the creator (a UNO control), it itself holds a hard reference to the
48 control model, and a weak reference to the control. The reference to the model is freed when the model
49 is being disposed.</p>
51 class OAccessibleControlContext final
52 :public ::comphelper::OAccessibleImplementationAccess
53 ,public OAccessibleControlContext_Base
54 ,public OAccessibleControlContext_IBase
57 /** creates an accessible context for a uno control
59 the uno control's XAccessible interface. This must be an XControl, from which an XControlModel
62 static OAccessibleControlContext
* create(
63 const css::uno::Reference
< css::accessibility::XAccessible
>& _rxCreator
69 DECLARE_XTYPEPROVIDER( )
72 virtual sal_Int32 SAL_CALL
getAccessibleChildCount( ) override
;
73 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleChild( sal_Int32 i
) override
;
74 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleParent( ) override
;
75 virtual sal_Int16 SAL_CALL
getAccessibleRole( ) override
;
76 virtual OUString SAL_CALL
getAccessibleDescription( ) override
;
77 virtual OUString SAL_CALL
getAccessibleName( ) override
;
78 virtual css::uno::Reference
< css::accessibility::XAccessibleRelationSet
> SAL_CALL
getAccessibleRelationSet( ) override
;
79 virtual css::uno::Reference
< css::accessibility::XAccessibleStateSet
> SAL_CALL
getAccessibleStateSet( ) override
;
81 // XAccessibleComponent
82 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleAtPoint( const css::awt::Point
& aPoint
) override
;
83 virtual void SAL_CALL
grabFocus( ) override
;
84 virtual sal_Int32 SAL_CALL
getForeground( ) override
;
85 virtual sal_Int32 SAL_CALL
getBackground( ) override
;
88 using comphelper::OAccessibleContextHelper::disposing
;
89 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
91 // retrieves the value of a string property from the model, if the property is present
92 OUString
getModelStringProperty( const sal_Char
* _pPropertyName
);
94 // starts listening at the control model (currently for disposal only)
95 void startModelListening( );
96 // stops listening at the control model
97 void stopModelListening( );
99 VclPtr
< vcl::Window
> implGetWindow( css::uno::Reference
< css::awt::XWindow
>* _pxUNOWindow
= nullptr ) const;
102 OAccessibleControlContext();
103 virtual ~OAccessibleControlContext() override
;
108 const css::uno::Reference
< css::accessibility::XAccessible
>& _rxCreator
111 // OCommonAccessibleComponent overridables
112 virtual css::awt::Rectangle
implGetBounds( ) override
;
114 css::uno::Reference
< css::beans::XPropertySet
>
115 m_xControlModel
; // the model of the control which's context we implement
116 css::uno::Reference
< css::beans::XPropertySetInfo
>
117 m_xModelPropsInfo
; // the cached property set info of the model
121 } // namespace toolkit
124 #endif // INCLUDED_TOOLKIT_CONTROLS_ACCESSIBLECONTROLCONTEXT_HXX
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */