15b190011SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 35b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 45b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file 55b190011SAndrew Rist * distributed with this work for additional information 65b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file 75b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the 85b190011SAndrew Rist * "License"); you may not use this file except in compliance 95b190011SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 115b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 135b190011SAndrew Rist * Unless required by applicable law or agreed to in writing, 145b190011SAndrew Rist * software distributed under the License is distributed on an 155b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 165b190011SAndrew Rist * KIND, either express or implied. See the License for the 175b190011SAndrew Rist * specific language governing permissions and limitations 185b190011SAndrew Rist * under the License. 19cdf0e10cSrcweir * 205b190011SAndrew Rist *************************************************************/ 215b190011SAndrew Rist 225b190011SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sd.hxx" 26cdf0e10cSrcweir #include "AccessibleDrawDocumentView.hxx" 27cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPage.hpp> 28cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawView.hpp> 29cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> 30cdf0e10cSrcweir #include <com/sun/star/drawing/XShapes.hpp> 31cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp> 32cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp> 33cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp> 34cdf0e10cSrcweir #include <com/sun/star/document/XEventBroadcaster.hpp> 35cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 36cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp> 37cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 38cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 39cdf0e10cSrcweir #include <rtl/ustring.h> 40cdf0e10cSrcweir #include<sfx2/viewfrm.hxx> 41cdf0e10cSrcweir 42cdf0e10cSrcweir #include <svx/AccessibleShape.hxx> 43cdf0e10cSrcweir 44cdf0e10cSrcweir #include <svx/svdobj.hxx> 45cdf0e10cSrcweir #include <svx/svdmodel.hxx> 46cdf0e10cSrcweir #include <svx/unoapi.hxx> 47cdf0e10cSrcweir #include <svx/unoshcol.hxx> 48cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 49cdf0e10cSrcweir #include "Window.hxx" 50cdf0e10cSrcweir #include <vcl/svapp.hxx> 51cdf0e10cSrcweir 52cdf0e10cSrcweir 53cdf0e10cSrcweir #include "ViewShell.hxx" 54cdf0e10cSrcweir #include "View.hxx" 550deba7fbSSteve Yin #include "DrawDocShell.hxx" 560deba7fbSSteve Yin #include <drawdoc.hxx> 570deba7fbSSteve Yin #include <algorithm> 580deba7fbSSteve Yin #include "sdpage.hxx" 590deba7fbSSteve Yin #include "slideshow.hxx" 600deba7fbSSteve Yin #include "anminfo.hxx" 61cdf0e10cSrcweir #include <memory> 62cdf0e10cSrcweir 63cdf0e10cSrcweir #include "accessibility.hrc" 64cdf0e10cSrcweir #include "sdresid.hxx" 65cdf0e10cSrcweir #include <vos/mutex.hxx> 66cdf0e10cSrcweir 67cdf0e10cSrcweir using ::rtl::OUString; 68cdf0e10cSrcweir using namespace ::com::sun::star; 69cdf0e10cSrcweir using namespace ::com::sun::star::uno; 70cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 71cdf0e10cSrcweir 72cdf0e10cSrcweir class SfxViewFrame; 73cdf0e10cSrcweir 74cdf0e10cSrcweir #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString))) 75cdf0e10cSrcweir 76cdf0e10cSrcweir namespace accessibility { 77cdf0e10cSrcweir 78cdf0e10cSrcweir 790deba7fbSSteve Yin struct XShapePosCompareHelper 800deba7fbSSteve Yin { 810deba7fbSSteve Yin bool operator() ( const uno::Reference<drawing::XShape>& xshape1, 820deba7fbSSteve Yin const uno::Reference<drawing::XShape>& xshape2 ) const 830deba7fbSSteve Yin { 840deba7fbSSteve Yin // modify the compare method to return the Z-Order, not layout order 850deba7fbSSteve Yin SdrObject* pObj1 = GetSdrObjectFromXShape(xshape1); 860deba7fbSSteve Yin SdrObject* pObj2 = GetSdrObjectFromXShape(xshape2); 870deba7fbSSteve Yin if(pObj1 && pObj2) 880deba7fbSSteve Yin return pObj1->GetOrdNum() < pObj2->GetOrdNum(); 890deba7fbSSteve Yin else 900deba7fbSSteve Yin return 0; 910deba7fbSSteve Yin } 920deba7fbSSteve Yin }; 93cdf0e10cSrcweir //===== internal ============================================================ 94cdf0e10cSrcweir 95cdf0e10cSrcweir AccessibleDrawDocumentView::AccessibleDrawDocumentView ( 96cdf0e10cSrcweir ::sd::Window* pSdWindow, 97cdf0e10cSrcweir ::sd::ViewShell* pViewShell, 98cdf0e10cSrcweir const uno::Reference<frame::XController>& rxController, 99cdf0e10cSrcweir const uno::Reference<XAccessible>& rxParent) 100cdf0e10cSrcweir : AccessibleDocumentViewBase (pSdWindow, pViewShell, rxController, rxParent), 1010deba7fbSSteve Yin mpSdViewSh( pViewShell ), 102cdf0e10cSrcweir mpChildrenManager (NULL) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir OSL_TRACE ("AccessibleDrawDocumentView"); 105cdf0e10cSrcweir UpdateAccessibleName(); 106cdf0e10cSrcweir } 107cdf0e10cSrcweir 108cdf0e10cSrcweir 109cdf0e10cSrcweir 110cdf0e10cSrcweir 111cdf0e10cSrcweir AccessibleDrawDocumentView::~AccessibleDrawDocumentView (void) 112cdf0e10cSrcweir { 113cdf0e10cSrcweir OSL_TRACE ("~AccessibleDrawDocumentView"); 114cdf0e10cSrcweir DBG_ASSERT (rBHelper.bDisposed || rBHelper.bInDispose, 115cdf0e10cSrcweir "~AccessibleDrawDocumentView: object has not been disposed"); 116cdf0e10cSrcweir } 117cdf0e10cSrcweir 118cdf0e10cSrcweir 119cdf0e10cSrcweir 120cdf0e10cSrcweir 121cdf0e10cSrcweir void AccessibleDrawDocumentView::Init (void) 122cdf0e10cSrcweir { 123cdf0e10cSrcweir AccessibleDocumentViewBase::Init (); 124cdf0e10cSrcweir 125cdf0e10cSrcweir // Determine the list of shapes on the current page. 126cdf0e10cSrcweir uno::Reference<drawing::XShapes> xShapeList; 127cdf0e10cSrcweir uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY); 128cdf0e10cSrcweir if (xView.is()) 129cdf0e10cSrcweir xShapeList = uno::Reference<drawing::XShapes> ( 130cdf0e10cSrcweir xView->getCurrentPage(), uno::UNO_QUERY); 131cdf0e10cSrcweir 132cdf0e10cSrcweir // Create the children manager. 133cdf0e10cSrcweir mpChildrenManager = new ChildrenManager(this, xShapeList, maShapeTreeInfo, *this); 134cdf0e10cSrcweir if (mpChildrenManager != NULL) 135cdf0e10cSrcweir { 136cdf0e10cSrcweir // Create the page shape and initialize it. The shape is acquired 137cdf0e10cSrcweir // before initialization and released after transferring ownership 138cdf0e10cSrcweir // to the children manager to prevent premature disposing of the 139cdf0e10cSrcweir // shape. 140cdf0e10cSrcweir AccessiblePageShape* pPage = CreateDrawPageShape(); 141cdf0e10cSrcweir if (pPage != NULL) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir pPage->acquire(); 144cdf0e10cSrcweir pPage->Init(); 145cdf0e10cSrcweir mpChildrenManager->AddAccessibleShape ( 146cdf0e10cSrcweir std::auto_ptr<AccessibleShape>(pPage)); 147cdf0e10cSrcweir pPage->release(); 148cdf0e10cSrcweir mpChildrenManager->Update (); 149cdf0e10cSrcweir } 150cdf0e10cSrcweir mpChildrenManager->UpdateSelection (); 151cdf0e10cSrcweir } 152cdf0e10cSrcweir } 153cdf0e10cSrcweir 154cdf0e10cSrcweir 155cdf0e10cSrcweir 156cdf0e10cSrcweir 157cdf0e10cSrcweir void AccessibleDrawDocumentView::ViewForwarderChanged (ChangeType aChangeType, 158cdf0e10cSrcweir const IAccessibleViewForwarder* pViewForwarder) 159cdf0e10cSrcweir { 160cdf0e10cSrcweir AccessibleDocumentViewBase::ViewForwarderChanged (aChangeType, pViewForwarder); 161cdf0e10cSrcweir if (mpChildrenManager != NULL) 162cdf0e10cSrcweir mpChildrenManager->ViewForwarderChanged (aChangeType, pViewForwarder); 163cdf0e10cSrcweir } 164cdf0e10cSrcweir 165cdf0e10cSrcweir 166cdf0e10cSrcweir 167cdf0e10cSrcweir 168cdf0e10cSrcweir /** The page shape is created on every call at the moment (provided that 169cdf0e10cSrcweir every thing goes well). 170cdf0e10cSrcweir */ 171cdf0e10cSrcweir AccessiblePageShape* AccessibleDrawDocumentView::CreateDrawPageShape (void) 172cdf0e10cSrcweir { 173cdf0e10cSrcweir AccessiblePageShape* pShape = NULL; 174cdf0e10cSrcweir 175cdf0e10cSrcweir // Create a shape that represents the actual draw page. 176cdf0e10cSrcweir uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY); 177cdf0e10cSrcweir if (xView.is()) 178cdf0e10cSrcweir { 179cdf0e10cSrcweir uno::Reference<beans::XPropertySet> xSet ( 180cdf0e10cSrcweir uno::Reference<beans::XPropertySet> (xView->getCurrentPage(), uno::UNO_QUERY)); 181cdf0e10cSrcweir if (xSet.is()) 182cdf0e10cSrcweir { 183cdf0e10cSrcweir // Create a rectangle shape that will represent the draw page. 184cdf0e10cSrcweir uno::Reference<lang::XMultiServiceFactory> xFactory (mxModel, uno::UNO_QUERY); 185cdf0e10cSrcweir uno::Reference<drawing::XShape> xRectangle; 186cdf0e10cSrcweir if (xFactory.is()) 187cdf0e10cSrcweir xRectangle = uno::Reference<drawing::XShape>(xFactory->createInstance ( 188cdf0e10cSrcweir OUString (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.RectangleShape"))), 189cdf0e10cSrcweir uno::UNO_QUERY); 190cdf0e10cSrcweir 191cdf0e10cSrcweir // Set the shape's size and position. 192cdf0e10cSrcweir if (xRectangle.is()) 193cdf0e10cSrcweir { 194cdf0e10cSrcweir uno::Any aValue; 195cdf0e10cSrcweir awt::Point aPosition; 196cdf0e10cSrcweir awt::Size aSize; 197cdf0e10cSrcweir 198cdf0e10cSrcweir // Set size and position of the shape to those of the draw 199cdf0e10cSrcweir // page. 200cdf0e10cSrcweir aValue = xSet->getPropertyValue ( 201cdf0e10cSrcweir OUString (RTL_CONSTASCII_USTRINGPARAM("BorderLeft"))); 202cdf0e10cSrcweir aValue >>= aPosition.X; 203cdf0e10cSrcweir aValue = xSet->getPropertyValue ( 204cdf0e10cSrcweir OUString (RTL_CONSTASCII_USTRINGPARAM("BorderTop"))); 205cdf0e10cSrcweir aValue >>= aPosition.Y; 206cdf0e10cSrcweir xRectangle->setPosition (aPosition); 207cdf0e10cSrcweir 208cdf0e10cSrcweir aValue = xSet->getPropertyValue ( 209cdf0e10cSrcweir OUString (RTL_CONSTASCII_USTRINGPARAM("Width"))); 210cdf0e10cSrcweir aValue >>= aSize.Width; 211cdf0e10cSrcweir aValue = xSet->getPropertyValue ( 212cdf0e10cSrcweir OUString (RTL_CONSTASCII_USTRINGPARAM("Height"))); 213cdf0e10cSrcweir aValue >>= aSize.Height; 214cdf0e10cSrcweir xRectangle->setSize (aSize); 215cdf0e10cSrcweir 216cdf0e10cSrcweir // Create the accessible object for the shape and 217cdf0e10cSrcweir // initialize it. 218cdf0e10cSrcweir pShape = new AccessiblePageShape ( 219cdf0e10cSrcweir xView->getCurrentPage(), this, maShapeTreeInfo); 220cdf0e10cSrcweir } 221cdf0e10cSrcweir } 222cdf0e10cSrcweir } 223cdf0e10cSrcweir return pShape; 224cdf0e10cSrcweir } 225cdf0e10cSrcweir 226cdf0e10cSrcweir 227cdf0e10cSrcweir 228cdf0e10cSrcweir 229cdf0e10cSrcweir //===== XAccessibleContext ================================================== 230cdf0e10cSrcweir 231cdf0e10cSrcweir sal_Int32 SAL_CALL 232cdf0e10cSrcweir AccessibleDrawDocumentView::getAccessibleChildCount (void) 233cdf0e10cSrcweir throw (uno::RuntimeException) 234cdf0e10cSrcweir { 235cdf0e10cSrcweir ThrowIfDisposed (); 236cdf0e10cSrcweir 237cdf0e10cSrcweir long mpChildCount = AccessibleDocumentViewBase::getAccessibleChildCount(); 238cdf0e10cSrcweir 239cdf0e10cSrcweir // Forward request to children manager. 240cdf0e10cSrcweir if (mpChildrenManager != NULL) 241cdf0e10cSrcweir mpChildCount += mpChildrenManager->GetChildCount (); 242cdf0e10cSrcweir 243cdf0e10cSrcweir return mpChildCount; 244cdf0e10cSrcweir } 245cdf0e10cSrcweir 246cdf0e10cSrcweir 247cdf0e10cSrcweir 248cdf0e10cSrcweir 249cdf0e10cSrcweir uno::Reference<XAccessible> SAL_CALL 250cdf0e10cSrcweir AccessibleDrawDocumentView::getAccessibleChild (sal_Int32 nIndex) 251cdf0e10cSrcweir throw (uno::RuntimeException, lang::IndexOutOfBoundsException) 252cdf0e10cSrcweir { 253cdf0e10cSrcweir ThrowIfDisposed (); 254cdf0e10cSrcweir 255cdf0e10cSrcweir ::osl::ClearableMutexGuard aGuard (maMutex); 256cdf0e10cSrcweir 257cdf0e10cSrcweir // Take care of children of the base class. 258cdf0e10cSrcweir sal_Int32 nCount = AccessibleDocumentViewBase::getAccessibleChildCount(); 259cdf0e10cSrcweir if (nCount > 0) 260cdf0e10cSrcweir { 261cdf0e10cSrcweir if (nIndex < nCount) 262cdf0e10cSrcweir return AccessibleDocumentViewBase::getAccessibleChild(nIndex); 263cdf0e10cSrcweir else 264cdf0e10cSrcweir nIndex -= nCount; 265cdf0e10cSrcweir } 266cdf0e10cSrcweir 267cdf0e10cSrcweir // Create a copy of the pointer to the children manager and release the 268cdf0e10cSrcweir // mutex before calling any of its methods. 269cdf0e10cSrcweir ChildrenManager* pChildrenManager = mpChildrenManager; 270cdf0e10cSrcweir aGuard.clear(); 271cdf0e10cSrcweir 272cdf0e10cSrcweir // Forward request to children manager. 273cdf0e10cSrcweir if (pChildrenManager != NULL) 274cdf0e10cSrcweir { 275cdf0e10cSrcweir return pChildrenManager->GetChild (nIndex); 276cdf0e10cSrcweir } 277cdf0e10cSrcweir else 278cdf0e10cSrcweir throw lang::IndexOutOfBoundsException ( 279cdf0e10cSrcweir ::rtl::OUString::createFromAscii ("no accessible child with index ") 280cdf0e10cSrcweir + rtl::OUString::valueOf(nIndex), 281cdf0e10cSrcweir static_cast<uno::XWeak*>(this)); 282cdf0e10cSrcweir } 283cdf0e10cSrcweir 2840deba7fbSSteve Yin OUString SAL_CALL 2850deba7fbSSteve Yin AccessibleDrawDocumentView::getAccessibleName(void) 2860deba7fbSSteve Yin throw (::com::sun::star::uno::RuntimeException) 2870deba7fbSSteve Yin { 2880deba7fbSSteve Yin OUString sName = String( SdResId(SID_SD_A11Y_D_PRESENTATION) ); 2890deba7fbSSteve Yin ::sd::View* pSdView = static_cast< ::sd::View* >( maShapeTreeInfo.GetSdrView() ); 2900deba7fbSSteve Yin if ( pSdView ) 2910deba7fbSSteve Yin { 2920deba7fbSSteve Yin SdDrawDocument* pDoc = pSdView->GetDoc(); 2930deba7fbSSteve Yin if ( pDoc ) 2940deba7fbSSteve Yin { 2950deba7fbSSteve Yin rtl::OUString sFileName = pDoc->getDocAccTitle(); 2960deba7fbSSteve Yin if ( !sFileName.getLength() ) 2970deba7fbSSteve Yin { 2980deba7fbSSteve Yin ::sd::DrawDocShell* pDocSh = pSdView->GetDocSh(); 2990deba7fbSSteve Yin if ( pDocSh ) 3000deba7fbSSteve Yin { 3010deba7fbSSteve Yin sFileName = pDocSh->GetTitle( SFX_TITLE_APINAME ); 3020deba7fbSSteve Yin } 3030deba7fbSSteve Yin } 304cdf0e10cSrcweir 3050deba7fbSSteve Yin OUString sReadOnly; 3060deba7fbSSteve Yin if(pDoc->getDocReadOnly()) 3070deba7fbSSteve Yin { 3080deba7fbSSteve Yin sReadOnly = String(SdResId(SID_SD_A11Y_D_PRESENTATION_READONLY)); 3090deba7fbSSteve Yin } 310cdf0e10cSrcweir 3110deba7fbSSteve Yin if ( sFileName.getLength() ) 3120deba7fbSSteve Yin { 3130deba7fbSSteve Yin sName = sFileName + sReadOnly + OUString(RTL_CONSTASCII_USTRINGPARAM(" - ")) + sName; 3140deba7fbSSteve Yin } 3150deba7fbSSteve Yin } 3160deba7fbSSteve Yin } 317cdf0e10cSrcweir 3180deba7fbSSteve Yin return sName; 3190deba7fbSSteve Yin } 320cdf0e10cSrcweir //===== XEventListener ====================================================== 321cdf0e10cSrcweir 322cdf0e10cSrcweir void SAL_CALL 323cdf0e10cSrcweir AccessibleDrawDocumentView::disposing (const lang::EventObject& rEventObject) 324cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 325cdf0e10cSrcweir { 326cdf0e10cSrcweir ThrowIfDisposed (); 327cdf0e10cSrcweir 328cdf0e10cSrcweir AccessibleDocumentViewBase::disposing (rEventObject); 329cdf0e10cSrcweir if (rEventObject.Source == mxModel) 330cdf0e10cSrcweir { 331cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex> aGuard (::osl::Mutex::getGlobalMutex()); 332cdf0e10cSrcweir // maShapeTreeInfo has been modified in base class. 333cdf0e10cSrcweir if (mpChildrenManager != NULL) 334cdf0e10cSrcweir mpChildrenManager->SetInfo (maShapeTreeInfo); 335cdf0e10cSrcweir } 336cdf0e10cSrcweir } 337cdf0e10cSrcweir 338cdf0e10cSrcweir 339cdf0e10cSrcweir 340cdf0e10cSrcweir 341cdf0e10cSrcweir //===== XPropertyChangeListener ============================================= 342cdf0e10cSrcweir 343cdf0e10cSrcweir void SAL_CALL 344cdf0e10cSrcweir AccessibleDrawDocumentView::propertyChange (const beans::PropertyChangeEvent& rEventObject) 345cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 346cdf0e10cSrcweir { 347cdf0e10cSrcweir ThrowIfDisposed (); 348cdf0e10cSrcweir 349cdf0e10cSrcweir AccessibleDocumentViewBase::propertyChange (rEventObject); 350cdf0e10cSrcweir 351cdf0e10cSrcweir OSL_TRACE ("AccessibleDrawDocumentView::propertyChange"); 3520deba7fbSSteve Yin // add page switch event for slide show mode 3530deba7fbSSteve Yin if (rEventObject.PropertyName == OUString (RTL_CONSTASCII_USTRINGPARAM("CurrentPage")) || 3540deba7fbSSteve Yin rEventObject.PropertyName == OUString (RTL_CONSTASCII_USTRINGPARAM("PageChange")) ) 355cdf0e10cSrcweir { 356cdf0e10cSrcweir OSL_TRACE (" current page changed"); 357cdf0e10cSrcweir 358cdf0e10cSrcweir // Update the accessible name to reflect the current slide. 359cdf0e10cSrcweir UpdateAccessibleName(); 360cdf0e10cSrcweir 361cdf0e10cSrcweir // The current page changed. Update the children manager accordingly. 362cdf0e10cSrcweir uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY); 363cdf0e10cSrcweir if (xView.is() && mpChildrenManager!=NULL) 364cdf0e10cSrcweir { 365cdf0e10cSrcweir // Inform the children manager to forget all children and give 366cdf0e10cSrcweir // him the new ones. 367cdf0e10cSrcweir mpChildrenManager->ClearAccessibleShapeList (); 368cdf0e10cSrcweir mpChildrenManager->SetShapeList (uno::Reference<drawing::XShapes> ( 369cdf0e10cSrcweir xView->getCurrentPage(), uno::UNO_QUERY)); 370cdf0e10cSrcweir 371cdf0e10cSrcweir // Create the page shape and initialize it. The shape is 372cdf0e10cSrcweir // acquired before initialization and released after 373cdf0e10cSrcweir // transferring ownership to the children manager to prevent 374cdf0e10cSrcweir // premature disposing of the shape. 375cdf0e10cSrcweir AccessiblePageShape* pPage = CreateDrawPageShape (); 376cdf0e10cSrcweir if (pPage != NULL) 377cdf0e10cSrcweir { 378cdf0e10cSrcweir pPage->acquire(); 379cdf0e10cSrcweir pPage->Init(); 380cdf0e10cSrcweir mpChildrenManager->AddAccessibleShape ( 381cdf0e10cSrcweir std::auto_ptr<AccessibleShape>(pPage)); 382cdf0e10cSrcweir mpChildrenManager->Update (false); 383cdf0e10cSrcweir pPage->release(); 384cdf0e10cSrcweir } 385cdf0e10cSrcweir } 386cdf0e10cSrcweir else 387cdf0e10cSrcweir OSL_TRACE ("View invalid"); 3880deba7fbSSteve Yin CommitChange(AccessibleEventId::PAGE_CHANGED,rEventObject.NewValue,rEventObject.OldValue); 389cdf0e10cSrcweir } 390cdf0e10cSrcweir else if (rEventObject.PropertyName == OUString (RTL_CONSTASCII_USTRINGPARAM("VisibleArea"))) 391cdf0e10cSrcweir { 392cdf0e10cSrcweir OSL_TRACE (" visible area changed"); 393cdf0e10cSrcweir if (mpChildrenManager != NULL) 394cdf0e10cSrcweir mpChildrenManager->ViewForwarderChanged ( 395cdf0e10cSrcweir IAccessibleViewForwarderListener::VISIBLE_AREA, 396cdf0e10cSrcweir &maViewForwarder); 397cdf0e10cSrcweir } 3980deba7fbSSteve Yin else if (rEventObject.PropertyName == OUString (RTL_CONSTASCII_USTRINGPARAM("ActiveLayer"))) 3990deba7fbSSteve Yin { 4000deba7fbSSteve Yin CommitChange(AccessibleEventId::PAGE_CHANGED,rEventObject.NewValue,rEventObject.OldValue); 4010deba7fbSSteve Yin } 4020deba7fbSSteve Yin else if (rEventObject.PropertyName == OUString (RTL_CONSTASCII_USTRINGPARAM("UpdateAcc"))) 4030deba7fbSSteve Yin { 4040deba7fbSSteve Yin OSL_TRACE (" acc on current page should be updated"); 4050deba7fbSSteve Yin 4060deba7fbSSteve Yin // The current page changed. Update the children manager accordingly. 4070deba7fbSSteve Yin uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY); 4080deba7fbSSteve Yin if (xView.is() && mpChildrenManager!=NULL) 4090deba7fbSSteve Yin { 4100deba7fbSSteve Yin // Inform the children manager to forget all children and give 4110deba7fbSSteve Yin // him the new ones. 4120deba7fbSSteve Yin mpChildrenManager->ClearAccessibleShapeList (); 4130deba7fbSSteve Yin // update the slide show page's accessible info 4140deba7fbSSteve Yin //mpChildrenManager->SetShapeList (uno::Reference<drawing::XShapes> ( 4150deba7fbSSteve Yin // xView->getCurrentPage(), uno::UNO_QUERY)); 4160deba7fbSSteve Yin rtl::Reference< sd::SlideShow > xSlideshow( sd::SlideShow::GetSlideShow( mpSdViewSh->GetViewShellBase() ) ); 4170deba7fbSSteve Yin if( xSlideshow.is() && xSlideshow->isRunning() && xSlideshow->isFullScreen() ) 4180deba7fbSSteve Yin { 4190deba7fbSSteve Yin ::com::sun::star::uno::Reference< drawing::XDrawPage > xSlide; 4200deba7fbSSteve Yin // MT IA2: Not used... 4210deba7fbSSteve Yin // sal_Int32 currentPageIndex = xSlideshow->getCurrentPageIndex(); 4220deba7fbSSteve Yin ::com::sun::star::uno::Reference< ::com::sun::star::presentation::XSlideShowController > mpSlideController = xSlideshow->getController(); 4230deba7fbSSteve Yin if( mpSlideController.is() ) 4240deba7fbSSteve Yin { 4250deba7fbSSteve Yin xSlide = mpSlideController->getCurrentSlide(); 4260deba7fbSSteve Yin if (xSlide.is()) 4270deba7fbSSteve Yin { 4280deba7fbSSteve Yin mpChildrenManager->SetShapeList (uno::Reference<drawing::XShapes> ( 4290deba7fbSSteve Yin xSlide, uno::UNO_QUERY)); 4300deba7fbSSteve Yin } 4310deba7fbSSteve Yin } 4320deba7fbSSteve Yin } 4330deba7fbSSteve Yin // Create the page shape and initialize it. The shape is 4340deba7fbSSteve Yin // acquired before initialization and released after 4350deba7fbSSteve Yin // transferring ownership to the children manager to prevent 4360deba7fbSSteve Yin // premature disposing of the shape. 4370deba7fbSSteve Yin AccessiblePageShape* pPage = CreateDrawPageShape (); 4380deba7fbSSteve Yin if (pPage != NULL) 4390deba7fbSSteve Yin { 4400deba7fbSSteve Yin pPage->acquire(); 4410deba7fbSSteve Yin pPage->Init(); 4420deba7fbSSteve Yin mpChildrenManager->AddAccessibleShape ( 4430deba7fbSSteve Yin std::auto_ptr<AccessibleShape>(pPage)); 4440deba7fbSSteve Yin mpChildrenManager->Update (false); 4450deba7fbSSteve Yin pPage->release(); 4460deba7fbSSteve Yin } 4470deba7fbSSteve Yin } 4480deba7fbSSteve Yin } 449cdf0e10cSrcweir else 450cdf0e10cSrcweir { 451cdf0e10cSrcweir OSL_TRACE (" unhandled"); 452cdf0e10cSrcweir } 453cdf0e10cSrcweir OSL_TRACE (" done"); 454cdf0e10cSrcweir } 455cdf0e10cSrcweir 456cdf0e10cSrcweir 457cdf0e10cSrcweir 458cdf0e10cSrcweir //===== XServiceInfo ======================================================== 459cdf0e10cSrcweir 460cdf0e10cSrcweir ::rtl::OUString SAL_CALL 461cdf0e10cSrcweir AccessibleDrawDocumentView::getImplementationName (void) 462cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 463cdf0e10cSrcweir { 464cdf0e10cSrcweir return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 465cdf0e10cSrcweir "AccessibleDrawDocumentView")); 466cdf0e10cSrcweir } 467cdf0e10cSrcweir 468cdf0e10cSrcweir 469cdf0e10cSrcweir 470cdf0e10cSrcweir 471cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL 472cdf0e10cSrcweir AccessibleDrawDocumentView::getSupportedServiceNames (void) 473cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 474cdf0e10cSrcweir { 475cdf0e10cSrcweir ThrowIfDisposed(); 476cdf0e10cSrcweir // Get list of supported service names from base class... 477cdf0e10cSrcweir uno::Sequence<OUString> aServiceNames = 478cdf0e10cSrcweir AccessibleDocumentViewBase::getSupportedServiceNames(); 479cdf0e10cSrcweir sal_Int32 nCount (aServiceNames.getLength()); 480cdf0e10cSrcweir 481cdf0e10cSrcweir // ...and add additional names. 482cdf0e10cSrcweir aServiceNames.realloc (nCount + 1); 483cdf0e10cSrcweir static const OUString sAdditionalServiceName (RTL_CONSTASCII_USTRINGPARAM( 484cdf0e10cSrcweir "com.sun.star.drawing.AccessibleDrawDocumentView")); 485cdf0e10cSrcweir aServiceNames[nCount] = sAdditionalServiceName; 486cdf0e10cSrcweir 487cdf0e10cSrcweir return aServiceNames; 488cdf0e10cSrcweir } 489cdf0e10cSrcweir 4900deba7fbSSteve Yin //===== XInterface ========================================================== 491cdf0e10cSrcweir 4920deba7fbSSteve Yin uno::Any SAL_CALL 4930deba7fbSSteve Yin AccessibleDrawDocumentView::queryInterface (const uno::Type & rType) 4940deba7fbSSteve Yin throw (uno::RuntimeException) 4950deba7fbSSteve Yin { 4960deba7fbSSteve Yin uno::Any aReturn = AccessibleDocumentViewBase::queryInterface (rType); 4970deba7fbSSteve Yin if ( ! aReturn.hasValue()) 4980deba7fbSSteve Yin aReturn = ::cppu::queryInterface (rType, 4990deba7fbSSteve Yin static_cast<XAccessibleGroupPosition*>(this) 5000deba7fbSSteve Yin ); 5010deba7fbSSteve Yin return aReturn; 5020deba7fbSSteve Yin } 503cdf0e10cSrcweir 5040deba7fbSSteve Yin void SAL_CALL 5050deba7fbSSteve Yin AccessibleDrawDocumentView::acquire (void) 5060deba7fbSSteve Yin throw () 5070deba7fbSSteve Yin { 5080deba7fbSSteve Yin AccessibleDocumentViewBase::acquire (); 5090deba7fbSSteve Yin } 5100deba7fbSSteve Yin void SAL_CALL 5110deba7fbSSteve Yin AccessibleDrawDocumentView::release (void) 5120deba7fbSSteve Yin throw () 5130deba7fbSSteve Yin { 5140deba7fbSSteve Yin AccessibleDocumentViewBase::release (); 5150deba7fbSSteve Yin } 5160deba7fbSSteve Yin //===== XAccessibleGroupPosition ========================================= 5170deba7fbSSteve Yin uno::Sequence< sal_Int32 > SAL_CALL 5180deba7fbSSteve Yin AccessibleDrawDocumentView::getGroupPosition( const uno::Any& rAny ) 5190deba7fbSSteve Yin throw (uno::RuntimeException) 5200deba7fbSSteve Yin { 5210deba7fbSSteve Yin // we will return the: 5220deba7fbSSteve Yin // [0] group level(always be 0 now) 5230deba7fbSSteve Yin // [1] similar items counts in the group 5240deba7fbSSteve Yin // [2] the position of the object in the group 5250deba7fbSSteve Yin uno::Sequence< sal_Int32 > aRet( 3 ); 5260deba7fbSSteve Yin //get the xShape of the current selected drawing object 5270deba7fbSSteve Yin uno::Reference<XAccessibleContext> xAccContent; 5280deba7fbSSteve Yin rAny >>= xAccContent; 5290deba7fbSSteve Yin if ( !xAccContent.is() ) 5300deba7fbSSteve Yin { 5310deba7fbSSteve Yin return aRet; 5320deba7fbSSteve Yin } 5330deba7fbSSteve Yin AccessibleShape* pAcc = AccessibleShape::getImplementation( xAccContent ); 5340deba7fbSSteve Yin if ( !pAcc ) 5350deba7fbSSteve Yin { 5360deba7fbSSteve Yin return aRet; 5370deba7fbSSteve Yin } 5380deba7fbSSteve Yin uno::Reference< drawing::XShape > xCurShape = pAcc->GetXShape(); 5390deba7fbSSteve Yin if ( !xCurShape.is() ) 5400deba7fbSSteve Yin { 5410deba7fbSSteve Yin return aRet; 5420deba7fbSSteve Yin } 5430deba7fbSSteve Yin //find all the child in the page, insert them into a vector and sort 5440deba7fbSSteve Yin if ( mpChildrenManager == NULL ) 5450deba7fbSSteve Yin { 5460deba7fbSSteve Yin return aRet; 5470deba7fbSSteve Yin } 5480deba7fbSSteve Yin std::vector< uno::Reference<drawing::XShape> > vXShapes; 5490deba7fbSSteve Yin sal_Int32 nCount = mpChildrenManager->GetChildCount(); 5500deba7fbSSteve Yin //get pointer of SdView & SdrPageView for further use. 5510deba7fbSSteve Yin SdrPageView* pPV = NULL; 5520deba7fbSSteve Yin ::sd::View* pSdView = NULL; 5530deba7fbSSteve Yin if ( mpSdViewSh ) 5540deba7fbSSteve Yin { 5550deba7fbSSteve Yin pSdView = mpSdViewSh->GetView(); 5560deba7fbSSteve Yin pPV = pSdView->GetSdrPageView(); 5570deba7fbSSteve Yin } 5580deba7fbSSteve Yin for ( sal_Int32 i = 0; i < nCount; i++ ) 5590deba7fbSSteve Yin { 5600deba7fbSSteve Yin uno::Reference< drawing::XShape > xShape = mpChildrenManager->GetChildShape(i); 5610deba7fbSSteve Yin if ( xShape.is() ) 5620deba7fbSSteve Yin { 563*86e1cf34SPedro Giffuni //if the object is visible in the page, we add it into the group list. 5640deba7fbSSteve Yin SdrObject* pObj = GetSdrObjectFromXShape(xShape); 5650deba7fbSSteve Yin if ( pObj && pPV && pSdView && pSdView->IsObjMarkable( pObj, pPV ) ) 5660deba7fbSSteve Yin { 5670deba7fbSSteve Yin vXShapes.push_back( xShape ); 5680deba7fbSSteve Yin } 5690deba7fbSSteve Yin } 5700deba7fbSSteve Yin } 5710deba7fbSSteve Yin std::sort( vXShapes.begin(), vXShapes.end(), XShapePosCompareHelper() ); 5720deba7fbSSteve Yin //get the the index of the selected object in the group 5730deba7fbSSteve Yin std::vector< uno::Reference<drawing::XShape> >::iterator aIter; 5740deba7fbSSteve Yin //we start counting position from 1 5750deba7fbSSteve Yin sal_Int32 nPos = 1; 5760deba7fbSSteve Yin for ( aIter = vXShapes.begin(); aIter != vXShapes.end(); aIter++, nPos++ ) 5770deba7fbSSteve Yin { 5780deba7fbSSteve Yin if ( (*aIter).get() == xCurShape.get() ) 5790deba7fbSSteve Yin { 5800deba7fbSSteve Yin sal_Int32* pArray = aRet.getArray(); 5810deba7fbSSteve Yin pArray[0] = 1; //it should be 1 based, not 0 based. 5820deba7fbSSteve Yin pArray[1] = vXShapes.size(); 5830deba7fbSSteve Yin pArray[2] = nPos; 5840deba7fbSSteve Yin break; 5850deba7fbSSteve Yin } 5860deba7fbSSteve Yin } 5870deba7fbSSteve Yin return aRet; 5880deba7fbSSteve Yin } 5890deba7fbSSteve Yin ::rtl::OUString AccessibleDrawDocumentView::getObjectLink( const uno::Any& rAny ) 5900deba7fbSSteve Yin throw (uno::RuntimeException) 5910deba7fbSSteve Yin { 5920deba7fbSSteve Yin ::rtl::OUString aRet; 5930deba7fbSSteve Yin //get the xShape of the current selected drawing object 5940deba7fbSSteve Yin uno::Reference<XAccessibleContext> xAccContent; 5950deba7fbSSteve Yin rAny >>= xAccContent; 5960deba7fbSSteve Yin if ( !xAccContent.is() ) 5970deba7fbSSteve Yin { 5980deba7fbSSteve Yin return aRet; 5990deba7fbSSteve Yin } 6000deba7fbSSteve Yin AccessibleShape* pAcc = AccessibleShape::getImplementation( xAccContent ); 6010deba7fbSSteve Yin if ( !pAcc ) 6020deba7fbSSteve Yin { 6030deba7fbSSteve Yin return aRet; 6040deba7fbSSteve Yin } 6050deba7fbSSteve Yin uno::Reference< drawing::XShape > xCurShape = pAcc->GetXShape(); 6060deba7fbSSteve Yin if ( !xCurShape.is() ) 6070deba7fbSSteve Yin { 6080deba7fbSSteve Yin return aRet; 6090deba7fbSSteve Yin } 6100deba7fbSSteve Yin SdrObject* pObj = GetSdrObjectFromXShape(xCurShape); 6110deba7fbSSteve Yin if (pObj) 6120deba7fbSSteve Yin { 6130deba7fbSSteve Yin SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj); 6140deba7fbSSteve Yin if( pInfo && (pInfo->meClickAction == presentation::ClickAction_DOCUMENT) ) 6150deba7fbSSteve Yin aRet = (::rtl::OUString)pInfo->GetBookmark(); 6160deba7fbSSteve Yin } 6170deba7fbSSteve Yin return aRet; 6180deba7fbSSteve Yin } 619cdf0e10cSrcweir /// Create a name for this view. 620cdf0e10cSrcweir ::rtl::OUString 621cdf0e10cSrcweir AccessibleDrawDocumentView::CreateAccessibleName (void) 622cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 623cdf0e10cSrcweir { 624cdf0e10cSrcweir rtl::OUString sName; 625cdf0e10cSrcweir 626cdf0e10cSrcweir uno::Reference<lang::XServiceInfo> xInfo (mxController, uno::UNO_QUERY); 627cdf0e10cSrcweir if (xInfo.is()) 628cdf0e10cSrcweir { 629cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aServices( xInfo->getSupportedServiceNames() ); 630cdf0e10cSrcweir OUString sFirstService = aServices[0]; 631cdf0e10cSrcweir if (sFirstService == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DrawingDocumentDrawView"))) 632cdf0e10cSrcweir { 633cdf0e10cSrcweir if( aServices.getLength() >= 2 && 634cdf0e10cSrcweir aServices[1] == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PresentationView"))) 635cdf0e10cSrcweir { 636cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 637cdf0e10cSrcweir 638cdf0e10cSrcweir sName = String( SdResId(SID_SD_A11Y_I_DRAWVIEW_N) ); 639cdf0e10cSrcweir } 640cdf0e10cSrcweir else 641cdf0e10cSrcweir { 642cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 643cdf0e10cSrcweir 644cdf0e10cSrcweir sName = String( SdResId(SID_SD_A11Y_D_DRAWVIEW_N) ); 645cdf0e10cSrcweir } 646cdf0e10cSrcweir } 647cdf0e10cSrcweir else if (sFirstService == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.NotesView"))) 648cdf0e10cSrcweir { 649cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 650cdf0e10cSrcweir 651cdf0e10cSrcweir sName = String( SdResId(SID_SD_A11Y_I_NOTESVIEW_N) ); 652cdf0e10cSrcweir } 653cdf0e10cSrcweir else if (sFirstService == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.HandoutView"))) 654cdf0e10cSrcweir { 655cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 656cdf0e10cSrcweir 657cdf0e10cSrcweir sName = String( SdResId(SID_SD_A11Y_I_HANDOUTVIEW_N) ); 658cdf0e10cSrcweir } 659cdf0e10cSrcweir else 660cdf0e10cSrcweir { 661cdf0e10cSrcweir sName = sFirstService; 662cdf0e10cSrcweir } 663cdf0e10cSrcweir } 664cdf0e10cSrcweir else 665cdf0e10cSrcweir { 666cdf0e10cSrcweir sName = OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleDrawDocumentView")); 667cdf0e10cSrcweir } 668cdf0e10cSrcweir return sName; 669cdf0e10cSrcweir } 670cdf0e10cSrcweir 671cdf0e10cSrcweir 672cdf0e10cSrcweir 673cdf0e10cSrcweir 674cdf0e10cSrcweir /** Create a description for this view. Use the model's description or URL 675cdf0e10cSrcweir if a description is not available. 676cdf0e10cSrcweir */ 677cdf0e10cSrcweir ::rtl::OUString 678cdf0e10cSrcweir AccessibleDrawDocumentView::CreateAccessibleDescription (void) 679cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 680cdf0e10cSrcweir { 681cdf0e10cSrcweir rtl::OUString sDescription; 682cdf0e10cSrcweir 683cdf0e10cSrcweir uno::Reference<lang::XServiceInfo> xInfo (mxController, uno::UNO_QUERY); 684cdf0e10cSrcweir if (xInfo.is()) 685cdf0e10cSrcweir { 686cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aServices( xInfo->getSupportedServiceNames() ); 687cdf0e10cSrcweir OUString sFirstService = aServices[0]; 688cdf0e10cSrcweir if (sFirstService == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DrawingDocumentDrawView"))) 689cdf0e10cSrcweir { 690cdf0e10cSrcweir if( aServices.getLength() >= 2 && 691cdf0e10cSrcweir aServices[1] == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PresentationView"))) 692cdf0e10cSrcweir { 693cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 694cdf0e10cSrcweir 695cdf0e10cSrcweir sDescription = String( SdResId(SID_SD_A11Y_I_DRAWVIEW_D) ); 696cdf0e10cSrcweir } 697cdf0e10cSrcweir else 698cdf0e10cSrcweir { 699cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 700cdf0e10cSrcweir 701cdf0e10cSrcweir sDescription = String( SdResId(SID_SD_A11Y_D_DRAWVIEW_D) ); 702cdf0e10cSrcweir } 703cdf0e10cSrcweir } 704cdf0e10cSrcweir else if (sFirstService == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.NotesView"))) 705cdf0e10cSrcweir { 706cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 707cdf0e10cSrcweir 708cdf0e10cSrcweir sDescription = String( SdResId(SID_SD_A11Y_I_NOTESVIEW_D) ); 709cdf0e10cSrcweir } 710cdf0e10cSrcweir else if (sFirstService == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.HandoutView"))) 711cdf0e10cSrcweir { 712cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 713cdf0e10cSrcweir 714cdf0e10cSrcweir sDescription = String( SdResId(SID_SD_A11Y_I_HANDOUTVIEW_D) ); 715cdf0e10cSrcweir } 716cdf0e10cSrcweir else 717cdf0e10cSrcweir { 718cdf0e10cSrcweir sDescription = sFirstService; 719cdf0e10cSrcweir } 720cdf0e10cSrcweir } 721cdf0e10cSrcweir else 722cdf0e10cSrcweir { 723cdf0e10cSrcweir sDescription = OUString(RTL_CONSTASCII_USTRINGPARAM("Accessible Draw Document")); 724cdf0e10cSrcweir } 725cdf0e10cSrcweir return sDescription; 726cdf0e10cSrcweir } 727cdf0e10cSrcweir 728cdf0e10cSrcweir 729cdf0e10cSrcweir 730cdf0e10cSrcweir 731cdf0e10cSrcweir /** Return selection state of specified child 732cdf0e10cSrcweir */ 733cdf0e10cSrcweir sal_Bool 734cdf0e10cSrcweir AccessibleDrawDocumentView::implIsSelected( sal_Int32 nAccessibleChildIndex ) 735cdf0e10cSrcweir throw (uno::RuntimeException) 736cdf0e10cSrcweir { 737cdf0e10cSrcweir const vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 738cdf0e10cSrcweir uno::Reference< view::XSelectionSupplier > xSel( mxController, uno::UNO_QUERY ); 739cdf0e10cSrcweir sal_Bool bRet = sal_False; 740cdf0e10cSrcweir 741cdf0e10cSrcweir OSL_ENSURE( 0 <= nAccessibleChildIndex, "AccessibleDrawDocumentView::implIsSelected: invalid index!" ); 742cdf0e10cSrcweir 743cdf0e10cSrcweir if( xSel.is() && ( 0 <= nAccessibleChildIndex ) ) 744cdf0e10cSrcweir { 745cdf0e10cSrcweir uno::Any aAny( xSel->getSelection() ); 746cdf0e10cSrcweir uno::Reference< drawing::XShapes > xShapes; 747cdf0e10cSrcweir 748cdf0e10cSrcweir aAny >>= xShapes; 749cdf0e10cSrcweir 750cdf0e10cSrcweir if( xShapes.is() ) 751cdf0e10cSrcweir { 752cdf0e10cSrcweir AccessibleShape* pAcc = AccessibleShape::getImplementation( getAccessibleChild( nAccessibleChildIndex ) ); 753cdf0e10cSrcweir 754cdf0e10cSrcweir if( pAcc ) 755cdf0e10cSrcweir { 756cdf0e10cSrcweir uno::Reference< drawing::XShape > xShape( pAcc->GetXShape() ); 757cdf0e10cSrcweir 758cdf0e10cSrcweir if( xShape.is() ) 759cdf0e10cSrcweir { 760cdf0e10cSrcweir for( sal_Int32 i = 0, nCount = xShapes->getCount(); ( i < nCount ) && !bRet; ++i ) 761cdf0e10cSrcweir if( xShapes->getByIndex( i ) == xShape ) 762cdf0e10cSrcweir bRet = sal_True; 763cdf0e10cSrcweir } 764cdf0e10cSrcweir } 765cdf0e10cSrcweir } 766cdf0e10cSrcweir } 767cdf0e10cSrcweir 768cdf0e10cSrcweir return( bRet ); 769cdf0e10cSrcweir } 770cdf0e10cSrcweir 771cdf0e10cSrcweir 772cdf0e10cSrcweir 773cdf0e10cSrcweir 774cdf0e10cSrcweir /** Select or delselect the specified shapes. The corresponding accessible 775cdf0e10cSrcweir shapes are notified over the selection change listeners registered with 776cdf0e10cSrcweir the XSelectionSupplier of the controller. 777cdf0e10cSrcweir */ 778cdf0e10cSrcweir void 779cdf0e10cSrcweir AccessibleDrawDocumentView::implSelect( sal_Int32 nAccessibleChildIndex, sal_Bool bSelect ) 780cdf0e10cSrcweir throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 781cdf0e10cSrcweir { 782cdf0e10cSrcweir const vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 783cdf0e10cSrcweir uno::Reference< view::XSelectionSupplier > xSel( mxController, uno::UNO_QUERY ); 784cdf0e10cSrcweir AccessibleShape* pAccessibleChild; 785cdf0e10cSrcweir 786cdf0e10cSrcweir if( xSel.is() ) 787cdf0e10cSrcweir { 788cdf0e10cSrcweir uno::Any aAny; 789cdf0e10cSrcweir 790cdf0e10cSrcweir if( ACCESSIBLE_SELECTION_CHILD_ALL == nAccessibleChildIndex ) 791cdf0e10cSrcweir { 792cdf0e10cSrcweir // Select or deselect all children. 793cdf0e10cSrcweir 794cdf0e10cSrcweir if( !bSelect ) 795cdf0e10cSrcweir xSel->select( aAny ); 796cdf0e10cSrcweir else 797cdf0e10cSrcweir { 798cdf0e10cSrcweir uno::Reference< drawing::XShapes > xShapes( new SvxShapeCollection() ); 799cdf0e10cSrcweir 800cdf0e10cSrcweir for(sal_Int32 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i ) 801cdf0e10cSrcweir { 802cdf0e10cSrcweir AccessibleShape* pAcc = AccessibleShape::getImplementation( getAccessibleChild( i ) ); 803cdf0e10cSrcweir 804cdf0e10cSrcweir if( pAcc && pAcc->GetXShape().is() ) 805cdf0e10cSrcweir { 806cdf0e10cSrcweir xShapes->add( pAcc->GetXShape() ); 807cdf0e10cSrcweir pAccessibleChild = pAcc; 808cdf0e10cSrcweir } 809cdf0e10cSrcweir } 810cdf0e10cSrcweir 811cdf0e10cSrcweir if( xShapes->getCount() ) 812cdf0e10cSrcweir { 813cdf0e10cSrcweir aAny <<= xShapes; 814cdf0e10cSrcweir xSel->select( aAny ); 815cdf0e10cSrcweir } 816cdf0e10cSrcweir } 817cdf0e10cSrcweir } 818cdf0e10cSrcweir else if( nAccessibleChildIndex >= 0 ) 819cdf0e10cSrcweir { 820cdf0e10cSrcweir // Select or deselect only the child with index 821cdf0e10cSrcweir // nAccessibleChildIndex. 822cdf0e10cSrcweir 823cdf0e10cSrcweir AccessibleShape* pAcc = AccessibleShape::getImplementation( 824cdf0e10cSrcweir getAccessibleChild( nAccessibleChildIndex )); 825cdf0e10cSrcweir pAccessibleChild = pAcc; 826cdf0e10cSrcweir 827cdf0e10cSrcweir // Add or remove the shape that is made accessible from the 828cdf0e10cSrcweir // selection of the controller. 829cdf0e10cSrcweir if( pAcc ) 830cdf0e10cSrcweir { 831cdf0e10cSrcweir uno::Reference< drawing::XShape > xShape( pAcc->GetXShape() ); 832cdf0e10cSrcweir 833cdf0e10cSrcweir if( xShape.is() ) 834cdf0e10cSrcweir { 835cdf0e10cSrcweir uno::Reference< drawing::XShapes > xShapes; 836cdf0e10cSrcweir sal_Bool bFound = sal_False; 837cdf0e10cSrcweir 838cdf0e10cSrcweir aAny = xSel->getSelection(); 839cdf0e10cSrcweir aAny >>= xShapes; 840cdf0e10cSrcweir 841cdf0e10cSrcweir // Search shape to be selected in current selection. 842cdf0e10cSrcweir if (xShapes.is()) 843cdf0e10cSrcweir { 844cdf0e10cSrcweir sal_Int32 nCount = xShapes->getCount(); 845cdf0e10cSrcweir for (sal_Int32 i=0; ( i < nCount ) && !bFound; ++i ) 846cdf0e10cSrcweir if( xShapes->getByIndex( i ) == xShape ) 847cdf0e10cSrcweir bFound = sal_True; 848cdf0e10cSrcweir } 849cdf0e10cSrcweir else 850cdf0e10cSrcweir // Create an empty selection to add the shape to. 851cdf0e10cSrcweir xShapes = new SvxShapeCollection(); 852cdf0e10cSrcweir 853cdf0e10cSrcweir // Update the selection. 854cdf0e10cSrcweir if( !bFound && bSelect ) 855cdf0e10cSrcweir xShapes->add( xShape ); 856cdf0e10cSrcweir else if( bFound && !bSelect ) 857cdf0e10cSrcweir xShapes->remove( xShape ); 858cdf0e10cSrcweir 859cdf0e10cSrcweir aAny <<= xShapes; 860cdf0e10cSrcweir xSel->select( aAny ); 861cdf0e10cSrcweir } 862cdf0e10cSrcweir } 863cdf0e10cSrcweir } 864cdf0e10cSrcweir } 865cdf0e10cSrcweir } 866cdf0e10cSrcweir 867cdf0e10cSrcweir 868cdf0e10cSrcweir 869cdf0e10cSrcweir 870cdf0e10cSrcweir void AccessibleDrawDocumentView::Activated (void) 871cdf0e10cSrcweir { 872cdf0e10cSrcweir if (mpChildrenManager != NULL) 873cdf0e10cSrcweir { 8740deba7fbSSteve Yin sal_Bool bChange = sal_False; 875cdf0e10cSrcweir // When none of the children has the focus then claim it for the 876cdf0e10cSrcweir // view. 877cdf0e10cSrcweir if ( ! mpChildrenManager->HasFocus()) 8780deba7fbSSteve Yin { 879cdf0e10cSrcweir SetState (AccessibleStateType::FOCUSED); 8800deba7fbSSteve Yin bChange = sal_True; 8810deba7fbSSteve Yin } 882cdf0e10cSrcweir else 883cdf0e10cSrcweir ResetState (AccessibleStateType::FOCUSED); 8840deba7fbSSteve Yin mpChildrenManager->UpdateSelection(); 8850deba7fbSSteve Yin // if the child gets focus in UpdateSelection(), needs to reset the focus on document. 8860deba7fbSSteve Yin if (mpChildrenManager->HasFocus() && bChange) 8870deba7fbSSteve Yin ResetState (AccessibleStateType::FOCUSED); 888cdf0e10cSrcweir } 889cdf0e10cSrcweir } 890cdf0e10cSrcweir 891cdf0e10cSrcweir 892cdf0e10cSrcweir 893cdf0e10cSrcweir 894cdf0e10cSrcweir void AccessibleDrawDocumentView::Deactivated (void) 895cdf0e10cSrcweir { 896cdf0e10cSrcweir if (mpChildrenManager != NULL) 897cdf0e10cSrcweir mpChildrenManager->RemoveFocus(); 898cdf0e10cSrcweir ResetState (AccessibleStateType::FOCUSED); 899cdf0e10cSrcweir } 900cdf0e10cSrcweir 901cdf0e10cSrcweir 902cdf0e10cSrcweir 903cdf0e10cSrcweir 904cdf0e10cSrcweir void AccessibleDrawDocumentView::impl_dispose (void) 905cdf0e10cSrcweir { 906cdf0e10cSrcweir if (mpChildrenManager != NULL) 907cdf0e10cSrcweir { 908cdf0e10cSrcweir delete mpChildrenManager; 909cdf0e10cSrcweir mpChildrenManager = NULL; 910cdf0e10cSrcweir } 911cdf0e10cSrcweir 912cdf0e10cSrcweir AccessibleDocumentViewBase::impl_dispose(); 913cdf0e10cSrcweir } 914cdf0e10cSrcweir 915cdf0e10cSrcweir 916cdf0e10cSrcweir 917cdf0e10cSrcweir /** This method is called from the component helper base class while 918cdf0e10cSrcweir disposing. 919cdf0e10cSrcweir */ 920cdf0e10cSrcweir void SAL_CALL AccessibleDrawDocumentView::disposing (void) 921cdf0e10cSrcweir { 922cdf0e10cSrcweir 923cdf0e10cSrcweir // Release resources. 924cdf0e10cSrcweir if (mpChildrenManager != NULL) 925cdf0e10cSrcweir { 926cdf0e10cSrcweir delete mpChildrenManager; 927cdf0e10cSrcweir mpChildrenManager = NULL; 928cdf0e10cSrcweir } 929cdf0e10cSrcweir 930cdf0e10cSrcweir // Forward call to base classes. 931cdf0e10cSrcweir AccessibleDocumentViewBase::disposing (); 932cdf0e10cSrcweir } 933cdf0e10cSrcweir 9340deba7fbSSteve Yin ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > 9350deba7fbSSteve Yin SAL_CALL AccessibleDrawDocumentView::get_AccFlowTo(const ::com::sun::star::uno::Any& rAny, sal_Int32 nType) 9360deba7fbSSteve Yin throw ( ::com::sun::star::uno::RuntimeException ) 9370deba7fbSSteve Yin { 9380deba7fbSSteve Yin const sal_Int32 SPELLCHECKFLOWTO = 1; 9390deba7fbSSteve Yin const sal_Int32 FINDREPLACEFLOWTO = 2; 9400deba7fbSSteve Yin if ( nType == SPELLCHECKFLOWTO ) 9410deba7fbSSteve Yin { 9420deba7fbSSteve Yin uno::Reference< ::com::sun::star::drawing::XShape > xShape; 9430deba7fbSSteve Yin rAny >>= xShape; 9440deba7fbSSteve Yin if ( mpChildrenManager && xShape.is() ) 9450deba7fbSSteve Yin { 9460deba7fbSSteve Yin uno::Reference < XAccessible > xAcc = mpChildrenManager->GetChild(xShape); 9470deba7fbSSteve Yin uno::Reference < XAccessibleSelection > xAccSelection( xAcc, uno::UNO_QUERY ); 9480deba7fbSSteve Yin if ( xAccSelection.is() ) 9490deba7fbSSteve Yin { 9500deba7fbSSteve Yin if ( xAccSelection->getSelectedAccessibleChildCount() ) 9510deba7fbSSteve Yin { 9520deba7fbSSteve Yin uno::Reference < XAccessible > xSel = xAccSelection->getSelectedAccessibleChild( 0 ); 9530deba7fbSSteve Yin if ( xSel.is() ) 9540deba7fbSSteve Yin { 9550deba7fbSSteve Yin uno::Reference < XAccessibleContext > xSelContext( xSel->getAccessibleContext() ); 9560deba7fbSSteve Yin if ( xSelContext.is() ) 9570deba7fbSSteve Yin { 9580deba7fbSSteve Yin //if in sw we find the selected paragraph here 9590deba7fbSSteve Yin if ( xSelContext->getAccessibleRole() == AccessibleRole::PARAGRAPH ) 9600deba7fbSSteve Yin { 9610deba7fbSSteve Yin uno::Sequence<uno::Any> aRet( 1 ); 9620deba7fbSSteve Yin aRet[0] = uno::makeAny( xSel ); 9630deba7fbSSteve Yin return aRet; 9640deba7fbSSteve Yin } 9650deba7fbSSteve Yin } 9660deba7fbSSteve Yin } 9670deba7fbSSteve Yin } 9680deba7fbSSteve Yin } 9690deba7fbSSteve Yin uno::Reference<XAccessible> xPara = GetSelAccContextInTable(); 9700deba7fbSSteve Yin if ( xPara.is() ) 9710deba7fbSSteve Yin { 9720deba7fbSSteve Yin uno::Sequence<uno::Any> aRet( 1 ); 9730deba7fbSSteve Yin aRet[0] = uno::makeAny( xPara ); 9740deba7fbSSteve Yin return aRet; 9750deba7fbSSteve Yin } 9760deba7fbSSteve Yin } 9770deba7fbSSteve Yin else 9780deba7fbSSteve Yin { 9790deba7fbSSteve Yin goto Rt; 9800deba7fbSSteve Yin } 9810deba7fbSSteve Yin } 9820deba7fbSSteve Yin else if ( nType == FINDREPLACEFLOWTO ) 9830deba7fbSSteve Yin { 9840deba7fbSSteve Yin sal_Int32 nChildCount = getSelectedAccessibleChildCount(); 9850deba7fbSSteve Yin if ( nChildCount ) 9860deba7fbSSteve Yin { 9870deba7fbSSteve Yin uno::Reference < XAccessible > xSel = getSelectedAccessibleChild( 0 ); 9880deba7fbSSteve Yin if ( xSel.is() ) 9890deba7fbSSteve Yin { 9900deba7fbSSteve Yin uno::Reference < XAccessibleSelection > xAccChildSelection( xSel, uno::UNO_QUERY ); 9910deba7fbSSteve Yin if ( xAccChildSelection.is() ) 9920deba7fbSSteve Yin { 9930deba7fbSSteve Yin if ( xAccChildSelection->getSelectedAccessibleChildCount() ) 9940deba7fbSSteve Yin { 9950deba7fbSSteve Yin uno::Reference < XAccessible > xChildSel = xAccChildSelection->getSelectedAccessibleChild( 0 ); 9960deba7fbSSteve Yin if ( xChildSel.is() ) 9970deba7fbSSteve Yin { 9980deba7fbSSteve Yin uno::Reference < XAccessibleContext > xChildSelContext( xChildSel->getAccessibleContext() ); 9990deba7fbSSteve Yin if ( xChildSelContext.is() && 10000deba7fbSSteve Yin xChildSelContext->getAccessibleRole() == AccessibleRole::PARAGRAPH ) 10010deba7fbSSteve Yin { 10020deba7fbSSteve Yin uno::Sequence<uno::Any> aRet( 1 ); 10030deba7fbSSteve Yin aRet[0] = uno::makeAny( xChildSel ); 10040deba7fbSSteve Yin return aRet; 10050deba7fbSSteve Yin } 10060deba7fbSSteve Yin } 10070deba7fbSSteve Yin } 10080deba7fbSSteve Yin } 10090deba7fbSSteve Yin } 10100deba7fbSSteve Yin } 10110deba7fbSSteve Yin else 10120deba7fbSSteve Yin { 10130deba7fbSSteve Yin uno::Reference<XAccessible> xPara = GetSelAccContextInTable(); 10140deba7fbSSteve Yin if ( xPara.is() ) 10150deba7fbSSteve Yin { 10160deba7fbSSteve Yin uno::Sequence<uno::Any> aRet( 1 ); 10170deba7fbSSteve Yin aRet[0] = uno::makeAny( xPara ); 10180deba7fbSSteve Yin return aRet; 10190deba7fbSSteve Yin } 10200deba7fbSSteve Yin } 10210deba7fbSSteve Yin } 1022cdf0e10cSrcweir 10230deba7fbSSteve Yin Rt: 10240deba7fbSSteve Yin ::com::sun::star::uno::Sequence< uno::Any> aRet; 10250deba7fbSSteve Yin return aRet; 10260deba7fbSSteve Yin } 10270deba7fbSSteve Yin uno::Reference<XAccessible> AccessibleDrawDocumentView::GetSelAccContextInTable() 10280deba7fbSSteve Yin { 10290deba7fbSSteve Yin uno::Reference<XAccessible> xRet; 10300deba7fbSSteve Yin sal_Int32 nCount = mpChildrenManager ? mpChildrenManager->GetChildCount() : 0; 10310deba7fbSSteve Yin if ( nCount ) 10320deba7fbSSteve Yin { 10330deba7fbSSteve Yin for ( sal_Int32 i = 0; i < nCount; i++ ) 10340deba7fbSSteve Yin { 10350deba7fbSSteve Yin try 10360deba7fbSSteve Yin { 10370deba7fbSSteve Yin uno::Reference<XAccessible> xObj = mpChildrenManager->GetChild(i); 10380deba7fbSSteve Yin if ( xObj.is() ) 10390deba7fbSSteve Yin { 10400deba7fbSSteve Yin uno::Reference<XAccessibleContext> xObjContext( xObj, uno::UNO_QUERY ); 10410deba7fbSSteve Yin if ( xObjContext.is() && xObjContext->getAccessibleRole() == AccessibleRole::TABLE ) 10420deba7fbSSteve Yin { 10430deba7fbSSteve Yin uno::Reference<XAccessibleSelection> xObjSelection( xObj, uno::UNO_QUERY ); 10440deba7fbSSteve Yin if ( xObjSelection.is() && xObjSelection->getSelectedAccessibleChildCount() ) 10450deba7fbSSteve Yin { 10460deba7fbSSteve Yin uno::Reference<XAccessible> xCell = xObjSelection->getSelectedAccessibleChild(0); 10470deba7fbSSteve Yin if ( xCell.is() ) 10480deba7fbSSteve Yin { 10490deba7fbSSteve Yin uno::Reference<XAccessibleSelection> xCellSel( xCell, uno::UNO_QUERY ); 10500deba7fbSSteve Yin if ( xCellSel.is() && xCellSel->getSelectedAccessibleChildCount() ) 10510deba7fbSSteve Yin { 10520deba7fbSSteve Yin uno::Reference<XAccessible> xPara = xCellSel->getSelectedAccessibleChild( 0 ); 10530deba7fbSSteve Yin if ( xPara.is() ) 10540deba7fbSSteve Yin { 10550deba7fbSSteve Yin uno::Reference<XAccessibleContext> xParaContext( xPara, uno::UNO_QUERY ); 10560deba7fbSSteve Yin if ( xParaContext.is() && 10570deba7fbSSteve Yin xParaContext->getAccessibleRole() == AccessibleRole::PARAGRAPH ) 10580deba7fbSSteve Yin { 10590deba7fbSSteve Yin xRet = xPara; 10600deba7fbSSteve Yin return xRet; 10610deba7fbSSteve Yin } 10620deba7fbSSteve Yin } 10630deba7fbSSteve Yin } 10640deba7fbSSteve Yin } 10650deba7fbSSteve Yin } 10660deba7fbSSteve Yin } 10670deba7fbSSteve Yin } 10680deba7fbSSteve Yin } 10690deba7fbSSteve Yin catch ( lang::IndexOutOfBoundsException ) 10700deba7fbSSteve Yin { 10710deba7fbSSteve Yin uno::Reference<XAccessible> xEmpty; 10720deba7fbSSteve Yin return xEmpty; 10730deba7fbSSteve Yin } 10740deba7fbSSteve Yin catch ( uno::RuntimeException ) 10750deba7fbSSteve Yin { 10760deba7fbSSteve Yin uno::Reference<XAccessible> xEmpty; 10770deba7fbSSteve Yin return xEmpty; 10780deba7fbSSteve Yin } 10790deba7fbSSteve Yin } 10800deba7fbSSteve Yin } 1081cdf0e10cSrcweir 10820deba7fbSSteve Yin return xRet; 10830deba7fbSSteve Yin } 1084cdf0e10cSrcweir 1085cdf0e10cSrcweir void AccessibleDrawDocumentView::UpdateAccessibleName (void) 1086cdf0e10cSrcweir { 1087cdf0e10cSrcweir OUString sNewName (CreateAccessibleName()); 1088cdf0e10cSrcweir sNewName += A2S(": "); 1089cdf0e10cSrcweir 1090cdf0e10cSrcweir // Add the number of the current slide. 1091cdf0e10cSrcweir uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY); 1092cdf0e10cSrcweir if (xView.is()) 1093cdf0e10cSrcweir { 1094cdf0e10cSrcweir uno::Reference<beans::XPropertySet> xProperties (xView->getCurrentPage(), UNO_QUERY); 1095cdf0e10cSrcweir if (xProperties.is()) 1096cdf0e10cSrcweir try 1097cdf0e10cSrcweir { 1098cdf0e10cSrcweir sal_Int16 nPageNumber (0); 1099cdf0e10cSrcweir if (xProperties->getPropertyValue(A2S("Number")) >>= nPageNumber) 1100cdf0e10cSrcweir { 1101cdf0e10cSrcweir sNewName += OUString::valueOf(sal_Int32(nPageNumber)); 1102cdf0e10cSrcweir } 1103cdf0e10cSrcweir } 1104cdf0e10cSrcweir catch (beans::UnknownPropertyException&) 1105cdf0e10cSrcweir { 1106cdf0e10cSrcweir } 1107cdf0e10cSrcweir } 1108cdf0e10cSrcweir 1109cdf0e10cSrcweir // Add the number of pages/slides. 1110cdf0e10cSrcweir Reference<drawing::XDrawPagesSupplier> xPagesSupplier (mxModel, UNO_QUERY); 1111cdf0e10cSrcweir if (xPagesSupplier.is()) 1112cdf0e10cSrcweir { 1113cdf0e10cSrcweir Reference<container::XIndexAccess> xPages (xPagesSupplier->getDrawPages(), UNO_QUERY); 1114cdf0e10cSrcweir if (xPages.is()) 1115cdf0e10cSrcweir { 1116cdf0e10cSrcweir sNewName += A2S(" / "); 1117cdf0e10cSrcweir sNewName += OUString::valueOf(xPages->getCount()); 1118cdf0e10cSrcweir } 1119cdf0e10cSrcweir } 1120cdf0e10cSrcweir 1121cdf0e10cSrcweir SetAccessibleName (sNewName, AutomaticallyCreated); 1122cdf0e10cSrcweir } 1123cdf0e10cSrcweir 1124cdf0e10cSrcweir 1125cdf0e10cSrcweir 1126cdf0e10cSrcweir 1127cdf0e10cSrcweir } // end of namespace accessibility 1128