add some protocols that don't make sense as floating frame targets
[LibreOffice.git] / include / svx / AccessibleControlShape.hxx
bloba90ab5ee9f277add5417767579f71c756615614b
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_SVX_ACCESSIBLECONTROLSHAPE_HXX
21 #define INCLUDED_SVX_ACCESSIBLECONTROLSHAPE_HXX
23 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
24 #include <com/sun/star/container/XContainerListener.hpp>
25 #include <com/sun/star/lang/EventObject.hpp>
26 #include <com/sun/star/uno/Reference.hxx>
27 #include <com/sun/star/util/XModeChangeListener.hpp>
28 #include <comphelper/uno3.hxx>
29 #include <cppuhelper/implbase4.hxx>
30 #include <cppuhelper/weakref.hxx>
31 #include <rtl/ref.hxx>
32 #include <rtl/ustring.hxx>
33 #include <sal/types.h>
34 #include <svx/AccessibleShape.hxx>
36 namespace com::sun::star {
37 namespace accessibility { class XAccessible; }
38 namespace accessibility { class XAccessibleContext; }
39 namespace accessibility { struct AccessibleEventObject; }
40 namespace accessibility { class XAccessibleRelationSet; }
41 namespace awt { class XControl; }
42 namespace beans { class XPropertySet; }
43 namespace beans { class XPropertySetInfo; }
44 namespace beans { struct PropertyChangeEvent; }
45 namespace container { struct ContainerEvent; }
46 namespace lang { class XComponent; }
47 namespace lang { class XTypeProvider; }
48 namespace uno { class XAggregation; }
49 namespace util { struct ModeChangeEvent; }
52 namespace comphelper
54 class OWrappedAccessibleChildrenManager;
57 namespace accessibility {
59 class AccessibleShapeInfo;
60 class AccessibleShapeTreeInfo;
62 typedef ::cppu::ImplHelper4 < css::beans::XPropertyChangeListener
63 , css::util::XModeChangeListener
64 , css::container::XContainerListener
65 , css::accessibility::XAccessibleEventListener
66 > AccessibleControlShape_Base;
67 /** @descr
69 class SAL_DLLPUBLIC_RTTI AccessibleControlShape final
70 :public AccessibleShape
71 ,public AccessibleControlShape_Base
73 public:
74 //===== internal ========================================================
75 AccessibleControlShape(
76 const AccessibleShapeInfo& rShapeInfo,
77 const AccessibleShapeTreeInfo& rShapeTreeInfo);
78 virtual ~AccessibleControlShape( ) override;
80 const css::uno::Reference< css::beans::XPropertySet >& GetControlModel( ) const { return m_xControlModel;}
81 AccessibleControlShape* GetLabeledByControlShape();
83 private:
84 //--- XAccessibleComponent -------------------------------
85 /// forward the focus to the contained control(in alive mode)
86 virtual void SAL_CALL grabFocus( ) override;
88 //--- XAccessibleContext ---------------------------------
89 virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) override;
90 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) override;
91 virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override;
93 //--- XServiceInfo ---------------------------------------
94 virtual OUString SAL_CALL getImplementationName( ) override;
96 //--- XInterface -----------------------------------------
97 DECLARE_XINTERFACE( )
99 //--- XTypeProvider --------------------------------------
100 DECLARE_XTYPEPROVIDER( )
102 //--- XPropertyChangeListener ----------------------------
103 virtual void SAL_CALL propertyChange( const css::beans::PropertyChangeEvent& _rEvent ) override;
105 //--- XComponent -----------------------------------------
106 virtual void SAL_CALL disposing( ) override;
108 //--- XEventListener -------------------------------------
109 virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override;
111 //--- XModeChangeListener --------------------------------
112 virtual void SAL_CALL modeChanged( const css::util::ModeChangeEvent& _rSource ) override;
114 //--- XAccessibleEventListener ----------------------------
115 virtual void SAL_CALL notifyEvent( const css::accessibility::AccessibleEventObject& aEvent ) override;
117 // XVclContainerListener
118 virtual void SAL_CALL elementInserted( const css::container::ContainerEvent& Event ) override;
119 virtual void SAL_CALL elementRemoved( const css::container::ContainerEvent& Event ) override;
120 virtual void SAL_CALL elementReplaced( const css::container::ContainerEvent& Event ) override;
122 /** Initialize a new shape. See the documentation of the base' constructor
123 for the reason of this method's existence.
125 virtual void Init( ) override;
127 /// Create a name string that contains the accessible name.
128 virtual OUString
129 CreateAccessibleBaseName( ) override;
131 /** Create a unique name string that contains the accessible name. The
132 name consists of the base name and the index.
134 virtual OUString
135 CreateAccessibleName( ) override;
137 /// Create a description string that contains the accessible description.
138 OUString CreateAccessibleDescription();
140 #ifdef DBG_UTIL
141 /// Set the specified state
142 virtual bool SetState( sal_Int16 _nState ) override;
143 #endif // DBG_UTIL
145 /// (safely) reads the given property from the model of the UNO control
146 OUString getControlModelStringProperty( const OUString& _rPropertyName ) const;
148 /// ensure that our control model exists(will be retrieved upon need only)
149 bool ensureControlModelAccess( );
151 /// ensures that we're listening for the given property if(and only if!) necessary
152 bool ensureListeningState( const bool _bCurrentlyListening, const bool _bNeedNewListening,
153 const OUString& _rPropertyName );
155 /// starts multiplexing the state changes of our aggregate context
156 void startStateMultiplexing( );
157 /// stops multiplexing the state changes of our aggregate context
158 void stopStateMultiplexing( );
160 /** adjusts our AccessibleRole, depending on the control type we're working for
162 <p>Only to be called during initialization</p>
164 void adjustAccessibleRole( );
166 /** initializes composed states of the context
168 <p>Some of the states of our inner context need to be propagated to the "composed context", too
169 (such as "checked" for check boxes). At lifetime, this is done by multiplexing state changes,
170 at initialization time, this method is used.</p>
172 void initializeComposedState( );
174 AccessibleControlShape(const AccessibleControlShape&) = delete;
175 AccessibleControlShape& operator= (const AccessibleControlShape&) = delete;
177 css::uno::Reference< css::beans::XPropertySet >
178 m_xControlModel;
179 css::uno::Reference< css::beans::XPropertySetInfo >
180 m_xModelPropsMeta; // cache this for performance reasons
181 css::uno::Reference< css::awt::XControl >
182 m_xUnoControl; // our UNO control
184 css::uno::WeakReference< css::accessibility::XAccessibleContext >
185 m_aControlContext; // the AccessibleContext of the control
186 css::uno::Reference< css::uno::XAggregation >
187 m_xControlContextProxy; // the proxy for "aggregating" the AccessibleContext of the control
188 css::uno::Reference< css::lang::XTypeProvider >
189 m_xControlContextTypeAccess; // cached interface of our aggregate
190 css::uno::Reference< css::lang::XComponent >
191 m_xControlContextComponent; // cached interface of our aggregate
193 rtl::Reference<::comphelper::OWrappedAccessibleChildrenManager>
194 m_pChildManager;
196 bool m_bListeningForName : 1; // are we currently listening for changes of the "Name" property?
197 bool m_bListeningForDesc : 1; // are we currently listening for changes of the "HelpText" property?
198 bool m_bMultiplexingStates : 1; // are we currently multiplexing state changes of the native context?
199 bool m_bDisposeNativeContext : 1; // do we need to dispose mxNativeContextComponent?
200 bool m_bWaitingForControl : 1; // if we are created before our control exists, we need to wait for it to appear ...
203 } // end of namespace accessibility
205 #endif
207 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */