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 <com/sun/star/drawing/XDrawPage.hpp> 31*cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawView.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/drawing/XShapes.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/document/XEventBroadcaster.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 38*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBLE_ACCESSIBLEEVENTID_HPP_ 39*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp> 40*cdf0e10cSrcweir #endif 41*cdf0e10cSrcweir #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> 42*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XMULSTISERVICEFACTORY_HPP_ 43*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 44*cdf0e10cSrcweir #endif 45*cdf0e10cSrcweir #include <rtl/ustring.h> 46*cdf0e10cSrcweir #ifndef _SFXFRAME_HXX 47*cdf0e10cSrcweir #include<sfx2/viewfrm.hxx> 48*cdf0e10cSrcweir #endif 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir #include <svx/AccessibleShape.hxx> 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir #include <svx/svdobj.hxx> 53*cdf0e10cSrcweir #include <svx/svdmodel.hxx> 54*cdf0e10cSrcweir #include <svx/unoapi.hxx> 55*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 56*cdf0e10cSrcweir #include <vcl/svapp.hxx> 57*cdf0e10cSrcweir #include "Window.hxx" 58*cdf0e10cSrcweir #include "ViewShell.hxx" 59*cdf0e10cSrcweir #include "OutlineViewShell.hxx" 60*cdf0e10cSrcweir #include "View.hxx" 61*cdf0e10cSrcweir #include "AccessibleOutlineView.hxx" 62*cdf0e10cSrcweir #include "AccessibleOutlineEditSource.hxx" 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir #include <memory> 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir #include "accessibility.hrc" 67*cdf0e10cSrcweir #include "sdresid.hxx" 68*cdf0e10cSrcweir #include <vos/mutex.hxx> 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir using namespace ::com::sun::star; 71*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir namespace accessibility { 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir //===== internal ============================================================ 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir AccessibleOutlineView::AccessibleOutlineView ( 79*cdf0e10cSrcweir ::sd::Window* pSdWindow, 80*cdf0e10cSrcweir ::sd::OutlineViewShell* pViewShell, 81*cdf0e10cSrcweir const uno::Reference<frame::XController>& rxController, 82*cdf0e10cSrcweir const uno::Reference<XAccessible>& rxParent) 83*cdf0e10cSrcweir : AccessibleDocumentViewBase (pSdWindow, pViewShell, rxController, rxParent), 84*cdf0e10cSrcweir maTextHelper( ::std::auto_ptr< SvxEditSource >( NULL ) ) 85*cdf0e10cSrcweir { 86*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir // Beware! Here we leave the paths of the UNO API and descend into the 89*cdf0e10cSrcweir // depths of the core. Necessary for making the edit engine accessible. 90*cdf0e10cSrcweir if( pViewShell && pSdWindow ) 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir ::sd::View* pView = pViewShell->GetView(); 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir if (pView && pView->ISA(::sd::OutlineView)) 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir OutlinerView* pOutlineView = static_cast< ::sd::OutlineView*>( 97*cdf0e10cSrcweir pView)->GetViewByWindow( pSdWindow ); 98*cdf0e10cSrcweir SdrOutliner* pOutliner = 99*cdf0e10cSrcweir static_cast< ::sd::OutlineView*>(pView)->GetOutliner(); 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir if( pOutlineView && pOutliner ) 102*cdf0e10cSrcweir { 103*cdf0e10cSrcweir maTextHelper.SetEditSource( ::std::auto_ptr< SvxEditSource >( new AccessibleOutlineEditSource( 104*cdf0e10cSrcweir *pOutliner, *pView, *pOutlineView, *pSdWindow ) ) ); 105*cdf0e10cSrcweir } 106*cdf0e10cSrcweir } 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir AccessibleOutlineView::~AccessibleOutlineView (void) 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir OSL_TRACE ("~AccessibleOutlineView"); 114*cdf0e10cSrcweir } 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir void AccessibleOutlineView::Init (void) 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir // #105479# Set event source _before_ starting to listen 120*cdf0e10cSrcweir maTextHelper.SetEventSource(this); 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir AccessibleDocumentViewBase::Init (); 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir void AccessibleOutlineView::ViewForwarderChanged (ChangeType aChangeType, 127*cdf0e10cSrcweir const IAccessibleViewForwarder* pViewForwarder) 128*cdf0e10cSrcweir { 129*cdf0e10cSrcweir AccessibleDocumentViewBase::ViewForwarderChanged (aChangeType, pViewForwarder); 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir UpdateChildren(); 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir //===== XAccessibleContext ================================================== 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir sal_Int32 SAL_CALL 138*cdf0e10cSrcweir AccessibleOutlineView::getAccessibleChildCount (void) 139*cdf0e10cSrcweir throw (uno::RuntimeException) 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir ThrowIfDisposed (); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir // forward 144*cdf0e10cSrcweir return maTextHelper.GetChildCount(); 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir uno::Reference<XAccessible> SAL_CALL 149*cdf0e10cSrcweir AccessibleOutlineView::getAccessibleChild (sal_Int32 nIndex) 150*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 151*cdf0e10cSrcweir { 152*cdf0e10cSrcweir ThrowIfDisposed (); 153*cdf0e10cSrcweir // Forward request to children manager. 154*cdf0e10cSrcweir return maTextHelper.GetChild(nIndex); 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir //===== XAccessibleEventBroadcaster ======================================== 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir void SAL_CALL AccessibleOutlineView::addEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException) 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir // delegate listener handling to children manager. 162*cdf0e10cSrcweir if ( ! IsDisposed()) 163*cdf0e10cSrcweir maTextHelper.AddEventListener(xListener); 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir void SAL_CALL AccessibleOutlineView::removeEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException) 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir // forward 169*cdf0e10cSrcweir if ( ! IsDisposed()) 170*cdf0e10cSrcweir maTextHelper.RemoveEventListener(xListener); 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir //===== XServiceInfo ======================================================== 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir ::rtl::OUString SAL_CALL 176*cdf0e10cSrcweir AccessibleOutlineView::getImplementationName (void) 177*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleOutlineView")); 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir //===== XEventListener ====================================================== 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir void SAL_CALL 186*cdf0e10cSrcweir AccessibleOutlineView::disposing (const lang::EventObject& rEventObject) 187*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir AccessibleDocumentViewBase::disposing (rEventObject); 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir //===== protected internal ================================================== 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir void AccessibleOutlineView::FireEvent(const AccessibleEventObject& aEvent ) 195*cdf0e10cSrcweir { 196*cdf0e10cSrcweir // delegate listener handling to children manager. 197*cdf0e10cSrcweir maTextHelper.FireEvent(aEvent); 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir void AccessibleOutlineView::Activated (void) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir // delegate listener handling to children manager. 205*cdf0e10cSrcweir maTextHelper.SetFocus(sal_True); 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir void AccessibleOutlineView::Deactivated (void) 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir // delegate listener handling to children manager. 213*cdf0e10cSrcweir maTextHelper.SetFocus(sal_False); 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir void SAL_CALL AccessibleOutlineView::disposing (void) 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir // dispose children 219*cdf0e10cSrcweir maTextHelper.Dispose(); 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir AccessibleDocumentViewBase::disposing (); 222*cdf0e10cSrcweir } 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir //===== XPropertyChangeListener ============================================= 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir void SAL_CALL 227*cdf0e10cSrcweir AccessibleOutlineView::propertyChange (const beans::PropertyChangeEvent& rEventObject) 228*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 229*cdf0e10cSrcweir { 230*cdf0e10cSrcweir ThrowIfDisposed (); 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir AccessibleDocumentViewBase::propertyChange (rEventObject); 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir OSL_TRACE ("AccessibleOutlineView::propertyChange"); 235*cdf0e10cSrcweir if (rEventObject.PropertyName == ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("CurrentPage"))) 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir OSL_TRACE (" current page changed"); 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir // The current page changed. Update the children accordingly. 240*cdf0e10cSrcweir UpdateChildren(); 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir else if (rEventObject.PropertyName == ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("VisibleArea"))) 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir OSL_TRACE (" visible area changed"); 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir // The visible area changed. Update the children accordingly. 247*cdf0e10cSrcweir UpdateChildren(); 248*cdf0e10cSrcweir } 249*cdf0e10cSrcweir else 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir OSL_TRACE (" unhandled"); 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir OSL_TRACE (" done"); 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir /// Create a name for this view. 258*cdf0e10cSrcweir ::rtl::OUString 259*cdf0e10cSrcweir AccessibleOutlineView::CreateAccessibleName (void) 260*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir return String( SdResId(SID_SD_A11Y_I_OUTLINEVIEW_N) ); 265*cdf0e10cSrcweir } 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir /** Create a description for this view. Use the model's description or URL 269*cdf0e10cSrcweir if a description is not available. 270*cdf0e10cSrcweir */ 271*cdf0e10cSrcweir ::rtl::OUString 272*cdf0e10cSrcweir AccessibleOutlineView::CreateAccessibleDescription (void) 273*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir return String( SdResId(SID_SD_A11Y_I_OUTLINEVIEW_D) ); 278*cdf0e10cSrcweir } 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir void AccessibleOutlineView::UpdateChildren() 281*cdf0e10cSrcweir { 282*cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir // Update visible children 285*cdf0e10cSrcweir maTextHelper.UpdateChildren(); 286*cdf0e10cSrcweir } 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir } // end of namespace accessibility 289