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