Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_SVX_ACCESSIBLECONTROLSHAPE_HXX
21 : #define INCLUDED_SVX_ACCESSIBLECONTROLSHAPE_HXX
22 :
23 : #include <svx/AccessibleShape.hxx>
24 :
25 : #include <com/sun/star/accessibility/XAccessibleAction.hpp>
26 : #include <com/sun/star/accessibility/XAccessibleEventListener.hpp>
27 : #include <com/sun/star/util/XModeChangeBroadcaster.hpp>
28 : #include <com/sun/star/container/XContainerListener.hpp>
29 : #include <cppuhelper/implbase3.hxx>
30 : #include <comphelper/uno3.hxx>
31 :
32 : namespace com { namespace sun { namespace star { namespace awt {
33 : class XControl;
34 : } } } }
35 :
36 : namespace comphelper
37 : {
38 : class OWrappedAccessibleChildrenManager;
39 : }
40 :
41 : class SdrObject;
42 : namespace accessibility {
43 :
44 : typedef ::cppu::ImplHelper4 < ::com::sun::star::beans::XPropertyChangeListener
45 : , ::com::sun::star::util::XModeChangeListener
46 : , ::com::sun::star::container::XContainerListener
47 : , ::com::sun::star::accessibility::XAccessibleEventListener
48 : > AccessibleControlShape_Base;
49 : /** @descr
50 : */
51 : class AccessibleControlShape
52 : :public AccessibleShape
53 : ,public AccessibleControlShape_Base
54 : {
55 : public:
56 : //===== internal ========================================================
57 : AccessibleControlShape(
58 : const AccessibleShapeInfo& rShapeInfo,
59 : const AccessibleShapeTreeInfo& rShapeTreeInfo);
60 : virtual ~AccessibleControlShape( );
61 :
62 0 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL GetControlModel( ) { return m_xControlModel;} ;
63 : AccessibleControlShape* SAL_CALL GetLabeledByControlShape();
64 : protected:
65 : //--- XAccessible ----------------------------------------
66 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext> SAL_CALL getAccessibleContext( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
67 :
68 : //--- XAccessibleComponent -------------------------------
69 : /// forward the focus to the contained control(in alive mode)
70 : virtual void SAL_CALL grabFocus( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
71 :
72 : //--- XAccessibleContext ---------------------------------
73 : virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
74 : 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;
75 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
76 :
77 : //--- XServiceInfo ---------------------------------------
78 : virtual OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
79 :
80 : //--- XInterface -----------------------------------------
81 : DECLARE_XINTERFACE( )
82 :
83 : //--- XTypeProvider --------------------------------------
84 : DECLARE_XTYPEPROVIDER( )
85 :
86 : //--- XPropertyChangeListener ----------------------------
87 : virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
88 :
89 : //--- XComponent -----------------------------------------
90 : virtual void SAL_CALL disposing( ) SAL_OVERRIDE;
91 :
92 : //--- XEventListener -------------------------------------
93 : virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
94 :
95 : //--- XModeChangeListener --------------------------------
96 : virtual void SAL_CALL modeChanged( const ::com::sun::star::util::ModeChangeEvent& _rSource ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
97 :
98 : //--- XAccessibleEventListener ----------------------------
99 : virtual void SAL_CALL notifyEvent( const ::com::sun::star::accessibility::AccessibleEventObject& aEvent ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
100 :
101 : //--- document::XEventListener ----------------------------
102 : using AccessibleShape::notifyEvent;
103 :
104 : // XVclContainerListener
105 : virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
106 : virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
107 : virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
108 :
109 : protected:
110 : /** Initialize a new shape. See the documentation of the base' constructor
111 : for the reason of this method's existence.
112 : */
113 : virtual void Init( ) SAL_OVERRIDE;
114 :
115 : /// Create a name string that contains the accessible name.
116 : virtual OUString
117 : CreateAccessibleBaseName( )
118 : throw(::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
119 :
120 : /** Create a unique name string that contains the accessible name. The
121 : name consists of the base name and the index.
122 : */
123 : virtual OUString
124 : CreateAccessibleName( )
125 : throw(::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
126 :
127 : /// Create a description string that contains the accessible description.
128 : virtual OUString
129 : CreateAccessibleDescription( )
130 : throw(::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
131 :
132 : #ifdef DBG_UTIL
133 : /// Set the specified state
134 : virtual bool SetState( sal_Int16 _nState ) SAL_OVERRIDE;
135 : #endif // DBG_UTIL
136 :
137 : /// (safely) reads the given property from the model of the UNO control
138 : OUString getControlModelStringProperty( const OUString& _rPropertyName ) const;
139 :
140 : /// ensure that our control model exists(will be retrieved upon need only)
141 : bool ensureControlModelAccess( );
142 :
143 : /// ensures that we're listening for the given property if(and only if!) necessary
144 : bool ensureListeningState( const bool _bCurrentlyListening, const bool _bNeedNewListening,
145 : const OUString& _rPropertyName );
146 :
147 : /// starts multiplexing the state changes of our aggregate context
148 : void startStateMultiplexing( );
149 : /// stops multiplexing the state changes of our aggregate context
150 : void stopStateMultiplexing( );
151 :
152 : /// retrieves the SdrObject of the shape we represent
153 : SdrObject* getSdrObject( ) const;
154 :
155 : /** adjusts our AccessibleRole, depending on the control type we're working for
156 :
157 : <p>Only to be called during inituialization</p>
158 : */
159 : void adjustAccessibleRole( );
160 :
161 : /** initializes composed states of the context
162 :
163 : <p>Some of the states of our inner context need to be propagated to the "composed context", too
164 : (such as "checked" for check boxes). At lifetime, this is done by multiplexing state changes,
165 : at initialization time, this method is used.</p>
166 : */
167 : void initializeComposedState( );
168 :
169 : private:
170 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
171 : m_xControlModel;
172 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
173 : m_xModelPropsMeta; // cache this for performance reasons
174 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >
175 : m_xUnoControl; // our UNO control
176 :
177 : ::com::sun::star::uno::WeakReference< ::com::sun::star::accessibility::XAccessibleContext >
178 : m_aControlContext; // the AccessibleContext of the control
179 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation >
180 : m_xControlContextProxy; // the proxy for "aggregating" the AccessibleContext of the control
181 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XTypeProvider >
182 : m_xControlContextTypeAccess; // cached interface of our aggregate
183 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
184 : m_xControlContextComponent; // cached interface of our aggregate
185 :
186 : ::comphelper::OWrappedAccessibleChildrenManager*
187 : m_pChildManager;
188 :
189 : bool m_bListeningForName : 1; // are we currently listening for changes of the "Name" property?
190 : bool m_bListeningForDesc : 1; // are we currently listening for changes of the "HelpText" property?
191 : bool m_bMultiplexingStates : 1; // are we currently multiplexing state changes of the native context?
192 : bool m_bDisposeNativeContext : 1; // do we need to dispose mxNativeContextComponent?
193 : bool m_bWaitingForControl : 1; // if we are created before our control exists, we need to wait for it to appear ...
194 :
195 : private:
196 : /** Don't use the default constructor. Use the public constructor that
197 : takes the original shape and the parent as arguments instead.
198 : */
199 : AccessibleControlShape( );
200 :
201 : /// Don't use the constructor. not implemented.
202 : AccessibleControlShape(const AccessibleControlShape&);
203 :
204 : /// Don't use the assignment operator. not implemented.
205 : AccessibleControlShape& operator= (const AccessibleControlShape&);
206 : };
207 :
208 : } // end of namespace accessibility
209 :
210 : #endif
211 :
212 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|