xref: /trunk/main/toolkit/source/controls/accessiblecontrolcontext.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_toolkit.hxx"
30*cdf0e10cSrcweir #include <toolkit/controls/accessiblecontrolcontext.hxx>
31*cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx>
32*cdf0e10cSrcweir #include <com/sun/star/awt/XControl.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
34*cdf0e10cSrcweir #include <vcl/svapp.hxx>
35*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp>
37*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
38*cdf0e10cSrcweir #include <vcl/window.hxx>
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir //........................................................................
41*cdf0e10cSrcweir namespace toolkit
42*cdf0e10cSrcweir {
43*cdf0e10cSrcweir //........................................................................
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir     using ::comphelper::OContextEntryGuard;
46*cdf0e10cSrcweir     using namespace ::com::sun::star;
47*cdf0e10cSrcweir     using namespace ::com::sun::star::uno;
48*cdf0e10cSrcweir     using namespace ::com::sun::star::lang;
49*cdf0e10cSrcweir     using namespace ::com::sun::star::beans;
50*cdf0e10cSrcweir     using namespace ::com::sun::star::accessibility;
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir     //====================================================================
53*cdf0e10cSrcweir     //= OAccessibleControlContext
54*cdf0e10cSrcweir     //====================================================================
55*cdf0e10cSrcweir     //--------------------------------------------------------------------
56*cdf0e10cSrcweir     OAccessibleControlContext::OAccessibleControlContext()
57*cdf0e10cSrcweir         :OAccessibleControlContext_Base( )
58*cdf0e10cSrcweir     {
59*cdf0e10cSrcweir         // nothing to do here, we have a late ctor
60*cdf0e10cSrcweir     }
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir     //--------------------------------------------------------------------
63*cdf0e10cSrcweir     OAccessibleControlContext::~OAccessibleControlContext()
64*cdf0e10cSrcweir     {
65*cdf0e10cSrcweir         ensureDisposed();
66*cdf0e10cSrcweir     }
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir     //--------------------------------------------------------------------
69*cdf0e10cSrcweir     IMPLEMENT_FORWARD_XINTERFACE3( OAccessibleControlContext, OAccessibleControlContext_Base, OAccessibleImplementationAccess, OAccessibleControlContext_IBase )
70*cdf0e10cSrcweir     IMPLEMENT_FORWARD_XTYPEPROVIDER3( OAccessibleControlContext, OAccessibleControlContext_Base, OAccessibleImplementationAccess, OAccessibleControlContext_IBase )
71*cdf0e10cSrcweir         // (order matters: the first is the class name, the second is the class doing the ref counting)
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir     //--------------------------------------------------------------------
74*cdf0e10cSrcweir     void OAccessibleControlContext::Init( const Reference< XAccessible >& _rxCreator ) SAL_THROW( ( Exception ) )
75*cdf0e10cSrcweir     {
76*cdf0e10cSrcweir         OContextEntryGuard aGuard( this );
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir         // retrieve the model of the control
79*cdf0e10cSrcweir         OSL_ENSURE( !m_xControlModel.is(), "OAccessibleControlContext::Init: already know a control model....!???" );
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir         Reference< awt::XControl > xControl( _rxCreator, UNO_QUERY );
82*cdf0e10cSrcweir         if ( xControl.is() )
83*cdf0e10cSrcweir             m_xControlModel = m_xControlModel.query( xControl->getModel() );
84*cdf0e10cSrcweir         OSL_ENSURE( m_xControlModel.is(), "OAccessibleControlContext::Init: invalid creator (no control, or control without model!" );
85*cdf0e10cSrcweir         if ( !m_xControlModel.is() )
86*cdf0e10cSrcweir             throw DisposedException();  // caught by the caller (the create method)
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir         // start listening at the model
89*cdf0e10cSrcweir         startModelListening();
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir         // announce the XAccessible to our base class
92*cdf0e10cSrcweir         OAccessibleControlContext_Base::lateInit( _rxCreator );
93*cdf0e10cSrcweir     }
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir     //--------------------------------------------------------------------
96*cdf0e10cSrcweir     OAccessibleControlContext* OAccessibleControlContext::create( const Reference< XAccessible >& _rxCreator ) SAL_THROW( ( ) )
97*cdf0e10cSrcweir     {
98*cdf0e10cSrcweir         OAccessibleControlContext* pNew = NULL;
99*cdf0e10cSrcweir         try
100*cdf0e10cSrcweir         {
101*cdf0e10cSrcweir             pNew = new OAccessibleControlContext;
102*cdf0e10cSrcweir             pNew->Init( _rxCreator );
103*cdf0e10cSrcweir         }
104*cdf0e10cSrcweir         catch( const Exception& )
105*cdf0e10cSrcweir         {
106*cdf0e10cSrcweir             OSL_ENSURE( sal_False, "OAccessibleControlContext::create: caught an exception from the late ctor!" );
107*cdf0e10cSrcweir         }
108*cdf0e10cSrcweir         return pNew;
109*cdf0e10cSrcweir     }
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir     //--------------------------------------------------------------------
112*cdf0e10cSrcweir     void OAccessibleControlContext::startModelListening( ) SAL_THROW( ( Exception ) )
113*cdf0e10cSrcweir     {
114*cdf0e10cSrcweir         Reference< XComponent > xModelComp( m_xControlModel, UNO_QUERY );
115*cdf0e10cSrcweir         OSL_ENSURE( xModelComp.is(), "OAccessibleControlContext::startModelListening: invalid model!" );
116*cdf0e10cSrcweir         if ( xModelComp.is() )
117*cdf0e10cSrcweir             xModelComp->addEventListener( this );
118*cdf0e10cSrcweir     }
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir     //--------------------------------------------------------------------
121*cdf0e10cSrcweir     void OAccessibleControlContext::stopModelListening( ) SAL_THROW( ( Exception ) )
122*cdf0e10cSrcweir     {
123*cdf0e10cSrcweir         Reference< XComponent > xModelComp( m_xControlModel, UNO_QUERY );
124*cdf0e10cSrcweir         OSL_ENSURE( xModelComp.is(), "OAccessibleControlContext::stopModelListening: invalid model!" );
125*cdf0e10cSrcweir         if ( xModelComp.is() )
126*cdf0e10cSrcweir             xModelComp->removeEventListener( this );
127*cdf0e10cSrcweir     }
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir     //--------------------------------------------------------------------
130*cdf0e10cSrcweir     sal_Int32 SAL_CALL OAccessibleControlContext::getAccessibleChildCount(  ) throw (RuntimeException)
131*cdf0e10cSrcweir     {
132*cdf0e10cSrcweir         // we do not have children
133*cdf0e10cSrcweir         return 0;
134*cdf0e10cSrcweir     }
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir     //--------------------------------------------------------------------
137*cdf0e10cSrcweir     Reference< XAccessible > SAL_CALL OAccessibleControlContext::getAccessibleChild( sal_Int32 ) throw (IndexOutOfBoundsException, RuntimeException)
138*cdf0e10cSrcweir     {
139*cdf0e10cSrcweir         // we do not have children
140*cdf0e10cSrcweir         throw IndexOutOfBoundsException();
141*cdf0e10cSrcweir     }
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir     //--------------------------------------------------------------------
144*cdf0e10cSrcweir     Reference< XAccessible > SAL_CALL OAccessibleControlContext::getAccessibleParent(  ) throw (RuntimeException)
145*cdf0e10cSrcweir     {
146*cdf0e10cSrcweir         OContextEntryGuard aGuard( this );
147*cdf0e10cSrcweir         OSL_ENSURE( implGetForeignControlledParent().is(), "OAccessibleControlContext::getAccessibleParent: somebody forgot to set a parent!" );
148*cdf0e10cSrcweir             // this parent of us is foreign controlled - somebody has to set it using the OAccessibleImplementationAccess
149*cdf0e10cSrcweir             // class, before integrating our instance into an AccessibleDocumentModel
150*cdf0e10cSrcweir         return implGetForeignControlledParent();
151*cdf0e10cSrcweir     }
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir     //--------------------------------------------------------------------
154*cdf0e10cSrcweir     sal_Int16 SAL_CALL OAccessibleControlContext::getAccessibleRole(  ) throw (RuntimeException)
155*cdf0e10cSrcweir     {
156*cdf0e10cSrcweir         return AccessibleRole::SHAPE;
157*cdf0e10cSrcweir     }
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir     //--------------------------------------------------------------------
160*cdf0e10cSrcweir     ::rtl::OUString SAL_CALL OAccessibleControlContext::getAccessibleDescription(  ) throw (RuntimeException)
161*cdf0e10cSrcweir     {
162*cdf0e10cSrcweir         OContextEntryGuard aGuard( this );
163*cdf0e10cSrcweir         return getModelStringProperty( "HelpText" );
164*cdf0e10cSrcweir     }
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir     //--------------------------------------------------------------------
167*cdf0e10cSrcweir     ::rtl::OUString SAL_CALL OAccessibleControlContext::getAccessibleName(  ) throw (RuntimeException)
168*cdf0e10cSrcweir     {
169*cdf0e10cSrcweir         OContextEntryGuard aGuard( this );
170*cdf0e10cSrcweir         return getModelStringProperty( "Name" );
171*cdf0e10cSrcweir     }
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir     //--------------------------------------------------------------------
174*cdf0e10cSrcweir     Reference< XAccessibleRelationSet > SAL_CALL OAccessibleControlContext::getAccessibleRelationSet(  ) throw (RuntimeException)
175*cdf0e10cSrcweir     {
176*cdf0e10cSrcweir         return NULL;
177*cdf0e10cSrcweir     }
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir     //--------------------------------------------------------------------
180*cdf0e10cSrcweir     Reference< XAccessibleStateSet > SAL_CALL OAccessibleControlContext::getAccessibleStateSet(  ) throw (RuntimeException)
181*cdf0e10cSrcweir     {
182*cdf0e10cSrcweir         ::osl::MutexGuard aGuard( GetMutex() );
183*cdf0e10cSrcweir             // no OContextEntryGuard here, as we do not want to throw an exception in case we're not alive anymore
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir         ::utl::AccessibleStateSetHelper* pStateSet = NULL;
186*cdf0e10cSrcweir         if ( isAlive() )
187*cdf0e10cSrcweir         {
188*cdf0e10cSrcweir             // no own states, only the ones which are foreign controlled
189*cdf0e10cSrcweir             pStateSet = new ::utl::AccessibleStateSetHelper( implGetForeignControlledStates() );
190*cdf0e10cSrcweir         }
191*cdf0e10cSrcweir         else
192*cdf0e10cSrcweir         {   // only the DEFUNC state if we're already disposed
193*cdf0e10cSrcweir             pStateSet = new ::utl::AccessibleStateSetHelper;
194*cdf0e10cSrcweir             pStateSet->AddState( AccessibleStateType::DEFUNC );
195*cdf0e10cSrcweir         }
196*cdf0e10cSrcweir         return pStateSet;
197*cdf0e10cSrcweir     }
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir     //--------------------------------------------------------------------
200*cdf0e10cSrcweir     void SAL_CALL OAccessibleControlContext::disposing( const EventObject&
201*cdf0e10cSrcweir     #if OSL_DEBUG_LEVEL > 0
202*cdf0e10cSrcweir     _rSource
203*cdf0e10cSrcweir     #endif
204*cdf0e10cSrcweir     ) throw ( RuntimeException )
205*cdf0e10cSrcweir     {
206*cdf0e10cSrcweir         OSL_ENSURE( Reference< XPropertySet >( _rSource.Source, UNO_QUERY ).get() == m_xControlModel.get(),
207*cdf0e10cSrcweir             "OAccessibleControlContext::disposing: where did this come from?" );
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir         stopModelListening( );
210*cdf0e10cSrcweir         m_xControlModel.clear();
211*cdf0e10cSrcweir         m_xModelPropsInfo.clear();
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir         OAccessibleControlContext_Base::disposing();
214*cdf0e10cSrcweir     }
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir     //--------------------------------------------------------------------
217*cdf0e10cSrcweir     ::rtl::OUString OAccessibleControlContext::getModelStringProperty( const sal_Char* _pPropertyName )
218*cdf0e10cSrcweir     {
219*cdf0e10cSrcweir         ::rtl::OUString sReturn;
220*cdf0e10cSrcweir         try
221*cdf0e10cSrcweir         {
222*cdf0e10cSrcweir             if ( !m_xModelPropsInfo.is() && m_xControlModel.is() )
223*cdf0e10cSrcweir                 m_xModelPropsInfo = m_xControlModel->getPropertySetInfo();
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir             ::rtl::OUString sPropertyName( ::rtl::OUString::createFromAscii( _pPropertyName ) );
226*cdf0e10cSrcweir             if ( m_xModelPropsInfo.is() && m_xModelPropsInfo->hasPropertyByName( sPropertyName ) )
227*cdf0e10cSrcweir                 m_xControlModel->getPropertyValue( sPropertyName ) >>= sReturn;
228*cdf0e10cSrcweir         }
229*cdf0e10cSrcweir         catch( const Exception& )
230*cdf0e10cSrcweir         {
231*cdf0e10cSrcweir             OSL_ENSURE( sal_False, "OAccessibleControlContext::getModelStringProperty: caught an exception!" );
232*cdf0e10cSrcweir         }
233*cdf0e10cSrcweir         return sReturn;
234*cdf0e10cSrcweir     }
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir     //--------------------------------------------------------------------
237*cdf0e10cSrcweir     Window* OAccessibleControlContext::implGetWindow( Reference< awt::XWindow >* _pxUNOWindow ) const
238*cdf0e10cSrcweir     {
239*cdf0e10cSrcweir         Reference< awt::XControl > xControl( getAccessibleCreator(), UNO_QUERY );
240*cdf0e10cSrcweir         Reference< awt::XWindow > xWindow;
241*cdf0e10cSrcweir         if ( xControl.is() )
242*cdf0e10cSrcweir             xWindow = xWindow.query( xControl->getPeer() );
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir         Window* pWindow = xWindow.is() ? VCLUnoHelper::GetWindow( xWindow ) : NULL;
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir         if ( _pxUNOWindow )
247*cdf0e10cSrcweir             *_pxUNOWindow = xWindow;
248*cdf0e10cSrcweir         return pWindow;
249*cdf0e10cSrcweir     }
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir     //--------------------------------------------------------------------
252*cdf0e10cSrcweir     awt::Rectangle SAL_CALL OAccessibleControlContext::implGetBounds(  ) throw (RuntimeException)
253*cdf0e10cSrcweir     {
254*cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
255*cdf0e10cSrcweir             // want to do some VCL stuff here ...
256*cdf0e10cSrcweir         OContextEntryGuard aGuard( this );
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir         OSL_ENSURE( sal_False, "OAccessibleControlContext::implGetBounds: performance issue: forced to calc the size myself!" );
259*cdf0e10cSrcweir         // In design mode (and this is what this class is for), the surrounding shape (if any) should handle this call
260*cdf0e10cSrcweir         // The problem is that in design mode, our size may not be correct (in the drawing layer, controls are
261*cdf0e10cSrcweir         // positioned/sized for painting only), and that calculation of our position is expensive
262*cdf0e10cSrcweir 
263*cdf0e10cSrcweir         // what we know (or can obtain from somewhere):
264*cdf0e10cSrcweir         // * the PosSize of our peer, relative to it's parent window
265*cdf0e10cSrcweir         // * the parent window which the PosSize is relative to
266*cdf0e10cSrcweir         // * our foreign controlled accessible parent
267*cdf0e10cSrcweir         // from this info, we can determine the the position of our peer relative to the foreign parent
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir         // our control
270*cdf0e10cSrcweir         Reference< awt::XWindow > xWindow;
271*cdf0e10cSrcweir         Window* pVCLWindow = implGetWindow( &xWindow );
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir         awt::Rectangle aBounds( 0, 0, 0, 0 );
274*cdf0e10cSrcweir         if ( xWindow.is() )
275*cdf0e10cSrcweir         {
276*cdf0e10cSrcweir             // ugly, but .... though the XWindow has a getPosSize, it is impossible to determine the
277*cdf0e10cSrcweir             // parent which this position/size is relative to. This means we must tunnel UNO and ask the
278*cdf0e10cSrcweir             // implementation
279*cdf0e10cSrcweir             Window* pVCLParent = pVCLWindow ? pVCLWindow->GetParent() : NULL;
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir             // the relative location of the window
282*cdf0e10cSrcweir             ::Point aWindowRelativePos( 0, 0);
283*cdf0e10cSrcweir             if ( pVCLWindow )
284*cdf0e10cSrcweir                 aWindowRelativePos = pVCLWindow->GetPosPixel();
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir             // the screnn position of the "window parent" of the control
287*cdf0e10cSrcweir             ::Point aVCLParentScreenPos( 0, 0 );
288*cdf0e10cSrcweir             if ( pVCLParent )
289*cdf0e10cSrcweir                 aVCLParentScreenPos = pVCLParent->GetPosPixel();
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir             // the screen position of the "accessible parent" of the control
292*cdf0e10cSrcweir             Reference< XAccessible > xParentAcc( implGetForeignControlledParent() );
293*cdf0e10cSrcweir             Reference< XAccessibleComponent > xParentAccComponent;
294*cdf0e10cSrcweir             if ( xParentAcc.is() )
295*cdf0e10cSrcweir                 xParentAccComponent = xParentAccComponent.query( xParentAcc->getAccessibleContext() );
296*cdf0e10cSrcweir             awt::Point aAccParentScreenPos( 0, 0 );
297*cdf0e10cSrcweir             if ( xParentAccComponent.is() )
298*cdf0e10cSrcweir                 aAccParentScreenPos = xParentAccComponent->getLocationOnScreen();
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir             // now the size of the control
301*cdf0e10cSrcweir             aBounds = xWindow->getPosSize();
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir             // correct the pos
304*cdf0e10cSrcweir             aBounds.X = aWindowRelativePos.X() + aVCLParentScreenPos.X() - aAccParentScreenPos.X;
305*cdf0e10cSrcweir             aBounds.Y = aWindowRelativePos.Y() + aVCLParentScreenPos.Y() - aAccParentScreenPos.Y;
306*cdf0e10cSrcweir         }
307*cdf0e10cSrcweir 
308*cdf0e10cSrcweir         return aBounds;
309*cdf0e10cSrcweir     }
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir     //--------------------------------------------------------------------
312*cdf0e10cSrcweir     Reference< XAccessible > SAL_CALL OAccessibleControlContext::getAccessibleAtPoint( const awt::Point& /* _rPoint */ ) throw (RuntimeException)
313*cdf0e10cSrcweir     {
314*cdf0e10cSrcweir         // no children at all
315*cdf0e10cSrcweir         return NULL;
316*cdf0e10cSrcweir     }
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir     //--------------------------------------------------------------------
319*cdf0e10cSrcweir     void SAL_CALL OAccessibleControlContext::grabFocus(  ) throw (RuntimeException)
320*cdf0e10cSrcweir     {
321*cdf0e10cSrcweir         OSL_ENSURE( sal_False, "OAccessibleControlContext::grabFocus: !isFocusTraversable, but grabFocus!" );
322*cdf0e10cSrcweir     }
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir     //--------------------------------------------------------------------
325*cdf0e10cSrcweir     Any SAL_CALL OAccessibleControlContext::getAccessibleKeyBinding(  ) throw (RuntimeException)
326*cdf0e10cSrcweir     {
327*cdf0e10cSrcweir         // we do not have any key bindings to activate a UNO control in design mode
328*cdf0e10cSrcweir         return Any();
329*cdf0e10cSrcweir     }
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir     //--------------------------------------------------------------------
332*cdf0e10cSrcweir     sal_Int32 SAL_CALL OAccessibleControlContext::getForeground(  ) throw (::com::sun::star::uno::RuntimeException)
333*cdf0e10cSrcweir     {
334*cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
335*cdf0e10cSrcweir             // want to do some VCL stuff here ...
336*cdf0e10cSrcweir         OContextEntryGuard aGuard( this );
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir         Window* pWindow = implGetWindow( );
339*cdf0e10cSrcweir         sal_Int32 nColor = 0;
340*cdf0e10cSrcweir         if ( pWindow )
341*cdf0e10cSrcweir         {
342*cdf0e10cSrcweir             if ( pWindow->IsControlForeground() )
343*cdf0e10cSrcweir                 nColor = pWindow->GetControlForeground().GetColor();
344*cdf0e10cSrcweir             else
345*cdf0e10cSrcweir             {
346*cdf0e10cSrcweir                 Font aFont;
347*cdf0e10cSrcweir                 if ( pWindow->IsControlFont() )
348*cdf0e10cSrcweir                     aFont = pWindow->GetControlFont();
349*cdf0e10cSrcweir                 else
350*cdf0e10cSrcweir                     aFont = pWindow->GetFont();
351*cdf0e10cSrcweir                 nColor = aFont.GetColor().GetColor();
352*cdf0e10cSrcweir             }
353*cdf0e10cSrcweir         }
354*cdf0e10cSrcweir         return nColor;
355*cdf0e10cSrcweir     }
356*cdf0e10cSrcweir 
357*cdf0e10cSrcweir     //--------------------------------------------------------------------
358*cdf0e10cSrcweir     sal_Int32 SAL_CALL OAccessibleControlContext::getBackground(  ) throw (::com::sun::star::uno::RuntimeException)
359*cdf0e10cSrcweir     {
360*cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
361*cdf0e10cSrcweir             // want to do some VCL stuff here ...
362*cdf0e10cSrcweir         OContextEntryGuard aGuard( this );
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir         Window* pWindow = implGetWindow( );
365*cdf0e10cSrcweir         sal_Int32 nColor = 0;
366*cdf0e10cSrcweir         if ( pWindow )
367*cdf0e10cSrcweir         {
368*cdf0e10cSrcweir             if ( pWindow->IsControlBackground() )
369*cdf0e10cSrcweir                 nColor = pWindow->GetControlBackground().GetColor();
370*cdf0e10cSrcweir             else
371*cdf0e10cSrcweir                 nColor = pWindow->GetBackground().GetColor().GetColor();
372*cdf0e10cSrcweir         }
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir         return nColor;
375*cdf0e10cSrcweir     }
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir //........................................................................
378*cdf0e10cSrcweir }   //namespace toolkit
379*cdf0e10cSrcweir //........................................................................
380*cdf0e10cSrcweir 
381