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 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 #include "AccessibleDocumentViewBase.hxx"
27 #include <com/sun/star/drawing/XDrawPage.hpp>
28 #include <com/sun/star/drawing/XDrawView.hpp>
29 #include <com/sun/star/drawing/XShapes.hpp>
30 #include <com/sun/star/container/XChild.hpp>
31 #include <com/sun/star/frame/XController.hpp>
32 #include <com/sun/star/frame/XFrame.hpp>
33 #include <com/sun/star/document/XEventBroadcaster.hpp>
34 #include <com/sun/star/beans/XPropertySet.hpp>
35 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
36 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
37 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38 #include <rtl/ustring.h>
39 #include<sfx2/viewfrm.hxx>
40 
41 #include <svx/AccessibleShape.hxx>
42 
43 #include <svx/svdobj.hxx>
44 #include <svx/svdmodel.hxx>
45 #include <svx/unoapi.hxx>
46 #include <toolkit/helper/vclunohelper.hxx>
47 #include "Window.hxx"
48 #include <vcl/svapp.hxx>
49 
50 
51 #include "ViewShell.hxx"
52 #include "View.hxx"
53 #include <memory>
54 
55 using ::rtl::OUString;
56 using namespace ::com::sun::star;
57 using namespace	::com::sun::star::accessibility;
58 using ::com::sun::star::uno::Reference;
59 
60 class SfxViewFrame;
61 
62 namespace accessibility {
63 
64 //=====  internal  ============================================================
65 AccessibleDocumentViewBase::AccessibleDocumentViewBase (
66     ::sd::Window* pSdWindow,
67     ::sd::ViewShell* pViewShell,
68     const uno::Reference<frame::XController>& rxController,
69     const uno::Reference<XAccessible>& rxParent)
70     : AccessibleContextBase (rxParent, AccessibleRole::DOCUMENT),
71       mpWindow (pSdWindow),
72       mxController (rxController),
73       mxModel (NULL),
74       maViewForwarder (
75         static_cast<SdrPaintView*>(pViewShell->GetView()),
76         *static_cast<OutputDevice*>(pSdWindow))
77 {
78     if (mxController.is())
79         mxModel = mxController->getModel();
80 
81     // Fill the shape tree info.
82     maShapeTreeInfo.SetModelBroadcaster (
83         uno::Reference<document::XEventBroadcaster>(
84             mxModel, uno::UNO_QUERY));
85     maShapeTreeInfo.SetController (mxController);
86     maShapeTreeInfo.SetSdrView (pViewShell->GetView());
87     maShapeTreeInfo.SetWindow (pSdWindow);
88     maShapeTreeInfo.SetViewForwarder (&maViewForwarder);
89 
90     mxWindow = ::VCLUnoHelper::GetInterface (pSdWindow);
91 }
92 
93 
94 
95 
96 AccessibleDocumentViewBase::~AccessibleDocumentViewBase (void)
97 {
98     // At this place we should be disposed.  You may want to add a
99     // corresponding assertion into the destructor of a derived class.
100 }
101 
102 
103 
104 
105 void AccessibleDocumentViewBase::Init (void)
106 {
107     // Finish the initialization of the shape tree info container.
108     maShapeTreeInfo.SetDocumentWindow (this);
109 
110     // Register as window listener to stay up to date with its size and
111     // position.
112     mxWindow->addWindowListener (this);
113     // Register as focus listener to
114     mxWindow->addFocusListener (this);
115 
116     // Determine the list of shapes on the current page.
117     uno::Reference<drawing::XShapes> xShapeList;
118     uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY);
119     if (xView.is())
120         xShapeList = uno::Reference<drawing::XShapes> (
121             xView->getCurrentPage(), uno::UNO_QUERY);
122 
123     // Register this object as dispose event listener at the model.
124 	if (mxModel.is())
125 		mxModel->addEventListener (
126             static_cast<awt::XWindowListener*>(this));
127 
128     // Register as property change listener at the controller.
129     uno::Reference<beans::XPropertySet> xSet (mxController, uno::UNO_QUERY);
130     if (xSet.is())
131         xSet->addPropertyChangeListener (
132             OUString (RTL_CONSTASCII_USTRINGPARAM("")),
133             static_cast<beans::XPropertyChangeListener*>(this));
134 
135     // Register this object as dispose event listener at the controller.
136     if (mxController.is())
137         mxController->addEventListener (
138             static_cast<awt::XWindowListener*>(this));
139 
140     // Register at VCL Window to be informed of activated and deactivated
141     // OLE objects.
142     Window* pWindow = maShapeTreeInfo.GetWindow();
143     if (pWindow != NULL)
144     {
145         maWindowLink = LINK(
146             this, AccessibleDocumentViewBase, WindowChildEventListener);
147 
148         pWindow->AddChildEventListener (maWindowLink);
149 
150         sal_uInt16 nCount = pWindow->GetChildCount();
151         for (sal_uInt16 i=0; i<nCount; i++)
152         {
153             Window* pChildWindow = pWindow->GetChild (i);
154             if (pChildWindow &&
155                 (AccessibleRole::EMBEDDED_OBJECT
156                     ==pChildWindow->GetAccessibleRole()))
157             {
158                 SetAccessibleOLEObject (pChildWindow->GetAccessible());
159             }
160         }
161     }
162 }
163 
164 
165 
166 
167 IMPL_LINK(AccessibleDocumentViewBase, WindowChildEventListener,
168     VclSimpleEvent*, pEvent)
169 {
170     OSL_ASSERT(pEvent!=NULL && pEvent->ISA(VclWindowEvent));
171     if (pEvent!=NULL && pEvent->ISA(VclWindowEvent))
172     {
173         VclWindowEvent* pWindowEvent = static_cast<VclWindowEvent*>(pEvent);
174         //      DBG_ASSERT( pVclEvent->GetWindow(), "Window???" );
175         switch (pWindowEvent->GetId())
176         {
177             case VCLEVENT_OBJECT_DYING:
178             {
179                 // Window is dying.  Unregister from VCL Window.
180                 // This is also attempted in the disposing() method.
181                 Window* pWindow = maShapeTreeInfo.GetWindow();
182                 Window* pDyingWindow = static_cast<Window*>(
183                     pWindowEvent->GetWindow());
184                 if (pWindow==pDyingWindow && pWindow!=NULL && maWindowLink.IsSet())
185                 {
186                     pWindow->RemoveChildEventListener (maWindowLink);
187                     maWindowLink = Link();
188                 }
189             }
190             break;
191 
192             case VCLEVENT_WINDOW_SHOW:
193             {
194                 // A new window has been created.  Is it an OLE object?
195                 Window* pChildWindow = static_cast<Window*>(
196                     pWindowEvent->GetData());
197                 if (pChildWindow!=NULL
198                     && (pChildWindow->GetAccessibleRole()
199                         == AccessibleRole::EMBEDDED_OBJECT))
200                 {
201                     SetAccessibleOLEObject (pChildWindow->GetAccessible());
202                 }
203             }
204             break;
205 
206             case VCLEVENT_WINDOW_HIDE:
207             {
208                 // A window has been destroyed.  Has that been an OLE
209                 // object?
210                 Window* pChildWindow = static_cast<Window*>(
211                     pWindowEvent->GetData());
212                 if (pChildWindow!=NULL
213                     && (pChildWindow->GetAccessibleRole()
214                         == AccessibleRole::EMBEDDED_OBJECT))
215                 {
216                     SetAccessibleOLEObject (NULL);
217                 }
218             }
219             break;
220         }
221     }
222 
223     return 0;
224 }
225 
226 
227 
228 
229 //=====  IAccessibleViewForwarderListener  ====================================
230 
231 void AccessibleDocumentViewBase::ViewForwarderChanged(ChangeType, const IAccessibleViewForwarder* )
232 {
233     // Empty
234 }
235 
236 
237 
238 
239 //=====  XAccessibleContext  ==================================================
240 
241 Reference<XAccessible> SAL_CALL
242    	AccessibleDocumentViewBase::getAccessibleParent (void)
243     throw (uno::RuntimeException)
244 {
245     ThrowIfDisposed ();
246 
247     return AccessibleContextBase::getAccessibleParent();
248 }
249 
250 
251 
252 sal_Int32 SAL_CALL
253     AccessibleDocumentViewBase::getAccessibleChildCount (void)
254     throw (uno::RuntimeException)
255 {
256     ThrowIfDisposed ();
257 
258     if (mxAccessibleOLEObject.is())
259         return 1;
260     else
261         return 0;
262 }
263 
264 
265 
266 
267 Reference<XAccessible> SAL_CALL
268     AccessibleDocumentViewBase::getAccessibleChild (sal_Int32 nIndex)
269     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
270 {
271     ThrowIfDisposed ();
272 
273     ::osl::MutexGuard aGuard (maMutex);
274     if (mxAccessibleOLEObject.is())
275         if (nIndex == 0)
276             return mxAccessibleOLEObject;
277 
278     throw lang::IndexOutOfBoundsException (
279         ::rtl::OUString::createFromAscii ("no child with index ")
280         + rtl::OUString::valueOf(nIndex),
281 		NULL);
282 }
283 
284 
285 
286 
287 //=====  XAccessibleComponent  ================================================
288 
289 /** Iterate over all children and test whether the specified point lies
290     within one of their bounding boxes.  Return the first child for which
291     this is true.
292 */
293 uno::Reference<XAccessible > SAL_CALL
294     AccessibleDocumentViewBase::getAccessibleAtPoint (
295         const awt::Point& aPoint)
296     throw (uno::RuntimeException)
297 {
298     ThrowIfDisposed ();
299 
300     ::osl::MutexGuard aGuard (maMutex);
301     uno::Reference<XAccessible> xChildAtPosition;
302 
303     sal_Int32 nChildCount = getAccessibleChildCount ();
304     for (sal_Int32 i=nChildCount-1; i>=0; --i)
305     {
306         Reference<XAccessible> xChild (getAccessibleChild (i));
307         if (xChild.is())
308         {
309             Reference<XAccessibleComponent> xChildComponent (
310                 xChild->getAccessibleContext(), uno::UNO_QUERY);
311             if (xChildComponent.is())
312             {
313                 awt::Rectangle aBBox (xChildComponent->getBounds());
314                 if ( (aPoint.X >= aBBox.X)
315                     && (aPoint.Y >= aBBox.Y)
316                     && (aPoint.X < aBBox.X+aBBox.Width)
317                     && (aPoint.Y < aBBox.Y+aBBox.Height) )
318                 {
319                     xChildAtPosition = xChild;
320                     break;
321                 }
322             }
323         }
324     }
325 
326     // Have not found a child under the given point.  Returning empty
327     // reference to indicate this.
328     return xChildAtPosition;
329 }
330 
331 
332 
333 
334 awt::Rectangle SAL_CALL
335     AccessibleDocumentViewBase::getBounds (void)
336     throw (::com::sun::star::uno::RuntimeException)
337 {
338     ThrowIfDisposed ();
339 
340     // Transform visible area into screen coordinates.
341     ::Rectangle aVisibleArea (
342         maShapeTreeInfo.GetViewForwarder()->GetVisibleArea());
343     ::Point aPixelTopLeft (
344         maShapeTreeInfo.GetViewForwarder()->LogicToPixel (
345             aVisibleArea.TopLeft()));
346     ::Point aPixelSize (
347         maShapeTreeInfo.GetViewForwarder()->LogicToPixel (
348             aVisibleArea.BottomRight())
349         - aPixelTopLeft);
350 
351     // Prepare to subtract the parent position to transform into relative
352     // coordinates.
353     awt::Point aParentPosition;
354     Reference<XAccessible> xParent = getAccessibleParent ();
355     if (xParent.is())
356     {
357         Reference<XAccessibleComponent> xParentComponent (
358             xParent->getAccessibleContext(), uno::UNO_QUERY);
359         if (xParentComponent.is())
360             aParentPosition = xParentComponent->getLocationOnScreen();
361     }
362 
363     return awt::Rectangle (
364         aPixelTopLeft.X() - aParentPosition.X,
365         aPixelTopLeft.Y() - aParentPosition.Y,
366         aPixelSize.X(),
367         aPixelSize.Y());
368 }
369 
370 
371 
372 
373 awt::Point SAL_CALL
374     AccessibleDocumentViewBase::getLocation (void)
375     throw (uno::RuntimeException)
376 {
377     ThrowIfDisposed ();
378     awt::Rectangle aBoundingBox (getBounds());
379     return awt::Point (aBoundingBox.X, aBoundingBox.Y);
380 }
381 
382 
383 
384 
385 awt::Point SAL_CALL
386     AccessibleDocumentViewBase::getLocationOnScreen (void)
387     throw (uno::RuntimeException)
388 {
389     ThrowIfDisposed ();
390     ::Point aLogicalPoint (maShapeTreeInfo.GetViewForwarder()->GetVisibleArea().TopLeft());
391     ::Point aPixelPoint (maShapeTreeInfo.GetViewForwarder()->LogicToPixel (aLogicalPoint));
392     return awt::Point (aPixelPoint.X(), aPixelPoint.Y());
393 }
394 
395 
396 
397 
398 awt::Size SAL_CALL
399     AccessibleDocumentViewBase::getSize (void)
400     throw (uno::RuntimeException)
401 {
402     ThrowIfDisposed ();
403 
404     // Transform visible area into screen coordinates.
405     ::Rectangle aVisibleArea (
406         maShapeTreeInfo.GetViewForwarder()->GetVisibleArea());
407     ::Point aPixelTopLeft (
408         maShapeTreeInfo.GetViewForwarder()->LogicToPixel (
409             aVisibleArea.TopLeft()));
410     ::Point aPixelSize (
411         maShapeTreeInfo.GetViewForwarder()->LogicToPixel (
412             aVisibleArea.BottomRight())
413         - aPixelTopLeft);
414 
415     return awt::Size (aPixelSize.X(), aPixelSize.Y());
416 }
417 
418 
419 
420 
421 //=====  XInterface  ==========================================================
422 
423 uno::Any SAL_CALL
424     AccessibleDocumentViewBase::queryInterface (const uno::Type & rType)
425     throw (uno::RuntimeException)
426 {
427     uno::Any aReturn = AccessibleContextBase::queryInterface (rType);
428     if ( ! aReturn.hasValue())
429         aReturn = ::cppu::queryInterface (rType,
430             static_cast<XAccessibleComponent*>(this),
431             static_cast<XAccessibleSelection*>(this),
432             static_cast<lang::XEventListener*>(
433                 static_cast<awt::XWindowListener*>(this)),
434             static_cast<beans::XPropertyChangeListener*>(this),
435             static_cast<awt::XWindowListener*>(this),
436             static_cast<awt::XFocusListener*>(this)
437             );
438     return aReturn;
439 }
440 
441 
442 
443 
444 void SAL_CALL
445     AccessibleDocumentViewBase::acquire (void)
446     throw ()
447 {
448     AccessibleContextBase::acquire ();
449 }
450 
451 
452 
453 
454 void SAL_CALL
455     AccessibleDocumentViewBase::release (void)
456     throw ()
457 {
458     AccessibleContextBase::release ();
459 }
460 
461 
462 
463 
464 //=====  XServiceInfo  ========================================================
465 
466 ::rtl::OUString SAL_CALL
467     AccessibleDocumentViewBase::getImplementationName (void)
468     throw (::com::sun::star::uno::RuntimeException)
469 {
470 	return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleDocumentViewBase"));
471 }
472 
473 
474 
475 
476 ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
477     AccessibleDocumentViewBase::getSupportedServiceNames (void)
478     throw (::com::sun::star::uno::RuntimeException)
479 {
480     ThrowIfDisposed ();
481     return AccessibleContextBase::getSupportedServiceNames ();
482 }
483 
484 
485 
486 
487 
488 //=====  XTypeProvider  =======================================================
489 
490 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> SAL_CALL
491     AccessibleDocumentViewBase::getTypes (void)
492     throw (::com::sun::star::uno::RuntimeException)
493 {
494     ThrowIfDisposed ();
495 
496     // Get list of types from the context base implementation, ...
497 	uno::Sequence<uno::Type> aTypeList (AccessibleContextBase::getTypes());
498     // ... get list of types from component base implementation, ...
499 	uno::Sequence<uno::Type> aComponentTypeList (AccessibleComponentBase::getTypes());
500 
501 
502     // ...and add the additional type for the component, ...
503     const uno::Type aLangEventListenerType =
504      	::getCppuType((const uno::Reference<lang::XEventListener>*)0);
505     const uno::Type aPropertyChangeListenerType =
506      	::getCppuType((const uno::Reference<beans::XPropertyChangeListener>*)0);
507     const uno::Type aWindowListenerType =
508      	::getCppuType((const uno::Reference<awt::XWindowListener>*)0);
509     const uno::Type aFocusListenerType =
510      	::getCppuType((const uno::Reference<awt::XFocusListener>*)0);
511     const uno::Type aEventBroadcaster =
512      	::getCppuType((const uno::Reference<XAccessibleEventBroadcaster>*)0);
513 
514     // ... and merge them all into one list.
515     sal_Int32 nTypeCount (aTypeList.getLength()),
516         nComponentTypeCount (aComponentTypeList.getLength()),
517         i;
518 
519     aTypeList.realloc (nTypeCount + nComponentTypeCount + 5);
520 
521     for (i=0; i<nComponentTypeCount; i++)
522         aTypeList[nTypeCount + i] = aComponentTypeList[i];
523 
524     aTypeList[nTypeCount + i++ ] = aLangEventListenerType;
525     aTypeList[nTypeCount + i++] = aPropertyChangeListenerType;
526     aTypeList[nTypeCount + i++] = aWindowListenerType;
527     aTypeList[nTypeCount + i++] = aFocusListenerType;
528     aTypeList[nTypeCount + i++] = aEventBroadcaster;
529 
530 	return aTypeList;
531 }
532 
533 
534 
535 
536 void AccessibleDocumentViewBase::impl_dispose()
537 {
538     // Unregister from VCL Window.
539     Window* pWindow = maShapeTreeInfo.GetWindow();
540     if (maWindowLink.IsSet())
541     {
542         if (pWindow)
543             pWindow->RemoveChildEventListener (maWindowLink);
544         maWindowLink = Link();
545     }
546     else
547     {
548         DBG_ASSERT (pWindow, "AccessibleDocumentViewBase::disposing");
549     }
550 
551     // Unregister from window.
552     if (mxWindow.is())
553     {
554         mxWindow->removeWindowListener (this);
555         mxWindow->removeFocusListener (this);
556         mxWindow = NULL;
557     }
558 
559     // Unregister form the model.
560     if (mxModel.is())
561         mxModel->removeEventListener (
562             static_cast<awt::XWindowListener*>(this));
563 
564     // Unregister from the controller.
565     if (mxController.is())
566     {
567         uno::Reference<beans::XPropertySet> xSet (mxController, uno::UNO_QUERY);
568         if (xSet.is())
569             xSet->removePropertyChangeListener (
570                 OUString (RTL_CONSTASCII_USTRINGPARAM("")),
571                 static_cast<beans::XPropertyChangeListener*>(this));
572 
573         mxController->removeEventListener (
574             static_cast<awt::XWindowListener*>(this));
575     }
576 
577     // Propagate change of controller down the shape tree.
578     maShapeTreeInfo.SetControllerBroadcaster (NULL);
579 
580     // Reset the model reference.
581     mxModel = NULL;
582     // Reset the model reference.
583     mxController = NULL;
584 
585     maShapeTreeInfo.SetDocumentWindow (NULL);
586 }
587 
588 
589 
590 
591 //=====  XEventListener  ======================================================
592 
593 void SAL_CALL
594     AccessibleDocumentViewBase::disposing (const lang::EventObject& rEventObject)
595     throw (::com::sun::star::uno::RuntimeException)
596 {
597     ThrowIfDisposed ();
598 
599     // Register this object as dispose event and document::XEventListener
600     // listener at the model.
601 
602     if ( ! rEventObject.Source.is())
603     {
604         // Paranoia. Can this really happen?
605     }
606     else if (rEventObject.Source == mxModel || rEventObject.Source == mxController)
607     {
608         impl_dispose();
609     }
610 }
611 
612 //=====  XPropertyChangeListener  =============================================
613 
614 void SAL_CALL AccessibleDocumentViewBase::propertyChange (const beans::PropertyChangeEvent& )
615     throw (::com::sun::star::uno::RuntimeException)
616 {
617     // Empty
618 }
619 
620 
621 
622 
623 //=====  XWindowListener  =====================================================
624 
625 void SAL_CALL
626     AccessibleDocumentViewBase::windowResized (const ::com::sun::star::awt::WindowEvent& )
627     throw (::com::sun::star::uno::RuntimeException)
628 {
629     if( IsDisposed() )
630         return;
631 
632     ViewForwarderChanged (
633         IAccessibleViewForwarderListener::VISIBLE_AREA,
634         &maViewForwarder);
635 }
636 
637 
638 
639 
640 void SAL_CALL
641     AccessibleDocumentViewBase::windowMoved (const ::com::sun::star::awt::WindowEvent& )
642     throw (::com::sun::star::uno::RuntimeException)
643 {
644     if( IsDisposed() )
645         return;
646 
647     ViewForwarderChanged (
648         IAccessibleViewForwarderListener::VISIBLE_AREA,
649         &maViewForwarder);
650 }
651 
652 
653 
654 
655 void SAL_CALL
656     AccessibleDocumentViewBase::windowShown (const ::com::sun::star::lang::EventObject& )
657     throw (::com::sun::star::uno::RuntimeException)
658 {
659     if( IsDisposed() )
660         return;
661 
662     ViewForwarderChanged (
663         IAccessibleViewForwarderListener::VISIBLE_AREA,
664         &maViewForwarder);
665 }
666 
667 
668 
669 
670 void SAL_CALL
671     AccessibleDocumentViewBase::windowHidden (const ::com::sun::star::lang::EventObject& )
672     throw (::com::sun::star::uno::RuntimeException)
673 {
674     if( IsDisposed() )
675         return;
676 
677     ViewForwarderChanged (
678         IAccessibleViewForwarderListener::VISIBLE_AREA,
679         &maViewForwarder);
680 }
681 
682 
683 
684 
685 //=====  XFocusListener  ==================================================
686 
687 void AccessibleDocumentViewBase::focusGained (const ::com::sun::star::awt::FocusEvent& e)
688     throw (::com::sun::star::uno::RuntimeException)
689 {
690     ThrowIfDisposed ();
691     if (e.Source == mxWindow)
692         Activated ();
693 }
694 
695 void AccessibleDocumentViewBase::focusLost (const ::com::sun::star::awt::FocusEvent& e)
696     throw (::com::sun::star::uno::RuntimeException)
697 {
698     ThrowIfDisposed ();
699     if (e.Source == mxWindow)
700         Deactivated ();
701 }
702 
703 
704 
705 
706 //=====  protected internal  ==================================================
707 
708 // This method is called from the component helper base class while disposing.
709 void SAL_CALL AccessibleDocumentViewBase::disposing (void)
710 {
711     impl_dispose();
712 
713     AccessibleContextBase::disposing ();
714 }
715 
716 
717 
718 
719 ///	Create a name for this view.
720 ::rtl::OUString
721     AccessibleDocumentViewBase::CreateAccessibleName (void)
722     throw (::com::sun::star::uno::RuntimeException)
723 {
724 	return ::rtl::OUString (
725         RTL_CONSTASCII_USTRINGPARAM("AccessibleDocumentViewBase"));
726 }
727 
728 
729 
730 
731 /** Create a description for this view.  Use the model's description or URL
732     if a description is not available.
733 */
734 ::rtl::OUString
735     AccessibleDocumentViewBase::CreateAccessibleDescription (void)
736     throw (::com::sun::star::uno::RuntimeException)
737 {
738 	rtl::OUString sDescription;
739 
740     uno::Reference<lang::XServiceInfo> xInfo (mxController, uno::UNO_QUERY);
741     if (xInfo.is())
742     {
743         OUString sFirstService = xInfo->getSupportedServiceNames()[0];
744         if (sFirstService == OUString (
745                 RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DrawingDocumentDrawView")))
746         {
747             sDescription = OUString (RTL_CONSTASCII_USTRINGPARAM("Draw Document"));
748         }
749         else
750             sDescription = sFirstService;
751     }
752     else
753         sDescription = OUString (
754             RTL_CONSTASCII_USTRINGPARAM("Accessible Draw Document"));
755 	return sDescription;
756 }
757 
758 
759 
760 
761 void AccessibleDocumentViewBase::Activated (void)
762 {
763     // Empty.  Overwrite to do something usefull.
764 }
765 
766 
767 
768 
769 void AccessibleDocumentViewBase::Deactivated (void)
770 {
771     // Empty.  Overwrite to do something usefull.
772 }
773 
774 
775 
776 
777 void AccessibleDocumentViewBase::SetAccessibleOLEObject (
778     const Reference <XAccessible>& xOLEObject)
779 {
780     // Send child event about removed accessible OLE object if necessary.
781     if (mxAccessibleOLEObject != xOLEObject)
782         if (mxAccessibleOLEObject.is())
783             CommitChange (
784                 AccessibleEventId::CHILD,
785                 uno::Any(),
786                 uno::makeAny (mxAccessibleOLEObject));
787 
788     // Assume that the accessible OLE Object disposes itself correctly.
789 
790     {
791         ::osl::MutexGuard aGuard (maMutex);
792         mxAccessibleOLEObject = xOLEObject;
793     }
794 
795     // Send child event about new accessible OLE object if necessary.
796     if (mxAccessibleOLEObject.is())
797         CommitChange (
798             AccessibleEventId::CHILD,
799             uno::makeAny (mxAccessibleOLEObject),
800             uno::Any());
801 }
802 
803 
804 
805 
806 //=====  methods from AccessibleSelectionBase ==================================================
807 
808 // return the member maMutex;
809 ::osl::Mutex&
810     AccessibleDocumentViewBase::implGetMutex()
811 {
812     return( maMutex );
813 }
814 
815 // return ourself as context in default case
816 uno::Reference< XAccessibleContext >
817     AccessibleDocumentViewBase::implGetAccessibleContext()
818     throw (uno::RuntimeException)
819 {
820     return( this );
821 }
822 
823 // return sal_False in default case
824 sal_Bool
825     AccessibleDocumentViewBase::implIsSelected( sal_Int32 )
826     throw (uno::RuntimeException)
827 {
828     return( sal_False );
829 }
830 
831 // return nothing in default case
832 void
833     AccessibleDocumentViewBase::implSelect( sal_Int32, sal_Bool )
834     throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
835 {
836 }
837 
838 } // end of namespace accessibility
839