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