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