xref: /trunk/main/svx/source/accessibility/svxpixelctlaccessiblecontext.cxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 // MARKER(update_precomp.py): autogen include statement, do not remove
24 #include "precompiled_svx.hxx"
25 
26 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_
27 #include <com/sun/star/accessibility/AccessibleRole.hpp>
28 #endif
29 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTID_HPP_
30 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
31 #endif
32 #ifndef _UTL_ACCESSIBLESTATESETHELPER_HXX_
33 #include <unotools/accessiblestatesethelper.hxx>
34 #endif
35 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLESTATETYPE_HPP_
36 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
37 #endif
38 
39 #ifndef _COM_SUN_STAR_BEANS_PROPERTYCHANGEEVENT_HPP_
40 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
41 #endif
42 
43 #ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_
44 #include <com/sun/star/awt/XWindow.hpp>
45 #endif
46 
47 #ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
48 #include <cppuhelper/typeprovider.hxx>
49 #endif
50 
51 #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
52 #include <toolkit/helper/vclunohelper.hxx>
53 #endif
54 #ifndef _TOOLKIT_HELPER_CONVERT_HXX_
55 #include <toolkit/helper/convert.hxx>
56 #endif
57 
58 #ifndef _SV_SVAPP_HXX
59 #include <vcl/svapp.hxx>
60 #endif
61 
62 #ifndef _OSL_MUTEX_HXX_
63 #include <osl/mutex.hxx>
64 #endif
65 #ifndef _RTL_UUID_H_
66 #include <rtl/uuid.h>
67 #endif
68 #ifndef _TOOLS_DEBUG_HXX
69 #include <tools/debug.hxx>
70 #endif
71 #ifndef _SV_GEN_HXX
72 #include <tools/gen.hxx>
73 #endif
74 
75 #include <svx/dialogs.hrc>
76 #include "accessibility.hrc"
77 #include <svx/dlgctrl.hxx>
78 
79 #ifndef _SVX_DIALMGR_HXX
80 #include <svx/dialmgr.hxx>
81 #endif
82 #ifndef COMPHELPER_ACCESSIBLE_EVENT_NOTIFIER
83 #include <comphelper/accessibleeventnotifier.hxx>
84 #endif
85 
86 #include <unotools/accessiblerelationsethelper.hxx>
87 
88 #ifndef _SVXPIXELACCESSIBLECONTEXT_HXX
89 #include "svxpixelctlaccessiblecontext.hxx"
90 #endif
91 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLERELATIONTYPE_HPP_
92 #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
93 #endif
94 using namespace ::cppu;
95 using namespace ::osl;
96 using namespace ::rtl;
97 using namespace ::com::sun::star;
98 using namespace ::com::sun::star::uno;
99 using namespace ::com::sun::star::accessibility;
100 
SvxPixelCtlAccessible(SvxPixelCtl & rControl)101 SvxPixelCtlAccessible::SvxPixelCtlAccessible( SvxPixelCtl& rControl) :
102     SvxPixelCtlAccessible_BASE(m_aMutex),
103     pPixelCtl(&rControl),
104     mnClientId(0)
105 {
106     //FreeResource();
107 }
108 
~SvxPixelCtlAccessible()109 SvxPixelCtlAccessible::~SvxPixelCtlAccessible()
110 {
111 //  DBG_DTOR( SvxPixelCtlAccessible, NULL );
112 
113     if( IsAlive() )
114     {
115         osl_incrementInterlockedCount( &m_refCount );
116         dispose();      // set mpRepr = NULL & release all childs
117     }
118 }
119 /*-- 04.02.2002 14:11:55---------------------------------------------------
120 
121   -----------------------------------------------------------------------*/
getAccessibleContext()122 uno::Reference< XAccessibleContext > SvxPixelCtlAccessible::getAccessibleContext(  )
123 {
124     return this;
125 }
126 
getAccessibleChildCount()127 sal_Int32 SvxPixelCtlAccessible::getAccessibleChildCount(  )
128 {
129     ::osl::MutexGuard   aGuard( m_aMutex );
130     IsValid();
131     if(pPixelCtl)
132     {
133         return pPixelCtl->GetSquares();
134     }
135     else
136         return 0;
137 }
138 /*-- 04.02.2002 14:11:56---------------------------------------------------
139 
140   -----------------------------------------------------------------------*/
getAccessibleChild(sal_Int32 i)141 uno::Reference< XAccessible > SvxPixelCtlAccessible::getAccessibleChild( sal_Int32 i )
142 {
143     ::osl::MutexGuard   aGuard( m_aMutex );
144     IsValid();
145     if ( i < 0 || i >= getAccessibleChildCount())
146     throw lang::IndexOutOfBoundsException();
147     uno::Reference <XAccessible> xAcc;
148     if(pPixelCtl)
149     {
150         return CreateChild(i, pPixelCtl->IndexToPoint(i));
151     }
152     else
153         return xAcc;
154     /*
155     throw lang::IndexOutOfBoundsException (
156         ::rtl::OUString::createFromAscii ("no child with index " + i),
157         NULL);
158     */
159 }
160 
161 
162 
getAccessibleParent()163 uno::Reference< XAccessible > SvxPixelCtlAccessible::getAccessibleParent(  )
164 {
165     ::osl::MutexGuard   aGuard( m_aMutex );
166     IsValid();
167     uno::Reference< XAccessible > xRet;
168     if(pPixelCtl)
169         xRet = pPixelCtl->GetParent()->GetAccessible( sal_True );
170     return xRet;
171 }
172 
getAccessibleIndexInParent()173 sal_Int32 SvxPixelCtlAccessible::getAccessibleIndexInParent(  )
174 {
175     ::osl::MutexGuard   aGuard( m_aMutex );
176     IsValid();
177     sal_uInt16 nIdx = 0;
178     if(pPixelCtl)
179     {
180         Window* pTabPage = pPixelCtl->GetParent();
181         sal_uInt16 nChildren = pTabPage->GetChildCount();
182         for(nIdx = 0; nIdx < nChildren; nIdx++)
183             if(pTabPage->GetChild( nIdx ) == pPixelCtl)
184                 break;
185     }
186     return nIdx;
187 }
188 /*-- 04.02.2002 14:11:57---------------------------------------------------
189 
190   -----------------------------------------------------------------------*/
getAccessibleRole()191 sal_Int16 SvxPixelCtlAccessible::getAccessibleRole(  )
192 {
193     return AccessibleRole::LIST;
194 }
195 
getAccessibleDescription()196 ::rtl::OUString SvxPixelCtlAccessible::getAccessibleDescription(  )
197 {
198 
199     ::osl::MutexGuard   aGuard( m_aMutex );
200     IsValid();
201     if(pPixelCtl)
202     return pPixelCtl->GetAccessibleDescription();
203     else
204     return String();
205 
206 }
207 
getAccessibleName()208 ::rtl::OUString SvxPixelCtlAccessible::getAccessibleName(  )
209 {
210 
211     ::osl::MutexGuard   aGuard( m_aMutex );
212     IsValid();
213     if(pPixelCtl)
214         return pPixelCtl->GetAccessibleName();
215     else
216         return String();
217 
218 }
219 
getAccessibleRelationSet()220 uno::Reference< XAccessibleRelationSet > SvxPixelCtlAccessible::getAccessibleRelationSet(  )
221 {
222     ::osl::MutexGuard   aGuard( m_aMutex );
223     IsValid();
224     Window* pWindow = (Window*)pPixelCtl;
225     utl::AccessibleRelationSetHelper* rRelationSet = new utl::AccessibleRelationSetHelper;
226     uno::Reference< accessibility::XAccessibleRelationSet > rSet = rRelationSet;
227     if ( pWindow )
228     {
229         Window *pLabeledBy = pWindow->GetAccessibleRelationLabeledBy();
230         if ( pLabeledBy && pLabeledBy != pWindow )
231         {
232             uno::Sequence< uno::Reference< uno::XInterface > > aSequence(1);
233             aSequence[0] = pLabeledBy->GetAccessible();
234             rRelationSet->AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::LABELED_BY, aSequence ) );
235         }
236 
237         Window* pMemberOf = pWindow->GetAccessibleRelationMemberOf();
238         if ( pMemberOf && pMemberOf != pWindow )
239         {
240             uno::Sequence< uno::Reference< uno::XInterface > > aSequence(1);
241             aSequence[0] = pMemberOf->GetAccessible();
242             rRelationSet->AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::MEMBER_OF, aSequence ) );
243         }
244         return rSet;
245     }
246 
247     return new utl::AccessibleRelationSetHelper;
248 }
249 
250 
getAccessibleStateSet()251 uno::Reference< XAccessibleStateSet > SvxPixelCtlAccessible::getAccessibleStateSet(  )
252 {
253     ::osl::MutexGuard   aGuard( m_aMutex );
254     utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
255     uno::Reference< XAccessibleStateSet > xRet = pStateSetHelper;
256 
257     if(!pPixelCtl)
258         pStateSetHelper->AddState(AccessibleStateType::DEFUNC);
259     else
260     {
261         const sal_Int16 aStandardStates[] =
262         {
263             AccessibleStateType::FOCUSABLE,
264                 AccessibleStateType::SELECTABLE,
265                 AccessibleStateType::SHOWING,
266                 AccessibleStateType::VISIBLE,
267                 AccessibleStateType::OPAQUE,
268                 0};
269 
270             sal_Int16 nState = 0;
271             while(aStandardStates[nState])
272             {
273                 pStateSetHelper->AddState(aStandardStates[nState++]);
274             }
275             if(pPixelCtl->IsEnabled())
276                 pStateSetHelper->AddState(AccessibleStateType::ENABLED);
277             if(pPixelCtl->HasFocus())
278                 pStateSetHelper->AddState(AccessibleStateType::FOCUSED);
279             pStateSetHelper->AddState(AccessibleStateType::MANAGES_DESCENDANTS);
280     }
281     return xRet;
282 }
283 
284 
getLocale()285 com::sun::star::lang::Locale SvxPixelCtlAccessible::getLocale(  )
286 {
287     ::osl::MutexGuard   aGuard( m_aMutex );
288     if( getAccessibleParent().is() )
289     {
290         uno::Reference< XAccessibleContext >        xParentContext( getAccessibleParent()->getAccessibleContext() );
291         if( xParentContext.is() )
292             return xParentContext->getLocale();
293     }
294 
295     //  No locale and no parent.  Therefore throw exception to indicate this
296     //  cluelessness.
297     throw IllegalAccessibleComponentStateException();
298 }
299 
300 
containsPoint(const awt::Point & aPt)301 sal_Bool SvxPixelCtlAccessible::containsPoint( const awt::Point& aPt )
302 {
303     ::osl::MutexGuard   aGuard( m_aMutex );
304     IsValid();
305     Point aPoint(aPt.X, aPt.Y);
306     if(pPixelCtl)
307         return (aPoint.X() >= 0)
308             && (aPoint.X() < pPixelCtl->GetSizePixel().getWidth())
309             && (aPoint.Y() >= 0)
310             && (aPoint.Y() < pPixelCtl->GetSizePixel().getHeight());
311     else
312         return sal_False;
313 }
getAccessibleAtPoint(const awt::Point & aPoint)314 uno::Reference<XAccessible > SAL_CALL SvxPixelCtlAccessible::getAccessibleAtPoint (
315         const awt::Point& aPoint)
316 {
317     ::osl::MutexGuard   aGuard( m_aMutex );
318     ensureIsAlive();
319     uno::Reference <XAccessible> xAcc;
320 
321     Point childPoint;
322     childPoint.X() = aPoint.X;
323     childPoint.Y() = aPoint.Y;
324 
325     if(pPixelCtl)
326     {
327         Point pt= pPixelCtl->PixelToLogic(childPoint);
328         long nIndex = pPixelCtl->PointToIndex(pt);
329         return CreateChild(nIndex,pPixelCtl->IndexToPoint(nIndex));
330     }
331     else
332        return xAcc;
333 
334 }
335 
getBounds()336 awt::Rectangle SvxPixelCtlAccessible::getBounds(  )
337 {
338     ::osl::MutexGuard   aGuard( m_aMutex );
339     IsValid();
340     Size aSz;
341     Point aPos(0,0);
342     awt::Rectangle aRet;
343     if(pPixelCtl)
344     {
345         aSz = pPixelCtl->GetSizePixel();
346         aPos = pPixelCtl->GetPosPixel();
347         aRet.X = aPos.X();
348         aRet.Y = aPos.Y();
349         aRet.Width = aSz.Width();
350         aRet.Height = aSz.Height();
351     }
352     return aRet;
353 }
354 
getLocation()355 awt::Point SvxPixelCtlAccessible::getLocation(  )
356 {
357     ::osl::MutexGuard   aGuard( m_aMutex );
358     IsValid();
359     Point aPos;
360     aPos = pPixelCtl->GetPosPixel();
361     awt::Point aRet(aPos.X(), aPos.Y());
362     return aRet;
363 }
364 
getLocationOnScreen()365 awt::Point SvxPixelCtlAccessible::getLocationOnScreen(  )
366 {
367     ::osl::MutexGuard   aGuard( m_aMutex );
368     IsValid();
369     Rectangle rect;
370     rect = pPixelCtl->GetWindowExtentsRelative(NULL);
371     awt::Point aRet(rect.Left(),rect.Top() );
372     return aRet;
373 }
374 
getSize()375 awt::Size SvxPixelCtlAccessible::getSize(  )
376 {
377     ::osl::MutexGuard   aGuard( m_aMutex );
378     IsValid();
379     Size aSz;
380     aSz = pPixelCtl->GetSizePixel();
381     awt::Size aRet(aSz.Width(),aSz.Height());
382     return aRet;
383 }
grabFocus()384 void SvxPixelCtlAccessible::grabFocus(  )
385 {
386     ::osl::MutexGuard   aGuard( m_aMutex );
387     IsValid();
388     if(pPixelCtl)
389     pPixelCtl->GrabFocus();
390 }
391 
getForeground()392 sal_Int32 SvxPixelCtlAccessible::getForeground(  )
393 {
394     uno::Any aRet;
395     ::osl::MutexGuard   aGuard( m_aMutex );
396     IsValid();
397     return pPixelCtl->GetControlForeground().GetColor();
398 }
399 
getBackground()400 sal_Int32 SvxPixelCtlAccessible::getBackground(  )
401 {
402     uno::Any aRet;
403     ::osl::MutexGuard   aGuard( m_aMutex );
404     IsValid();
405     return pPixelCtl->GetControlBackground().GetColor();
406 }
407 
getImplementationName()408 ::rtl::OUString SvxPixelCtlAccessible::getImplementationName(  )
409 {
410     return rtl::OUString::createFromAscii("SvxPixelCtlAccessible");
411 }
412 /*-- 04.02.2002 14:12:05---------------------------------------------------
413 
414   -----------------------------------------------------------------------*/
415 const sal_Char sAccessible[]          = "Accessible";
416 const sal_Char sAccessibleContext[]   = "AccessibleContext";
417 const sal_Char sAccessibleComponent[] = "AccessibleComponent";
418 //const sal_Char sAccessibleTable[] = "AccessibleTable";
419 
supportsService(const::rtl::OUString & rServiceName)420 sal_Bool SvxPixelCtlAccessible::supportsService( const ::rtl::OUString& rServiceName )
421 {
422     return  rServiceName.equalsAsciiL( sAccessible         , sizeof(sAccessible         )-1 ) ||
423             rServiceName.equalsAsciiL( sAccessibleContext  , sizeof(sAccessibleContext  )-1 ) ||
424             rServiceName.equalsAsciiL( sAccessibleComponent, sizeof(sAccessibleComponent)-1 );// ||
425 //            rServiceName.equalsAsciiL( sAccessibleTable, sizeof(sAccessibleTable)-1 );
426 }
427 /*-- 04.02.2002 14:12:05---------------------------------------------------
428 
429   -----------------------------------------------------------------------*/
getSupportedServiceNames()430 uno::Sequence< ::rtl::OUString > SvxPixelCtlAccessible::getSupportedServiceNames(  )
431 {
432     uno::Sequence< OUString > aRet(2);
433     OUString* pArray = aRet.getArray();
434     pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessible         ) );
435     pArray[1] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleContext  ) );
436     pArray[2] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleComponent) );
437 //    pArray[3] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleTable) );
438     return aRet;
439 }
440 
441 // -----------------------------------------------------------------------------
442 // XAccessibleSelection
443 // -----------------------------------------------------------------------------
selectAccessibleChild(sal_Int32 nChildIndex)444 void SAL_CALL SvxPixelCtlAccessible::selectAccessibleChild( sal_Int32 nChildIndex )
445 {
446     ::osl::MutexGuard   aGuard( m_aMutex );
447     IsValid();
448 
449     if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount())
450         throw lang::IndexOutOfBoundsException();
451 
452     long nIndex = pPixelCtl->ShowPosition(pPixelCtl->IndexToPoint(nChildIndex));
453     NotifyChild(nIndex,sal_True,sal_False);
454 }
455 // -----------------------------------------------------------------------------
isAccessibleChildSelected(sal_Int32 nChildIndex)456 sal_Bool SAL_CALL SvxPixelCtlAccessible::isAccessibleChildSelected( sal_Int32 nChildIndex )
457 {
458     ::osl::MutexGuard   aGuard( m_aMutex );
459 
460     IsValid();
461 
462     return pPixelCtl->GetFoucsPosIndex() == nChildIndex;
463 }
464 // -----------------------------------------------------------------------------
clearAccessibleSelection()465 void SAL_CALL SvxPixelCtlAccessible::clearAccessibleSelection(  )
466 {
467     ::osl::MutexGuard   aGuard( m_aMutex );
468 
469     IsValid();
470 
471 }
472 // -----------------------------------------------------------------------------
selectAllAccessibleChildren()473 void SAL_CALL SvxPixelCtlAccessible::selectAllAccessibleChildren(  )
474 {
475     ::osl::MutexGuard   aGuard( m_aMutex );
476 
477     IsValid();
478 
479 }
480 // -----------------------------------------------------------------------------
getSelectedAccessibleChildCount()481 sal_Int32 SAL_CALL SvxPixelCtlAccessible::getSelectedAccessibleChildCount(  )
482 {
483     ::osl::MutexGuard   aGuard( m_aMutex );
484 
485     IsValid();
486 
487     return 1;
488 }
489 // -----------------------------------------------------------------------------
getSelectedAccessibleChild(sal_Int32 nSelectedChildIndex)490 uno::Reference< XAccessible > SAL_CALL SvxPixelCtlAccessible::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
491 {
492     ::osl::MutexGuard   aGuard( m_aMutex );
493 
494     IsValid();
495 
496     if ( nSelectedChildIndex >= 1)
497         throw lang::IndexOutOfBoundsException();
498 
499     uno::Reference< XAccessible > xChild;
500     if(pPixelCtl)
501     {
502         if(m_xCurChild.is())
503         {
504             xChild = m_xCurChild;
505         }
506     }
507     return xChild;
508 }
509 // -----------------------------------------------------------------------------
deselectAccessibleChild(sal_Int32)510 void SAL_CALL SvxPixelCtlAccessible::deselectAccessibleChild( sal_Int32 )
511 {
512     ::osl::MutexGuard   aGuard( m_aMutex );
513 
514     IsValid();
515 
516 
517 }
518 
519 // Added by lq
ensureIsAlive() const520 void SvxPixelCtlAccessible::ensureIsAlive() const
521 {
522     if( !IsAlive() )
523         throw lang::DisposedException();
524 }
525 
ensureIsValidRow(sal_Int32 nRow)526 void SvxPixelCtlAccessible::ensureIsValidRow( sal_Int32 nRow )
527 {
528     if( nRow >= pPixelCtl->GetHeight() || nRow <0)
529         throw lang::IndexOutOfBoundsException(
530             OUString( RTL_CONSTASCII_USTRINGPARAM( "row index is invalid" ) ), *this );
531 }
532 
ensureIsValidColumn(sal_Int32 nColumn)533 void SvxPixelCtlAccessible::ensureIsValidColumn( sal_Int32 nColumn )
534 {
535     if( nColumn >= pPixelCtl->GetWidth() || nColumn <0 )
536         throw lang::IndexOutOfBoundsException(
537             OUString( RTL_CONSTASCII_USTRINGPARAM("column index is invalid") ), *this );
538 }
539 
ensureIsValidAddress(sal_Int32 nRow,sal_Int32 nColumn)540 void SvxPixelCtlAccessible::ensureIsValidAddress(
541         sal_Int32 nRow, sal_Int32 nColumn )
542 {
543     ensureIsValidRow( nRow );
544     ensureIsValidColumn( nColumn );
545 }
546 
ensureIsValidIndex(sal_Int32 nChildIndex)547 void SvxPixelCtlAccessible::ensureIsValidIndex( sal_Int32 nChildIndex )
548 {
549     if( nChildIndex >=  pPixelCtl->GetSquares())
550         throw lang::IndexOutOfBoundsException(
551             OUString( RTL_CONSTASCII_USTRINGPARAM("child index is invalid") ), *this );
552 }
553 
554 // XAccessibleTable -----------------------------------------------------------
555 /*
556 sal_Int32 SAL_CALL SvxPixelCtlAccessible::getAccessibleRowCount()
557     throw ( uno::RuntimeException )
558 {
559    ::osl::MutexGuard    aGuard( m_aMutex );
560    ensureIsAlive();
561     return pPixelCtl->GetLineCount();
562 }
563 
564 sal_Int32 SAL_CALL SvxPixelCtlAccessible::getAccessibleColumnCount()
565     throw ( uno::RuntimeException )
566 {
567     ::osl::MutexGuard   aGuard( m_aMutex );
568     ensureIsAlive();
569     return pPixelCtl->GetLineCount();
570 }
571 
572 sal_Int32 SAL_CALL SvxPixelCtlAccessible::getAccessibleRowExtentAt(
573         sal_Int32 nRow, sal_Int32 nColumn )
574     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
575 {
576     ::osl::MutexGuard   aGuard( m_aMutex );
577     ensureIsAlive();
578     return 1;   // merged cells not supported
579 }
580 
581 sal_Int32 SAL_CALL SvxPixelCtlAccessible::getAccessibleColumnExtentAt(
582         sal_Int32 nRow, sal_Int32 nColumn )
583     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
584 {
585     ::osl::MutexGuard   aGuard( m_aMutex );
586     ensureIsAlive();
587     return 1;   // merged cells not supported
588 }
589 
590 uno::Reference< XAccessible > SAL_CALL SvxPixelCtlAccessible::getAccessibleCaption()
591     throw ( uno::RuntimeException )
592 {
593     uno::Reference< XAccessible > xAccessble;
594     ensureIsAlive();
595     return xAccessble;    // not supported
596 }
597 
598 uno::Reference< XAccessible > SAL_CALL SvxPixelCtlAccessible::getAccessibleSummary()
599     throw ( uno::RuntimeException )
600 {
601     uno::Reference< XAccessible > xAccessble;
602     ensureIsAlive();
603     return xAccessble;    // not supported
604 }
605 
606 sal_Int32 SAL_CALL SvxPixelCtlAccessible::getAccessibleIndex(
607         sal_Int32 nRow, sal_Int32 nColumn )
608     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
609 {
610     ::osl::MutexGuard   aGuard( m_aMutex );
611     ensureIsAlive();
612     ensureIsValidAddress(nRow,nColumn);
613     return nRow + nColumn * pPixelCtl->GetLineCount() ;
614 }
615 
616 sal_Int32 SAL_CALL SvxPixelCtlAccessible::getAccessibleRow( sal_Int32 nChildIndex )
617     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
618 {
619     ::osl::MutexGuard   aGuard( m_aMutex );
620     ensureIsAlive();
621     ensureIsValidIndex( nChildIndex );
622     return nChildIndex/pPixelCtl->GetLineCount();
623 }
624 
625 sal_Int32 SAL_CALL SvxPixelCtlAccessible::getAccessibleColumn( sal_Int32 nChildIndex )
626     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
627 {
628     ::osl::MutexGuard   aGuard( m_aMutex );
629     ensureIsAlive();
630     ensureIsValidIndex( nChildIndex );
631     return nChildIndex%pPixelCtl->GetLineCount();
632 }
633 
634 ::rtl::OUString SAL_CALL SvxPixelCtlAccessible::getAccessibleRowDescription( sal_Int32 nRow )
635     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
636 {
637     ::osl::MutexGuard   aGuard( m_aMutex );
638     ensureIsAlive();
639     ensureIsValidRow( nRow );
640     return ::rtl::OUString::createFromAscii ("");
641 }
642 
643 ::rtl::OUString SAL_CALL SvxPixelCtlAccessible::getAccessibleColumnDescription( sal_Int32 nColumn )
644     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
645 {
646     ::osl::MutexGuard   aGuard( m_aMutex );
647     ensureIsAlive();
648     ensureIsValidColumn( nColumn );
649     return ::rtl::OUString::createFromAscii ("");
650 }
651 
652 uno::Reference< XAccessibleTable > SAL_CALL SvxPixelCtlAccessible::getAccessibleRowHeaders()
653     throw ( uno::RuntimeException )
654 {
655     ::osl::MutexGuard   aGuard( m_aMutex );
656     uno::Reference< XAccessibleTable > xAccessble;
657     ensureIsAlive();
658     return xAccessble;
659 }
660 
661 uno::Reference< XAccessibleTable > SAL_CALL SvxPixelCtlAccessible::getAccessibleColumnHeaders()
662     throw ( uno::RuntimeException )
663 {
664     ::osl::MutexGuard   aGuard( m_aMutex );
665     uno::Reference< XAccessibleTable > xAccessble;
666     ensureIsAlive();
667     return xAccessble;
668 }
669 
670 Sequence< sal_Int32 > SAL_CALL SvxPixelCtlAccessible::getSelectedAccessibleRows()
671     throw ( uno::RuntimeException )
672 {
673     ::osl::MutexGuard   aGuard( m_aMutex );
674     Sequence< sal_Int32 > accRows;
675     ensureIsAlive();
676 
677     return accRows;
678 }
679 
680 Sequence< sal_Int32 > SAL_CALL SvxPixelCtlAccessible::getSelectedAccessibleColumns()
681     throw ( uno::RuntimeException )
682 {
683     ::osl::MutexGuard   aGuard( m_aMutex );
684     Sequence< sal_Int32 > accColumns;
685     ensureIsAlive();
686 
687     return accColumns;
688 }
689 
690 sal_Bool SAL_CALL SvxPixelCtlAccessible::isAccessibleRowSelected( sal_Int32 nRow )
691     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
692 {
693     ::osl::MutexGuard   aGuard( m_aMutex );
694     ensureIsAlive();
695     ensureIsValidRow( nRow );
696     return sal_False;
697 }
698 
699 sal_Bool SAL_CALL SvxPixelCtlAccessible::isAccessibleColumnSelected( sal_Int32 nColumn )
700     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
701 {
702     ::osl::MutexGuard   aGuard( m_aMutex );
703     ensureIsAlive();
704     ensureIsValidColumn( nColumn );
705     return sal_False;
706 }
707 
708 uno::Reference< XAccessible > SAL_CALL SvxPixelCtlAccessible::getAccessibleCellAt(
709         sal_Int32 nRow, sal_Int32 nColumn )
710     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
711 {
712     ::osl::MutexGuard   aGuard( m_aMutex );
713     ensureIsAlive();
714     ensureIsValidAddress( nRow, nColumn );
715     return getAccessibleChild(nRow*pPixelCtl->GetLineCount()+nColumn);
716 }
717 
718 sal_Bool SAL_CALL SvxPixelCtlAccessible::isAccessibleSelected(
719         sal_Int32 nRow, sal_Int32 nColumn )
720     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
721 {
722     ::osl::MutexGuard   aGuard( m_aMutex );
723     ensureIsAlive();
724     ensureIsValidAddress( nRow, nColumn );
725     return isAccessibleChildSelected(nRow*pPixelCtl->GetLineCount()+nColumn);
726 }
727 // Added by lq end
728 */
729 
730 //XAccessibleEventBroadcaster
addEventListener(const uno::Reference<XAccessibleEventListener> & xListener)731 void SAL_CALL SvxPixelCtlAccessible::addEventListener( const uno::Reference< XAccessibleEventListener >& xListener )
732 {
733     if (xListener.is())
734     {
735         ::osl::MutexGuard   aGuard( m_aMutex );
736         if (!mnClientId)
737                 mnClientId = comphelper::AccessibleEventNotifier::registerClient( );
738         comphelper::AccessibleEventNotifier::addEventListener( mnClientId, xListener );
739     }
740 }
741 
removeEventListener(const uno::Reference<XAccessibleEventListener> & xListener)742 void SAL_CALL SvxPixelCtlAccessible::removeEventListener( const uno::Reference< XAccessibleEventListener >& xListener )
743 {
744     if (xListener.is())
745     {
746         ::osl::MutexGuard   aGuard( m_aMutex );
747 
748         sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener );
749         if ( !nListenerCount )
750         {
751             comphelper::AccessibleEventNotifier::revokeClient( mnClientId );
752             mnClientId = 0;
753         }
754     }
755 }
CommitChange(const AccessibleEventObject & rEvent)756 void SvxPixelCtlAccessible::CommitChange( const AccessibleEventObject& rEvent )
757 {
758     if (mnClientId)
759         comphelper::AccessibleEventNotifier::addEvent( mnClientId, rEvent );
760 }
761 
762 //Solution:Add the event handling method
FireAccessibleEvent(short nEventId,const::com::sun::star::uno::Any & rOld,const::com::sun::star::uno::Any & rNew)763 void SvxPixelCtlAccessible::FireAccessibleEvent (short nEventId, const ::com::sun::star::uno::Any& rOld, const ::com::sun::star::uno::Any& rNew)
764 {
765     const uno::Reference< XInterface >  xSource( *this );
766     CommitChange( AccessibleEventObject( xSource, nEventId, rNew,rOld ) );
767 }
768 
disposing()769 void SAL_CALL SvxPixelCtlAccessible::disposing()
770 {
771     if( !rBHelper.bDisposed )
772     {
773         {
774             ::osl::MutexGuard   aGuard( m_aMutex );
775             if ( mnClientId )
776             {
777                 comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this );
778                 mnClientId =  0;
779             }
780         }
781         //mxParent = uno::Reference< XAccessible >();
782 
783     }
784 }
Invalidate()785 void SvxPixelCtlAccessible::Invalidate()
786 {
787     pPixelCtl = 0;
788 }
ThrowExceptionIfNotAlive(void)789 void SvxPixelCtlAccessible::ThrowExceptionIfNotAlive( void )
790 {
791     if( IsNotAlive() )
792         throw lang::DisposedException();
793 }
IsValid()794 void SvxPixelCtlAccessible::IsValid()
795 {
796     if(!pPixelCtl)
797         throw uno::RuntimeException();
798 }
799 
800 
NotifyChild(long nIndex,sal_Bool bSelect,sal_Bool bCheck)801 void SvxPixelCtlAccessible::NotifyChild(long nIndex,sal_Bool bSelect ,sal_Bool bCheck)
802 {
803     DBG_ASSERT( !(!bSelect && !bCheck),"" );//non is false
804 
805     SvxPixelCtlAccessibleChild *pChild= NULL;
806 
807     if (m_xCurChild.is())
808     {
809         pChild= static_cast<SvxPixelCtlAccessibleChild*>(m_xCurChild.get());
810         DBG_ASSERT(pChild,"Child Must be Valid");
811         if (pChild->getAccessibleIndexInParent() == nIndex )
812         {
813             if (bSelect)
814             {
815                 pChild->SelectChild(sal_True);
816             }
817             if (bCheck)
818             {
819                 pChild->ChangePixelColorOrBG(sal_Bool(pPixelCtl->GetBitmapPixel(sal_uInt16(nIndex))));
820                 pChild->CheckChild();
821             }
822             return ;
823         }
824     }
825     uno::Reference <XAccessible> xNewChild =CreateChild(nIndex, pPixelCtl->IndexToPoint(nIndex));
826     SvxPixelCtlAccessibleChild *pNewChild= static_cast<SvxPixelCtlAccessibleChild*>(xNewChild.get());
827     DBG_ASSERT(pNewChild,"Child Must be Valid");
828 
829     Any aNewValue,aOldValue;
830     aNewValue<<= xNewChild;
831     FireAccessibleEvent(    AccessibleEventId::ACTIVE_DESCENDANT_CHANGED,
832                             aOldValue,
833                             aNewValue );
834 
835     if (bSelect)
836     {
837         if (pChild)
838         {
839             pChild->SelectChild(sal_False);
840         }
841         pNewChild->SelectChild(sal_True);
842     }
843     if (bCheck)
844     {
845         pNewChild->CheckChild();
846     }
847     m_xCurChild= xNewChild;
848 
849 
850 }
851 
CreateChild(long nIndex,Point mPoint)852 uno::Reference<XAccessible> SvxPixelCtlAccessible::CreateChild (long nIndex,Point mPoint)
853 {
854     long nX = mPoint.X();
855     long nY = mPoint.Y();
856     if( Application::GetSettings().GetLayoutRTL())
857     {
858         nX = (sal_uInt16) pPixelCtl->GetWidth() - 1 - nX;
859     }
860 
861     sal_Bool bPixelColorOrBG= sal_Bool(pPixelCtl->GetBitmapPixel(sal_uInt16(nIndex)));
862     Size size(pPixelCtl->GetWidth() / pPixelCtl->GetLineCount(),pPixelCtl->GetHeight() / pPixelCtl->GetLineCount());
863     uno::Reference<XAccessible> xChild;
864     xChild = new SvxPixelCtlAccessibleChild(pPixelCtl,
865                 bPixelColorOrBG,
866                 Point(nX,nY),
867                 Rectangle(mPoint,size),
868                 this,
869                 nIndex);
870 
871     return xChild;
872 }
873 
874 
LoseFocus()875 void SvxPixelCtlAccessible::LoseFocus()
876 {
877     m_xCurChild = uno::Reference< XAccessible >() ;
878 }
879 
CheckChild()880 void SvxPixelCtlAccessibleChild::CheckChild()
881 {
882     Any aChecked;
883     aChecked <<= AccessibleStateType::CHECKED;
884 
885     if (m_bPixelColorOrBG)//Current Child State
886     {
887         FireAccessibleEvent(    AccessibleEventId::STATE_CHANGED,
888                                 Any(),
889                                 aChecked);
890     }
891     else
892     {
893         FireAccessibleEvent(    AccessibleEventId::STATE_CHANGED,
894                                 aChecked,
895                                 Any() );
896     }
897 }
898 
SelectChild(sal_Bool bSelect)899 void SvxPixelCtlAccessibleChild::SelectChild( sal_Bool bSelect)
900 {
901     Any aSelected;
902     aSelected <<= AccessibleStateType::SELECTED;
903 
904     if (bSelect)
905     {
906         FireAccessibleEvent(    AccessibleEventId::STATE_CHANGED,
907                                 Any(),
908                                 aSelected);
909     }
910     else
911     {
912         FireAccessibleEvent(    AccessibleEventId::STATE_CHANGED,
913                                 aSelected,
914                                 Any());
915     }
916 }
FireAccessibleEvent(short nEventId,const::com::sun::star::uno::Any & rOld,const::com::sun::star::uno::Any & rNew)917 void SvxPixelCtlAccessibleChild::FireAccessibleEvent (
918     short nEventId,
919     const ::com::sun::star::uno::Any& rOld,
920     const ::com::sun::star::uno::Any& rNew)
921 {
922     const uno::Reference< XInterface >  xSource( *this );
923     CommitChange( AccessibleEventObject( xSource, nEventId, rNew,rOld ) );
924 }
925 
926 
927 
DBG_NAME(SvxPixelCtlAccessibleChild)928 DBG_NAME( SvxPixelCtlAccessibleChild )
929 
930 
931 SvxPixelCtlAccessibleChild::SvxPixelCtlAccessibleChild(
932     SvxPixelCtl* rWindow,
933     sal_Bool bPixelColorOrBG,
934     const Point &aPoint,
935     const Rectangle& rBoundingBox,
936     const uno::Reference<XAccessible>&  rxParent,
937     long nIndexInParent ) :
938     SvxPixelCtlAccessibleChild_BASE( m_aMutex ),
939     mrParentWindow( rWindow ),
940     mxParent(rxParent),
941     m_bPixelColorOrBG(bPixelColorOrBG),
942     maPoint(aPoint),
943     mpBoundingBox( new Rectangle( rBoundingBox ) ),
944     mnIndexInParent( nIndexInParent ),
945     mnClientId( 0 )
946 {
947     DBG_CTOR( SvxPixelCtlAccessibleChild, NULL );
948 }
949 
950 
~SvxPixelCtlAccessibleChild()951 SvxPixelCtlAccessibleChild::~SvxPixelCtlAccessibleChild()
952 {
953     DBG_DTOR( SvxPixelCtlAccessibleChild, NULL );
954 
955     if( IsAlive() )
956     {
957         osl_incrementInterlockedCount( &m_refCount );
958         dispose();      // set mpRepr = NULL & release all childs
959     }
960 }
961 
962 //=====  XAccessible  =========================================================
963 
getAccessibleContext(void)964 uno::Reference< XAccessibleContext> SAL_CALL SvxPixelCtlAccessibleChild::getAccessibleContext( void )
965 {
966     return this;
967 }
968 
969 //=====  XAccessibleComponent  ================================================
970 
containsPoint(const awt::Point & rPoint)971 sal_Bool SAL_CALL SvxPixelCtlAccessibleChild::containsPoint( const awt::Point& rPoint )
972 {
973     // no guard -> done in getBounds()
974 //  return GetBoundingBox().IsInside( VCLPoint( rPoint ) );
975     return Rectangle( Point( 0, 0 ), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) );
976 }
977 
getAccessibleAtPoint(const awt::Point &)978 uno::Reference< XAccessible > SAL_CALL SvxPixelCtlAccessibleChild::getAccessibleAtPoint( const awt::Point& )
979 {
980     return uno::Reference< XAccessible >();
981 }
982 
getBounds()983 awt::Rectangle SAL_CALL SvxPixelCtlAccessibleChild::getBounds()
984 {
985     // no guard -> done in getBoundingBox()
986     //Modified by lq, 09/26
987     //return AWTRectangle( GetBoundingBox() );
988     awt::Rectangle rect = AWTRectangle( GetBoundingBox() );
989     rect.X = rect.X + mrParentWindow->GetClientWindowExtentsRelative(NULL).Left()-mrParentWindow->GetWindowExtentsRelative(NULL).Left();
990     rect.Y = rect.Y + mrParentWindow->GetClientWindowExtentsRelative(NULL).Top()-mrParentWindow->GetWindowExtentsRelative(NULL).Top();
991     return rect;
992     // End
993 }
994 
getLocation()995 awt::Point SAL_CALL SvxPixelCtlAccessibleChild::getLocation()
996 {
997     // no guard -> done in getBoundingBox()
998     return AWTPoint( GetBoundingBox().TopLeft() );
999 }
1000 
getLocationOnScreen()1001 awt::Point SAL_CALL SvxPixelCtlAccessibleChild::getLocationOnScreen()
1002 {
1003     // no guard -> done in getBoundingBoxOnScreen()
1004     return AWTPoint( GetBoundingBoxOnScreen().TopLeft() );
1005 }
1006 
getSize()1007 awt::Size SAL_CALL SvxPixelCtlAccessibleChild::getSize()
1008 {
1009     // no guard -> done in getBoundingBox()
1010     return AWTSize( GetBoundingBox().GetSize() );
1011 }
1012 
grabFocus()1013 void SAL_CALL SvxPixelCtlAccessibleChild::grabFocus()
1014 {
1015 }
1016 
getForeground()1017 sal_Int32 SvxPixelCtlAccessibleChild::getForeground(  )
1018 {
1019     //::vos::OGuard       aSolarGuard( Application::GetSolarMutex() );
1020     ::osl::MutexGuard   aGuard( m_aMutex );
1021     ThrowExceptionIfNotAlive();
1022     return mrParentWindow->GetControlForeground().GetColor();
1023 }
getBackground()1024 sal_Int32 SvxPixelCtlAccessibleChild::getBackground(  )
1025 {
1026     //::vos::OGuard       aSolarGuard( Application::GetSolarMutex() );
1027     ::osl::MutexGuard   aGuard( m_aMutex );
1028 
1029     ThrowExceptionIfNotAlive();
1030     return mrParentWindow->GetControlBackground().GetColor();
1031 }
1032 
1033 //=====  XAccessibleContext  ==================================================
1034 
getAccessibleChildCount(void)1035 sal_Int32 SAL_CALL SvxPixelCtlAccessibleChild::getAccessibleChildCount( void )
1036 {
1037     return 0;
1038 }
1039 
getAccessibleChild(sal_Int32)1040 uno::Reference< XAccessible > SAL_CALL SvxPixelCtlAccessibleChild::getAccessibleChild( sal_Int32 )
1041 {
1042     throw lang::IndexOutOfBoundsException();
1043 }
1044 
getAccessibleParent(void)1045 uno::Reference< XAccessible > SAL_CALL SvxPixelCtlAccessibleChild::getAccessibleParent( void )
1046 {
1047     return mxParent;
1048 }
1049 
getAccessibleIndexInParent(void)1050 sal_Int32 SAL_CALL SvxPixelCtlAccessibleChild::getAccessibleIndexInParent( void )
1051 {
1052    return mnIndexInParent;
1053 }
1054 
getAccessibleRole(void)1055 sal_Int16 SAL_CALL SvxPixelCtlAccessibleChild::getAccessibleRole( void )
1056 {
1057     return AccessibleRole::CHECK_BOX;
1058 }
1059 
getAccessibleDescription(void)1060 OUString SAL_CALL SvxPixelCtlAccessibleChild::getAccessibleDescription( void )
1061 {
1062     ::osl::MutexGuard   aGuard( m_aMutex );
1063 
1064     return  GetName();
1065 }
1066 
getAccessibleName(void)1067 OUString SAL_CALL SvxPixelCtlAccessibleChild::getAccessibleName( void )
1068 {
1069     ::osl::MutexGuard   aGuard( m_aMutex );
1070     return  GetName();
1071 }
1072 
1073 /** Return empty uno::Reference to indicate that the relation set is not
1074     supported.
1075 */
getAccessibleRelationSet(void)1076 uno::Reference<XAccessibleRelationSet> SAL_CALL SvxPixelCtlAccessibleChild::getAccessibleRelationSet( void )
1077 {
1078     return uno::Reference< XAccessibleRelationSet >();
1079 }
1080 
getAccessibleStateSet(void)1081 uno::Reference< XAccessibleStateSet > SAL_CALL SvxPixelCtlAccessibleChild::getAccessibleStateSet( void )
1082 {
1083     ::osl::MutexGuard                       aGuard( m_aMutex );
1084     utl::AccessibleStateSetHelper*          pStateSetHelper = new utl::AccessibleStateSetHelper;
1085 
1086     if( IsAlive() )
1087     {
1088 
1089         pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
1090         pStateSetHelper->AddState( AccessibleStateType::ENABLED );
1091         pStateSetHelper->AddState( AccessibleStateType::OPAQUE );
1092         pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
1093         pStateSetHelper->AddState( AccessibleStateType::SHOWING );
1094         pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
1095 
1096         if (mrParentWindow )
1097         {
1098             long nIndex = mrParentWindow->GetFoucsPosIndex();
1099             if ( nIndex == mnIndexInParent)
1100             {
1101                 pStateSetHelper->AddState( AccessibleStateType::SELECTED );
1102             }
1103             if (mrParentWindow->GetBitmapPixel(sal_uInt16(mnIndexInParent)))
1104             {
1105                 pStateSetHelper->AddState( AccessibleStateType::CHECKED );
1106             }
1107         }
1108     }
1109     else
1110         pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
1111 
1112     return pStateSetHelper;
1113 }
1114 
getLocale(void)1115 lang::Locale SAL_CALL SvxPixelCtlAccessibleChild::getLocale( void )
1116 {
1117     ::osl::MutexGuard                       aGuard( m_aMutex );
1118     if( mxParent.is() )
1119     {
1120         uno::Reference< XAccessibleContext >        xParentContext( mxParent->getAccessibleContext() );
1121         if( xParentContext.is() )
1122             return xParentContext->getLocale();
1123     }
1124 
1125     //  No locale and no parent.  Therefore throw exception to indicate this
1126     //  cluelessness.
1127     throw IllegalAccessibleComponentStateException();
1128 }
1129 
addEventListener(const uno::Reference<XAccessibleEventListener> & xListener)1130 void SAL_CALL SvxPixelCtlAccessibleChild::addEventListener( const uno::Reference< XAccessibleEventListener >& xListener )
1131 {
1132     if (xListener.is())
1133     {
1134         ::osl::MutexGuard   aGuard( m_aMutex );
1135         if (!mnClientId)
1136             mnClientId = comphelper::AccessibleEventNotifier::registerClient( );
1137         comphelper::AccessibleEventNotifier::addEventListener( mnClientId, xListener );
1138     }
1139 }
1140 
1141 
1142 
1143 
removeEventListener(const uno::Reference<XAccessibleEventListener> & xListener)1144 void SAL_CALL SvxPixelCtlAccessibleChild::removeEventListener( const uno::Reference< XAccessibleEventListener >& xListener )
1145 {
1146     if (xListener.is())
1147     {
1148         ::osl::MutexGuard   aGuard( m_aMutex );
1149 
1150         sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener );
1151         if ( !nListenerCount )
1152         {
1153             // no listeners anymore
1154             // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
1155             // and at least to us not firing any events anymore, in case somebody calls
1156             // NotifyAccessibleEvent, again
1157             comphelper::AccessibleEventNotifier::revokeClient( mnClientId );
1158             mnClientId = 0;
1159         }
1160     }
1161 }
1162 
1163 
1164 //=====  XServiceInfo  ========================================================
1165 
getImplementationName(void)1166 OUString SAL_CALL SvxPixelCtlAccessibleChild::getImplementationName( void )
1167 {
1168     return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxPixelCtlAccessibleChild" ) );
1169 }
1170 
supportsService(const OUString & rServiceName)1171 sal_Bool SAL_CALL SvxPixelCtlAccessibleChild::supportsService( const OUString& rServiceName )
1172 {
1173     return  rServiceName.equalsAsciiL( sAccessible         , sizeof(sAccessible         )-1 ) ||
1174             rServiceName.equalsAsciiL( sAccessibleContext  , sizeof(sAccessibleContext  )-1 ) ||
1175             rServiceName.equalsAsciiL( sAccessibleComponent, sizeof(sAccessibleComponent)-1 );
1176 
1177 }
1178 
getSupportedServiceNames(void)1179 Sequence< OUString > SAL_CALL SvxPixelCtlAccessibleChild::getSupportedServiceNames( void )
1180 {
1181     uno::Sequence< OUString > aRet(3);
1182     OUString* pArray = aRet.getArray();
1183     pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessible         ) );
1184     pArray[1] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleContext  ) );
1185     pArray[2] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleComponent) );
1186     return aRet;
1187 }
1188 
1189 //=====  internal  ============================================================
1190 
CommitChange(const AccessibleEventObject & rEvent)1191 void SvxPixelCtlAccessibleChild::CommitChange( const AccessibleEventObject& rEvent )
1192 {
1193     if (mnClientId)
1194         comphelper::AccessibleEventNotifier::addEvent( mnClientId, rEvent );
1195 }
1196 
disposing()1197 void SAL_CALL SvxPixelCtlAccessibleChild::disposing()
1198 {
1199     if( !rBHelper.bDisposed )
1200     {
1201         ::osl::MutexGuard   aGuard( m_aMutex );
1202 
1203         // Send a disposing to all listeners.
1204         if ( mnClientId )
1205         {
1206             comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this );
1207             mnClientId =  0;
1208         }
1209 
1210         mxParent = uno::Reference< XAccessible >();
1211 
1212         delete mpBoundingBox;
1213     }
1214 }
1215 
ThrowExceptionIfNotAlive(void)1216 void SvxPixelCtlAccessibleChild::ThrowExceptionIfNotAlive( void )
1217 {
1218     if( IsNotAlive() )
1219         throw lang::DisposedException();
1220 }
1221 
GetBoundingBoxOnScreen(void)1222 Rectangle SvxPixelCtlAccessibleChild::GetBoundingBoxOnScreen( void )
1223 {
1224     ::osl::MutexGuard   aGuard( m_aMutex );
1225 
1226     // no ThrowExceptionIfNotAlive() because its done in GetBoundingBox()
1227     Rectangle           aRect( GetBoundingBox() );
1228 
1229     return Rectangle( mrParentWindow->OutputToAbsoluteScreenPixel( aRect.TopLeft() ), aRect.GetSize() );
1230 }
1231 
GetBoundingBox(void)1232 Rectangle SvxPixelCtlAccessibleChild::GetBoundingBox( void )
1233 {
1234     // no guard necessary, because no one changes mpBoundingBox after creating it
1235     ThrowExceptionIfNotAlive();
1236 
1237     return *mpBoundingBox;
1238 }
1239 
GetName()1240 ::rtl::OUString SvxPixelCtlAccessibleChild::GetName()
1241 {
1242     sal_Int32 nXIndex = mnIndexInParent % mrParentWindow->GetLineCount();
1243     sal_Int32 nYIndex = mnIndexInParent / mrParentWindow->GetLineCount();
1244 
1245     OUString str;
1246     str += OUString::createFromAscii("(");
1247     str += OUString::valueOf(nXIndex);
1248     str += OUString::createFromAscii(",");
1249     str += OUString::valueOf(nYIndex);
1250 //  str += OUString::createFromAscii(",");
1251 //  str += OUString::valueOf(m_bPixelColorOrBG);
1252     str += OUString::createFromAscii(")");
1253     return str;
1254 }
1255