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