xref: /trunk/main/basctl/source/accessibility/accessibledialogcontrolshape.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_basctl.hxx"
30*cdf0e10cSrcweir #include <accessibledialogcontrolshape.hxx>
31*cdf0e10cSrcweir #include <baside3.hxx>
32*cdf0e10cSrcweir #include <dlgeddef.hxx>
33*cdf0e10cSrcweir #include <dlgedview.hxx>
34*cdf0e10cSrcweir #include <dlgedobj.hxx>
35*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
38*cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx>
39*cdf0e10cSrcweir #include <unotools/accessiblerelationsethelper.hxx>
40*cdf0e10cSrcweir #include <toolkit/awt/vclxfont.hxx>
41*cdf0e10cSrcweir #include <toolkit/helper/externallock.hxx>
42*cdf0e10cSrcweir #include <toolkit/helper/convert.hxx>
43*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
44*cdf0e10cSrcweir #include <vcl/svapp.hxx>
45*cdf0e10cSrcweir 
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 using namespace ::comphelper;
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir // -----------------------------------------------------------------------------
55*cdf0e10cSrcweir // class AccessibleDialogControlShape
56*cdf0e10cSrcweir // -----------------------------------------------------------------------------
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir AccessibleDialogControlShape::AccessibleDialogControlShape( DialogWindow* pDialogWindow, DlgEdObj* pDlgEdObj )
59*cdf0e10cSrcweir     :AccessibleExtendedComponentHelper_BASE( new VCLExternalSolarLock() )
60*cdf0e10cSrcweir     ,m_pDialogWindow( pDialogWindow )
61*cdf0e10cSrcweir     ,m_pDlgEdObj( pDlgEdObj )
62*cdf0e10cSrcweir {
63*cdf0e10cSrcweir     m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock() );
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir     if ( m_pDlgEdObj )
66*cdf0e10cSrcweir         m_xControlModel = Reference< XPropertySet >( m_pDlgEdObj->GetUnoControlModel(), UNO_QUERY );
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir     if ( m_xControlModel.is() )
69*cdf0e10cSrcweir         m_xControlModel->addPropertyChangeListener( ::rtl::OUString(), static_cast< beans::XPropertyChangeListener* >( this ) );
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir     m_bFocused = IsFocused();
72*cdf0e10cSrcweir     m_bSelected = IsSelected();
73*cdf0e10cSrcweir     m_aBounds = GetBounds();
74*cdf0e10cSrcweir }
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir // -----------------------------------------------------------------------------
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir AccessibleDialogControlShape::~AccessibleDialogControlShape()
79*cdf0e10cSrcweir {
80*cdf0e10cSrcweir     if ( m_xControlModel.is() )
81*cdf0e10cSrcweir         m_xControlModel->removePropertyChangeListener( ::rtl::OUString(), static_cast< beans::XPropertyChangeListener* >( this ) );
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir     delete m_pExternalLock;
84*cdf0e10cSrcweir     m_pExternalLock = NULL;
85*cdf0e10cSrcweir }
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir // -----------------------------------------------------------------------------
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir sal_Bool AccessibleDialogControlShape::IsFocused()
90*cdf0e10cSrcweir {
91*cdf0e10cSrcweir     sal_Bool bFocused = sal_False;
92*cdf0e10cSrcweir     if ( m_pDialogWindow )
93*cdf0e10cSrcweir     {
94*cdf0e10cSrcweir         SdrView* pSdrView = m_pDialogWindow->GetView();
95*cdf0e10cSrcweir         if ( pSdrView && pSdrView->IsObjMarked( m_pDlgEdObj ) && pSdrView->GetMarkedObjectList().GetMarkCount() == 1 )
96*cdf0e10cSrcweir             bFocused = sal_True;
97*cdf0e10cSrcweir     }
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir     return bFocused;
100*cdf0e10cSrcweir }
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir // -----------------------------------------------------------------------------
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir sal_Bool AccessibleDialogControlShape::IsSelected()
105*cdf0e10cSrcweir {
106*cdf0e10cSrcweir     sal_Bool bSelected = sal_False;
107*cdf0e10cSrcweir     if ( m_pDialogWindow )
108*cdf0e10cSrcweir     {
109*cdf0e10cSrcweir         SdrView* pSdrView = m_pDialogWindow->GetView();
110*cdf0e10cSrcweir         if ( pSdrView )
111*cdf0e10cSrcweir             bSelected = pSdrView->IsObjMarked( m_pDlgEdObj );
112*cdf0e10cSrcweir     }
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir     return bSelected;
115*cdf0e10cSrcweir }
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir // -----------------------------------------------------------------------------
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir void AccessibleDialogControlShape::SetFocused( sal_Bool bFocused )
120*cdf0e10cSrcweir {
121*cdf0e10cSrcweir     if ( m_bFocused != bFocused )
122*cdf0e10cSrcweir     {
123*cdf0e10cSrcweir         Any aOldValue, aNewValue;
124*cdf0e10cSrcweir         if ( m_bFocused )
125*cdf0e10cSrcweir             aOldValue <<= AccessibleStateType::FOCUSED;
126*cdf0e10cSrcweir         else
127*cdf0e10cSrcweir             aNewValue <<= AccessibleStateType::FOCUSED;
128*cdf0e10cSrcweir         m_bFocused = bFocused;
129*cdf0e10cSrcweir         NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
130*cdf0e10cSrcweir     }
131*cdf0e10cSrcweir }
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir // -----------------------------------------------------------------------------
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir void AccessibleDialogControlShape::SetSelected( sal_Bool bSelected )
136*cdf0e10cSrcweir {
137*cdf0e10cSrcweir     if ( m_bSelected != bSelected )
138*cdf0e10cSrcweir     {
139*cdf0e10cSrcweir         Any aOldValue, aNewValue;
140*cdf0e10cSrcweir         if ( m_bSelected )
141*cdf0e10cSrcweir             aOldValue <<= AccessibleStateType::SELECTED;
142*cdf0e10cSrcweir         else
143*cdf0e10cSrcweir             aNewValue <<= AccessibleStateType::SELECTED;
144*cdf0e10cSrcweir         m_bSelected = bSelected;
145*cdf0e10cSrcweir         NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
146*cdf0e10cSrcweir     }
147*cdf0e10cSrcweir }
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir // -----------------------------------------------------------------------------
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir awt::Rectangle AccessibleDialogControlShape::GetBounds()
152*cdf0e10cSrcweir {
153*cdf0e10cSrcweir     awt::Rectangle aBounds( 0, 0, 0, 0 );
154*cdf0e10cSrcweir     if ( m_pDlgEdObj )
155*cdf0e10cSrcweir     {
156*cdf0e10cSrcweir         // get the bounding box of the shape in logic units
157*cdf0e10cSrcweir         Rectangle aRect = m_pDlgEdObj->GetSnapRect();
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir         if ( m_pDialogWindow )
160*cdf0e10cSrcweir         {
161*cdf0e10cSrcweir             // transform coordinates relative to the parent
162*cdf0e10cSrcweir             MapMode aMap = m_pDialogWindow->GetMapMode();
163*cdf0e10cSrcweir             Point aOrg = aMap.GetOrigin();
164*cdf0e10cSrcweir             aRect.Move( aOrg.X(), aOrg.Y() );
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir             // convert logic units to pixel
167*cdf0e10cSrcweir             aRect = m_pDialogWindow->LogicToPixel( aRect, MapMode(MAP_100TH_MM) );
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir             // clip the shape's bounding box with the bounding box of its parent
170*cdf0e10cSrcweir             Rectangle aParentRect( Point( 0, 0 ), m_pDialogWindow->GetSizePixel() );
171*cdf0e10cSrcweir             aRect = aRect.GetIntersection( aParentRect );
172*cdf0e10cSrcweir             aBounds = AWTRectangle( aRect );
173*cdf0e10cSrcweir         }
174*cdf0e10cSrcweir     }
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir     return aBounds;
177*cdf0e10cSrcweir }
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir // -----------------------------------------------------------------------------
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir void AccessibleDialogControlShape::SetBounds( const awt::Rectangle& aBounds )
182*cdf0e10cSrcweir {
183*cdf0e10cSrcweir     if ( m_aBounds.X != aBounds.X || m_aBounds.Y != aBounds.Y || m_aBounds.Width != aBounds.Width || m_aBounds.Height != aBounds.Height )
184*cdf0e10cSrcweir     {
185*cdf0e10cSrcweir         m_aBounds = aBounds;
186*cdf0e10cSrcweir         NotifyAccessibleEvent( AccessibleEventId::BOUNDRECT_CHANGED, Any(), Any() );
187*cdf0e10cSrcweir     }
188*cdf0e10cSrcweir }
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir // -----------------------------------------------------------------------------
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir Window* AccessibleDialogControlShape::GetWindow() const
193*cdf0e10cSrcweir {
194*cdf0e10cSrcweir     Window* pWindow = NULL;
195*cdf0e10cSrcweir     if ( m_pDlgEdObj )
196*cdf0e10cSrcweir     {
197*cdf0e10cSrcweir         Reference< awt::XControl > xControl( m_pDlgEdObj->GetControl(), UNO_QUERY );
198*cdf0e10cSrcweir         if ( xControl.is() )
199*cdf0e10cSrcweir             pWindow = VCLUnoHelper::GetWindow( xControl->getPeer() );
200*cdf0e10cSrcweir     }
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir     return pWindow;
203*cdf0e10cSrcweir }
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir // -----------------------------------------------------------------------------
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir ::rtl::OUString AccessibleDialogControlShape::GetModelStringProperty( const sal_Char* pPropertyName )
208*cdf0e10cSrcweir {
209*cdf0e10cSrcweir     ::rtl::OUString sReturn;
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir     try
212*cdf0e10cSrcweir     {
213*cdf0e10cSrcweir         if ( m_xControlModel.is() )
214*cdf0e10cSrcweir         {
215*cdf0e10cSrcweir             ::rtl::OUString sPropertyName( ::rtl::OUString::createFromAscii( pPropertyName ) );
216*cdf0e10cSrcweir             Reference< XPropertySetInfo > xInfo = m_xControlModel->getPropertySetInfo();
217*cdf0e10cSrcweir             if ( xInfo.is() && xInfo->hasPropertyByName( sPropertyName ) )
218*cdf0e10cSrcweir                 m_xControlModel->getPropertyValue( sPropertyName ) >>= sReturn;
219*cdf0e10cSrcweir         }
220*cdf0e10cSrcweir     }
221*cdf0e10cSrcweir     catch ( const Exception& )
222*cdf0e10cSrcweir     {
223*cdf0e10cSrcweir         OSL_ENSURE( sal_False, "AccessibleDialogControlShape::GetModelStringProperty: caught an exception!" );
224*cdf0e10cSrcweir     }
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir     return sReturn;
227*cdf0e10cSrcweir }
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir // -----------------------------------------------------------------------------
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir void AccessibleDialogControlShape::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
232*cdf0e10cSrcweir {
233*cdf0e10cSrcweir     rStateSet.AddState( AccessibleStateType::ENABLED );
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir     rStateSet.AddState( AccessibleStateType::VISIBLE );
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir     rStateSet.AddState( AccessibleStateType::SHOWING );
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir     rStateSet.AddState( AccessibleStateType::FOCUSABLE );
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir     if ( IsFocused() )
242*cdf0e10cSrcweir         rStateSet.AddState( AccessibleStateType::FOCUSED );
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir     rStateSet.AddState( AccessibleStateType::SELECTABLE );
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir     if ( IsSelected() )
247*cdf0e10cSrcweir         rStateSet.AddState( AccessibleStateType::SELECTED );
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir     rStateSet.AddState( AccessibleStateType::RESIZABLE );
250*cdf0e10cSrcweir }
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir // -----------------------------------------------------------------------------
253*cdf0e10cSrcweir // OCommonAccessibleComponent
254*cdf0e10cSrcweir // -----------------------------------------------------------------------------
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir awt::Rectangle AccessibleDialogControlShape::implGetBounds() throw (RuntimeException)
257*cdf0e10cSrcweir {
258*cdf0e10cSrcweir     return GetBounds();
259*cdf0e10cSrcweir }
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir // -----------------------------------------------------------------------------
262*cdf0e10cSrcweir // XInterface
263*cdf0e10cSrcweir // -----------------------------------------------------------------------------
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( AccessibleDialogControlShape, AccessibleExtendedComponentHelper_BASE, AccessibleDialogControlShape_BASE )
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir // -----------------------------------------------------------------------------
268*cdf0e10cSrcweir // XTypeProvider
269*cdf0e10cSrcweir // -----------------------------------------------------------------------------
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleDialogControlShape, AccessibleExtendedComponentHelper_BASE, AccessibleDialogControlShape_BASE )
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir // -----------------------------------------------------------------------------
274*cdf0e10cSrcweir // XComponent
275*cdf0e10cSrcweir // -----------------------------------------------------------------------------
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir void AccessibleDialogControlShape::disposing()
278*cdf0e10cSrcweir {
279*cdf0e10cSrcweir     AccessibleExtendedComponentHelper_BASE::disposing();
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir     m_pDialogWindow = NULL;
282*cdf0e10cSrcweir     m_pDlgEdObj = NULL;
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir     if ( m_xControlModel.is() )
285*cdf0e10cSrcweir         m_xControlModel->removePropertyChangeListener( ::rtl::OUString(), static_cast< beans::XPropertyChangeListener* >( this ) );
286*cdf0e10cSrcweir     m_xControlModel.clear();
287*cdf0e10cSrcweir }
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir // -----------------------------------------------------------------------------
290*cdf0e10cSrcweir // XEventListener
291*cdf0e10cSrcweir // -----------------------------------------------------------------------------
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir void AccessibleDialogControlShape::disposing( const lang::EventObject& ) throw (RuntimeException)
294*cdf0e10cSrcweir {
295*cdf0e10cSrcweir     if ( m_xControlModel.is() )
296*cdf0e10cSrcweir         m_xControlModel->removePropertyChangeListener( ::rtl::OUString(), static_cast< beans::XPropertyChangeListener* >( this ) );
297*cdf0e10cSrcweir     m_xControlModel.clear();
298*cdf0e10cSrcweir }
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir // -----------------------------------------------------------------------------
301*cdf0e10cSrcweir // XPropertyChangeListener
302*cdf0e10cSrcweir // -----------------------------------------------------------------------------
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir void AccessibleDialogControlShape::propertyChange( const beans::PropertyChangeEvent& rEvent ) throw (RuntimeException)
305*cdf0e10cSrcweir {
306*cdf0e10cSrcweir     if ( rEvent.PropertyName == DLGED_PROP_NAME )
307*cdf0e10cSrcweir     {
308*cdf0e10cSrcweir         NotifyAccessibleEvent( AccessibleEventId::NAME_CHANGED, rEvent.OldValue, rEvent.NewValue );
309*cdf0e10cSrcweir     }
310*cdf0e10cSrcweir     else if ( rEvent.PropertyName == DLGED_PROP_POSITIONX ||
311*cdf0e10cSrcweir               rEvent.PropertyName == DLGED_PROP_POSITIONY ||
312*cdf0e10cSrcweir               rEvent.PropertyName == DLGED_PROP_WIDTH ||
313*cdf0e10cSrcweir               rEvent.PropertyName == DLGED_PROP_HEIGHT )
314*cdf0e10cSrcweir     {
315*cdf0e10cSrcweir         SetBounds( GetBounds() );
316*cdf0e10cSrcweir     }
317*cdf0e10cSrcweir     else if ( rEvent.PropertyName == DLGED_PROP_BACKGROUNDCOLOR ||
318*cdf0e10cSrcweir               rEvent.PropertyName == DLGED_PROP_TEXTCOLOR ||
319*cdf0e10cSrcweir               rEvent.PropertyName == DLGED_PROP_TEXTLINECOLOR )
320*cdf0e10cSrcweir     {
321*cdf0e10cSrcweir         NotifyAccessibleEvent( AccessibleEventId::VISIBLE_DATA_CHANGED, Any(), Any() );
322*cdf0e10cSrcweir     }
323*cdf0e10cSrcweir }
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir // -----------------------------------------------------------------------------
326*cdf0e10cSrcweir // XServiceInfo
327*cdf0e10cSrcweir // -----------------------------------------------------------------------------
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir ::rtl::OUString AccessibleDialogControlShape::getImplementationName() throw (RuntimeException)
330*cdf0e10cSrcweir {
331*cdf0e10cSrcweir     return ::rtl::OUString::createFromAscii( "com.sun.star.comp.basctl.AccessibleShape" );
332*cdf0e10cSrcweir }
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir // -----------------------------------------------------------------------------
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir sal_Bool AccessibleDialogControlShape::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException)
337*cdf0e10cSrcweir {
338*cdf0e10cSrcweir     Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() );
339*cdf0e10cSrcweir     const ::rtl::OUString* pNames = aNames.getConstArray();
340*cdf0e10cSrcweir     const ::rtl::OUString* pEnd = pNames + aNames.getLength();
341*cdf0e10cSrcweir     for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
342*cdf0e10cSrcweir         ;
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir     return pNames != pEnd;
345*cdf0e10cSrcweir }
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir // -----------------------------------------------------------------------------
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir Sequence< ::rtl::OUString > AccessibleDialogControlShape::getSupportedServiceNames() throw (RuntimeException)
350*cdf0e10cSrcweir {
351*cdf0e10cSrcweir     Sequence< ::rtl::OUString > aNames(1);
352*cdf0e10cSrcweir     aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.drawing.AccessibleShape" );
353*cdf0e10cSrcweir     return aNames;
354*cdf0e10cSrcweir }
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir // -----------------------------------------------------------------------------
357*cdf0e10cSrcweir // XAccessible
358*cdf0e10cSrcweir // -----------------------------------------------------------------------------
359*cdf0e10cSrcweir 
360*cdf0e10cSrcweir Reference< XAccessibleContext > AccessibleDialogControlShape::getAccessibleContext(  ) throw (RuntimeException)
361*cdf0e10cSrcweir {
362*cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir     return this;
365*cdf0e10cSrcweir }
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir // -----------------------------------------------------------------------------
368*cdf0e10cSrcweir // XAccessibleContext
369*cdf0e10cSrcweir // -----------------------------------------------------------------------------
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir sal_Int32 AccessibleDialogControlShape::getAccessibleChildCount() throw (RuntimeException)
372*cdf0e10cSrcweir {
373*cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir     return 0;
376*cdf0e10cSrcweir }
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir // -----------------------------------------------------------------------------
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir Reference< XAccessible > AccessibleDialogControlShape::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
381*cdf0e10cSrcweir {
382*cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir     if ( i < 0 || i >= getAccessibleChildCount() )
385*cdf0e10cSrcweir         throw IndexOutOfBoundsException();
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir     return Reference< XAccessible >();
388*cdf0e10cSrcweir }
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir // -----------------------------------------------------------------------------
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir Reference< XAccessible > AccessibleDialogControlShape::getAccessibleParent(  ) throw (RuntimeException)
393*cdf0e10cSrcweir {
394*cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir     Reference< XAccessible > xParent;
397*cdf0e10cSrcweir     if ( m_pDialogWindow )
398*cdf0e10cSrcweir         xParent = m_pDialogWindow->GetAccessible();
399*cdf0e10cSrcweir 
400*cdf0e10cSrcweir     return xParent;
401*cdf0e10cSrcweir }
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir // -----------------------------------------------------------------------------
404*cdf0e10cSrcweir 
405*cdf0e10cSrcweir sal_Int32 AccessibleDialogControlShape::getAccessibleIndexInParent(  ) throw (RuntimeException)
406*cdf0e10cSrcweir {
407*cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir     sal_Int32 nIndexInParent = -1;
410*cdf0e10cSrcweir     Reference< XAccessible > xParent( getAccessibleParent() );
411*cdf0e10cSrcweir     if ( xParent.is() )
412*cdf0e10cSrcweir     {
413*cdf0e10cSrcweir         Reference< XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
414*cdf0e10cSrcweir         if ( xParentContext.is() )
415*cdf0e10cSrcweir         {
416*cdf0e10cSrcweir             for ( sal_Int32 i = 0, nCount = xParentContext->getAccessibleChildCount(); i < nCount; ++i )
417*cdf0e10cSrcweir             {
418*cdf0e10cSrcweir                 Reference< XAccessible > xChild( xParentContext->getAccessibleChild( i ) );
419*cdf0e10cSrcweir                 if ( xChild.is() )
420*cdf0e10cSrcweir                 {
421*cdf0e10cSrcweir                     Reference< XAccessibleContext > xChildContext = xChild->getAccessibleContext();
422*cdf0e10cSrcweir                     if ( xChildContext == (XAccessibleContext*)this )
423*cdf0e10cSrcweir                     {
424*cdf0e10cSrcweir                         nIndexInParent = i;
425*cdf0e10cSrcweir                         break;
426*cdf0e10cSrcweir                     }
427*cdf0e10cSrcweir                 }
428*cdf0e10cSrcweir             }
429*cdf0e10cSrcweir         }
430*cdf0e10cSrcweir     }
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir     return nIndexInParent;
433*cdf0e10cSrcweir }
434*cdf0e10cSrcweir 
435*cdf0e10cSrcweir // -----------------------------------------------------------------------------
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir sal_Int16 AccessibleDialogControlShape::getAccessibleRole(  ) throw (RuntimeException)
438*cdf0e10cSrcweir {
439*cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
440*cdf0e10cSrcweir 
441*cdf0e10cSrcweir     return AccessibleRole::SHAPE;
442*cdf0e10cSrcweir }
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir // -----------------------------------------------------------------------------
445*cdf0e10cSrcweir 
446*cdf0e10cSrcweir ::rtl::OUString AccessibleDialogControlShape::getAccessibleDescription( ) throw (RuntimeException)
447*cdf0e10cSrcweir {
448*cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir     return GetModelStringProperty( "HelpText" );
451*cdf0e10cSrcweir }
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir // -----------------------------------------------------------------------------
454*cdf0e10cSrcweir 
455*cdf0e10cSrcweir ::rtl::OUString AccessibleDialogControlShape::getAccessibleName(  ) throw (RuntimeException)
456*cdf0e10cSrcweir {
457*cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir     return GetModelStringProperty( "Name" );
460*cdf0e10cSrcweir }
461*cdf0e10cSrcweir 
462*cdf0e10cSrcweir // -----------------------------------------------------------------------------
463*cdf0e10cSrcweir 
464*cdf0e10cSrcweir Reference< XAccessibleRelationSet > AccessibleDialogControlShape::getAccessibleRelationSet(  ) throw (RuntimeException)
465*cdf0e10cSrcweir {
466*cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
467*cdf0e10cSrcweir 
468*cdf0e10cSrcweir     utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
469*cdf0e10cSrcweir     Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
470*cdf0e10cSrcweir     return xSet;
471*cdf0e10cSrcweir }
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir // -----------------------------------------------------------------------------
474*cdf0e10cSrcweir 
475*cdf0e10cSrcweir Reference< XAccessibleStateSet > AccessibleDialogControlShape::getAccessibleStateSet(  ) throw (RuntimeException)
476*cdf0e10cSrcweir {
477*cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
478*cdf0e10cSrcweir 
479*cdf0e10cSrcweir     utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
480*cdf0e10cSrcweir     Reference< XAccessibleStateSet > xSet = pStateSetHelper;
481*cdf0e10cSrcweir 
482*cdf0e10cSrcweir     if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
483*cdf0e10cSrcweir     {
484*cdf0e10cSrcweir         FillAccessibleStateSet( *pStateSetHelper );
485*cdf0e10cSrcweir     }
486*cdf0e10cSrcweir     else
487*cdf0e10cSrcweir     {
488*cdf0e10cSrcweir         pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
489*cdf0e10cSrcweir     }
490*cdf0e10cSrcweir 
491*cdf0e10cSrcweir     return xSet;
492*cdf0e10cSrcweir }
493*cdf0e10cSrcweir 
494*cdf0e10cSrcweir // -----------------------------------------------------------------------------
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir Locale AccessibleDialogControlShape::getLocale(  ) throw (IllegalAccessibleComponentStateException, RuntimeException)
497*cdf0e10cSrcweir {
498*cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir     return Application::GetSettings().GetLocale();
501*cdf0e10cSrcweir }
502*cdf0e10cSrcweir 
503*cdf0e10cSrcweir // -----------------------------------------------------------------------------
504*cdf0e10cSrcweir // XAccessibleComponent
505*cdf0e10cSrcweir // -----------------------------------------------------------------------------
506*cdf0e10cSrcweir 
507*cdf0e10cSrcweir Reference< XAccessible > AccessibleDialogControlShape::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException)
508*cdf0e10cSrcweir {
509*cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
510*cdf0e10cSrcweir 
511*cdf0e10cSrcweir     return Reference< XAccessible >();
512*cdf0e10cSrcweir }
513*cdf0e10cSrcweir 
514*cdf0e10cSrcweir // -----------------------------------------------------------------------------
515*cdf0e10cSrcweir 
516*cdf0e10cSrcweir void AccessibleDialogControlShape::grabFocus(  ) throw (RuntimeException)
517*cdf0e10cSrcweir {
518*cdf0e10cSrcweir     // no focus for shapes
519*cdf0e10cSrcweir }
520*cdf0e10cSrcweir 
521*cdf0e10cSrcweir // -----------------------------------------------------------------------------
522*cdf0e10cSrcweir 
523*cdf0e10cSrcweir sal_Int32 AccessibleDialogControlShape::getForeground(  ) throw (RuntimeException)
524*cdf0e10cSrcweir {
525*cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
526*cdf0e10cSrcweir 
527*cdf0e10cSrcweir     sal_Int32 nColor = 0;
528*cdf0e10cSrcweir     Window* pWindow = GetWindow();
529*cdf0e10cSrcweir     if ( pWindow )
530*cdf0e10cSrcweir     {
531*cdf0e10cSrcweir         if ( pWindow->IsControlForeground() )
532*cdf0e10cSrcweir             nColor = pWindow->GetControlForeground().GetColor();
533*cdf0e10cSrcweir         else
534*cdf0e10cSrcweir         {
535*cdf0e10cSrcweir             Font aFont;
536*cdf0e10cSrcweir             if ( pWindow->IsControlFont() )
537*cdf0e10cSrcweir                 aFont = pWindow->GetControlFont();
538*cdf0e10cSrcweir             else
539*cdf0e10cSrcweir                 aFont = pWindow->GetFont();
540*cdf0e10cSrcweir             nColor = aFont.GetColor().GetColor();
541*cdf0e10cSrcweir         }
542*cdf0e10cSrcweir     }
543*cdf0e10cSrcweir 
544*cdf0e10cSrcweir     return nColor;
545*cdf0e10cSrcweir }
546*cdf0e10cSrcweir 
547*cdf0e10cSrcweir // -----------------------------------------------------------------------------
548*cdf0e10cSrcweir 
549*cdf0e10cSrcweir sal_Int32 AccessibleDialogControlShape::getBackground(  ) throw (RuntimeException)
550*cdf0e10cSrcweir {
551*cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
552*cdf0e10cSrcweir 
553*cdf0e10cSrcweir     sal_Int32 nColor = 0;
554*cdf0e10cSrcweir     Window* pWindow = GetWindow();
555*cdf0e10cSrcweir     if ( pWindow )
556*cdf0e10cSrcweir     {
557*cdf0e10cSrcweir         if ( pWindow->IsControlBackground() )
558*cdf0e10cSrcweir             nColor = pWindow->GetControlBackground().GetColor();
559*cdf0e10cSrcweir         else
560*cdf0e10cSrcweir             nColor = pWindow->GetBackground().GetColor().GetColor();
561*cdf0e10cSrcweir     }
562*cdf0e10cSrcweir 
563*cdf0e10cSrcweir     return nColor;
564*cdf0e10cSrcweir }
565*cdf0e10cSrcweir 
566*cdf0e10cSrcweir // -----------------------------------------------------------------------------
567*cdf0e10cSrcweir // XAccessibleExtendedComponent
568*cdf0e10cSrcweir // -----------------------------------------------------------------------------
569*cdf0e10cSrcweir 
570*cdf0e10cSrcweir Reference< awt::XFont > AccessibleDialogControlShape::getFont(  ) throw (RuntimeException)
571*cdf0e10cSrcweir {
572*cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
573*cdf0e10cSrcweir 
574*cdf0e10cSrcweir     Reference< awt::XFont > xFont;
575*cdf0e10cSrcweir     Window* pWindow = GetWindow();
576*cdf0e10cSrcweir     if ( pWindow )
577*cdf0e10cSrcweir     {
578*cdf0e10cSrcweir         Reference< awt::XDevice > xDev( pWindow->GetComponentInterface(), UNO_QUERY );
579*cdf0e10cSrcweir         if ( xDev.is() )
580*cdf0e10cSrcweir         {
581*cdf0e10cSrcweir             Font aFont;
582*cdf0e10cSrcweir             if ( pWindow->IsControlFont() )
583*cdf0e10cSrcweir                 aFont = pWindow->GetControlFont();
584*cdf0e10cSrcweir             else
585*cdf0e10cSrcweir                 aFont = pWindow->GetFont();
586*cdf0e10cSrcweir             VCLXFont* pVCLXFont = new VCLXFont;
587*cdf0e10cSrcweir             pVCLXFont->Init( *xDev.get(), aFont );
588*cdf0e10cSrcweir             xFont = pVCLXFont;
589*cdf0e10cSrcweir         }
590*cdf0e10cSrcweir     }
591*cdf0e10cSrcweir 
592*cdf0e10cSrcweir     return xFont;
593*cdf0e10cSrcweir }
594*cdf0e10cSrcweir 
595*cdf0e10cSrcweir // -----------------------------------------------------------------------------
596*cdf0e10cSrcweir 
597*cdf0e10cSrcweir ::rtl::OUString AccessibleDialogControlShape::getTitledBorderText(  ) throw (RuntimeException)
598*cdf0e10cSrcweir {
599*cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
600*cdf0e10cSrcweir 
601*cdf0e10cSrcweir     return ::rtl::OUString();
602*cdf0e10cSrcweir }
603*cdf0e10cSrcweir 
604*cdf0e10cSrcweir // -----------------------------------------------------------------------------
605*cdf0e10cSrcweir 
606*cdf0e10cSrcweir ::rtl::OUString AccessibleDialogControlShape::getToolTipText(  ) throw (RuntimeException)
607*cdf0e10cSrcweir {
608*cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
609*cdf0e10cSrcweir 
610*cdf0e10cSrcweir     ::rtl::OUString sText;
611*cdf0e10cSrcweir     Window* pWindow = GetWindow();
612*cdf0e10cSrcweir     if ( pWindow )
613*cdf0e10cSrcweir         sText = pWindow->GetQuickHelpText();
614*cdf0e10cSrcweir 
615*cdf0e10cSrcweir     return sText;
616*cdf0e10cSrcweir }
617*cdf0e10cSrcweir 
618*cdf0e10cSrcweir // -----------------------------------------------------------------------------
619*cdf0e10cSrcweir 
620