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 .
22 #include <comphelper/accessiblecomponenthelper.hxx>
23 #include <com/sun/star/lang/XEventListener.hpp>
24 #include <cppuhelper/implbase.hxx>
25 #include <rtl/ref.hxx>
27 namespace vcl
{ class Window
; }
28 namespace com::sun::star::awt
{ class XWindow
; }
29 namespace com::sun::star::beans
{ class XPropertySet
; }
30 namespace com::sun::star::beans
{ class XPropertySetInfo
; }
36 //= OAccessibleControlContext
39 typedef ::comphelper::OAccessibleComponentHelper OAccessibleControlContext_Base
;
41 /** class implementing the AccessibleContext for a UNO control - to be used in design mode of the control.
42 <p><b>life time control<b/><br/>
43 This control should be held weak by the creator (a UNO control), it itself holds a hard reference to the
44 control model, and a weak reference to the control. The reference to the model is freed when the model
45 is being disposed.</p>
47 class OAccessibleControlContext final
48 :public cppu::ImplInheritanceHelper
<
49 OAccessibleControlContext_Base
, css::lang::XEventListener
>
52 /** creates an accessible context for a uno control
54 the uno control's XAccessible interface. This must be an XControl, from which an XControlModel
57 static rtl::Reference
<OAccessibleControlContext
> create(
58 const css::uno::Reference
< css::accessibility::XAccessible
>& _rxCreator
64 virtual sal_Int64 SAL_CALL
getAccessibleChildCount( ) override
;
65 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleChild( sal_Int64 i
) override
;
66 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleParent( ) override
;
67 virtual sal_Int16 SAL_CALL
getAccessibleRole( ) override
;
68 virtual OUString SAL_CALL
getAccessibleDescription( ) override
;
69 virtual OUString SAL_CALL
getAccessibleName( ) override
;
70 virtual css::uno::Reference
< css::accessibility::XAccessibleRelationSet
> SAL_CALL
getAccessibleRelationSet( ) override
;
71 virtual sal_Int64 SAL_CALL
getAccessibleStateSet( ) override
;
73 // XAccessibleComponent
74 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleAtPoint( const css::awt::Point
& aPoint
) override
;
75 virtual void SAL_CALL
grabFocus( ) override
;
76 virtual sal_Int32 SAL_CALL
getForeground( ) override
;
77 virtual sal_Int32 SAL_CALL
getBackground( ) override
;
80 using comphelper::OCommonAccessibleComponent::disposing
;
81 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
83 // retrieves the value of a string property from the model, if the property is present
84 OUString
getModelStringProperty( const char* _pPropertyName
);
86 // starts listening at the control model (currently for disposal only)
87 void startModelListening( );
88 // stops listening at the control model
89 void stopModelListening( );
91 vcl::Window
* implGetWindow( css::uno::Reference
< css::awt::XWindow
>* _pxUNOWindow
= nullptr ) const;
94 OAccessibleControlContext();
95 virtual ~OAccessibleControlContext() override
;
100 const css::uno::Reference
< css::accessibility::XAccessible
>& _rxCreator
103 // OCommonAccessibleComponent overridables
104 virtual css::awt::Rectangle
implGetBounds( ) override
;
106 css::uno::Reference
< css::beans::XPropertySet
>
107 m_xControlModel
; // the model of the control which's context we implement
108 css::uno::Reference
< css::beans::XPropertySetInfo
>
109 m_xModelPropsInfo
; // the cached property set info of the model
113 } // namespace toolkit
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */