bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / accessibility / AccessibleDocumentViewBase.cxx
blob973ac3eb54e6e344a121cbdaa47adcff5e447f76
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "AccessibleDocumentViewBase.hxx"
21 #include <com/sun/star/drawing/XDrawPage.hpp>
22 #include <com/sun/star/drawing/XDrawView.hpp>
23 #include <com/sun/star/drawing/XShapes.hpp>
24 #include <com/sun/star/container/XChild.hpp>
25 #include <com/sun/star/frame/XController.hpp>
26 #include <com/sun/star/frame/XFrame.hpp>
27 #include <com/sun/star/document/XEventBroadcaster.hpp>
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
30 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
31 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
32 #include <rtl/ustring.h>
33 #include <sfx2/viewfrm.hxx>
34 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
35 #include <sfx2/objsh.hxx>
36 #include <svx/AccessibleShape.hxx>
38 #include <svx/svdobj.hxx>
39 #include <svx/svdmodel.hxx>
40 #include <svx/unoapi.hxx>
41 #include <toolkit/helper/vclunohelper.hxx>
42 #include "Window.hxx"
43 #include <vcl/svapp.hxx>
44 #include "OutlineViewShell.hxx"
46 #include <svx/svdlayer.hxx>
47 #include <editeng/editobj.hxx>
48 #include "LayerTabBar.hxx"
49 #include <svtools/colorcfg.hxx>
50 #include "ViewShell.hxx"
51 #include "View.hxx"
53 using namespace ::com::sun::star;
54 using namespace ::com::sun::star::accessibility;
55 using ::com::sun::star::uno::Reference;
57 namespace accessibility {
59 //===== internal ============================================================
60 AccessibleDocumentViewBase::AccessibleDocumentViewBase (
61 ::sd::Window* pSdWindow,
62 ::sd::ViewShell* pViewShell,
63 const uno::Reference<frame::XController>& rxController,
64 const uno::Reference<XAccessible>& rxParent)
65 : AccessibleContextBase (rxParent,
66 pViewShell->GetDoc()->GetDocumentType() == DOCUMENT_TYPE_IMPRESS ?
67 AccessibleRole::DOCUMENT_PRESENTATION :
68 AccessibleRole::DOCUMENT),
69 mpWindow (pSdWindow),
70 mxController (rxController),
71 mxModel (NULL),
72 maViewForwarder (
73 static_cast<SdrPaintView*>(pViewShell->GetView()),
74 *static_cast<OutputDevice*>(pSdWindow))
76 if (mxController.is())
77 mxModel = mxController->getModel();
79 // Fill the shape tree info.
80 maShapeTreeInfo.SetModelBroadcaster (
81 uno::Reference<document::XEventBroadcaster>(
82 mxModel, uno::UNO_QUERY));
83 maShapeTreeInfo.SetController (mxController);
84 maShapeTreeInfo.SetSdrView (pViewShell->GetView());
85 maShapeTreeInfo.SetWindow (pSdWindow);
86 maShapeTreeInfo.SetViewForwarder (&maViewForwarder);
88 mxWindow = ::VCLUnoHelper::GetInterface (pSdWindow);
89 mpViewShell = pViewShell;
92 AccessibleDocumentViewBase::~AccessibleDocumentViewBase()
94 // At this place we should be disposed. You may want to add a
95 // corresponding assertion into the destructor of a derived class.
97 SolarMutexGuard g;
98 mpWindow.reset();
101 void AccessibleDocumentViewBase::Init()
103 // Finish the initialization of the shape tree info container.
104 maShapeTreeInfo.SetDocumentWindow (this);
106 // Register as window listener to stay up to date with its size and
107 // position.
108 mxWindow->addWindowListener (this);
109 // Register as focus listener to
110 mxWindow->addFocusListener (this);
112 // Determine the list of shapes on the current page.
113 uno::Reference<drawing::XShapes> xShapeList;
114 uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY);
115 if (xView.is())
116 xShapeList = uno::Reference<drawing::XShapes> (
117 xView->getCurrentPage(), uno::UNO_QUERY);
119 // Register this object as dispose event listener at the model.
120 if (mxModel.is())
121 mxModel->addEventListener (
122 static_cast<awt::XWindowListener*>(this));
124 // Register as property change listener at the controller.
125 uno::Reference<beans::XPropertySet> xSet (mxController, uno::UNO_QUERY);
126 if (xSet.is())
127 xSet->addPropertyChangeListener (
129 static_cast<beans::XPropertyChangeListener*>(this));
131 // Register this object as dispose event listener at the controller.
132 if (mxController.is())
133 mxController->addEventListener (
134 static_cast<awt::XWindowListener*>(this));
136 // Register at VCL Window to be informed of activated and deactivated
137 // OLE objects.
138 vcl::Window* pWindow = maShapeTreeInfo.GetWindow();
139 if (pWindow != NULL)
141 maWindowLink = LINK(
142 this, AccessibleDocumentViewBase, WindowChildEventListener);
144 pWindow->AddChildEventListener (maWindowLink);
146 sal_uInt16 nCount = pWindow->GetChildCount();
147 for (sal_uInt16 i=0; i<nCount; i++)
149 vcl::Window* pChildWindow = pWindow->GetChild (i);
150 if (pChildWindow &&
151 (AccessibleRole::EMBEDDED_OBJECT
152 ==pChildWindow->GetAccessibleRole()))
154 SetAccessibleOLEObject (pChildWindow->GetAccessible());
158 SfxObjectShell* pObjShell = mpViewShell->GetViewFrame()->GetObjectShell();
159 if(!pObjShell->IsReadOnly())
160 SetState(AccessibleStateType::EDITABLE);
163 IMPL_LINK(AccessibleDocumentViewBase, WindowChildEventListener,
164 VclSimpleEvent*, pEvent)
166 OSL_ASSERT(pEvent!=NULL && pEvent->ISA(VclWindowEvent));
167 if (pEvent!=NULL && pEvent->ISA(VclWindowEvent))
169 VclWindowEvent* pWindowEvent = static_cast<VclWindowEvent*>(pEvent);
170 // DBG_ASSERT( pVclEvent->GetWindow(), "Window???" );
171 switch (pWindowEvent->GetId())
173 case VCLEVENT_OBJECT_DYING:
175 // Window is dying. Unregister from VCL Window.
176 // This is also attempted in the disposing() method.
177 vcl::Window* pWindow = maShapeTreeInfo.GetWindow();
178 vcl::Window* pDyingWindow = static_cast<vcl::Window*>(
179 pWindowEvent->GetWindow());
180 if (pWindow==pDyingWindow && pWindow!=NULL && maWindowLink.IsSet())
182 pWindow->RemoveChildEventListener (maWindowLink);
183 maWindowLink = Link<>();
186 break;
188 case VCLEVENT_WINDOW_SHOW:
190 // A new window has been created. Is it an OLE object?
191 vcl::Window* pChildWindow = static_cast<vcl::Window*>(
192 pWindowEvent->GetData());
193 if (pChildWindow!=NULL
194 && (pChildWindow->GetAccessibleRole()
195 == AccessibleRole::EMBEDDED_OBJECT))
197 SetAccessibleOLEObject (pChildWindow->GetAccessible());
200 break;
202 case VCLEVENT_WINDOW_HIDE:
204 // A window has been destroyed. Has that been an OLE
205 // object?
206 vcl::Window* pChildWindow = static_cast<vcl::Window*>(
207 pWindowEvent->GetData());
208 if (pChildWindow!=NULL
209 && (pChildWindow->GetAccessibleRole()
210 == AccessibleRole::EMBEDDED_OBJECT))
212 SetAccessibleOLEObject (NULL);
215 break;
219 return 0;
222 //===== IAccessibleViewForwarderListener ====================================
224 void AccessibleDocumentViewBase::ViewForwarderChanged(ChangeType, const IAccessibleViewForwarder* )
226 // Empty
229 //===== XAccessibleContext ==================================================
231 Reference<XAccessible> SAL_CALL
232 AccessibleDocumentViewBase::getAccessibleParent()
233 throw (uno::RuntimeException, std::exception)
235 ThrowIfDisposed ();
237 return AccessibleContextBase::getAccessibleParent();
240 sal_Int32 SAL_CALL
241 AccessibleDocumentViewBase::getAccessibleChildCount()
242 throw (uno::RuntimeException, std::exception)
244 ThrowIfDisposed ();
246 if (mxAccessibleOLEObject.is())
247 return 1;
248 else
249 return 0;
252 Reference<XAccessible> SAL_CALL
253 AccessibleDocumentViewBase::getAccessibleChild (sal_Int32 nIndex)
254 throw (uno::RuntimeException, lang::IndexOutOfBoundsException, std::exception)
256 ThrowIfDisposed ();
258 ::osl::MutexGuard aGuard (maMutex);
259 if (mxAccessibleOLEObject.is())
260 if (nIndex == 0)
261 return mxAccessibleOLEObject;
263 throw lang::IndexOutOfBoundsException ( "no child with index " + OUString::number(nIndex) );
266 //===== XAccessibleComponent ================================================
268 /** Iterate over all children and test whether the specified point lies
269 within one of their bounding boxes. Return the first child for which
270 this is true.
272 uno::Reference<XAccessible > SAL_CALL
273 AccessibleDocumentViewBase::getAccessibleAtPoint (
274 const awt::Point& aPoint)
275 throw (uno::RuntimeException, std::exception)
277 ThrowIfDisposed ();
279 ::osl::MutexGuard aGuard (maMutex);
280 uno::Reference<XAccessible> xChildAtPosition;
282 sal_Int32 nChildCount = getAccessibleChildCount ();
283 for (sal_Int32 i=nChildCount-1; i>=0; --i)
285 Reference<XAccessible> xChild (getAccessibleChild (i));
286 if (xChild.is())
288 Reference<XAccessibleComponent> xChildComponent (
289 xChild->getAccessibleContext(), uno::UNO_QUERY);
290 if (xChildComponent.is())
292 awt::Rectangle aBBox (xChildComponent->getBounds());
293 if ( (aPoint.X >= aBBox.X)
294 && (aPoint.Y >= aBBox.Y)
295 && (aPoint.X < aBBox.X+aBBox.Width)
296 && (aPoint.Y < aBBox.Y+aBBox.Height) )
298 xChildAtPosition = xChild;
299 break;
305 // Have not found a child under the given point. Returning empty
306 // reference to indicate this.
307 return xChildAtPosition;
310 awt::Rectangle SAL_CALL
311 AccessibleDocumentViewBase::getBounds()
312 throw (::com::sun::star::uno::RuntimeException, std::exception)
314 ThrowIfDisposed ();
316 // Transform visible area into screen coordinates.
317 ::Rectangle aVisibleArea (
318 maShapeTreeInfo.GetViewForwarder()->GetVisibleArea());
319 ::Point aPixelTopLeft (
320 maShapeTreeInfo.GetViewForwarder()->LogicToPixel (
321 aVisibleArea.TopLeft()));
322 ::Point aPixelSize (
323 maShapeTreeInfo.GetViewForwarder()->LogicToPixel (
324 aVisibleArea.BottomRight())
325 - aPixelTopLeft);
327 // Prepare to subtract the parent position to transform into relative
328 // coordinates.
329 awt::Point aParentPosition;
330 Reference<XAccessible> xParent = getAccessibleParent ();
331 if (xParent.is())
333 Reference<XAccessibleComponent> xParentComponent (
334 xParent->getAccessibleContext(), uno::UNO_QUERY);
335 if (xParentComponent.is())
336 aParentPosition = xParentComponent->getLocationOnScreen();
339 return awt::Rectangle (
340 aPixelTopLeft.X() - aParentPosition.X,
341 aPixelTopLeft.Y() - aParentPosition.Y,
342 aPixelSize.X(),
343 aPixelSize.Y());
346 awt::Point SAL_CALL
347 AccessibleDocumentViewBase::getLocation()
348 throw (uno::RuntimeException, std::exception)
350 ThrowIfDisposed ();
351 awt::Rectangle aBoundingBox (getBounds());
352 return awt::Point (aBoundingBox.X, aBoundingBox.Y);
355 awt::Point SAL_CALL
356 AccessibleDocumentViewBase::getLocationOnScreen()
357 throw (uno::RuntimeException, std::exception)
359 ThrowIfDisposed ();
360 ::Point aLogicalPoint (maShapeTreeInfo.GetViewForwarder()->GetVisibleArea().TopLeft());
361 ::Point aPixelPoint (maShapeTreeInfo.GetViewForwarder()->LogicToPixel (aLogicalPoint));
362 return awt::Point (aPixelPoint.X(), aPixelPoint.Y());
365 awt::Size SAL_CALL
366 AccessibleDocumentViewBase::getSize()
367 throw (uno::RuntimeException, std::exception)
369 ThrowIfDisposed ();
371 // Transform visible area into screen coordinates.
372 ::Rectangle aVisibleArea (
373 maShapeTreeInfo.GetViewForwarder()->GetVisibleArea());
374 ::Point aPixelTopLeft (
375 maShapeTreeInfo.GetViewForwarder()->LogicToPixel (
376 aVisibleArea.TopLeft()));
377 ::Point aPixelSize (
378 maShapeTreeInfo.GetViewForwarder()->LogicToPixel (
379 aVisibleArea.BottomRight())
380 - aPixelTopLeft);
382 return awt::Size (aPixelSize.X(), aPixelSize.Y());
385 //===== XInterface ==========================================================
387 uno::Any SAL_CALL
388 AccessibleDocumentViewBase::queryInterface (const uno::Type & rType)
389 throw (uno::RuntimeException, std::exception)
391 uno::Any aReturn = AccessibleContextBase::queryInterface (rType);
392 if ( ! aReturn.hasValue())
393 aReturn = ::cppu::queryInterface (rType,
394 static_cast<XAccessibleComponent*>(this),
395 static_cast<XAccessibleSelection*>(this),
396 static_cast<lang::XEventListener*>(
397 static_cast<awt::XWindowListener*>(this)),
398 static_cast<beans::XPropertyChangeListener*>(this),
399 static_cast<awt::XWindowListener*>(this),
400 static_cast<awt::XFocusListener*>(this)
401 ,static_cast<XAccessibleExtendedAttributes*>(this)
402 ,static_cast<XAccessibleGetAccFlowTo*>(this)
404 return aReturn;
407 void SAL_CALL
408 AccessibleDocumentViewBase::acquire()
409 throw ()
411 AccessibleContextBase::acquire ();
414 void SAL_CALL
415 AccessibleDocumentViewBase::release()
416 throw ()
418 AccessibleContextBase::release ();
421 // XServiceInfo
423 OUString SAL_CALL
424 AccessibleDocumentViewBase::getImplementationName()
425 throw (::com::sun::star::uno::RuntimeException, std::exception)
427 return OUString("AccessibleDocumentViewBase");
430 ::com::sun::star::uno::Sequence< OUString> SAL_CALL
431 AccessibleDocumentViewBase::getSupportedServiceNames()
432 throw (::com::sun::star::uno::RuntimeException, std::exception)
434 ThrowIfDisposed ();
435 return AccessibleContextBase::getSupportedServiceNames ();
438 //===== XTypeProvider =======================================================
440 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> SAL_CALL
441 AccessibleDocumentViewBase::getTypes()
442 throw (::com::sun::star::uno::RuntimeException, std::exception)
444 ThrowIfDisposed ();
446 // Get list of types from the context base implementation, ...
447 uno::Sequence<uno::Type> aTypeList (AccessibleContextBase::getTypes());
448 // ... get list of types from component base implementation, ...
449 uno::Sequence<uno::Type> aComponentTypeList (AccessibleComponentBase::getTypes());
451 // ...and add the additional type for the component, ...
452 const uno::Type aLangEventListenerType =
453 cppu::UnoType<lang::XEventListener>::get();
454 const uno::Type aPropertyChangeListenerType =
455 cppu::UnoType<beans::XPropertyChangeListener>::get();
456 const uno::Type aWindowListenerType =
457 cppu::UnoType<awt::XWindowListener>::get();
458 const uno::Type aFocusListenerType =
459 cppu::UnoType<awt::XFocusListener>::get();
460 const uno::Type aEventBroadcaster =
461 cppu::UnoType<XAccessibleEventBroadcaster>::get();
463 // ... and merge them all into one list.
464 sal_Int32 nTypeCount (aTypeList.getLength()),
465 nComponentTypeCount (aComponentTypeList.getLength()),
468 aTypeList.realloc (nTypeCount + nComponentTypeCount + 5);
470 for (i=0; i<nComponentTypeCount; i++)
471 aTypeList[nTypeCount + i] = aComponentTypeList[i];
473 aTypeList[nTypeCount + i++ ] = aLangEventListenerType;
474 aTypeList[nTypeCount + i++] = aPropertyChangeListenerType;
475 aTypeList[nTypeCount + i++] = aWindowListenerType;
476 aTypeList[nTypeCount + i++] = aFocusListenerType;
477 aTypeList[nTypeCount + i++] = aEventBroadcaster;
479 return aTypeList;
482 void AccessibleDocumentViewBase::impl_dispose()
484 // Unregister from VCL Window.
485 vcl::Window* pWindow = maShapeTreeInfo.GetWindow();
486 if (maWindowLink.IsSet())
488 if (pWindow)
489 pWindow->RemoveChildEventListener (maWindowLink);
490 maWindowLink = Link<>();
492 else
494 DBG_ASSERT (pWindow, "AccessibleDocumentViewBase::disposing");
497 // Unregister from window.
498 if (mxWindow.is())
500 mxWindow->removeWindowListener (this);
501 mxWindow->removeFocusListener (this);
502 mxWindow = NULL;
505 // Unregister form the model.
506 if (mxModel.is())
507 mxModel->removeEventListener (
508 static_cast<awt::XWindowListener*>(this));
510 // Unregister from the controller.
511 if (mxController.is())
513 uno::Reference<beans::XPropertySet> xSet (mxController, uno::UNO_QUERY);
514 if (xSet.is())
515 xSet->removePropertyChangeListener ("", static_cast<beans::XPropertyChangeListener*>(this));
517 mxController->removeEventListener (
518 static_cast<awt::XWindowListener*>(this));
521 // Propagate change of controller down the shape tree.
522 maShapeTreeInfo.SetModelBroadcaster (NULL);
524 // Reset the model reference.
525 mxModel = NULL;
526 // Reset the model reference.
527 mxController = NULL;
529 maShapeTreeInfo.SetDocumentWindow (NULL);
532 //===== XEventListener ======================================================
534 void SAL_CALL
535 AccessibleDocumentViewBase::disposing (const lang::EventObject& rEventObject)
536 throw (::com::sun::star::uno::RuntimeException, std::exception)
538 ThrowIfDisposed ();
540 // Register this object as dispose event and document::XEventListener
541 // listener at the model.
543 if ( ! rEventObject.Source.is())
545 // Paranoia. Can this really happen?
547 else if (rEventObject.Source == mxModel || rEventObject.Source == mxController)
549 impl_dispose();
553 //===== XPropertyChangeListener =============================================
555 void SAL_CALL AccessibleDocumentViewBase::propertyChange (const beans::PropertyChangeEvent& )
556 throw (::com::sun::star::uno::RuntimeException, std::exception)
558 // Empty
561 //===== XWindowListener =====================================================
563 void SAL_CALL
564 AccessibleDocumentViewBase::windowResized (const ::com::sun::star::awt::WindowEvent& )
565 throw (::com::sun::star::uno::RuntimeException, std::exception)
567 if( IsDisposed() )
568 return;
570 ViewForwarderChanged (
571 IAccessibleViewForwarderListener::VISIBLE_AREA,
572 &maViewForwarder);
575 void SAL_CALL
576 AccessibleDocumentViewBase::windowMoved (const ::com::sun::star::awt::WindowEvent& )
577 throw (::com::sun::star::uno::RuntimeException, std::exception)
579 if( IsDisposed() )
580 return;
582 ViewForwarderChanged (
583 IAccessibleViewForwarderListener::VISIBLE_AREA,
584 &maViewForwarder);
587 void SAL_CALL
588 AccessibleDocumentViewBase::windowShown (const ::com::sun::star::lang::EventObject& )
589 throw (::com::sun::star::uno::RuntimeException, std::exception)
591 if( IsDisposed() )
592 return;
594 ViewForwarderChanged (
595 IAccessibleViewForwarderListener::VISIBLE_AREA,
596 &maViewForwarder);
599 void SAL_CALL
600 AccessibleDocumentViewBase::windowHidden (const ::com::sun::star::lang::EventObject& )
601 throw (::com::sun::star::uno::RuntimeException, std::exception)
603 if( IsDisposed() )
604 return;
606 ViewForwarderChanged (
607 IAccessibleViewForwarderListener::VISIBLE_AREA,
608 &maViewForwarder);
611 //===== XFocusListener ==================================================
613 void AccessibleDocumentViewBase::focusGained (const ::com::sun::star::awt::FocusEvent& e)
614 throw (::com::sun::star::uno::RuntimeException, std::exception)
616 ThrowIfDisposed ();
617 if (e.Source == mxWindow)
618 Activated ();
621 void AccessibleDocumentViewBase::focusLost (const ::com::sun::star::awt::FocusEvent& e)
622 throw (::com::sun::star::uno::RuntimeException, std::exception)
624 ThrowIfDisposed ();
625 if (e.Source == mxWindow)
626 Deactivated ();
629 //===== protected internal ==================================================
631 // This method is called from the component helper base class while disposing.
632 void SAL_CALL AccessibleDocumentViewBase::disposing()
634 impl_dispose();
636 AccessibleContextBase::disposing ();
639 /// Create a name for this view.
640 OUString
641 AccessibleDocumentViewBase::CreateAccessibleName()
642 throw (::com::sun::star::uno::RuntimeException)
644 return OUString ("AccessibleDocumentViewBase");
647 /** Create a description for this view. Use the model's description or URL
648 if a description is not available.
650 OUString
651 AccessibleDocumentViewBase::CreateAccessibleDescription()
652 throw (::com::sun::star::uno::RuntimeException)
654 OUString sDescription;
656 uno::Reference<lang::XServiceInfo> xInfo (mxController, uno::UNO_QUERY);
657 if (xInfo.is())
659 OUString sFirstService = xInfo->getSupportedServiceNames()[0];
660 if ( sFirstService == "com.sun.star.drawing.DrawingDocumentDrawView" )
662 sDescription = "Draw Document";
664 else
665 sDescription = sFirstService;
667 else
668 sDescription = "Accessible Draw Document";
669 return sDescription;
672 void AccessibleDocumentViewBase::Activated()
674 // Empty. Overwrite to do something useful.
677 void AccessibleDocumentViewBase::Deactivated()
679 // Empty. Overwrite to do something useful.
682 void AccessibleDocumentViewBase::SetAccessibleOLEObject (
683 const Reference <XAccessible>& xOLEObject)
685 // Send child event about removed accessible OLE object if necessary.
686 if (mxAccessibleOLEObject != xOLEObject)
687 if (mxAccessibleOLEObject.is())
688 CommitChange (
689 AccessibleEventId::CHILD,
690 uno::Any(),
691 uno::makeAny (mxAccessibleOLEObject));
693 // Assume that the accessible OLE Object disposes itself correctly.
696 ::osl::MutexGuard aGuard (maMutex);
697 mxAccessibleOLEObject = xOLEObject;
700 // Send child event about new accessible OLE object if necessary.
701 if (mxAccessibleOLEObject.is())
702 CommitChange (
703 AccessibleEventId::CHILD,
704 uno::makeAny (mxAccessibleOLEObject),
705 uno::Any());
708 //===== methods from AccessibleSelectionBase ==================================================
710 // return the member maMutex;
711 ::osl::Mutex&
712 AccessibleDocumentViewBase::implGetMutex()
714 return maMutex;
717 // return ourself as context in default case
718 uno::Reference< XAccessibleContext >
719 AccessibleDocumentViewBase::implGetAccessibleContext()
720 throw (uno::RuntimeException)
722 return this;
725 // return sal_False in default case
726 bool
727 AccessibleDocumentViewBase::implIsSelected( sal_Int32 )
728 throw (uno::RuntimeException)
730 return false;
733 // return nothing in default case
734 void
735 AccessibleDocumentViewBase::implSelect( sal_Int32, bool )
736 throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
740 uno::Any SAL_CALL AccessibleDocumentViewBase::getExtendedAttributes()
741 throw (::com::sun::star::lang::IndexOutOfBoundsException,
742 ::com::sun::star::uno::RuntimeException,
743 std::exception)
745 ::osl::MutexGuard aGuard (maMutex);
747 uno::Any anyAtrribute;
748 OUString sValue;
749 if (mpViewShell && mpViewShell->ISA(::sd::DrawViewShell))
751 ::sd::DrawViewShell* pDrViewSh = static_cast< ::sd::DrawViewShell*>(mpViewShell);
752 OUString sDisplay;
753 OUString sName = "page-name:";
754 // MT IA2: Not used...
755 // SdPage* pCurrPge = pDrViewSh->getCurrentPage();
756 SdDrawDocument* pDoc = pDrViewSh->GetDoc();
757 sDisplay = pDrViewSh->getCurrentPage()->GetName();
758 sDisplay = sDisplay.replaceFirst( "\\", "\\\\" );
759 sDisplay = sDisplay.replaceFirst( "=", "\\=" );
760 sDisplay = sDisplay.replaceFirst( ";", "\\;" );
761 sDisplay = sDisplay.replaceFirst( ",", "\\," );
762 sDisplay = sDisplay.replaceFirst( ":", "\\:" );
763 sValue = sName + sDisplay ;
764 sName = ";page-number:";
765 sValue += sName;
766 sValue += OUString::number((sal_Int16)((sal_uInt16)((pDrViewSh->getCurrentPage()->GetPageNum()-1)>>1) + 1)) ;
767 sName = ";total-pages:";
768 sValue += sName;
769 sValue += OUString::number(pDrViewSh->GetPageTabControl().GetPageCount()) ;
770 sValue += ";";
771 if(pDrViewSh->IsLayerModeActive() && pDrViewSh->GetLayerTabControl()) // #i87182#
773 sName = "page-name:";
774 sValue = sName;
775 sDisplay = pDrViewSh->GetLayerTabControl()->GetPageText(pDrViewSh->GetLayerTabControl()->GetCurPageId());
776 if( pDoc )
778 SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin();
779 SdrLayer* aSdrLayer = rLayerAdmin.GetLayer(sDisplay, false);
780 if( aSdrLayer )
782 OUString layerAltText = aSdrLayer->GetTitle();
783 if (!layerAltText.isEmpty())
785 sName = " ";
786 sDisplay = sDisplay + sName;
787 sDisplay += layerAltText;
791 sDisplay = sDisplay.replaceFirst( "\\", "\\\\" );
792 sDisplay = sDisplay.replaceFirst( "=", "\\=" );
793 sDisplay = sDisplay.replaceFirst( ";", "\\;" );
794 sDisplay = sDisplay.replaceFirst( ",", "\\," );
795 sDisplay = sDisplay.replaceFirst( ":", "\\:" );
796 sValue += sDisplay;
797 sName = ";page-number:";
798 sValue += sName;
799 sValue += OUString::number(pDrViewSh->GetActiveTabLayerIndex()+1) ;
800 sName = ";total-pages:";
801 sValue += sName;
802 sValue += OUString::number(pDrViewSh->GetLayerTabControl()->GetPageCount()) ;
803 sValue += ";";
806 if (mpViewShell && mpViewShell->ISA(::sd::PresentationViewShell))
808 ::sd::PresentationViewShell* pPresViewSh = static_cast< ::sd::PresentationViewShell*>(mpViewShell);
809 SdPage* pCurrPge = pPresViewSh->getCurrentPage();
810 SdDrawDocument* pDoc = pPresViewSh->GetDoc();
811 SdPage* pNotesPge = pDoc->GetSdPage((pCurrPge->GetPageNum()-1)>>1, PK_NOTES);
812 if (pNotesPge)
814 SdrObject* pNotesObj = pNotesPge->GetPresObj(PRESOBJ_NOTES);
815 if (pNotesObj)
817 OutlinerParaObject* pPara = pNotesObj->GetOutlinerParaObject();
818 if (pPara)
820 sValue += "note:";
821 const EditTextObject& rEdit = pPara->GetTextObject();
822 for (sal_uInt16 i=0;i<rEdit.GetParagraphCount();i++)
824 OUString strNote = rEdit.GetText(i);
825 strNote = strNote.replaceFirst( "\\", "\\\\" );
826 strNote = strNote.replaceFirst( "=", "\\=" );
827 strNote = strNote.replaceFirst( ";", "\\;" );
828 strNote = strNote.replaceFirst( ",", "\\," );
829 strNote = strNote.replaceFirst( ":", "\\:" );
830 sValue += strNote;
831 sValue += ";";//to divide each paragraph
837 if (mpViewShell && mpViewShell->ISA(::sd::OutlineViewShell) )
839 OUString sName;
840 OUString sDisplay;
841 SdPage* pCurrPge = mpViewShell->GetActualPage();
842 SdDrawDocument* pDoc = mpViewShell->GetDoc();
843 if(pCurrPge && pDoc)
845 sName = "page-name:";
846 sDisplay = pCurrPge->GetName();
847 sDisplay = sDisplay.replaceFirst( "=", "\\=" );
848 sDisplay = sDisplay.replaceFirst( ";", "\\;" );
849 sDisplay = sDisplay.replaceFirst( ",", "\\," );
850 sDisplay = sDisplay.replaceFirst( ":", "\\:" );
851 sValue = sName + sDisplay ;
852 sName = ";page-number:";
853 sValue += sName;
854 sValue += OUString::number((sal_Int16)((sal_uInt16)((pCurrPge->GetPageNum()-1)>>1) + 1)) ;
855 sName = ";total-pages:";
856 sValue += sName;
857 sValue += OUString::number(pDoc->GetSdPageCount(PK_STANDARD)) ;
858 sValue += ";";
861 if (sValue.getLength())
862 anyAtrribute <<= sValue;
863 return anyAtrribute;
866 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
867 SAL_CALL AccessibleDocumentViewBase::getAccFlowTo(const ::com::sun::star::uno::Any&, sal_Int32 )
868 throw ( ::com::sun::star::uno::RuntimeException, std::exception )
870 ::com::sun::star::uno::Sequence< uno::Any> aRet;
872 return aRet;
875 sal_Int32 SAL_CALL AccessibleDocumentViewBase::getForeground( )
876 throw (uno::RuntimeException, std::exception)
878 return COL_BLACK;
881 sal_Int32 SAL_CALL AccessibleDocumentViewBase::getBackground( )
882 throw (uno::RuntimeException, std::exception)
884 ThrowIfDisposed ();
885 ::osl::MutexGuard aGuard (maMutex);
886 return mpViewShell->GetView()->getColorConfig().GetColorValue( ::svtools::DOCCOLOR ).nColor;
888 } // end of namespace accessibility
890 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */