1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sd.hxx" 30*cdf0e10cSrcweir #include "AccessibleDrawDocumentView.hxx" 31*cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPage.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawView.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/drawing/XShapes.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/document/XEventBroadcaster.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 43*cdf0e10cSrcweir #include <rtl/ustring.h> 44*cdf0e10cSrcweir #include<sfx2/viewfrm.hxx> 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir #include <svx/AccessibleShape.hxx> 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir #include <svx/svdobj.hxx> 49*cdf0e10cSrcweir #include <svx/svdmodel.hxx> 50*cdf0e10cSrcweir #include <svx/unoapi.hxx> 51*cdf0e10cSrcweir #include <svx/unoshcol.hxx> 52*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 53*cdf0e10cSrcweir #include "Window.hxx" 54*cdf0e10cSrcweir #include <vcl/svapp.hxx> 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir #include "ViewShell.hxx" 58*cdf0e10cSrcweir #include "View.hxx" 59*cdf0e10cSrcweir #include <memory> 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir #include "accessibility.hrc" 62*cdf0e10cSrcweir #include "sdresid.hxx" 63*cdf0e10cSrcweir #include <vos/mutex.hxx> 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir using ::rtl::OUString; 66*cdf0e10cSrcweir using namespace ::com::sun::star; 67*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 68*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir class SfxViewFrame; 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir #define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString))) 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir namespace accessibility { 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir //===== internal ============================================================ 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir AccessibleDrawDocumentView::AccessibleDrawDocumentView ( 80*cdf0e10cSrcweir ::sd::Window* pSdWindow, 81*cdf0e10cSrcweir ::sd::ViewShell* pViewShell, 82*cdf0e10cSrcweir const uno::Reference<frame::XController>& rxController, 83*cdf0e10cSrcweir const uno::Reference<XAccessible>& rxParent) 84*cdf0e10cSrcweir : AccessibleDocumentViewBase (pSdWindow, pViewShell, rxController, rxParent), 85*cdf0e10cSrcweir mpChildrenManager (NULL) 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir OSL_TRACE ("AccessibleDrawDocumentView"); 88*cdf0e10cSrcweir UpdateAccessibleName(); 89*cdf0e10cSrcweir } 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir AccessibleDrawDocumentView::~AccessibleDrawDocumentView (void) 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir OSL_TRACE ("~AccessibleDrawDocumentView"); 97*cdf0e10cSrcweir DBG_ASSERT (rBHelper.bDisposed || rBHelper.bInDispose, 98*cdf0e10cSrcweir "~AccessibleDrawDocumentView: object has not been disposed"); 99*cdf0e10cSrcweir } 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir void AccessibleDrawDocumentView::Init (void) 105*cdf0e10cSrcweir { 106*cdf0e10cSrcweir AccessibleDocumentViewBase::Init (); 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir // Determine the list of shapes on the current page. 109*cdf0e10cSrcweir uno::Reference<drawing::XShapes> xShapeList; 110*cdf0e10cSrcweir uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY); 111*cdf0e10cSrcweir if (xView.is()) 112*cdf0e10cSrcweir xShapeList = uno::Reference<drawing::XShapes> ( 113*cdf0e10cSrcweir xView->getCurrentPage(), uno::UNO_QUERY); 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir // Create the children manager. 116*cdf0e10cSrcweir mpChildrenManager = new ChildrenManager(this, xShapeList, maShapeTreeInfo, *this); 117*cdf0e10cSrcweir if (mpChildrenManager != NULL) 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir // Create the page shape and initialize it. The shape is acquired 120*cdf0e10cSrcweir // before initialization and released after transferring ownership 121*cdf0e10cSrcweir // to the children manager to prevent premature disposing of the 122*cdf0e10cSrcweir // shape. 123*cdf0e10cSrcweir AccessiblePageShape* pPage = CreateDrawPageShape(); 124*cdf0e10cSrcweir if (pPage != NULL) 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir pPage->acquire(); 127*cdf0e10cSrcweir pPage->Init(); 128*cdf0e10cSrcweir mpChildrenManager->AddAccessibleShape ( 129*cdf0e10cSrcweir std::auto_ptr<AccessibleShape>(pPage)); 130*cdf0e10cSrcweir pPage->release(); 131*cdf0e10cSrcweir mpChildrenManager->Update (); 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir mpChildrenManager->UpdateSelection (); 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir void AccessibleDrawDocumentView::ViewForwarderChanged (ChangeType aChangeType, 141*cdf0e10cSrcweir const IAccessibleViewForwarder* pViewForwarder) 142*cdf0e10cSrcweir { 143*cdf0e10cSrcweir AccessibleDocumentViewBase::ViewForwarderChanged (aChangeType, pViewForwarder); 144*cdf0e10cSrcweir if (mpChildrenManager != NULL) 145*cdf0e10cSrcweir mpChildrenManager->ViewForwarderChanged (aChangeType, pViewForwarder); 146*cdf0e10cSrcweir } 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir /** The page shape is created on every call at the moment (provided that 152*cdf0e10cSrcweir every thing goes well). 153*cdf0e10cSrcweir */ 154*cdf0e10cSrcweir AccessiblePageShape* AccessibleDrawDocumentView::CreateDrawPageShape (void) 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir AccessiblePageShape* pShape = NULL; 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir // Create a shape that represents the actual draw page. 159*cdf0e10cSrcweir uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY); 160*cdf0e10cSrcweir if (xView.is()) 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir uno::Reference<beans::XPropertySet> xSet ( 163*cdf0e10cSrcweir uno::Reference<beans::XPropertySet> (xView->getCurrentPage(), uno::UNO_QUERY)); 164*cdf0e10cSrcweir if (xSet.is()) 165*cdf0e10cSrcweir { 166*cdf0e10cSrcweir // Create a rectangle shape that will represent the draw page. 167*cdf0e10cSrcweir uno::Reference<lang::XMultiServiceFactory> xFactory (mxModel, uno::UNO_QUERY); 168*cdf0e10cSrcweir uno::Reference<drawing::XShape> xRectangle; 169*cdf0e10cSrcweir if (xFactory.is()) 170*cdf0e10cSrcweir xRectangle = uno::Reference<drawing::XShape>(xFactory->createInstance ( 171*cdf0e10cSrcweir OUString (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.RectangleShape"))), 172*cdf0e10cSrcweir uno::UNO_QUERY); 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir // Set the shape's size and position. 175*cdf0e10cSrcweir if (xRectangle.is()) 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir uno::Any aValue; 178*cdf0e10cSrcweir awt::Point aPosition; 179*cdf0e10cSrcweir awt::Size aSize; 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir // Set size and position of the shape to those of the draw 182*cdf0e10cSrcweir // page. 183*cdf0e10cSrcweir aValue = xSet->getPropertyValue ( 184*cdf0e10cSrcweir OUString (RTL_CONSTASCII_USTRINGPARAM("BorderLeft"))); 185*cdf0e10cSrcweir aValue >>= aPosition.X; 186*cdf0e10cSrcweir aValue = xSet->getPropertyValue ( 187*cdf0e10cSrcweir OUString (RTL_CONSTASCII_USTRINGPARAM("BorderTop"))); 188*cdf0e10cSrcweir aValue >>= aPosition.Y; 189*cdf0e10cSrcweir xRectangle->setPosition (aPosition); 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir aValue = xSet->getPropertyValue ( 192*cdf0e10cSrcweir OUString (RTL_CONSTASCII_USTRINGPARAM("Width"))); 193*cdf0e10cSrcweir aValue >>= aSize.Width; 194*cdf0e10cSrcweir aValue = xSet->getPropertyValue ( 195*cdf0e10cSrcweir OUString (RTL_CONSTASCII_USTRINGPARAM("Height"))); 196*cdf0e10cSrcweir aValue >>= aSize.Height; 197*cdf0e10cSrcweir xRectangle->setSize (aSize); 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir // Create the accessible object for the shape and 200*cdf0e10cSrcweir // initialize it. 201*cdf0e10cSrcweir pShape = new AccessiblePageShape ( 202*cdf0e10cSrcweir xView->getCurrentPage(), this, maShapeTreeInfo); 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir return pShape; 207*cdf0e10cSrcweir } 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir //===== XAccessibleContext ================================================== 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir sal_Int32 SAL_CALL 215*cdf0e10cSrcweir AccessibleDrawDocumentView::getAccessibleChildCount (void) 216*cdf0e10cSrcweir throw (uno::RuntimeException) 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir ThrowIfDisposed (); 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir long mpChildCount = AccessibleDocumentViewBase::getAccessibleChildCount(); 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir // Forward request to children manager. 223*cdf0e10cSrcweir if (mpChildrenManager != NULL) 224*cdf0e10cSrcweir mpChildCount += mpChildrenManager->GetChildCount (); 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir return mpChildCount; 227*cdf0e10cSrcweir } 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir uno::Reference<XAccessible> SAL_CALL 233*cdf0e10cSrcweir AccessibleDrawDocumentView::getAccessibleChild (sal_Int32 nIndex) 234*cdf0e10cSrcweir throw (uno::RuntimeException, lang::IndexOutOfBoundsException) 235*cdf0e10cSrcweir { 236*cdf0e10cSrcweir ThrowIfDisposed (); 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir ::osl::ClearableMutexGuard aGuard (maMutex); 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir // Take care of children of the base class. 241*cdf0e10cSrcweir sal_Int32 nCount = AccessibleDocumentViewBase::getAccessibleChildCount(); 242*cdf0e10cSrcweir if (nCount > 0) 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir if (nIndex < nCount) 245*cdf0e10cSrcweir return AccessibleDocumentViewBase::getAccessibleChild(nIndex); 246*cdf0e10cSrcweir else 247*cdf0e10cSrcweir nIndex -= nCount; 248*cdf0e10cSrcweir } 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir // Create a copy of the pointer to the children manager and release the 251*cdf0e10cSrcweir // mutex before calling any of its methods. 252*cdf0e10cSrcweir ChildrenManager* pChildrenManager = mpChildrenManager; 253*cdf0e10cSrcweir aGuard.clear(); 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir // Forward request to children manager. 256*cdf0e10cSrcweir if (pChildrenManager != NULL) 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir return pChildrenManager->GetChild (nIndex); 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir else 261*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException ( 262*cdf0e10cSrcweir ::rtl::OUString::createFromAscii ("no accessible child with index ") 263*cdf0e10cSrcweir + rtl::OUString::valueOf(nIndex), 264*cdf0e10cSrcweir static_cast<uno::XWeak*>(this)); 265*cdf0e10cSrcweir } 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir //===== XEventListener ====================================================== 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir void SAL_CALL 273*cdf0e10cSrcweir AccessibleDrawDocumentView::disposing (const lang::EventObject& rEventObject) 274*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 275*cdf0e10cSrcweir { 276*cdf0e10cSrcweir ThrowIfDisposed (); 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir AccessibleDocumentViewBase::disposing (rEventObject); 279*cdf0e10cSrcweir if (rEventObject.Source == mxModel) 280*cdf0e10cSrcweir { 281*cdf0e10cSrcweir ::osl::Guard< ::osl::Mutex> aGuard (::osl::Mutex::getGlobalMutex()); 282*cdf0e10cSrcweir // maShapeTreeInfo has been modified in base class. 283*cdf0e10cSrcweir if (mpChildrenManager != NULL) 284*cdf0e10cSrcweir mpChildrenManager->SetInfo (maShapeTreeInfo); 285*cdf0e10cSrcweir } 286*cdf0e10cSrcweir } 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir //===== XPropertyChangeListener ============================================= 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir void SAL_CALL 294*cdf0e10cSrcweir AccessibleDrawDocumentView::propertyChange (const beans::PropertyChangeEvent& rEventObject) 295*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir ThrowIfDisposed (); 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir AccessibleDocumentViewBase::propertyChange (rEventObject); 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir OSL_TRACE ("AccessibleDrawDocumentView::propertyChange"); 302*cdf0e10cSrcweir if (rEventObject.PropertyName == OUString (RTL_CONSTASCII_USTRINGPARAM("CurrentPage"))) 303*cdf0e10cSrcweir { 304*cdf0e10cSrcweir OSL_TRACE (" current page changed"); 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir // Update the accessible name to reflect the current slide. 307*cdf0e10cSrcweir UpdateAccessibleName(); 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir // The current page changed. Update the children manager accordingly. 310*cdf0e10cSrcweir uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY); 311*cdf0e10cSrcweir if (xView.is() && mpChildrenManager!=NULL) 312*cdf0e10cSrcweir { 313*cdf0e10cSrcweir // Inform the children manager to forget all children and give 314*cdf0e10cSrcweir // him the new ones. 315*cdf0e10cSrcweir mpChildrenManager->ClearAccessibleShapeList (); 316*cdf0e10cSrcweir mpChildrenManager->SetShapeList (uno::Reference<drawing::XShapes> ( 317*cdf0e10cSrcweir xView->getCurrentPage(), uno::UNO_QUERY)); 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir // Create the page shape and initialize it. The shape is 320*cdf0e10cSrcweir // acquired before initialization and released after 321*cdf0e10cSrcweir // transferring ownership to the children manager to prevent 322*cdf0e10cSrcweir // premature disposing of the shape. 323*cdf0e10cSrcweir AccessiblePageShape* pPage = CreateDrawPageShape (); 324*cdf0e10cSrcweir if (pPage != NULL) 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir pPage->acquire(); 327*cdf0e10cSrcweir pPage->Init(); 328*cdf0e10cSrcweir mpChildrenManager->AddAccessibleShape ( 329*cdf0e10cSrcweir std::auto_ptr<AccessibleShape>(pPage)); 330*cdf0e10cSrcweir mpChildrenManager->Update (false); 331*cdf0e10cSrcweir pPage->release(); 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir } 334*cdf0e10cSrcweir else 335*cdf0e10cSrcweir OSL_TRACE ("View invalid"); 336*cdf0e10cSrcweir } 337*cdf0e10cSrcweir else if (rEventObject.PropertyName == OUString (RTL_CONSTASCII_USTRINGPARAM("VisibleArea"))) 338*cdf0e10cSrcweir { 339*cdf0e10cSrcweir OSL_TRACE (" visible area changed"); 340*cdf0e10cSrcweir if (mpChildrenManager != NULL) 341*cdf0e10cSrcweir mpChildrenManager->ViewForwarderChanged ( 342*cdf0e10cSrcweir IAccessibleViewForwarderListener::VISIBLE_AREA, 343*cdf0e10cSrcweir &maViewForwarder); 344*cdf0e10cSrcweir } 345*cdf0e10cSrcweir else 346*cdf0e10cSrcweir { 347*cdf0e10cSrcweir OSL_TRACE (" unhandled"); 348*cdf0e10cSrcweir } 349*cdf0e10cSrcweir OSL_TRACE (" done"); 350*cdf0e10cSrcweir } 351*cdf0e10cSrcweir 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir //===== XServiceInfo ======================================================== 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir ::rtl::OUString SAL_CALL 357*cdf0e10cSrcweir AccessibleDrawDocumentView::getImplementationName (void) 358*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 359*cdf0e10cSrcweir { 360*cdf0e10cSrcweir return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 361*cdf0e10cSrcweir "AccessibleDrawDocumentView")); 362*cdf0e10cSrcweir } 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL 368*cdf0e10cSrcweir AccessibleDrawDocumentView::getSupportedServiceNames (void) 369*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 370*cdf0e10cSrcweir { 371*cdf0e10cSrcweir ThrowIfDisposed(); 372*cdf0e10cSrcweir // Get list of supported service names from base class... 373*cdf0e10cSrcweir uno::Sequence<OUString> aServiceNames = 374*cdf0e10cSrcweir AccessibleDocumentViewBase::getSupportedServiceNames(); 375*cdf0e10cSrcweir sal_Int32 nCount (aServiceNames.getLength()); 376*cdf0e10cSrcweir 377*cdf0e10cSrcweir // ...and add additional names. 378*cdf0e10cSrcweir aServiceNames.realloc (nCount + 1); 379*cdf0e10cSrcweir static const OUString sAdditionalServiceName (RTL_CONSTASCII_USTRINGPARAM( 380*cdf0e10cSrcweir "com.sun.star.drawing.AccessibleDrawDocumentView")); 381*cdf0e10cSrcweir aServiceNames[nCount] = sAdditionalServiceName; 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir return aServiceNames; 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir /// Create a name for this view. 390*cdf0e10cSrcweir ::rtl::OUString 391*cdf0e10cSrcweir AccessibleDrawDocumentView::CreateAccessibleName (void) 392*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir rtl::OUString sName; 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir uno::Reference<lang::XServiceInfo> xInfo (mxController, uno::UNO_QUERY); 397*cdf0e10cSrcweir if (xInfo.is()) 398*cdf0e10cSrcweir { 399*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aServices( xInfo->getSupportedServiceNames() ); 400*cdf0e10cSrcweir OUString sFirstService = aServices[0]; 401*cdf0e10cSrcweir if (sFirstService == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DrawingDocumentDrawView"))) 402*cdf0e10cSrcweir { 403*cdf0e10cSrcweir if( aServices.getLength() >= 2 && 404*cdf0e10cSrcweir aServices[1] == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PresentationView"))) 405*cdf0e10cSrcweir { 406*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir sName = String( SdResId(SID_SD_A11Y_I_DRAWVIEW_N) ); 409*cdf0e10cSrcweir } 410*cdf0e10cSrcweir else 411*cdf0e10cSrcweir { 412*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir sName = String( SdResId(SID_SD_A11Y_D_DRAWVIEW_N) ); 415*cdf0e10cSrcweir } 416*cdf0e10cSrcweir } 417*cdf0e10cSrcweir else if (sFirstService == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.NotesView"))) 418*cdf0e10cSrcweir { 419*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir sName = String( SdResId(SID_SD_A11Y_I_NOTESVIEW_N) ); 422*cdf0e10cSrcweir } 423*cdf0e10cSrcweir else if (sFirstService == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.HandoutView"))) 424*cdf0e10cSrcweir { 425*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir sName = String( SdResId(SID_SD_A11Y_I_HANDOUTVIEW_N) ); 428*cdf0e10cSrcweir } 429*cdf0e10cSrcweir else 430*cdf0e10cSrcweir { 431*cdf0e10cSrcweir sName = sFirstService; 432*cdf0e10cSrcweir } 433*cdf0e10cSrcweir } 434*cdf0e10cSrcweir else 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir sName = OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleDrawDocumentView")); 437*cdf0e10cSrcweir } 438*cdf0e10cSrcweir return sName; 439*cdf0e10cSrcweir } 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir 444*cdf0e10cSrcweir /** Create a description for this view. Use the model's description or URL 445*cdf0e10cSrcweir if a description is not available. 446*cdf0e10cSrcweir */ 447*cdf0e10cSrcweir ::rtl::OUString 448*cdf0e10cSrcweir AccessibleDrawDocumentView::CreateAccessibleDescription (void) 449*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 450*cdf0e10cSrcweir { 451*cdf0e10cSrcweir rtl::OUString sDescription; 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir uno::Reference<lang::XServiceInfo> xInfo (mxController, uno::UNO_QUERY); 454*cdf0e10cSrcweir if (xInfo.is()) 455*cdf0e10cSrcweir { 456*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aServices( xInfo->getSupportedServiceNames() ); 457*cdf0e10cSrcweir OUString sFirstService = aServices[0]; 458*cdf0e10cSrcweir if (sFirstService == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DrawingDocumentDrawView"))) 459*cdf0e10cSrcweir { 460*cdf0e10cSrcweir if( aServices.getLength() >= 2 && 461*cdf0e10cSrcweir aServices[1] == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PresentationView"))) 462*cdf0e10cSrcweir { 463*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir sDescription = String( SdResId(SID_SD_A11Y_I_DRAWVIEW_D) ); 466*cdf0e10cSrcweir } 467*cdf0e10cSrcweir else 468*cdf0e10cSrcweir { 469*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 470*cdf0e10cSrcweir 471*cdf0e10cSrcweir sDescription = String( SdResId(SID_SD_A11Y_D_DRAWVIEW_D) ); 472*cdf0e10cSrcweir } 473*cdf0e10cSrcweir } 474*cdf0e10cSrcweir else if (sFirstService == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.NotesView"))) 475*cdf0e10cSrcweir { 476*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir sDescription = String( SdResId(SID_SD_A11Y_I_NOTESVIEW_D) ); 479*cdf0e10cSrcweir } 480*cdf0e10cSrcweir else if (sFirstService == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.HandoutView"))) 481*cdf0e10cSrcweir { 482*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir sDescription = String( SdResId(SID_SD_A11Y_I_HANDOUTVIEW_D) ); 485*cdf0e10cSrcweir } 486*cdf0e10cSrcweir else 487*cdf0e10cSrcweir { 488*cdf0e10cSrcweir sDescription = sFirstService; 489*cdf0e10cSrcweir } 490*cdf0e10cSrcweir } 491*cdf0e10cSrcweir else 492*cdf0e10cSrcweir { 493*cdf0e10cSrcweir sDescription = OUString(RTL_CONSTASCII_USTRINGPARAM("Accessible Draw Document")); 494*cdf0e10cSrcweir } 495*cdf0e10cSrcweir return sDescription; 496*cdf0e10cSrcweir } 497*cdf0e10cSrcweir 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir 500*cdf0e10cSrcweir 501*cdf0e10cSrcweir /** Return selection state of specified child 502*cdf0e10cSrcweir */ 503*cdf0e10cSrcweir sal_Bool 504*cdf0e10cSrcweir AccessibleDrawDocumentView::implIsSelected( sal_Int32 nAccessibleChildIndex ) 505*cdf0e10cSrcweir throw (uno::RuntimeException) 506*cdf0e10cSrcweir { 507*cdf0e10cSrcweir const vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 508*cdf0e10cSrcweir uno::Reference< view::XSelectionSupplier > xSel( mxController, uno::UNO_QUERY ); 509*cdf0e10cSrcweir sal_Bool bRet = sal_False; 510*cdf0e10cSrcweir 511*cdf0e10cSrcweir OSL_ENSURE( 0 <= nAccessibleChildIndex, "AccessibleDrawDocumentView::implIsSelected: invalid index!" ); 512*cdf0e10cSrcweir 513*cdf0e10cSrcweir if( xSel.is() && ( 0 <= nAccessibleChildIndex ) ) 514*cdf0e10cSrcweir { 515*cdf0e10cSrcweir uno::Any aAny( xSel->getSelection() ); 516*cdf0e10cSrcweir uno::Reference< drawing::XShapes > xShapes; 517*cdf0e10cSrcweir 518*cdf0e10cSrcweir aAny >>= xShapes; 519*cdf0e10cSrcweir 520*cdf0e10cSrcweir if( xShapes.is() ) 521*cdf0e10cSrcweir { 522*cdf0e10cSrcweir AccessibleShape* pAcc = AccessibleShape::getImplementation( getAccessibleChild( nAccessibleChildIndex ) ); 523*cdf0e10cSrcweir 524*cdf0e10cSrcweir if( pAcc ) 525*cdf0e10cSrcweir { 526*cdf0e10cSrcweir uno::Reference< drawing::XShape > xShape( pAcc->GetXShape() ); 527*cdf0e10cSrcweir 528*cdf0e10cSrcweir if( xShape.is() ) 529*cdf0e10cSrcweir { 530*cdf0e10cSrcweir for( sal_Int32 i = 0, nCount = xShapes->getCount(); ( i < nCount ) && !bRet; ++i ) 531*cdf0e10cSrcweir if( xShapes->getByIndex( i ) == xShape ) 532*cdf0e10cSrcweir bRet = sal_True; 533*cdf0e10cSrcweir } 534*cdf0e10cSrcweir } 535*cdf0e10cSrcweir } 536*cdf0e10cSrcweir } 537*cdf0e10cSrcweir 538*cdf0e10cSrcweir return( bRet ); 539*cdf0e10cSrcweir } 540*cdf0e10cSrcweir 541*cdf0e10cSrcweir 542*cdf0e10cSrcweir 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir /** Select or delselect the specified shapes. The corresponding accessible 545*cdf0e10cSrcweir shapes are notified over the selection change listeners registered with 546*cdf0e10cSrcweir the XSelectionSupplier of the controller. 547*cdf0e10cSrcweir */ 548*cdf0e10cSrcweir void 549*cdf0e10cSrcweir AccessibleDrawDocumentView::implSelect( sal_Int32 nAccessibleChildIndex, sal_Bool bSelect ) 550*cdf0e10cSrcweir throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 551*cdf0e10cSrcweir { 552*cdf0e10cSrcweir const vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 553*cdf0e10cSrcweir uno::Reference< view::XSelectionSupplier > xSel( mxController, uno::UNO_QUERY ); 554*cdf0e10cSrcweir AccessibleShape* pAccessibleChild; 555*cdf0e10cSrcweir 556*cdf0e10cSrcweir if( xSel.is() ) 557*cdf0e10cSrcweir { 558*cdf0e10cSrcweir uno::Any aAny; 559*cdf0e10cSrcweir 560*cdf0e10cSrcweir if( ACCESSIBLE_SELECTION_CHILD_ALL == nAccessibleChildIndex ) 561*cdf0e10cSrcweir { 562*cdf0e10cSrcweir // Select or deselect all children. 563*cdf0e10cSrcweir 564*cdf0e10cSrcweir if( !bSelect ) 565*cdf0e10cSrcweir xSel->select( aAny ); 566*cdf0e10cSrcweir else 567*cdf0e10cSrcweir { 568*cdf0e10cSrcweir uno::Reference< drawing::XShapes > xShapes( new SvxShapeCollection() ); 569*cdf0e10cSrcweir 570*cdf0e10cSrcweir for(sal_Int32 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i ) 571*cdf0e10cSrcweir { 572*cdf0e10cSrcweir AccessibleShape* pAcc = AccessibleShape::getImplementation( getAccessibleChild( i ) ); 573*cdf0e10cSrcweir 574*cdf0e10cSrcweir if( pAcc && pAcc->GetXShape().is() ) 575*cdf0e10cSrcweir { 576*cdf0e10cSrcweir xShapes->add( pAcc->GetXShape() ); 577*cdf0e10cSrcweir pAccessibleChild = pAcc; 578*cdf0e10cSrcweir } 579*cdf0e10cSrcweir } 580*cdf0e10cSrcweir 581*cdf0e10cSrcweir if( xShapes->getCount() ) 582*cdf0e10cSrcweir { 583*cdf0e10cSrcweir aAny <<= xShapes; 584*cdf0e10cSrcweir xSel->select( aAny ); 585*cdf0e10cSrcweir } 586*cdf0e10cSrcweir } 587*cdf0e10cSrcweir } 588*cdf0e10cSrcweir else if( nAccessibleChildIndex >= 0 ) 589*cdf0e10cSrcweir { 590*cdf0e10cSrcweir // Select or deselect only the child with index 591*cdf0e10cSrcweir // nAccessibleChildIndex. 592*cdf0e10cSrcweir 593*cdf0e10cSrcweir AccessibleShape* pAcc = AccessibleShape::getImplementation( 594*cdf0e10cSrcweir getAccessibleChild( nAccessibleChildIndex )); 595*cdf0e10cSrcweir pAccessibleChild = pAcc; 596*cdf0e10cSrcweir 597*cdf0e10cSrcweir // Add or remove the shape that is made accessible from the 598*cdf0e10cSrcweir // selection of the controller. 599*cdf0e10cSrcweir if( pAcc ) 600*cdf0e10cSrcweir { 601*cdf0e10cSrcweir uno::Reference< drawing::XShape > xShape( pAcc->GetXShape() ); 602*cdf0e10cSrcweir 603*cdf0e10cSrcweir if( xShape.is() ) 604*cdf0e10cSrcweir { 605*cdf0e10cSrcweir uno::Reference< drawing::XShapes > xShapes; 606*cdf0e10cSrcweir sal_Bool bFound = sal_False; 607*cdf0e10cSrcweir 608*cdf0e10cSrcweir aAny = xSel->getSelection(); 609*cdf0e10cSrcweir aAny >>= xShapes; 610*cdf0e10cSrcweir 611*cdf0e10cSrcweir // Search shape to be selected in current selection. 612*cdf0e10cSrcweir if (xShapes.is()) 613*cdf0e10cSrcweir { 614*cdf0e10cSrcweir sal_Int32 nCount = xShapes->getCount(); 615*cdf0e10cSrcweir for (sal_Int32 i=0; ( i < nCount ) && !bFound; ++i ) 616*cdf0e10cSrcweir if( xShapes->getByIndex( i ) == xShape ) 617*cdf0e10cSrcweir bFound = sal_True; 618*cdf0e10cSrcweir } 619*cdf0e10cSrcweir else 620*cdf0e10cSrcweir // Create an empty selection to add the shape to. 621*cdf0e10cSrcweir xShapes = new SvxShapeCollection(); 622*cdf0e10cSrcweir 623*cdf0e10cSrcweir // Update the selection. 624*cdf0e10cSrcweir if( !bFound && bSelect ) 625*cdf0e10cSrcweir xShapes->add( xShape ); 626*cdf0e10cSrcweir else if( bFound && !bSelect ) 627*cdf0e10cSrcweir xShapes->remove( xShape ); 628*cdf0e10cSrcweir 629*cdf0e10cSrcweir aAny <<= xShapes; 630*cdf0e10cSrcweir xSel->select( aAny ); 631*cdf0e10cSrcweir } 632*cdf0e10cSrcweir } 633*cdf0e10cSrcweir } 634*cdf0e10cSrcweir } 635*cdf0e10cSrcweir } 636*cdf0e10cSrcweir 637*cdf0e10cSrcweir 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir 640*cdf0e10cSrcweir void AccessibleDrawDocumentView::Activated (void) 641*cdf0e10cSrcweir { 642*cdf0e10cSrcweir if (mpChildrenManager != NULL) 643*cdf0e10cSrcweir { 644*cdf0e10cSrcweir mpChildrenManager->UpdateSelection(); 645*cdf0e10cSrcweir // When none of the children has the focus then claim it for the 646*cdf0e10cSrcweir // view. 647*cdf0e10cSrcweir if ( ! mpChildrenManager->HasFocus()) 648*cdf0e10cSrcweir SetState (AccessibleStateType::FOCUSED); 649*cdf0e10cSrcweir else 650*cdf0e10cSrcweir ResetState (AccessibleStateType::FOCUSED); 651*cdf0e10cSrcweir } 652*cdf0e10cSrcweir } 653*cdf0e10cSrcweir 654*cdf0e10cSrcweir 655*cdf0e10cSrcweir 656*cdf0e10cSrcweir 657*cdf0e10cSrcweir void AccessibleDrawDocumentView::Deactivated (void) 658*cdf0e10cSrcweir { 659*cdf0e10cSrcweir if (mpChildrenManager != NULL) 660*cdf0e10cSrcweir mpChildrenManager->RemoveFocus(); 661*cdf0e10cSrcweir ResetState (AccessibleStateType::FOCUSED); 662*cdf0e10cSrcweir } 663*cdf0e10cSrcweir 664*cdf0e10cSrcweir 665*cdf0e10cSrcweir 666*cdf0e10cSrcweir 667*cdf0e10cSrcweir void AccessibleDrawDocumentView::impl_dispose (void) 668*cdf0e10cSrcweir { 669*cdf0e10cSrcweir if (mpChildrenManager != NULL) 670*cdf0e10cSrcweir { 671*cdf0e10cSrcweir delete mpChildrenManager; 672*cdf0e10cSrcweir mpChildrenManager = NULL; 673*cdf0e10cSrcweir } 674*cdf0e10cSrcweir 675*cdf0e10cSrcweir AccessibleDocumentViewBase::impl_dispose(); 676*cdf0e10cSrcweir } 677*cdf0e10cSrcweir 678*cdf0e10cSrcweir 679*cdf0e10cSrcweir 680*cdf0e10cSrcweir /** This method is called from the component helper base class while 681*cdf0e10cSrcweir disposing. 682*cdf0e10cSrcweir */ 683*cdf0e10cSrcweir void SAL_CALL AccessibleDrawDocumentView::disposing (void) 684*cdf0e10cSrcweir { 685*cdf0e10cSrcweir 686*cdf0e10cSrcweir // Release resources. 687*cdf0e10cSrcweir if (mpChildrenManager != NULL) 688*cdf0e10cSrcweir { 689*cdf0e10cSrcweir delete mpChildrenManager; 690*cdf0e10cSrcweir mpChildrenManager = NULL; 691*cdf0e10cSrcweir } 692*cdf0e10cSrcweir 693*cdf0e10cSrcweir // Forward call to base classes. 694*cdf0e10cSrcweir AccessibleDocumentViewBase::disposing (); 695*cdf0e10cSrcweir } 696*cdf0e10cSrcweir 697*cdf0e10cSrcweir 698*cdf0e10cSrcweir 699*cdf0e10cSrcweir 700*cdf0e10cSrcweir void AccessibleDrawDocumentView::UpdateAccessibleName (void) 701*cdf0e10cSrcweir { 702*cdf0e10cSrcweir OUString sNewName (CreateAccessibleName()); 703*cdf0e10cSrcweir sNewName += A2S(": "); 704*cdf0e10cSrcweir 705*cdf0e10cSrcweir // Add the number of the current slide. 706*cdf0e10cSrcweir uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY); 707*cdf0e10cSrcweir if (xView.is()) 708*cdf0e10cSrcweir { 709*cdf0e10cSrcweir uno::Reference<beans::XPropertySet> xProperties (xView->getCurrentPage(), UNO_QUERY); 710*cdf0e10cSrcweir if (xProperties.is()) 711*cdf0e10cSrcweir try 712*cdf0e10cSrcweir { 713*cdf0e10cSrcweir sal_Int16 nPageNumber (0); 714*cdf0e10cSrcweir if (xProperties->getPropertyValue(A2S("Number")) >>= nPageNumber) 715*cdf0e10cSrcweir { 716*cdf0e10cSrcweir sNewName += OUString::valueOf(sal_Int32(nPageNumber)); 717*cdf0e10cSrcweir } 718*cdf0e10cSrcweir } 719*cdf0e10cSrcweir catch (beans::UnknownPropertyException&) 720*cdf0e10cSrcweir { 721*cdf0e10cSrcweir } 722*cdf0e10cSrcweir } 723*cdf0e10cSrcweir 724*cdf0e10cSrcweir // Add the number of pages/slides. 725*cdf0e10cSrcweir Reference<drawing::XDrawPagesSupplier> xPagesSupplier (mxModel, UNO_QUERY); 726*cdf0e10cSrcweir if (xPagesSupplier.is()) 727*cdf0e10cSrcweir { 728*cdf0e10cSrcweir Reference<container::XIndexAccess> xPages (xPagesSupplier->getDrawPages(), UNO_QUERY); 729*cdf0e10cSrcweir if (xPages.is()) 730*cdf0e10cSrcweir { 731*cdf0e10cSrcweir sNewName += A2S(" / "); 732*cdf0e10cSrcweir sNewName += OUString::valueOf(xPages->getCount()); 733*cdf0e10cSrcweir } 734*cdf0e10cSrcweir } 735*cdf0e10cSrcweir 736*cdf0e10cSrcweir SetAccessibleName (sNewName, AutomaticallyCreated); 737*cdf0e10cSrcweir } 738*cdf0e10cSrcweir 739*cdf0e10cSrcweir 740*cdf0e10cSrcweir 741*cdf0e10cSrcweir 742*cdf0e10cSrcweir } // end of namespace accessibility 743