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 throw (uno::RuntimeException)
255 {
256 ThrowIfDisposed ();
257
258 return AccessibleContextBase::getAccessibleParent();
259 }
260
261
262
263 sal_Int32 SAL_CALL
getAccessibleChildCount(void)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
getAccessibleChild(sal_Int32 nIndex)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
getAccessibleAtPoint(const awt::Point & aPoint)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
getBounds(void)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
getLocation(void)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
getLocationOnScreen(void)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
getSize(void)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
queryInterface(const uno::Type & rType)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
acquire(void)458 AccessibleDocumentViewBase::acquire (void)
459 throw ()
460 {
461 AccessibleContextBase::acquire ();
462 }
463
464
465
466
467 void SAL_CALL
release(void)468 AccessibleDocumentViewBase::release (void)
469 throw ()
470 {
471 AccessibleContextBase::release ();
472 }
473
474
475
476
477 //===== XServiceInfo ========================================================
478
479 ::rtl::OUString SAL_CALL
getImplementationName(void)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
getSupportedServiceNames(void)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
getTypes(void)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
impl_dispose()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
disposing(const lang::EventObject & rEventObject)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
propertyChange(const beans::PropertyChangeEvent &)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
windowResized(const::com::sun::star::awt::WindowEvent &)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
windowMoved(const::com::sun::star::awt::WindowEvent &)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
windowShown(const::com::sun::star::lang::EventObject &)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
windowHidden(const::com::sun::star::lang::EventObject &)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
focusGained(const::com::sun::star::awt::FocusEvent & e)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
focusLost(const::com::sun::star::awt::FocusEvent & e)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.
disposing(void)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
CreateAccessibleName(void)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
CreateAccessibleDescription(void)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
Activated(void)774 void AccessibleDocumentViewBase::Activated (void)
775 {
776 // Empty. Overwrite to do something useful.
777 }
778
779
780
781
Deactivated(void)782 void AccessibleDocumentViewBase::Deactivated (void)
783 {
784 // Empty. Overwrite to do something useful.
785 }
786
787
788
789
SetAccessibleOLEObject(const Reference<XAccessible> & xOLEObject)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&
implGetMutex()823 AccessibleDocumentViewBase::implGetMutex()
824 {
825 return( maMutex );
826 }
827
828 // return ourself as context in default case
829 uno::Reference< XAccessibleContext >
implGetAccessibleContext()830 AccessibleDocumentViewBase::implGetAccessibleContext()
831 throw (uno::RuntimeException)
832 {
833 return( this );
834 }
835
836 // return sal_False in default case
837 sal_Bool
implIsSelected(sal_Int32)838 AccessibleDocumentViewBase::implIsSelected( sal_Int32 )
839 throw (uno::RuntimeException)
840 {
841 return( sal_False );
842 }
843
844 // return nothing in default case
845 void
implSelect(sal_Int32,sal_Bool)846 AccessibleDocumentViewBase::implSelect( sal_Int32, sal_Bool )
847 throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
848 {
849 }
850
getExtendedAttributes()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
880 if(pDrViewSh->IsLayerModeActive() && pDrViewSh->GetLayerTabControl()) // #87182#
881 {
882 sName = rtl::OUString::createFromAscii("page-name:");
883 sValue = sName;
884 sDisplay = pDrViewSh->GetLayerTabControl()->GetPageText(pDrViewSh->GetLayerTabControl()->GetCurPageId());
885 if( pDoc )
886 {
887 SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin();
888 SdrLayer* aSdrLayer = rLayerAdmin.GetLayer(sDisplay, sal_False);
889 if( aSdrLayer )
890 {
891 String layerAltText = aSdrLayer->GetTitle();
892 if( layerAltText.Len() > 0)
893 {
894 sName = rtl::OUString::createFromAscii(" ");
895 sDisplay = sDisplay + sName;
896 sDisplay += layerAltText;
897 }
898 }
899 }
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 sDisplay.SearchAndReplace( String::CreateFromAscii( ":" ), String::CreateFromAscii("\\:" ));
905 sValue += sDisplay;
906 sName = rtl::OUString::createFromAscii(";page-number:");
907 sValue += sName;
908 sValue += String::CreateFromInt32(pDrViewSh->GetActiveTabLayerIndex()+1) ;
909 sName = rtl::OUString::createFromAscii(";total-pages:");
910 sValue += sName;
911 sValue += String::CreateFromInt32(pDrViewSh->GetLayerTabControl()->GetPageCount()) ;
912 sValue += rtl::OUString::createFromAscii(";");
913 }
914 }
915 if (mpViewShell && mpViewShell->ISA(::sd::PresentationViewShell))
916 {
917 ::sd::PresentationViewShell* pPresViewSh = (::sd::PresentationViewShell*) mpViewShell;
918 SdPage* pCurrPge = pPresViewSh->getCurrentPage();
919 SdDrawDocument* pDoc = pPresViewSh->GetDoc();
920 SdPage* pNotesPge = (SdPage*)pDoc->GetSdPage((pCurrPge->GetPageNum()-1)>>1, PK_NOTES);
921 if (pNotesPge)
922 {
923 SdrObject* pNotesObj = pNotesPge->GetPresObj(PRESOBJ_NOTES);
924 if (pNotesObj)
925 {
926 OutlinerParaObject* pPara = pNotesObj->GetOutlinerParaObject();
927 if (pPara)
928 {
929 sValue += rtl::OUString::createFromAscii("note:");
930 const EditTextObject& rEdit = pPara->GetTextObject();
931 for (sal_uInt32 i=0;i<rEdit.GetParagraphCount();i++)
932 {
933 String strNote = rEdit.GetText(i);
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 strNote.SearchAndReplace( String::CreateFromAscii( ":" ), String::CreateFromAscii("\\:" ));
939 sValue += rtl::OUString( strNote );
940 sValue += rtl::OUString::createFromAscii(";");//to divide each paragraph
941 }
942 }
943 }
944 }
945 }
946 if (mpViewShell && mpViewShell->ISA(::sd::OutlineViewShell) )
947 {
948 rtl::OUString sName;
949 String sDisplay;
950 SdPage* pCurrPge = mpViewShell->GetActualPage();
951 SdDrawDocument* pDoc = mpViewShell->GetDoc();
952 if(pCurrPge && pDoc)
953 {
954 sName = rtl::OUString::createFromAscii("page-name:");
955 sDisplay = pCurrPge->GetName();
956 sDisplay.SearchAndReplace( String::CreateFromAscii( "=" ), String::CreateFromAscii("\\=" ) );
957 sDisplay.SearchAndReplace( String::CreateFromAscii( ";" ), String::CreateFromAscii("\\;" ) );
958 sDisplay.SearchAndReplace( String::CreateFromAscii( "," ), String::CreateFromAscii("\\," ) );
959 sDisplay.SearchAndReplace( String::CreateFromAscii( ":" ), String::CreateFromAscii("\\:" ) );
960 sValue = sName + sDisplay ;
961 sName = rtl::OUString::createFromAscii(";page-number:");
962 sValue += sName;
963 sValue += String::CreateFromInt32((sal_Int16)((sal_uInt16)((pCurrPge->GetPageNum()-1)>>1) + 1)) ;
964 sName = rtl::OUString::createFromAscii(";total-pages:");
965 sValue += sName;
966 sValue += String::CreateFromInt32(pDoc->GetSdPageCount(PK_STANDARD)) ;
967 sValue += rtl::OUString::createFromAscii(";");
968 }
969 }
970 if (sValue.getLength())
971 anyAtrribute <<= sValue;
972 return anyAtrribute;
973 }
974 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
get_AccFlowTo(const::com::sun::star::uno::Any &,sal_Int32)975 SAL_CALL AccessibleDocumentViewBase::get_AccFlowTo(const ::com::sun::star::uno::Any&, sal_Int32 )
976 throw ( ::com::sun::star::uno::RuntimeException )
977 {
978 ::com::sun::star::uno::Sequence< uno::Any> aRet;
979
980 return aRet;
981 }
982
getForeground()983 sal_Int32 SAL_CALL AccessibleDocumentViewBase::getForeground( )
984 throw (uno::RuntimeException)
985 {
986 return COL_BLACK;
987 }
988
getBackground()989 sal_Int32 SAL_CALL AccessibleDocumentViewBase::getBackground( )
990 throw (uno::RuntimeException)
991 {
992 ThrowIfDisposed ();
993 ::osl::MutexGuard aGuard (maMutex);
994 return mpViewShell->GetView()->getColorConfig().GetColorValue( ::svtools::DOCCOLOR ).nColor;
995 }
996 } // end of namespace accessibility
997