Branch libreoffice-5-0-4
[LibreOffice.git] / include / toolkit / controls / accessiblecontrolcontext.hxx
blobb991b80793f32f41b35dd4f2f7c2f516254b643c
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_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 <com/sun/star/beans/XPropertySet.hpp>
28 #include <com/sun/star/awt/XWindow.hpp>
29 #include <vcl/vclptr.hxx>
31 namespace vcl { class Window; }
33 namespace toolkit
38 //= OAccessibleControlContext
41 typedef ::comphelper::OAccessibleComponentHelper OAccessibleControlContext_Base;
42 typedef ::cppu::ImplHelper1 < ::com::sun::star::lang::XEventListener
43 > OAccessibleControlContext_IBase;
45 /** class implementing the AccessibleContext for an 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 (an 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
52 :public ::comphelper::OAccessibleImplementationAccess
53 ,public OAccessibleControlContext_Base
54 ,public OAccessibleControlContext_IBase
56 private:
57 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
58 m_xControlModel; // the model of the control which's context we implement
59 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
60 m_xModelPropsInfo; // the cached property set info of the model
62 protected:
63 /// ctor. @see Init
64 OAccessibleControlContext();
65 virtual ~OAccessibleControlContext();
67 /** late ctor
69 void Init(
70 const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxCreator
73 // OCommonAccessibleComponent overridables
74 virtual ::com::sun::star::awt::Rectangle implGetBounds( ) throw (::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
76 public:
77 /** creates an accessible context for an uno control
78 @param _rxCreator
79 the uno control's XAccessible interface. This must be an XControl, from which an XControlModel
80 can be retrieved.
82 static OAccessibleControlContext* create(
83 const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxCreator
86 protected:
87 // XInterface
88 DECLARE_XINTERFACE( )
89 DECLARE_XTYPEPROVIDER( )
91 // XAccessibleContext
92 virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
93 virtual ::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;
94 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
95 virtual sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
96 virtual OUString SAL_CALL getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
97 virtual OUString SAL_CALL getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
98 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
99 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
101 // XAccessibleComponent
102 virtual ::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;
103 virtual void SAL_CALL grabFocus( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
104 virtual sal_Int32 SAL_CALL getForeground( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
105 virtual sal_Int32 SAL_CALL getBackground( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
107 // XEventListener
108 using comphelper::OAccessibleContextHelper::disposing;
109 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
111 private:
112 // retrieves the value of a string property from the model, if the property is present
113 OUString getModelStringProperty( const sal_Char* _pPropertyName );
115 // starts listening at the control model (currently for disposal only)
116 void startModelListening( );
117 // stops listening at the control model
118 void stopModelListening( );
120 VclPtr< vcl::Window > implGetWindow( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >* _pxUNOWindow = NULL ) const;
124 } // namespace toolkit
127 #endif // INCLUDED_TOOLKIT_CONTROLS_ACCESSIBLECONTROLCONTEXT_HXX
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */