xref: /AOO41X/main/editeng/source/accessibility/AccessibleImageBullet.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_editeng.hxx"
30*cdf0e10cSrcweir #include <tools/gen.hxx>
31*cdf0e10cSrcweir #include <vos/mutex.hxx>
32*cdf0e10cSrcweir #include <vcl/svapp.hxx>
33*cdf0e10cSrcweir #include <rtl/ustring.hxx>
34*cdf0e10cSrcweir #include <com/sun/star/awt/Point.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/awt/Rectangle.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleTextType.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp>
41*cdf0e10cSrcweir #include <comphelper/accessibleeventnotifier.hxx>
42*cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx>
43*cdf0e10cSrcweir #include <editeng/unolingu.hxx>
44*cdf0e10cSrcweir #include "editeng/AccessibleEditableTextPara.hxx"
45*cdf0e10cSrcweir #include "editeng/AccessibleImageBullet.hxx"
46*cdf0e10cSrcweir #include <editeng/eerdll.hxx>
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir #include <editeng/editdata.hxx>
49*cdf0e10cSrcweir #include <editeng/editeng.hxx>
50*cdf0e10cSrcweir #include <editeng/outliner.hxx>
51*cdf0e10cSrcweir #include "editeng.hrc"
52*cdf0e10cSrcweir #include <svtools/colorcfg.hxx>
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir using namespace ::com::sun::star;
56*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir namespace accessibility
59*cdf0e10cSrcweir {
60*cdf0e10cSrcweir     DBG_NAME( AccessibleImageBullet )
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir     AccessibleImageBullet::AccessibleImageBullet ( const uno::Reference< XAccessible >& rParent ) :
63*cdf0e10cSrcweir         mnParagraphIndex( 0 ),
64*cdf0e10cSrcweir         mnIndexInParent( 0 ),
65*cdf0e10cSrcweir         mpEditSource( NULL ),
66*cdf0e10cSrcweir         maEEOffset( 0, 0 ),
67*cdf0e10cSrcweir         mxParent( rParent ),
68*cdf0e10cSrcweir         // well, that's strictly (UNO) exception safe, though not
69*cdf0e10cSrcweir         // really robust. We rely on the fact that this member is
70*cdf0e10cSrcweir         // constructed last, and that the constructor body catches
71*cdf0e10cSrcweir         // exceptions, thus no chance for exceptions once the Id is
72*cdf0e10cSrcweir         // fetched. Nevertheless, normally should employ RAII here...
73*cdf0e10cSrcweir         mnNotifierClientId(::comphelper::AccessibleEventNotifier::registerClient())
74*cdf0e10cSrcweir     {
75*cdf0e10cSrcweir #ifdef DBG_UTIL
76*cdf0e10cSrcweir         DBG_CTOR( AccessibleImageBullet, NULL );
77*cdf0e10cSrcweir         OSL_TRACE( "Received ID: %d", mnNotifierClientId );
78*cdf0e10cSrcweir #endif
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir         try
81*cdf0e10cSrcweir         {
82*cdf0e10cSrcweir             // Create the state set.
83*cdf0e10cSrcweir             ::utl::AccessibleStateSetHelper* pStateSet  = new ::utl::AccessibleStateSetHelper ();
84*cdf0e10cSrcweir             mxStateSet = pStateSet;
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir             // these are always on
87*cdf0e10cSrcweir             pStateSet->AddState( AccessibleStateType::VISIBLE );
88*cdf0e10cSrcweir             pStateSet->AddState( AccessibleStateType::SHOWING );
89*cdf0e10cSrcweir             pStateSet->AddState( AccessibleStateType::ENABLED );
90*cdf0e10cSrcweir             pStateSet->AddState( AccessibleStateType::SENSITIVE );
91*cdf0e10cSrcweir         }
92*cdf0e10cSrcweir         catch( const uno::Exception& ) {}
93*cdf0e10cSrcweir     }
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir     AccessibleImageBullet::~AccessibleImageBullet()
96*cdf0e10cSrcweir     {
97*cdf0e10cSrcweir         DBG_DTOR( AccessibleImageBullet, NULL );
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir         // sign off from event notifier
100*cdf0e10cSrcweir         if( getNotifierClientId() != -1 )
101*cdf0e10cSrcweir         {
102*cdf0e10cSrcweir             try
103*cdf0e10cSrcweir             {
104*cdf0e10cSrcweir                 ::comphelper::AccessibleEventNotifier::revokeClient( getNotifierClientId() );
105*cdf0e10cSrcweir #ifdef DBG_UTIL
106*cdf0e10cSrcweir                 OSL_TRACE( "AccessibleImageBullet revoked ID: %d\n", mnNotifierClientId );
107*cdf0e10cSrcweir #endif
108*cdf0e10cSrcweir             }
109*cdf0e10cSrcweir             catch( const uno::Exception& ) {}
110*cdf0e10cSrcweir         }
111*cdf0e10cSrcweir     }
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir     uno::Any SAL_CALL AccessibleImageBullet::queryInterface (const uno::Type & rType) throw (uno::RuntimeException)
114*cdf0e10cSrcweir     {
115*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir         return AccessibleImageBulletInterfaceBase::queryInterface(rType);
118*cdf0e10cSrcweir     }
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir     uno::Reference< XAccessibleContext > SAL_CALL AccessibleImageBullet::getAccessibleContext(  ) throw (uno::RuntimeException)
121*cdf0e10cSrcweir     {
122*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir         // We implement the XAccessibleContext interface in the same object
125*cdf0e10cSrcweir         return uno::Reference< XAccessibleContext > ( this );
126*cdf0e10cSrcweir     }
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir     sal_Int32 SAL_CALL  AccessibleImageBullet::getAccessibleChildCount() throw (uno::RuntimeException)
129*cdf0e10cSrcweir     {
130*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir         return 0;
133*cdf0e10cSrcweir     }
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir     uno::Reference< XAccessible > SAL_CALL  AccessibleImageBullet::getAccessibleChild( sal_Int32 i ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
136*cdf0e10cSrcweir     {
137*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
138*cdf0e10cSrcweir         (void)i;
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No childs available")),
141*cdf0e10cSrcweir                                               uno::Reference< uno::XInterface >
142*cdf0e10cSrcweir                                               ( static_cast< ::cppu::OWeakObject* > (this) ) );	// static_cast: disambiguate hierarchy
143*cdf0e10cSrcweir     }
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir     uno::Reference< XAccessible > SAL_CALL  AccessibleImageBullet::getAccessibleParent() throw (uno::RuntimeException)
146*cdf0e10cSrcweir     {
147*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir         return mxParent;
150*cdf0e10cSrcweir     }
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir     sal_Int32 SAL_CALL  AccessibleImageBullet::getAccessibleIndexInParent() throw (uno::RuntimeException)
153*cdf0e10cSrcweir     {
154*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir         return mnIndexInParent;
157*cdf0e10cSrcweir     }
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir     sal_Int16 SAL_CALL  AccessibleImageBullet::getAccessibleRole() throw (uno::RuntimeException)
160*cdf0e10cSrcweir     {
161*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir         return AccessibleRole::GRAPHIC;
164*cdf0e10cSrcweir     }
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir     ::rtl::OUString SAL_CALL  AccessibleImageBullet::getAccessibleDescription() throw (uno::RuntimeException)
167*cdf0e10cSrcweir     {
168*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir         ::vos::OGuard aGuard( Application::GetSolarMutex() );
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir         // Get the string from the resource for the specified id.
173*cdf0e10cSrcweir         return ::rtl::OUString( String( EditResId (RID_SVXSTR_A11Y_IMAGEBULLET_DESCRIPTION) ) );
174*cdf0e10cSrcweir     }
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir     ::rtl::OUString SAL_CALL  AccessibleImageBullet::getAccessibleName() throw (uno::RuntimeException)
177*cdf0e10cSrcweir     {
178*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir         ::vos::OGuard aGuard( Application::GetSolarMutex() );
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir         // Get the string from the resource for the specified id.
183*cdf0e10cSrcweir         return ::rtl::OUString( String ( EditResId (RID_SVXSTR_A11Y_IMAGEBULLET_NAME) ) );
184*cdf0e10cSrcweir     }
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir     uno::Reference< XAccessibleRelationSet > SAL_CALL AccessibleImageBullet::getAccessibleRelationSet() throw (uno::RuntimeException)
187*cdf0e10cSrcweir     {
188*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir         // no relations, therefore empty
191*cdf0e10cSrcweir         return uno::Reference< XAccessibleRelationSet >();
192*cdf0e10cSrcweir     }
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir     uno::Reference< XAccessibleStateSet > SAL_CALL AccessibleImageBullet::getAccessibleStateSet() throw (uno::RuntimeException)
195*cdf0e10cSrcweir     {
196*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir         ::vos::OGuard aGuard( Application::GetSolarMutex() );
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir         // Create a copy of the state set and return it.
201*cdf0e10cSrcweir         ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir         if( !pStateSet )
204*cdf0e10cSrcweir             return uno::Reference<XAccessibleStateSet>();
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir         return uno::Reference<XAccessibleStateSet>( new ::utl::AccessibleStateSetHelper (*pStateSet) );
207*cdf0e10cSrcweir     }
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir     lang::Locale SAL_CALL AccessibleImageBullet::getLocale() throw (IllegalAccessibleComponentStateException, uno::RuntimeException)
210*cdf0e10cSrcweir     {
211*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir         ::vos::OGuard aGuard( Application::GetSolarMutex() );
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir         lang::Locale		aLocale;
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
218*cdf0e10cSrcweir                    "AccessibleImageBullet::getLocale: paragraph index value overflow");
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir         // return locale of first character in the paragraph
221*cdf0e10cSrcweir         return SvxLanguageToLocale(aLocale, GetTextForwarder().GetLanguage( static_cast< sal_uInt16 >( GetParagraphIndex() ), 0 ));
222*cdf0e10cSrcweir     }
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir     void SAL_CALL AccessibleImageBullet::addEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException)
225*cdf0e10cSrcweir     {
226*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir         if( getNotifierClientId() != -1 )
229*cdf0e10cSrcweir             ::comphelper::AccessibleEventNotifier::addEventListener( getNotifierClientId(), xListener );
230*cdf0e10cSrcweir     }
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir     void SAL_CALL AccessibleImageBullet::removeEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException)
233*cdf0e10cSrcweir     {
234*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir         if( getNotifierClientId() != -1 )
237*cdf0e10cSrcweir             ::comphelper::AccessibleEventNotifier::removeEventListener( getNotifierClientId(), xListener );
238*cdf0e10cSrcweir     }
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir     sal_Bool SAL_CALL AccessibleImageBullet::containsPoint( const awt::Point& rPoint ) throw (uno::RuntimeException)
241*cdf0e10cSrcweir     {
242*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir         ::vos::OGuard aGuard( Application::GetSolarMutex() );
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
247*cdf0e10cSrcweir                    "AccessibleEditableTextPara::contains: index value overflow");
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir         awt::Rectangle aTmpRect = getBounds();
250*cdf0e10cSrcweir         Rectangle aRect( Point(aTmpRect.X, aTmpRect.Y), Size(aTmpRect.Width, aTmpRect.Height) );
251*cdf0e10cSrcweir         Point aPoint( rPoint.X, rPoint.Y );
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir         return aRect.IsInside( aPoint );
254*cdf0e10cSrcweir     }
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir     uno::Reference< XAccessible > SAL_CALL AccessibleImageBullet::getAccessibleAtPoint( const awt::Point& /*aPoint*/ ) throw (uno::RuntimeException)
257*cdf0e10cSrcweir     {
258*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir         // as we have no children, empty reference
261*cdf0e10cSrcweir         return uno::Reference< XAccessible >();
262*cdf0e10cSrcweir     }
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir     awt::Rectangle SAL_CALL AccessibleImageBullet::getBounds(  ) throw (uno::RuntimeException)
265*cdf0e10cSrcweir     {
266*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir         ::vos::OGuard aGuard( Application::GetSolarMutex() );
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
271*cdf0e10cSrcweir                    "AccessibleEditableTextPara::getBounds: index value overflow");
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir         SvxTextForwarder& rCacheTF = GetTextForwarder();
274*cdf0e10cSrcweir         EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 > (GetParagraphIndex()) );
275*cdf0e10cSrcweir         Rectangle aParentRect = rCacheTF.GetParaBounds( static_cast< sal_uInt16 >( GetParagraphIndex() ) );
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir         if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND &&
278*cdf0e10cSrcweir             aBulletInfo.bVisible &&
279*cdf0e10cSrcweir             aBulletInfo.nType == SVX_NUM_BITMAP )
280*cdf0e10cSrcweir         {
281*cdf0e10cSrcweir             Rectangle aRect = aBulletInfo.aBounds;
282*cdf0e10cSrcweir 
283*cdf0e10cSrcweir             // subtract paragraph position (bullet pos is absolute in EditEngine/Outliner)
284*cdf0e10cSrcweir             aRect.Move( -aParentRect.Left(), -aParentRect.Top() );
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir             // convert to screen coordinates
287*cdf0e10cSrcweir             Rectangle aScreenRect = AccessibleEditableTextPara::LogicToPixel( aRect,
288*cdf0e10cSrcweir                                                                               rCacheTF.GetMapMode(),
289*cdf0e10cSrcweir                                                                               GetViewForwarder() );
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir             // offset from shape/cell
292*cdf0e10cSrcweir             Point aOffset = GetEEOffset();
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir             return awt::Rectangle( aScreenRect.Left() + aOffset.X(),
295*cdf0e10cSrcweir                                    aScreenRect.Top() + aOffset.Y(),
296*cdf0e10cSrcweir                                    aScreenRect.GetSize().Width(),
297*cdf0e10cSrcweir                                    aScreenRect.GetSize().Height() );
298*cdf0e10cSrcweir         }
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir         return awt::Rectangle();
301*cdf0e10cSrcweir     }
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir     awt::Point SAL_CALL AccessibleImageBullet::getLocation(  ) throw (uno::RuntimeException)
304*cdf0e10cSrcweir     {
305*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir         ::vos::OGuard aGuard( Application::GetSolarMutex() );
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir         awt::Rectangle aRect = getBounds();
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir         return awt::Point( aRect.X, aRect.Y );
312*cdf0e10cSrcweir     }
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir     awt::Point SAL_CALL AccessibleImageBullet::getLocationOnScreen(  ) throw (uno::RuntimeException)
315*cdf0e10cSrcweir     {
316*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir         ::vos::OGuard aGuard( Application::GetSolarMutex() );
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir         // relate us to parent
321*cdf0e10cSrcweir         uno::Reference< XAccessible > xParent = getAccessibleParent();
322*cdf0e10cSrcweir         if( xParent.is() )
323*cdf0e10cSrcweir         {
324*cdf0e10cSrcweir             uno::Reference< XAccessibleComponent > xParentComponent( xParent, uno::UNO_QUERY );
325*cdf0e10cSrcweir             if( xParentComponent.is() )
326*cdf0e10cSrcweir             {
327*cdf0e10cSrcweir                 awt::Point aRefPoint = xParentComponent->getLocationOnScreen();
328*cdf0e10cSrcweir                 awt::Point aPoint = getLocation();
329*cdf0e10cSrcweir                 aPoint.X += aRefPoint.X;
330*cdf0e10cSrcweir                 aPoint.Y += aRefPoint.Y;
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir                 return aPoint;
333*cdf0e10cSrcweir             }
334*cdf0e10cSrcweir         }
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir         throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Cannot access parent")),
337*cdf0e10cSrcweir                                     uno::Reference< uno::XInterface >
338*cdf0e10cSrcweir                                     ( static_cast< XAccessible* > (this) ) );	// disambiguate hierarchy
339*cdf0e10cSrcweir     }
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir     awt::Size SAL_CALL AccessibleImageBullet::getSize(  ) throw (uno::RuntimeException)
342*cdf0e10cSrcweir     {
343*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir         ::vos::OGuard aGuard( Application::GetSolarMutex() );
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir         awt::Rectangle aRect = getBounds();
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir         return awt::Size( aRect.Width, aRect.Height );
350*cdf0e10cSrcweir     }
351*cdf0e10cSrcweir 
352*cdf0e10cSrcweir     void SAL_CALL AccessibleImageBullet::grabFocus(  ) throw (uno::RuntimeException)
353*cdf0e10cSrcweir     {
354*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir         throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Not focusable")),
357*cdf0e10cSrcweir                                     uno::Reference< uno::XInterface >
358*cdf0e10cSrcweir                                     ( static_cast< XAccessible* > (this) ) );	// disambiguate hierarchy
359*cdf0e10cSrcweir     }
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir     sal_Int32 SAL_CALL AccessibleImageBullet::getForeground(  ) throw (::com::sun::star::uno::RuntimeException)
362*cdf0e10cSrcweir     {
363*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir         // #104444# Added to XAccessibleComponent interface
366*cdf0e10cSrcweir 		svtools::ColorConfig aColorConfig;
367*cdf0e10cSrcweir 		sal_uInt32 nColor = aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor;
368*cdf0e10cSrcweir         return static_cast<sal_Int32>(nColor);
369*cdf0e10cSrcweir     }
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir     sal_Int32 SAL_CALL AccessibleImageBullet::getBackground(  ) throw (::com::sun::star::uno::RuntimeException)
372*cdf0e10cSrcweir     {
373*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir         // #104444# Added to XAccessibleComponent interface
376*cdf0e10cSrcweir         Color aColor( Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor() );
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir         // the background is transparent
379*cdf0e10cSrcweir         aColor.SetTransparency( 0xFF);
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir         return static_cast<sal_Int32>( aColor.GetColor() );
382*cdf0e10cSrcweir     }
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir     ::rtl::OUString SAL_CALL AccessibleImageBullet::getImplementationName (void) throw (uno::RuntimeException)
385*cdf0e10cSrcweir     {
386*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
387*cdf0e10cSrcweir 
388*cdf0e10cSrcweir         return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("AccessibleImageBullet"));
389*cdf0e10cSrcweir     }
390*cdf0e10cSrcweir 
391*cdf0e10cSrcweir     sal_Bool SAL_CALL AccessibleImageBullet::supportsService (const ::rtl::OUString& sServiceName) throw (uno::RuntimeException)
392*cdf0e10cSrcweir     {
393*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir         //  Iterate over all supported service names and return true if on of them
396*cdf0e10cSrcweir         //  matches the given name.
397*cdf0e10cSrcweir         uno::Sequence< ::rtl::OUString> aSupportedServices (
398*cdf0e10cSrcweir             getSupportedServiceNames ());
399*cdf0e10cSrcweir         for (int i=0; i<aSupportedServices.getLength(); i++)
400*cdf0e10cSrcweir             if (sServiceName == aSupportedServices[i])
401*cdf0e10cSrcweir                 return sal_True;
402*cdf0e10cSrcweir         return sal_False;
403*cdf0e10cSrcweir     }
404*cdf0e10cSrcweir 
405*cdf0e10cSrcweir     uno::Sequence< ::rtl::OUString> SAL_CALL AccessibleImageBullet::getSupportedServiceNames (void) throw (uno::RuntimeException)
406*cdf0e10cSrcweir     {
407*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir         const ::rtl::OUString sServiceName (RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.accessibility.AccessibleContext"));
410*cdf0e10cSrcweir         return uno::Sequence< ::rtl::OUString > (&sServiceName, 1);
411*cdf0e10cSrcweir     }
412*cdf0e10cSrcweir 
413*cdf0e10cSrcweir     ::rtl::OUString SAL_CALL AccessibleImageBullet::getServiceName (void) throw (uno::RuntimeException)
414*cdf0e10cSrcweir     {
415*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir         return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.AccessibleContext"));
418*cdf0e10cSrcweir     }
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir     void AccessibleImageBullet::SetIndexInParent( sal_Int32 nIndex )
421*cdf0e10cSrcweir     {
422*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir         mnIndexInParent = nIndex;
425*cdf0e10cSrcweir     }
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir     sal_Int32 AccessibleImageBullet::GetIndexInParent() const
428*cdf0e10cSrcweir     {
429*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir         return mnIndexInParent;
432*cdf0e10cSrcweir     }
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir     void AccessibleImageBullet::SetEEOffset( const Point& rOffset )
435*cdf0e10cSrcweir     {
436*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
437*cdf0e10cSrcweir 
438*cdf0e10cSrcweir         maEEOffset = rOffset;
439*cdf0e10cSrcweir     }
440*cdf0e10cSrcweir 
441*cdf0e10cSrcweir     void AccessibleImageBullet::Dispose()
442*cdf0e10cSrcweir     {
443*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir         int nClientId( getNotifierClientId() );
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir         // #108212# drop all references before notifying dispose
448*cdf0e10cSrcweir         mxParent = NULL;
449*cdf0e10cSrcweir         mnNotifierClientId = -1;
450*cdf0e10cSrcweir         mpEditSource = NULL;
451*cdf0e10cSrcweir 
452*cdf0e10cSrcweir         // notify listeners
453*cdf0e10cSrcweir         if( nClientId != -1 )
454*cdf0e10cSrcweir         {
455*cdf0e10cSrcweir             try
456*cdf0e10cSrcweir             {
457*cdf0e10cSrcweir                 uno::Reference < XAccessibleContext > xThis = getAccessibleContext();
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir                 // #106234# Delegate to EventNotifier
460*cdf0e10cSrcweir                 ::comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nClientId, xThis );
461*cdf0e10cSrcweir #ifdef DBG_UTIL
462*cdf0e10cSrcweir                 OSL_TRACE( "AccessibleImageBullet disposed ID: %d", nClientId );
463*cdf0e10cSrcweir #endif
464*cdf0e10cSrcweir             }
465*cdf0e10cSrcweir             catch( const uno::Exception& ) {}
466*cdf0e10cSrcweir         }
467*cdf0e10cSrcweir     }
468*cdf0e10cSrcweir 
469*cdf0e10cSrcweir     void AccessibleImageBullet::SetEditSource( SvxEditSource* pEditSource )
470*cdf0e10cSrcweir     {
471*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir         mpEditSource = pEditSource;
474*cdf0e10cSrcweir 
475*cdf0e10cSrcweir         if( !mpEditSource )
476*cdf0e10cSrcweir         {
477*cdf0e10cSrcweir             // going defunc
478*cdf0e10cSrcweir             UnSetState( AccessibleStateType::SHOWING );
479*cdf0e10cSrcweir             UnSetState( AccessibleStateType::VISIBLE );
480*cdf0e10cSrcweir             SetState( AccessibleStateType::INVALID );
481*cdf0e10cSrcweir             SetState( AccessibleStateType::DEFUNC );
482*cdf0e10cSrcweir 
483*cdf0e10cSrcweir             Dispose();
484*cdf0e10cSrcweir         }
485*cdf0e10cSrcweir     }
486*cdf0e10cSrcweir 
487*cdf0e10cSrcweir     void AccessibleImageBullet::FireEvent(const sal_Int16 nEventId, const uno::Any& rNewValue, const uno::Any& rOldValue ) const
488*cdf0e10cSrcweir     {
489*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
490*cdf0e10cSrcweir 
491*cdf0e10cSrcweir         uno::Reference < XAccessibleContext > xThis( const_cast< AccessibleImageBullet* > (this)->getAccessibleContext() );
492*cdf0e10cSrcweir 
493*cdf0e10cSrcweir         AccessibleEventObject aEvent(xThis, nEventId, rNewValue, rOldValue);
494*cdf0e10cSrcweir 
495*cdf0e10cSrcweir         // #106234# Delegate to EventNotifier
496*cdf0e10cSrcweir         ::comphelper::AccessibleEventNotifier::addEvent( getNotifierClientId(),
497*cdf0e10cSrcweir                                                          aEvent );
498*cdf0e10cSrcweir     }
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir     void AccessibleImageBullet::GotPropertyEvent( const uno::Any& rNewValue, const sal_Int16 nEventId ) const
501*cdf0e10cSrcweir     {
502*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
503*cdf0e10cSrcweir 
504*cdf0e10cSrcweir         FireEvent( nEventId, rNewValue );
505*cdf0e10cSrcweir     }
506*cdf0e10cSrcweir 
507*cdf0e10cSrcweir     void AccessibleImageBullet::LostPropertyEvent( const uno::Any& rOldValue, const sal_Int16 nEventId ) const
508*cdf0e10cSrcweir     {
509*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
510*cdf0e10cSrcweir 
511*cdf0e10cSrcweir         FireEvent( nEventId, uno::Any(), rOldValue );
512*cdf0e10cSrcweir     }
513*cdf0e10cSrcweir 
514*cdf0e10cSrcweir     void AccessibleImageBullet::SetState( const sal_Int16 nStateId )
515*cdf0e10cSrcweir     {
516*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir         ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
519*cdf0e10cSrcweir         if( pStateSet != NULL &&
520*cdf0e10cSrcweir             !pStateSet->contains(nStateId) )
521*cdf0e10cSrcweir         {
522*cdf0e10cSrcweir             pStateSet->AddState( nStateId );
523*cdf0e10cSrcweir             GotPropertyEvent( uno::makeAny( nStateId ), AccessibleEventId::STATE_CHANGED );
524*cdf0e10cSrcweir         }
525*cdf0e10cSrcweir     }
526*cdf0e10cSrcweir 
527*cdf0e10cSrcweir     void AccessibleImageBullet::UnSetState( const sal_Int16 nStateId )
528*cdf0e10cSrcweir     {
529*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
530*cdf0e10cSrcweir 
531*cdf0e10cSrcweir         ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
532*cdf0e10cSrcweir         if( pStateSet != NULL &&
533*cdf0e10cSrcweir             pStateSet->contains(nStateId) )
534*cdf0e10cSrcweir         {
535*cdf0e10cSrcweir             pStateSet->RemoveState( nStateId );
536*cdf0e10cSrcweir             LostPropertyEvent( uno::makeAny( nStateId ), AccessibleEventId::STATE_CHANGED );
537*cdf0e10cSrcweir         }
538*cdf0e10cSrcweir     }
539*cdf0e10cSrcweir 
540*cdf0e10cSrcweir     int AccessibleImageBullet::getNotifierClientId() const
541*cdf0e10cSrcweir     {
542*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
543*cdf0e10cSrcweir 
544*cdf0e10cSrcweir         return mnNotifierClientId;
545*cdf0e10cSrcweir     }
546*cdf0e10cSrcweir 
547*cdf0e10cSrcweir     void AccessibleImageBullet::SetParagraphIndex( sal_Int32 nIndex )
548*cdf0e10cSrcweir     {
549*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
550*cdf0e10cSrcweir 
551*cdf0e10cSrcweir         uno::Any aOldDesc;
552*cdf0e10cSrcweir         uno::Any aOldName;
553*cdf0e10cSrcweir 
554*cdf0e10cSrcweir         try
555*cdf0e10cSrcweir         {
556*cdf0e10cSrcweir             aOldDesc <<= getAccessibleDescription();
557*cdf0e10cSrcweir             aOldName <<= getAccessibleName();
558*cdf0e10cSrcweir         }
559*cdf0e10cSrcweir         catch( const uno::Exception& ) {} // optional behaviour
560*cdf0e10cSrcweir 
561*cdf0e10cSrcweir         sal_Int32 nOldIndex = mnParagraphIndex;
562*cdf0e10cSrcweir 
563*cdf0e10cSrcweir         mnParagraphIndex = nIndex;
564*cdf0e10cSrcweir 
565*cdf0e10cSrcweir         try
566*cdf0e10cSrcweir         {
567*cdf0e10cSrcweir             if( nOldIndex != nIndex )
568*cdf0e10cSrcweir             {
569*cdf0e10cSrcweir                 // index and therefore description changed
570*cdf0e10cSrcweir                 FireEvent( AccessibleEventId::DESCRIPTION_CHANGED, uno::makeAny( getAccessibleDescription() ), aOldDesc );
571*cdf0e10cSrcweir                 FireEvent( AccessibleEventId::NAME_CHANGED, uno::makeAny( getAccessibleName() ), aOldName );
572*cdf0e10cSrcweir             }
573*cdf0e10cSrcweir         }
574*cdf0e10cSrcweir         catch( const uno::Exception& ) {} // optional behaviour
575*cdf0e10cSrcweir     }
576*cdf0e10cSrcweir 
577*cdf0e10cSrcweir     sal_Int32 AccessibleImageBullet::GetParagraphIndex() const SAL_THROW((uno::RuntimeException))
578*cdf0e10cSrcweir     {
579*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
580*cdf0e10cSrcweir 
581*cdf0e10cSrcweir         return mnParagraphIndex;
582*cdf0e10cSrcweir     }
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir     SvxEditSource& AccessibleImageBullet::GetEditSource() const SAL_THROW((uno::RuntimeException))
585*cdf0e10cSrcweir     {
586*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
587*cdf0e10cSrcweir 
588*cdf0e10cSrcweir         if( mpEditSource )
589*cdf0e10cSrcweir             return *mpEditSource;
590*cdf0e10cSrcweir         else
591*cdf0e10cSrcweir             throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No edit source, object is defunct")),
592*cdf0e10cSrcweir                                         uno::Reference< uno::XInterface >
593*cdf0e10cSrcweir                                         ( static_cast< ::cppu::OWeakObject* >
594*cdf0e10cSrcweir                                           ( const_cast< AccessibleImageBullet* > (this) ) ) );	// disambiguate hierarchy
595*cdf0e10cSrcweir     }
596*cdf0e10cSrcweir 
597*cdf0e10cSrcweir     SvxTextForwarder& AccessibleImageBullet::GetTextForwarder() const SAL_THROW((uno::RuntimeException))
598*cdf0e10cSrcweir     {
599*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
600*cdf0e10cSrcweir 
601*cdf0e10cSrcweir         SvxEditSource& rEditSource = GetEditSource();
602*cdf0e10cSrcweir         SvxTextForwarder* pTextForwarder = rEditSource.GetTextForwarder();
603*cdf0e10cSrcweir 
604*cdf0e10cSrcweir         if( !pTextForwarder )
605*cdf0e10cSrcweir             throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unable to fetch text forwarder, object is defunct")),
606*cdf0e10cSrcweir                                         uno::Reference< uno::XInterface >
607*cdf0e10cSrcweir                                         ( static_cast< ::cppu::OWeakObject* >
608*cdf0e10cSrcweir                                           ( const_cast< AccessibleImageBullet* > (this) ) ) );	// disambiguate hierarchy
609*cdf0e10cSrcweir 
610*cdf0e10cSrcweir         if( pTextForwarder->IsValid() )
611*cdf0e10cSrcweir             return *pTextForwarder;
612*cdf0e10cSrcweir         else
613*cdf0e10cSrcweir             throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Text forwarder is invalid, object is defunct")),
614*cdf0e10cSrcweir                                         uno::Reference< uno::XInterface >
615*cdf0e10cSrcweir                                         ( static_cast< ::cppu::OWeakObject* >
616*cdf0e10cSrcweir                                           ( const_cast< AccessibleImageBullet* > (this) ) ) );	// disambiguate hierarchy
617*cdf0e10cSrcweir     }
618*cdf0e10cSrcweir 
619*cdf0e10cSrcweir     SvxViewForwarder& AccessibleImageBullet::GetViewForwarder() const SAL_THROW((uno::RuntimeException))
620*cdf0e10cSrcweir     {
621*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
622*cdf0e10cSrcweir 
623*cdf0e10cSrcweir         SvxEditSource& rEditSource = GetEditSource();
624*cdf0e10cSrcweir         SvxViewForwarder* pViewForwarder = rEditSource.GetViewForwarder();
625*cdf0e10cSrcweir 
626*cdf0e10cSrcweir         if( !pViewForwarder )
627*cdf0e10cSrcweir         {
628*cdf0e10cSrcweir             throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unable to fetch view forwarder, object is defunct")),
629*cdf0e10cSrcweir                                         uno::Reference< uno::XInterface >
630*cdf0e10cSrcweir                                         ( static_cast< ::cppu::OWeakObject* >
631*cdf0e10cSrcweir                                           ( const_cast< AccessibleImageBullet* > (this) ) ) );	// disambiguate hierarchy
632*cdf0e10cSrcweir         }
633*cdf0e10cSrcweir 
634*cdf0e10cSrcweir         if( pViewForwarder->IsValid() )
635*cdf0e10cSrcweir             return *pViewForwarder;
636*cdf0e10cSrcweir         else
637*cdf0e10cSrcweir             throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("View forwarder is invalid, object is defunct")),
638*cdf0e10cSrcweir                                         uno::Reference< uno::XInterface >
639*cdf0e10cSrcweir                                         ( static_cast< ::cppu::OWeakObject* >
640*cdf0e10cSrcweir                                           ( const_cast< AccessibleImageBullet* > (this) )  ) );	// disambiguate hierarchy
641*cdf0e10cSrcweir     }
642*cdf0e10cSrcweir 
643*cdf0e10cSrcweir     const Point& AccessibleImageBullet::GetEEOffset() const
644*cdf0e10cSrcweir     {
645*cdf0e10cSrcweir         DBG_CHKTHIS( AccessibleImageBullet, NULL );
646*cdf0e10cSrcweir 
647*cdf0e10cSrcweir         return maEEOffset;
648*cdf0e10cSrcweir     }
649*cdf0e10cSrcweir 
650*cdf0e10cSrcweir } // end of namespace accessibility
651*cdf0e10cSrcweir 
652