xref: /trunk/main/sd/source/ui/accessibility/AccessibleDocumentViewBase.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 
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  ============================================================
AccessibleDocumentViewBase(::sd::Window * pSdWindow,::sd::ViewShell * pViewShell,const uno::Reference<frame::XController> & rxController,const uno::Reference<XAccessible> & rxParent)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 
~AccessibleDocumentViewBase(void)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 
Init(void)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 
IMPL_LINK(AccessibleDocumentViewBase,WindowChildEventListener,VclSimpleEvent *,pEvent)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 
ViewForwarderChanged(ChangeType,const IAccessibleViewForwarder *)242 void AccessibleDocumentViewBase::ViewForwarderChanged(ChangeType, const IAccessibleViewForwarder* )
243 {
244     // Empty
245 }
246 
247 
248 
249 
250 //=====  XAccessibleContext  ==================================================
251 
252 Reference<XAccessible> SAL_CALL
getAccessibleParent(void)253     AccessibleDocumentViewBase::getAccessibleParent (void)
254 {
255     ThrowIfDisposed ();
256 
257     return AccessibleContextBase::getAccessibleParent();
258 }
259 
260 
261 
262 sal_Int32 SAL_CALL
getAccessibleChildCount(void)263     AccessibleDocumentViewBase::getAccessibleChildCount (void)
264 {
265     ThrowIfDisposed ();
266 
267     if (mxAccessibleOLEObject.is())
268         return 1;
269     else
270         return 0;
271 }
272 
273 
274 
275 
276 Reference<XAccessible> SAL_CALL
getAccessibleChild(sal_Int32 nIndex)277     AccessibleDocumentViewBase::getAccessibleChild (sal_Int32 nIndex)
278 {
279     ThrowIfDisposed ();
280 
281     ::osl::MutexGuard aGuard (maMutex);
282     if (mxAccessibleOLEObject.is())
283         if (nIndex == 0)
284             return mxAccessibleOLEObject;
285 
286     throw lang::IndexOutOfBoundsException (
287         ::rtl::OUString::createFromAscii ("no child with index ")
288         + rtl::OUString::valueOf(nIndex),
289         NULL);
290 }
291 
292 
293 
294 
295 //=====  XAccessibleComponent  ================================================
296 
297 /** Iterate over all children and test whether the specified point lies
298     within one of their bounding boxes.  Return the first child for which
299     this is true.
300 */
301 uno::Reference<XAccessible > SAL_CALL
getAccessibleAtPoint(const awt::Point & aPoint)302     AccessibleDocumentViewBase::getAccessibleAtPoint (
303         const awt::Point& aPoint)
304 {
305     ThrowIfDisposed ();
306 
307     ::osl::MutexGuard aGuard (maMutex);
308     uno::Reference<XAccessible> xChildAtPosition;
309 
310     sal_Int32 nChildCount = getAccessibleChildCount ();
311     for (sal_Int32 i=nChildCount-1; i>=0; --i)
312     {
313         Reference<XAccessible> xChild (getAccessibleChild (i));
314         if (xChild.is())
315         {
316             Reference<XAccessibleComponent> xChildComponent (
317                 xChild->getAccessibleContext(), uno::UNO_QUERY);
318             if (xChildComponent.is())
319             {
320                 awt::Rectangle aBBox (xChildComponent->getBounds());
321                 if ( (aPoint.X >= aBBox.X)
322                     && (aPoint.Y >= aBBox.Y)
323                     && (aPoint.X < aBBox.X+aBBox.Width)
324                     && (aPoint.Y < aBBox.Y+aBBox.Height) )
325                 {
326                     xChildAtPosition = xChild;
327                     break;
328                 }
329             }
330         }
331     }
332 
333     // Have not found a child under the given point.  Returning empty
334     // reference to indicate this.
335     return xChildAtPosition;
336 }
337 
338 
339 
340 
341 awt::Rectangle SAL_CALL
getBounds(void)342     AccessibleDocumentViewBase::getBounds (void)
343 {
344     ThrowIfDisposed ();
345 
346     // Transform visible area into screen coordinates.
347     ::Rectangle aVisibleArea (
348         maShapeTreeInfo.GetViewForwarder()->GetVisibleArea());
349     ::Point aPixelTopLeft (
350         maShapeTreeInfo.GetViewForwarder()->LogicToPixel (
351             aVisibleArea.TopLeft()));
352     ::Point aPixelSize (
353         maShapeTreeInfo.GetViewForwarder()->LogicToPixel (
354             aVisibleArea.BottomRight())
355         - aPixelTopLeft);
356 
357     // Prepare to subtract the parent position to transform into relative
358     // coordinates.
359     awt::Point aParentPosition;
360     Reference<XAccessible> xParent = getAccessibleParent ();
361     if (xParent.is())
362     {
363         Reference<XAccessibleComponent> xParentComponent (
364             xParent->getAccessibleContext(), uno::UNO_QUERY);
365         if (xParentComponent.is())
366             aParentPosition = xParentComponent->getLocationOnScreen();
367     }
368 
369     return awt::Rectangle (
370         aPixelTopLeft.X() - aParentPosition.X,
371         aPixelTopLeft.Y() - aParentPosition.Y,
372         aPixelSize.X(),
373         aPixelSize.Y());
374 }
375 
376 
377 
378 
379 awt::Point SAL_CALL
getLocation(void)380     AccessibleDocumentViewBase::getLocation (void)
381 {
382     ThrowIfDisposed ();
383     awt::Rectangle aBoundingBox (getBounds());
384     return awt::Point (aBoundingBox.X, aBoundingBox.Y);
385 }
386 
387 
388 
389 
390 awt::Point SAL_CALL
getLocationOnScreen(void)391     AccessibleDocumentViewBase::getLocationOnScreen (void)
392 {
393     ThrowIfDisposed ();
394     ::Point aLogicalPoint (maShapeTreeInfo.GetViewForwarder()->GetVisibleArea().TopLeft());
395     ::Point aPixelPoint (maShapeTreeInfo.GetViewForwarder()->LogicToPixel (aLogicalPoint));
396     return awt::Point (aPixelPoint.X(), aPixelPoint.Y());
397 }
398 
399 
400 
401 
402 awt::Size SAL_CALL
getSize(void)403     AccessibleDocumentViewBase::getSize (void)
404 {
405     ThrowIfDisposed ();
406 
407     // Transform visible area into screen coordinates.
408     ::Rectangle aVisibleArea (
409         maShapeTreeInfo.GetViewForwarder()->GetVisibleArea());
410     ::Point aPixelTopLeft (
411         maShapeTreeInfo.GetViewForwarder()->LogicToPixel (
412             aVisibleArea.TopLeft()));
413     ::Point aPixelSize (
414         maShapeTreeInfo.GetViewForwarder()->LogicToPixel (
415             aVisibleArea.BottomRight())
416         - aPixelTopLeft);
417 
418     return awt::Size (aPixelSize.X(), aPixelSize.Y());
419 }
420 
421 
422 
423 
424 //=====  XInterface  ==========================================================
425 
426 uno::Any SAL_CALL
queryInterface(const uno::Type & rType)427     AccessibleDocumentViewBase::queryInterface (const uno::Type & rType)
428 {
429     uno::Any aReturn = AccessibleContextBase::queryInterface (rType);
430     if ( ! aReturn.hasValue())
431         aReturn = ::cppu::queryInterface (rType,
432             static_cast<XAccessibleComponent*>(this),
433             static_cast<XAccessibleSelection*>(this),
434             static_cast<lang::XEventListener*>(
435                 static_cast<awt::XWindowListener*>(this)),
436             static_cast<beans::XPropertyChangeListener*>(this),
437             static_cast<awt::XWindowListener*>(this),
438             static_cast<awt::XFocusListener*>(this)
439            ,static_cast<XAccessibleExtendedAttributes*>(this)
440            ,static_cast<XAccessibleGetAccFlowTo*>(this)
441             );
442     return aReturn;
443 }
444 
445 
446 
447 
448 void SAL_CALL
acquire(void)449     AccessibleDocumentViewBase::acquire (void)
450     throw ()
451 {
452     AccessibleContextBase::acquire ();
453 }
454 
455 
456 
457 
458 void SAL_CALL
release(void)459     AccessibleDocumentViewBase::release (void)
460     throw ()
461 {
462     AccessibleContextBase::release ();
463 }
464 
465 
466 
467 
468 //=====  XServiceInfo  ========================================================
469 
470 ::rtl::OUString SAL_CALL
getImplementationName(void)471     AccessibleDocumentViewBase::getImplementationName (void)
472 {
473     return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleDocumentViewBase"));
474 }
475 
476 
477 
478 
479 ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
getSupportedServiceNames(void)480     AccessibleDocumentViewBase::getSupportedServiceNames (void)
481 {
482     ThrowIfDisposed ();
483     return AccessibleContextBase::getSupportedServiceNames ();
484 }
485 
486 
487 
488 
489 
490 //=====  XTypeProvider  =======================================================
491 
492 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> SAL_CALL
getTypes(void)493     AccessibleDocumentViewBase::getTypes (void)
494 {
495     ThrowIfDisposed ();
496 
497     // Get list of types from the context base implementation, ...
498     uno::Sequence<uno::Type> aTypeList (AccessibleContextBase::getTypes());
499     // ... get list of types from component base implementation, ...
500     uno::Sequence<uno::Type> aComponentTypeList (AccessibleComponentBase::getTypes());
501 
502 
503     // ...and add the additional type for the component, ...
504     const uno::Type aLangEventListenerType =
505         ::getCppuType((const uno::Reference<lang::XEventListener>*)0);
506     const uno::Type aPropertyChangeListenerType =
507         ::getCppuType((const uno::Reference<beans::XPropertyChangeListener>*)0);
508     const uno::Type aWindowListenerType =
509         ::getCppuType((const uno::Reference<awt::XWindowListener>*)0);
510     const uno::Type aFocusListenerType =
511         ::getCppuType((const uno::Reference<awt::XFocusListener>*)0);
512     const uno::Type aEventBroadcaster =
513         ::getCppuType((const uno::Reference<XAccessibleEventBroadcaster>*)0);
514 
515     // ... and merge them all into one list.
516     sal_Int32 nTypeCount (aTypeList.getLength()),
517         nComponentTypeCount (aComponentTypeList.getLength()),
518         i;
519 
520     aTypeList.realloc (nTypeCount + nComponentTypeCount + 5);
521 
522     for (i=0; i<nComponentTypeCount; i++)
523         aTypeList[nTypeCount + i] = aComponentTypeList[i];
524 
525     aTypeList[nTypeCount + i++ ] = aLangEventListenerType;
526     aTypeList[nTypeCount + i++] = aPropertyChangeListenerType;
527     aTypeList[nTypeCount + i++] = aWindowListenerType;
528     aTypeList[nTypeCount + i++] = aFocusListenerType;
529     aTypeList[nTypeCount + i++] = aEventBroadcaster;
530 
531     return aTypeList;
532 }
533 
534 
535 
536 
impl_dispose()537 void AccessibleDocumentViewBase::impl_dispose()
538 {
539     // Unregister from VCL Window.
540     Window* pWindow = maShapeTreeInfo.GetWindow();
541     if (maWindowLink.IsSet())
542     {
543         if (pWindow)
544             pWindow->RemoveChildEventListener (maWindowLink);
545         maWindowLink = Link();
546     }
547     else
548     {
549         DBG_ASSERT (pWindow, "AccessibleDocumentViewBase::disposing");
550     }
551 
552     // Unregister from window.
553     if (mxWindow.is())
554     {
555         mxWindow->removeWindowListener (this);
556         mxWindow->removeFocusListener (this);
557         mxWindow = NULL;
558     }
559 
560     // Unregister form the model.
561     if (mxModel.is())
562         mxModel->removeEventListener (
563             static_cast<awt::XWindowListener*>(this));
564 
565     // Unregister from the controller.
566     if (mxController.is())
567     {
568         uno::Reference<beans::XPropertySet> xSet (mxController, uno::UNO_QUERY);
569         if (xSet.is())
570             xSet->removePropertyChangeListener (
571                 OUString (RTL_CONSTASCII_USTRINGPARAM("")),
572                 static_cast<beans::XPropertyChangeListener*>(this));
573 
574         mxController->removeEventListener (
575             static_cast<awt::XWindowListener*>(this));
576     }
577 
578     // Propagate change of controller down the shape tree.
579     maShapeTreeInfo.SetControllerBroadcaster (NULL);
580 
581     // Reset the model reference.
582     mxModel = NULL;
583     // Reset the model reference.
584     mxController = NULL;
585 
586     maShapeTreeInfo.SetDocumentWindow (NULL);
587 }
588 
589 
590 
591 
592 //=====  XEventListener  ======================================================
593 
594 void SAL_CALL
disposing(const lang::EventObject & rEventObject)595     AccessibleDocumentViewBase::disposing (const lang::EventObject& rEventObject)
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 
propertyChange(const beans::PropertyChangeEvent &)614 void SAL_CALL AccessibleDocumentViewBase::propertyChange (const beans::PropertyChangeEvent& )
615 {
616     // Empty
617 }
618 
619 
620 
621 
622 //=====  XWindowListener  =====================================================
623 
624 void SAL_CALL
windowResized(const::com::sun::star::awt::WindowEvent &)625     AccessibleDocumentViewBase::windowResized (const ::com::sun::star::awt::WindowEvent& )
626 {
627     if( IsDisposed() )
628         return;
629 
630     ViewForwarderChanged (
631         IAccessibleViewForwarderListener::VISIBLE_AREA,
632         &maViewForwarder);
633 }
634 
635 
636 
637 
638 void SAL_CALL
windowMoved(const::com::sun::star::awt::WindowEvent &)639     AccessibleDocumentViewBase::windowMoved (const ::com::sun::star::awt::WindowEvent& )
640 {
641     if( IsDisposed() )
642         return;
643 
644     ViewForwarderChanged (
645         IAccessibleViewForwarderListener::VISIBLE_AREA,
646         &maViewForwarder);
647 }
648 
649 
650 
651 
652 void SAL_CALL
windowShown(const::com::sun::star::lang::EventObject &)653     AccessibleDocumentViewBase::windowShown (const ::com::sun::star::lang::EventObject& )
654 {
655     if( IsDisposed() )
656         return;
657 
658     ViewForwarderChanged (
659         IAccessibleViewForwarderListener::VISIBLE_AREA,
660         &maViewForwarder);
661 }
662 
663 
664 
665 
666 void SAL_CALL
windowHidden(const::com::sun::star::lang::EventObject &)667     AccessibleDocumentViewBase::windowHidden (const ::com::sun::star::lang::EventObject& )
668 {
669     if( IsDisposed() )
670         return;
671 
672     ViewForwarderChanged (
673         IAccessibleViewForwarderListener::VISIBLE_AREA,
674         &maViewForwarder);
675 }
676 
677 
678 
679 
680 //=====  XFocusListener  ==================================================
681 
focusGained(const::com::sun::star::awt::FocusEvent & e)682 void AccessibleDocumentViewBase::focusGained (const ::com::sun::star::awt::FocusEvent& e)
683 {
684     ThrowIfDisposed ();
685     if (e.Source == mxWindow)
686         Activated ();
687 }
688 
focusLost(const::com::sun::star::awt::FocusEvent & e)689 void AccessibleDocumentViewBase::focusLost (const ::com::sun::star::awt::FocusEvent& e)
690 {
691     ThrowIfDisposed ();
692     if (e.Source == mxWindow)
693         Deactivated ();
694 }
695 
696 
697 
698 
699 //=====  protected internal  ==================================================
700 
701 // This method is called from the component helper base class while disposing.
disposing(void)702 void SAL_CALL AccessibleDocumentViewBase::disposing (void)
703 {
704     impl_dispose();
705 
706     AccessibleContextBase::disposing ();
707 }
708 
709 
710 
711 
712 /// Create a name for this view.
713 ::rtl::OUString
CreateAccessibleName(void)714     AccessibleDocumentViewBase::CreateAccessibleName (void)
715 {
716     return ::rtl::OUString (
717         RTL_CONSTASCII_USTRINGPARAM("AccessibleDocumentViewBase"));
718 }
719 
720 
721 
722 
723 /** Create a description for this view.  Use the model's description or URL
724     if a description is not available.
725 */
726 ::rtl::OUString
CreateAccessibleDescription(void)727     AccessibleDocumentViewBase::CreateAccessibleDescription (void)
728 {
729     rtl::OUString sDescription;
730 
731     uno::Reference<lang::XServiceInfo> xInfo (mxController, uno::UNO_QUERY);
732     if (xInfo.is())
733     {
734         OUString sFirstService = xInfo->getSupportedServiceNames()[0];
735         if (sFirstService == OUString (
736                 RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DrawingDocumentDrawView")))
737         {
738             sDescription = OUString (RTL_CONSTASCII_USTRINGPARAM("Draw Document"));
739         }
740         else
741             sDescription = sFirstService;
742     }
743     else
744         sDescription = OUString (
745             RTL_CONSTASCII_USTRINGPARAM("Accessible Draw Document"));
746     return sDescription;
747 }
748 
749 
750 
751 
Activated(void)752 void AccessibleDocumentViewBase::Activated (void)
753 {
754     // Empty.  Overwrite to do something useful.
755 }
756 
757 
758 
759 
Deactivated(void)760 void AccessibleDocumentViewBase::Deactivated (void)
761 {
762     // Empty.  Overwrite to do something useful.
763 }
764 
765 
766 
767 
SetAccessibleOLEObject(const Reference<XAccessible> & xOLEObject)768 void AccessibleDocumentViewBase::SetAccessibleOLEObject (
769     const Reference <XAccessible>& xOLEObject)
770 {
771     // Send child event about removed accessible OLE object if necessary.
772     if (mxAccessibleOLEObject != xOLEObject)
773         if (mxAccessibleOLEObject.is())
774             CommitChange (
775                 AccessibleEventId::CHILD,
776                 uno::Any(),
777                 uno::makeAny (mxAccessibleOLEObject));
778 
779     // Assume that the accessible OLE Object disposes itself correctly.
780 
781     {
782         ::osl::MutexGuard aGuard (maMutex);
783         mxAccessibleOLEObject = xOLEObject;
784     }
785 
786     // Send child event about new accessible OLE object if necessary.
787     if (mxAccessibleOLEObject.is())
788         CommitChange (
789             AccessibleEventId::CHILD,
790             uno::makeAny (mxAccessibleOLEObject),
791             uno::Any());
792 }
793 
794 
795 
796 
797 //=====  methods from AccessibleSelectionBase ==================================================
798 
799 // return the member maMutex;
800 ::osl::Mutex&
implGetMutex()801     AccessibleDocumentViewBase::implGetMutex()
802 {
803     return( maMutex );
804 }
805 
806 // return ourself as context in default case
807 uno::Reference< XAccessibleContext >
implGetAccessibleContext()808     AccessibleDocumentViewBase::implGetAccessibleContext()
809 {
810     return( this );
811 }
812 
813 // return sal_False in default case
814 sal_Bool
implIsSelected(sal_Int32)815     AccessibleDocumentViewBase::implIsSelected( sal_Int32 )
816 {
817     return( sal_False );
818 }
819 
820 // return nothing in default case
821 void
implSelect(sal_Int32,sal_Bool)822     AccessibleDocumentViewBase::implSelect( sal_Int32, sal_Bool )
823 {
824 }
825 
getExtendedAttributes()826 uno::Any SAL_CALL AccessibleDocumentViewBase::getExtendedAttributes()
827 {
828     uno::Any anyAtrribute;
829     rtl::OUString sValue;
830     if (mpViewShell && mpViewShell->ISA(::sd::DrawViewShell))
831     {
832         ::sd::DrawViewShell* pDrViewSh = (::sd::DrawViewShell*) mpViewShell;
833         rtl::OUString sName;
834         String sDisplay;
835             sName = rtl::OUString::createFromAscii("page-name:");
836             // MT IA2: Not used...
837             // SdPage*  pCurrPge = pDrViewSh->getCurrentPage();
838             SdDrawDocument* pDoc = pDrViewSh->GetDoc();
839             sDisplay = pDrViewSh->getCurrentPage()->GetName();
840             sDisplay.SearchAndReplace( String::CreateFromAscii( "\\" ), String::CreateFromAscii("\\\\" ));
841             sDisplay.SearchAndReplace( String::CreateFromAscii( "=" ), String::CreateFromAscii("\\=" ) );
842             sDisplay.SearchAndReplace( String::CreateFromAscii( ";" ), String::CreateFromAscii("\\;" ) );
843             sDisplay.SearchAndReplace( String::CreateFromAscii( "," ), String::CreateFromAscii("\\," ) );
844             sDisplay.SearchAndReplace( String::CreateFromAscii( ":" ), String::CreateFromAscii("\\:" ) );
845             sValue = sName + sDisplay ;
846             sName = rtl::OUString::createFromAscii(";page-number:");
847             sValue += sName;
848             sValue += String::CreateFromInt32((sal_Int16)((sal_uInt16)((pDrViewSh->getCurrentPage()->GetPageNum()-1)>>1) + 1)) ;
849             sName = rtl::OUString::createFromAscii(";total-pages:");
850             sValue += sName;
851             sValue += String::CreateFromInt32(pDrViewSh->GetPageTabControl()->GetPageCount()) ;
852             sValue +=  rtl::OUString::createFromAscii(";");
853 
854         if(pDrViewSh->IsLayerModeActive() && pDrViewSh->GetLayerTabControl()) // #87182#
855         {
856             sName = rtl::OUString::createFromAscii("page-name:");
857             sValue = sName;
858             sDisplay = pDrViewSh->GetLayerTabControl()->GetPageText(pDrViewSh->GetLayerTabControl()->GetCurPageId());
859             if( pDoc )
860             {
861                 SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin();
862                 SdrLayer* aSdrLayer = rLayerAdmin.GetLayer(sDisplay, sal_False);
863                 if( aSdrLayer )
864                 {
865                     String layerAltText = aSdrLayer->GetTitle();
866                     if(  layerAltText.Len() > 0)
867                     {
868                         sName = rtl::OUString::createFromAscii(" ");
869                         sDisplay = sDisplay + sName;
870                         sDisplay += layerAltText;
871                     }
872                 }
873             }
874             sDisplay.SearchAndReplace( String::CreateFromAscii( "\\" ), String::CreateFromAscii("\\\\" ));
875             sDisplay.SearchAndReplace( String::CreateFromAscii( "=" ), String::CreateFromAscii("\\=" ));
876             sDisplay.SearchAndReplace( String::CreateFromAscii( ";" ), String::CreateFromAscii("\\;" ));
877             sDisplay.SearchAndReplace( String::CreateFromAscii( "," ), String::CreateFromAscii("\\," ));
878             sDisplay.SearchAndReplace( String::CreateFromAscii( ":" ), String::CreateFromAscii("\\:" ));
879             sValue +=  sDisplay;
880             sName = rtl::OUString::createFromAscii(";page-number:");
881             sValue += sName;
882             sValue += String::CreateFromInt32(pDrViewSh->GetActiveTabLayerIndex()+1) ;
883             sName = rtl::OUString::createFromAscii(";total-pages:");
884             sValue += sName;
885             sValue += String::CreateFromInt32(pDrViewSh->GetLayerTabControl()->GetPageCount()) ;
886             sValue +=  rtl::OUString::createFromAscii(";");
887         }
888     }
889     if (mpViewShell && mpViewShell->ISA(::sd::PresentationViewShell))
890     {
891         ::sd::PresentationViewShell* pPresViewSh = (::sd::PresentationViewShell*) mpViewShell;
892         SdPage* pCurrPge = pPresViewSh->getCurrentPage();
893         SdDrawDocument* pDoc = pPresViewSh->GetDoc();
894         SdPage* pNotesPge = (SdPage*)pDoc->GetSdPage((pCurrPge->GetPageNum()-1)>>1, PK_NOTES);
895         if (pNotesPge)
896         {
897             SdrObject* pNotesObj = pNotesPge->GetPresObj(PRESOBJ_NOTES);
898             if (pNotesObj)
899             {
900                 OutlinerParaObject* pPara = pNotesObj->GetOutlinerParaObject();
901                 if (pPara)
902                 {
903                     sValue += rtl::OUString::createFromAscii("note:");
904                     const EditTextObject& rEdit = pPara->GetTextObject();
905                     for (sal_uInt32 i=0;i<rEdit.GetParagraphCount();i++)
906                     {
907                         String strNote = rEdit.GetText(i);
908                         strNote.SearchAndReplace( String::CreateFromAscii( "\\" ), String::CreateFromAscii("\\\\" ));
909                         strNote.SearchAndReplace( String::CreateFromAscii( "=" ), String::CreateFromAscii("\\=" ));
910                         strNote.SearchAndReplace( String::CreateFromAscii( ";" ), String::CreateFromAscii("\\;" ));
911                         strNote.SearchAndReplace( String::CreateFromAscii( "," ), String::CreateFromAscii("\\," ));
912                         strNote.SearchAndReplace( String::CreateFromAscii( ":" ), String::CreateFromAscii("\\:" ));
913                         sValue += rtl::OUString( strNote );
914                         sValue += rtl::OUString::createFromAscii(";");//to divide each paragraph
915                     }
916                 }
917             }
918         }
919     }
920     if (mpViewShell && mpViewShell->ISA(::sd::OutlineViewShell) )
921     {
922         rtl::OUString sName;
923         String sDisplay;
924         SdPage* pCurrPge = mpViewShell->GetActualPage();
925         SdDrawDocument* pDoc = mpViewShell->GetDoc();
926         if(pCurrPge && pDoc)
927         {
928             sName = rtl::OUString::createFromAscii("page-name:");
929             sDisplay = pCurrPge->GetName();
930             sDisplay.SearchAndReplace( String::CreateFromAscii( "=" ), String::CreateFromAscii("\\=" ) );
931             sDisplay.SearchAndReplace( String::CreateFromAscii( ";" ), String::CreateFromAscii("\\;" ) );
932             sDisplay.SearchAndReplace( String::CreateFromAscii( "," ), String::CreateFromAscii("\\," ) );
933             sDisplay.SearchAndReplace( String::CreateFromAscii( ":" ), String::CreateFromAscii("\\:" ) );
934             sValue = sName + sDisplay ;
935             sName = rtl::OUString::createFromAscii(";page-number:");
936             sValue += sName;
937             sValue += String::CreateFromInt32((sal_Int16)((sal_uInt16)((pCurrPge->GetPageNum()-1)>>1) + 1)) ;
938             sName = rtl::OUString::createFromAscii(";total-pages:");
939             sValue += sName;
940             sValue += String::CreateFromInt32(pDoc->GetSdPageCount(PK_STANDARD)) ;
941             sValue +=  rtl::OUString::createFromAscii(";");
942         }
943     }
944     if (sValue.getLength())
945         anyAtrribute <<= sValue;
946     return anyAtrribute;
947 }
948 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
get_AccFlowTo(const::com::sun::star::uno::Any &,sal_Int32)949         SAL_CALL AccessibleDocumentViewBase::get_AccFlowTo(const ::com::sun::star::uno::Any&, sal_Int32 )
950 {
951     ::com::sun::star::uno::Sequence< uno::Any> aRet;
952 
953     return aRet;
954 }
955 
getForeground()956 sal_Int32 SAL_CALL AccessibleDocumentViewBase::getForeground(  )
957 {
958     return COL_BLACK;
959 }
960 
getBackground()961 sal_Int32 SAL_CALL AccessibleDocumentViewBase::getBackground(  )
962 {
963      ThrowIfDisposed ();
964     ::osl::MutexGuard aGuard (maMutex);
965     return mpViewShell->GetView()->getColorConfig().GetColorValue( ::svtools::DOCCOLOR ).nColor;
966 }
967 } // end of namespace accessibility
968