1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <AccessibleDrawDocumentView.hxx>
21 #include <com/sun/star/drawing/ShapeCollection.hpp>
22 #include <com/sun/star/drawing/XDrawView.hpp>
23 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
24 #include <com/sun/star/drawing/XShapes.hpp>
25 #include <com/sun/star/beans/XPropertySet.hpp>
26 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
27 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
28 #include <com/sun/star/accessibility/AccessibleRole.hpp>
29 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
30 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
31 #include <com/sun/star/view/XSelectionSupplier.hpp>
32 #include <cppuhelper/queryinterface.hxx>
33 #include <comphelper/accflowenum.hxx>
34 #include <comphelper/processfactory.hxx>
35 #include <sal/log.hxx>
36 #include <tools/debug.hxx>
38 #include <svx/AccessibleShape.hxx>
39 #include <svx/ChildrenManager.hxx>
40 #include <svx/svdobj.hxx>
41 #include <svx/unoapi.hxx>
42 #include <vcl/svapp.hxx>
44 #include <ViewShell.hxx>
46 #include <DrawDocShell.hxx>
47 #include <drawdoc.hxx>
49 #include <slideshow.hxx>
50 #include <anminfo.hxx>
51 #include <AccessiblePageShape.hxx>
53 #include <strings.hrc>
54 #include <sdresid.hxx>
55 #include <osl/mutex.hxx>
57 using namespace ::com::sun::star
;
58 using namespace ::com::sun::star::uno
;
59 using namespace ::com::sun::star::accessibility
;
61 namespace accessibility
{
63 struct XShapePosCompareHelper
65 bool operator() ( const uno::Reference
<drawing::XShape
>& xshape1
,
66 const uno::Reference
<drawing::XShape
>& xshape2
) const
68 // modify the compare method to return the Z-Order, not layout order
69 SdrObject
* pObj1
= GetSdrObjectFromXShape(xshape1
);
70 SdrObject
* pObj2
= GetSdrObjectFromXShape(xshape2
);
72 return pObj1
->GetOrdNum() < pObj2
->GetOrdNum();
77 //===== internal ============================================================
79 AccessibleDrawDocumentView::AccessibleDrawDocumentView (
80 ::sd::Window
* pSdWindow
,
81 ::sd::ViewShell
* pViewShell
,
82 const uno::Reference
<frame::XController
>& rxController
,
83 const uno::Reference
<XAccessible
>& rxParent
)
84 : AccessibleDocumentViewBase (pSdWindow
, pViewShell
, rxController
, rxParent
),
85 mpSdViewSh( pViewShell
)
87 UpdateAccessibleName();
90 AccessibleDrawDocumentView::~AccessibleDrawDocumentView()
92 DBG_ASSERT (rBHelper
.bDisposed
|| rBHelper
.bInDispose
,
93 "~AccessibleDrawDocumentView: object has not been disposed");
96 void AccessibleDrawDocumentView::Init()
98 AccessibleDocumentViewBase::Init ();
100 // Determine the list of shapes on the current page.
101 uno::Reference
<drawing::XShapes
> xShapeList
;
102 uno::Reference
<drawing::XDrawView
> xView (mxController
, uno::UNO_QUERY
);
104 xShapeList
= xView
->getCurrentPage();
106 // Create the children manager.
107 mpChildrenManager
.reset(new ChildrenManager(this, xShapeList
, maShapeTreeInfo
, *this));
109 rtl::Reference
<AccessiblePageShape
> xPage(CreateDrawPageShape());
113 mpChildrenManager
->AddAccessibleShape (xPage
.get());
114 mpChildrenManager
->Update ();
117 mpChildrenManager
->UpdateSelection ();
120 void AccessibleDrawDocumentView::ViewForwarderChanged()
122 AccessibleDocumentViewBase::ViewForwarderChanged();
123 if (mpChildrenManager
!= nullptr)
124 mpChildrenManager
->ViewForwarderChanged();
127 /** The page shape is created on every call at the moment (provided that
128 everything goes well).
130 rtl::Reference
<AccessiblePageShape
> AccessibleDrawDocumentView::CreateDrawPageShape()
132 rtl::Reference
<AccessiblePageShape
> xShape
;
134 // Create a shape that represents the actual draw page.
135 uno::Reference
<drawing::XDrawView
> xView (mxController
, uno::UNO_QUERY
);
138 uno::Reference
<beans::XPropertySet
> xSet (
139 uno::Reference
<beans::XPropertySet
> (xView
->getCurrentPage(), uno::UNO_QUERY
));
142 // Create a rectangle shape that will represent the draw page.
143 uno::Reference
<lang::XMultiServiceFactory
> xFactory (mxModel
, uno::UNO_QUERY
);
144 uno::Reference
<drawing::XShape
> xRectangle
;
146 xRectangle
.set(xFactory
->createInstance ("com.sun.star.drawing.RectangleShape"),
149 // Set the shape's size and position.
153 awt::Point aPosition
;
156 // Set size and position of the shape to those of the draw
158 aValue
= xSet
->getPropertyValue ("BorderLeft");
159 aValue
>>= aPosition
.X
;
160 aValue
= xSet
->getPropertyValue ("BorderTop");
161 aValue
>>= aPosition
.Y
;
162 xRectangle
->setPosition (aPosition
);
164 aValue
= xSet
->getPropertyValue ("Width");
165 aValue
>>= aSize
.Width
;
166 aValue
= xSet
->getPropertyValue ("Height");
167 aValue
>>= aSize
.Height
;
168 xRectangle
->setSize (aSize
);
170 // Create the accessible object for the shape and
172 xShape
= new AccessiblePageShape (
173 xView
->getCurrentPage(), this, maShapeTreeInfo
);
180 //===== XAccessibleContext ==================================================
183 AccessibleDrawDocumentView::getAccessibleChildCount()
187 long nChildCount
= AccessibleDocumentViewBase::getAccessibleChildCount();
189 // Forward request to children manager.
190 if (mpChildrenManager
!= nullptr)
191 nChildCount
+= mpChildrenManager
->GetChildCount();
196 uno::Reference
<XAccessible
> SAL_CALL
197 AccessibleDrawDocumentView::getAccessibleChild (sal_Int32 nIndex
)
201 ::osl::ClearableMutexGuard
aGuard (maMutex
);
203 // Take care of children of the base class.
204 sal_Int32 nCount
= AccessibleDocumentViewBase::getAccessibleChildCount();
208 return AccessibleDocumentViewBase::getAccessibleChild(nIndex
);
213 // Create a copy of the pointer to the children manager and release the
214 // mutex before calling any of its methods.
215 ChildrenManager
* pChildrenManager
= mpChildrenManager
.get();
218 // Forward request to children manager.
219 if (pChildrenManager
== nullptr)
220 throw lang::IndexOutOfBoundsException (
221 "no accessible child with index " + OUString::number(nIndex
),
222 static_cast<uno::XWeak
*>(this));
224 return pChildrenManager
->GetChild (nIndex
);
228 AccessibleDrawDocumentView::getAccessibleName()
232 OUString sName
= SdResId(SID_SD_A11Y_D_PRESENTATION
);
233 ::sd::View
* pSdView
= static_cast< ::sd::View
* >( maShapeTreeInfo
.GetSdrView() );
236 SdDrawDocument
& rDoc
= pSdView
->GetDoc();
237 OUString sFileName
= rDoc
.getDocAccTitle();
238 if ( !sFileName
.getLength() )
240 ::sd::DrawDocShell
* pDocSh
= pSdView
->GetDocSh();
243 sFileName
= pDocSh
->GetTitle( SFX_TITLE_APINAME
);
248 if(rDoc
.getDocReadOnly())
250 sReadOnly
= SdResId(SID_SD_A11Y_D_PRESENTATION_READONLY
);
253 if ( sFileName
.getLength() )
255 sName
= sFileName
+ sReadOnly
+ " - " + sName
;
262 //===== XEventListener ======================================================
265 AccessibleDrawDocumentView::disposing (const lang::EventObject
& rEventObject
)
269 AccessibleDocumentViewBase::disposing (rEventObject
);
270 if (rEventObject
.Source
== mxModel
)
272 ::osl::Guard
< ::osl::Mutex
> aGuard (::osl::Mutex::getGlobalMutex());
273 // maShapeTreeInfo has been modified in base class.
274 if (mpChildrenManager
!= nullptr)
275 mpChildrenManager
->SetInfo (maShapeTreeInfo
);
279 //===== XPropertyChangeListener =============================================
282 AccessibleDrawDocumentView::propertyChange (const beans::PropertyChangeEvent
& rEventObject
)
286 AccessibleDocumentViewBase::propertyChange (rEventObject
);
288 // add page switch event for slide show mode
289 if (rEventObject
.PropertyName
== "CurrentPage" ||
290 rEventObject
.PropertyName
== "PageChange")
292 // Update the accessible name to reflect the current slide.
293 UpdateAccessibleName();
295 // The current page changed. Update the children manager accordingly.
296 uno::Reference
<drawing::XDrawView
> xView (mxController
, uno::UNO_QUERY
);
297 if (xView
.is() && mpChildrenManager
!=nullptr)
299 // Inform the children manager to forget all children and give
301 mpChildrenManager
->ClearAccessibleShapeList ();
302 mpChildrenManager
->SetShapeList (xView
->getCurrentPage());
304 rtl::Reference
<AccessiblePageShape
> xPage(CreateDrawPageShape ());
308 mpChildrenManager
->AddAccessibleShape (xPage
.get());
309 mpChildrenManager
->Update (false);
313 SAL_WARN("sd", "View invalid");
314 CommitChange(AccessibleEventId::PAGE_CHANGED
,rEventObject
.NewValue
,rEventObject
.OldValue
);
316 else if ( rEventObject
.PropertyName
== "VisibleArea" )
318 if (mpChildrenManager
!= nullptr)
319 mpChildrenManager
->ViewForwarderChanged();
321 else if (rEventObject
.PropertyName
== "ActiveLayer")
323 CommitChange(AccessibleEventId::PAGE_CHANGED
,rEventObject
.NewValue
,rEventObject
.OldValue
);
325 else if (rEventObject
.PropertyName
== "UpdateAcc")
327 // The current page changed. Update the children manager accordingly.
328 uno::Reference
<drawing::XDrawView
> xView (mxController
, uno::UNO_QUERY
);
329 if (xView
.is() && mpChildrenManager
!=nullptr)
331 // Inform the children manager to forget all children and give
333 mpChildrenManager
->ClearAccessibleShapeList ();
334 // update the slide show page's accessible info
335 //mpChildrenManager->SetShapeList (uno::Reference<drawing::XShapes> (
336 // xView->getCurrentPage(), uno::UNO_QUERY));
337 rtl::Reference
< sd::SlideShow
> xSlideshow( sd::SlideShow::GetSlideShow( mpSdViewSh
->GetViewShellBase() ) );
338 if( xSlideshow
.is() && xSlideshow
->isRunning() && xSlideshow
->isFullScreen() )
340 css::uno::Reference
< drawing::XDrawPage
> xSlide
;
341 // MT IA2: Not used...
342 // sal_Int32 currentPageIndex = xSlideshow->getCurrentPageIndex();
343 css::uno::Reference
< css::presentation::XSlideShowController
> xSlideController
= xSlideshow
->getController();
344 if( xSlideController
.is() )
346 xSlide
= xSlideController
->getCurrentSlide();
349 mpChildrenManager
->SetShapeList (xSlide
);
353 rtl::Reference
<AccessiblePageShape
> xPage(CreateDrawPageShape ());
357 mpChildrenManager
->AddAccessibleShape (xPage
.get());
358 mpChildrenManager
->Update (false);
364 SAL_INFO("sd", "unhandled");
371 AccessibleDrawDocumentView::getImplementationName()
373 return "AccessibleDrawDocumentView";
376 css::uno::Sequence
< OUString
> SAL_CALL
377 AccessibleDrawDocumentView::getSupportedServiceNames()
380 // Get list of supported service names from base class...
381 uno::Sequence
<OUString
> aServiceNames
=
382 AccessibleDocumentViewBase::getSupportedServiceNames();
383 sal_Int32
nCount (aServiceNames
.getLength());
385 // ...and add additional names.
386 aServiceNames
.realloc (nCount
+ 1);
387 aServiceNames
[nCount
] = "com.sun.star.drawing.AccessibleDrawDocumentView";
389 return aServiceNames
;
392 //===== XInterface ==========================================================
395 AccessibleDrawDocumentView::queryInterface (const uno::Type
& rType
)
397 uno::Any aReturn
= AccessibleDocumentViewBase::queryInterface (rType
);
398 if ( ! aReturn
.hasValue())
399 aReturn
= ::cppu::queryInterface (rType
,
400 static_cast<XAccessibleGroupPosition
*>(this)
406 AccessibleDrawDocumentView::acquire()
409 AccessibleDocumentViewBase::acquire ();
412 AccessibleDrawDocumentView::release()
415 AccessibleDocumentViewBase::release ();
417 //===== XAccessibleGroupPosition =========================================
418 uno::Sequence
< sal_Int32
> SAL_CALL
419 AccessibleDrawDocumentView::getGroupPosition( const uno::Any
& rAny
)
423 // we will return the:
424 // [0] group level(always be 0 now)
425 // [1] similar items counts in the group
426 // [2] the position of the object in the group
427 uno::Sequence
< sal_Int32
> aRet( 3 );
428 //get the xShape of the current selected drawing object
429 uno::Reference
<XAccessibleContext
> xAccContent
;
430 rAny
>>= xAccContent
;
431 if ( !xAccContent
.is() )
435 AccessibleShape
* pAcc
= comphelper::getUnoTunnelImplementation
<AccessibleShape
>( xAccContent
);
440 uno::Reference
< drawing::XShape
> xCurShape
= pAcc
->GetXShape();
441 if ( !xCurShape
.is() )
445 //find all the child in the page, insert them into a vector and sort
446 if ( mpChildrenManager
== nullptr )
450 std::vector
< uno::Reference
<drawing::XShape
> > vXShapes
;
451 sal_Int32 nCount
= mpChildrenManager
->GetChildCount();
452 //get pointer of SdView & SdrPageView for further use.
453 SdrPageView
* pPV
= nullptr;
454 ::sd::View
* pSdView
= nullptr;
457 pSdView
= mpSdViewSh
->GetView();
458 pPV
= pSdView
->GetSdrPageView();
460 for ( sal_Int32 i
= 0; i
< nCount
; i
++ )
462 uno::Reference
< drawing::XShape
> xShape
= mpChildrenManager
->GetChildShape(i
);
465 //if the object is visible in the page, we add it into the group list.
466 SdrObject
* pObj
= GetSdrObjectFromXShape(xShape
);
467 if ( pObj
&& pPV
&& pSdView
&& pSdView
->IsObjMarkable( pObj
, pPV
) )
469 vXShapes
.push_back( xShape
);
473 std::sort( vXShapes
.begin(), vXShapes
.end(), XShapePosCompareHelper() );
474 //get the index of the selected object in the group
475 auto aIter
= std::find_if(vXShapes
.begin(), vXShapes
.end(),
476 [&xCurShape
](const uno::Reference
<drawing::XShape
>& rxShape
) { return rxShape
.get() == xCurShape
.get(); });
477 if (aIter
!= vXShapes
.end())
479 sal_Int32
* pArray
= aRet
.getArray();
480 pArray
[0] = 1; //it should be 1 based, not 0 based.
481 pArray
[1] = vXShapes
.size();
482 pArray
[2] = static_cast<sal_Int32
>(std::distance(vXShapes
.begin(), aIter
)) + 1; //we start counting position from 1
487 OUString
AccessibleDrawDocumentView::getObjectLink( const uno::Any
& rAny
)
492 //get the xShape of the current selected drawing object
493 uno::Reference
<XAccessibleContext
> xAccContent
;
494 rAny
>>= xAccContent
;
495 if ( !xAccContent
.is() )
499 AccessibleShape
* pAcc
= comphelper::getUnoTunnelImplementation
<AccessibleShape
>( xAccContent
);
504 uno::Reference
< drawing::XShape
> xCurShape
= pAcc
->GetXShape();
505 if ( !xCurShape
.is() )
509 SdrObject
* pObj
= GetSdrObjectFromXShape(xCurShape
);
512 SdAnimationInfo
* pInfo
= SdDrawDocument::GetShapeUserData(*pObj
);
513 if( pInfo
&& (pInfo
->meClickAction
== presentation::ClickAction_DOCUMENT
) )
514 aRet
= pInfo
->GetBookmark();
519 /// Create a name for this view.
520 OUString
AccessibleDrawDocumentView::CreateAccessibleName()
524 uno::Reference
<lang::XServiceInfo
> xInfo (mxController
, uno::UNO_QUERY
);
527 uno::Sequence
< OUString
> aServices( xInfo
->getSupportedServiceNames() );
528 OUString sFirstService
= aServices
[0];
529 if ( sFirstService
== "com.sun.star.drawing.DrawingDocumentDrawView" )
531 if( aServices
.getLength() >= 2 && aServices
[1] == "com.sun.star.presentation.PresentationView")
533 SolarMutexGuard aGuard
;
535 sName
= SdResId(SID_SD_A11Y_I_DRAWVIEW_N
);
539 SolarMutexGuard aGuard
;
541 sName
= SdResId(SID_SD_A11Y_D_DRAWVIEW_N
);
544 else if ( sFirstService
== "com.sun.star.presentation.NotesView" )
546 SolarMutexGuard aGuard
;
548 sName
= SdResId(SID_SD_A11Y_I_NOTESVIEW_N
);
550 else if ( sFirstService
== "com.sun.star.presentation.HandoutView" )
552 SolarMutexGuard aGuard
;
554 sName
= SdResId(SID_SD_A11Y_I_HANDOUTVIEW_N
);
558 sName
= sFirstService
;
563 sName
= "AccessibleDrawDocumentView";
568 /** Return selection state of specified child
571 AccessibleDrawDocumentView::implIsSelected( sal_Int32 nAccessibleChildIndex
)
573 const SolarMutexGuard aSolarGuard
;
574 uno::Reference
< view::XSelectionSupplier
> xSel( mxController
, uno::UNO_QUERY
);
577 OSL_ENSURE( 0 <= nAccessibleChildIndex
, "AccessibleDrawDocumentView::implIsSelected: invalid index!" );
579 if( xSel
.is() && ( 0 <= nAccessibleChildIndex
) )
581 uno::Any
aAny( xSel
->getSelection() );
582 uno::Reference
< drawing::XShapes
> xShapes
;
588 AccessibleShape
* pAcc
= comphelper::getUnoTunnelImplementation
<AccessibleShape
>( getAccessibleChild( nAccessibleChildIndex
) );
592 uno::Reference
< drawing::XShape
> xShape( pAcc
->GetXShape() );
596 for( sal_Int32 i
= 0, nCount
= xShapes
->getCount(); ( i
< nCount
) && !bRet
; ++i
)
597 if( xShapes
->getByIndex( i
) == xShape
)
607 /** Select or deselect the specified shapes. The corresponding accessible
608 shapes are notified over the selection change listeners registered with
609 the XSelectionSupplier of the controller.
612 AccessibleDrawDocumentView::implSelect( sal_Int32 nAccessibleChildIndex
, bool bSelect
)
614 const SolarMutexGuard aSolarGuard
;
615 uno::Reference
< view::XSelectionSupplier
> xSel( mxController
, uno::UNO_QUERY
);
622 if( ACCESSIBLE_SELECTION_CHILD_ALL
== nAccessibleChildIndex
)
624 // Select or deselect all children.
627 xSel
->select( aAny
);
630 uno::Reference
< drawing::XShapes
> xShapes
= drawing::ShapeCollection::create(
631 comphelper::getProcessComponentContext());
633 for(sal_Int32 i
= 0, nCount
= getAccessibleChildCount(); i
< nCount
; ++i
)
635 AccessibleShape
* pAcc
= comphelper::getUnoTunnelImplementation
<AccessibleShape
>( getAccessibleChild( i
) );
637 if( pAcc
&& pAcc
->GetXShape().is() )
638 xShapes
->add( pAcc
->GetXShape() );
641 if( xShapes
->getCount() )
643 xSel
->select( Any(xShapes
) );
647 else if( nAccessibleChildIndex
>= 0 )
649 // Select or deselect only the child with index
650 // nAccessibleChildIndex.
652 AccessibleShape
* pAcc
= comphelper::getUnoTunnelImplementation
<AccessibleShape
>(
653 getAccessibleChild( nAccessibleChildIndex
));
655 // Add or remove the shape that is made accessible from the
656 // selection of the controller.
659 uno::Reference
< drawing::XShape
> xShape( pAcc
->GetXShape() );
663 uno::Reference
< drawing::XShapes
> xShapes
;
666 aAny
= xSel
->getSelection();
669 // Search shape to be selected in current selection.
672 sal_Int32 nCount
= xShapes
->getCount();
673 for (sal_Int32 i
=0; ( i
< nCount
) && !bFound
; ++i
)
674 if( xShapes
->getByIndex( i
) == xShape
)
678 // Create an empty selection to add the shape to.
679 xShapes
= drawing::ShapeCollection::create(
680 comphelper::getProcessComponentContext());
682 // Update the selection.
683 if( !bFound
&& bSelect
)
684 xShapes
->add( xShape
);
685 else if( bFound
&& !bSelect
)
686 xShapes
->remove( xShape
);
688 xSel
->select( Any(xShapes
) );
694 void AccessibleDrawDocumentView::Activated()
696 if (mpChildrenManager
== nullptr)
699 bool bChange
= false;
700 // When none of the children has the focus then claim it for the
702 if ( ! mpChildrenManager
->HasFocus())
704 SetState (AccessibleStateType::FOCUSED
);
708 ResetState (AccessibleStateType::FOCUSED
);
709 mpChildrenManager
->UpdateSelection();
710 // if the child gets focus in UpdateSelection(), needs to reset the focus on document.
711 if (mpChildrenManager
->HasFocus() && bChange
)
712 ResetState (AccessibleStateType::FOCUSED
);
715 void AccessibleDrawDocumentView::Deactivated()
717 if (mpChildrenManager
!= nullptr)
718 mpChildrenManager
->RemoveFocus();
719 ResetState (AccessibleStateType::FOCUSED
);
722 void AccessibleDrawDocumentView::impl_dispose()
724 mpChildrenManager
.reset();
725 AccessibleDocumentViewBase::impl_dispose();
728 /** This method is called from the component helper base class while
731 void SAL_CALL
AccessibleDrawDocumentView::disposing()
733 // Release resources.
734 mpChildrenManager
.reset();
736 // Forward call to base classes.
737 AccessibleDocumentViewBase::disposing ();
740 css::uno::Sequence
< css::uno::Any
>
741 SAL_CALL
AccessibleDrawDocumentView::getAccFlowTo(const css::uno::Any
& rAny
, sal_Int32 nType
)
745 if (nType
== AccessibilityFlowTo::FORSPELLCHECKFLOWTO
)
747 uno::Reference
< css::drawing::XShape
> xShape
;
749 if ( mpChildrenManager
&& xShape
.is() )
751 uno::Reference
< XAccessible
> xAcc
= mpChildrenManager
->GetChild(xShape
);
752 uno::Reference
< XAccessibleSelection
> xAccSelection( xAcc
, uno::UNO_QUERY
);
753 if ( xAccSelection
.is() )
755 if ( xAccSelection
->getSelectedAccessibleChildCount() )
757 uno::Reference
< XAccessible
> xSel
= xAccSelection
->getSelectedAccessibleChild( 0 );
760 uno::Reference
< XAccessibleContext
> xSelContext( xSel
->getAccessibleContext() );
761 if ( xSelContext
.is() )
763 //if in sw we find the selected paragraph here
764 if ( xSelContext
->getAccessibleRole() == AccessibleRole::PARAGRAPH
)
766 uno::Sequence
<uno::Any
> aRet( 1 );
774 uno::Reference
<XAccessible
> xPara
= GetSelAccContextInTable();
777 uno::Sequence
<uno::Any
> aRet( 1 );
787 else if (nType
== AccessibilityFlowTo::FORFINDREPLACEFLOWTO_ITEM
|| nType
== AccessibilityFlowTo::FORFINDREPLACEFLOWTO_RANGE
)
789 sal_Int32 nChildCount
= getSelectedAccessibleChildCount();
792 uno::Reference
< XAccessible
> xSel
= getSelectedAccessibleChild( 0 );
795 uno::Reference
< XAccessibleSelection
> xAccChildSelection( xSel
, uno::UNO_QUERY
);
796 if ( xAccChildSelection
.is() )
798 if ( xAccChildSelection
->getSelectedAccessibleChildCount() )
800 uno::Reference
< XAccessible
> xChildSel
= xAccChildSelection
->getSelectedAccessibleChild( 0 );
801 if ( xChildSel
.is() )
803 uno::Reference
< XAccessibleContext
> xChildSelContext( xChildSel
->getAccessibleContext() );
804 if ( xChildSelContext
.is() &&
805 xChildSelContext
->getAccessibleRole() == AccessibleRole::PARAGRAPH
)
807 uno::Sequence
<uno::Any
> aRet( 1 );
808 aRet
[0] <<= xChildSel
;
818 uno::Reference
<XAccessible
> xPara
= GetSelAccContextInTable();
821 uno::Sequence
<uno::Any
> aRet( 1 );
829 css::uno::Sequence
< uno::Any
> aRet
;
832 uno::Reference
<XAccessible
> AccessibleDrawDocumentView::GetSelAccContextInTable()
834 uno::Reference
<XAccessible
> xRet
;
835 sal_Int32 nCount
= mpChildrenManager
? mpChildrenManager
->GetChildCount() : 0;
838 for ( sal_Int32 i
= 0; i
< nCount
; i
++ )
842 uno::Reference
<XAccessible
> xObj
= mpChildrenManager
->GetChild(i
);
845 uno::Reference
<XAccessibleContext
> xObjContext( xObj
, uno::UNO_QUERY
);
846 if ( xObjContext
.is() && xObjContext
->getAccessibleRole() == AccessibleRole::TABLE
)
848 uno::Reference
<XAccessibleSelection
> xObjSelection( xObj
, uno::UNO_QUERY
);
849 if ( xObjSelection
.is() && xObjSelection
->getSelectedAccessibleChildCount() )
851 uno::Reference
<XAccessible
> xCell
= xObjSelection
->getSelectedAccessibleChild(0);
854 uno::Reference
<XAccessibleSelection
> xCellSel( xCell
, uno::UNO_QUERY
);
855 if ( xCellSel
.is() && xCellSel
->getSelectedAccessibleChildCount() )
857 uno::Reference
<XAccessible
> xPara
= xCellSel
->getSelectedAccessibleChild( 0 );
860 uno::Reference
<XAccessibleContext
> xParaContext( xPara
, uno::UNO_QUERY
);
861 if ( xParaContext
.is() &&
862 xParaContext
->getAccessibleRole() == AccessibleRole::PARAGRAPH
)
874 catch (const lang::IndexOutOfBoundsException
&)
876 uno::Reference
<XAccessible
> xEmpty
;
879 catch (const uno::RuntimeException
&)
881 uno::Reference
<XAccessible
> xEmpty
;
890 void AccessibleDrawDocumentView::UpdateAccessibleName()
892 OUString
sNewName (CreateAccessibleName() + ": ");
894 // Add the number of the current slide.
895 uno::Reference
<drawing::XDrawView
> xView (mxController
, uno::UNO_QUERY
);
898 uno::Reference
<beans::XPropertySet
> xProperties (xView
->getCurrentPage(), UNO_QUERY
);
899 if (xProperties
.is())
902 sal_Int16
nPageNumber (0);
903 if (xProperties
->getPropertyValue("Number") >>= nPageNumber
)
905 sNewName
+= OUString::number(nPageNumber
);
908 catch (const beans::UnknownPropertyException
&)
913 // Add the number of pages/slides.
914 Reference
<drawing::XDrawPagesSupplier
> xPagesSupplier (mxModel
, UNO_QUERY
);
915 if (xPagesSupplier
.is())
917 Reference
<container::XIndexAccess
> xPages
= xPagesSupplier
->getDrawPages();
920 sNewName
+= " / " + OUString::number(xPages
->getCount());
924 SetAccessibleName (sNewName
, AutomaticallyCreated
);
927 } // end of namespace accessibility
929 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */