1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sd.hxx" 26 #include <com/sun/star/drawing/XDrawPage.hpp> 27 #include <com/sun/star/drawing/XDrawView.hpp> 28 #include <com/sun/star/drawing/XShapes.hpp> 29 #include <com/sun/star/container/XChild.hpp> 30 #include <com/sun/star/frame/XController.hpp> 31 #include <com/sun/star/frame/XFrame.hpp> 32 #include <com/sun/star/document/XEventBroadcaster.hpp> 33 #include <com/sun/star/beans/XPropertySet.hpp> 34 #ifndef _COM_SUN_STAR_ACCESSIBLE_ACCESSIBLEEVENTID_HPP_ 35 #include <com/sun/star/accessibility/AccessibleEventId.hpp> 36 #endif 37 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> 38 #ifndef _COM_SUN_STAR_LANG_XMULSTISERVICEFACTORY_HPP_ 39 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 40 #endif 41 #include <rtl/ustring.h> 42 #ifndef _SFXFRAME_HXX 43 #include<sfx2/viewfrm.hxx> 44 #endif 45 46 #include <svx/AccessibleShape.hxx> 47 48 #include <svx/svdobj.hxx> 49 #include <svx/svdmodel.hxx> 50 #include <svx/unoapi.hxx> 51 #include <toolkit/helper/vclunohelper.hxx> 52 #include <vcl/svapp.hxx> 53 #include "Window.hxx" 54 #include "ViewShell.hxx" 55 #include "OutlineViewShell.hxx" 56 #include "View.hxx" 57 #include "AccessibleOutlineView.hxx" 58 #include "AccessibleOutlineEditSource.hxx" 59 60 #include <memory> 61 62 #include "accessibility.hrc" 63 #include "sdresid.hxx" 64 #include <vos/mutex.hxx> 65 66 using namespace ::com::sun::star; 67 using namespace ::com::sun::star::accessibility; 68 69 namespace accessibility { 70 71 72 //===== internal ============================================================ 73 74 AccessibleOutlineView::AccessibleOutlineView ( 75 ::sd::Window* pSdWindow, 76 ::sd::OutlineViewShell* pViewShell, 77 const uno::Reference<frame::XController>& rxController, 78 const uno::Reference<XAccessible>& rxParent) 79 : AccessibleDocumentViewBase (pSdWindow, pViewShell, rxController, rxParent), 80 maTextHelper( ::std::auto_ptr< SvxEditSource >( NULL ) ) 81 { 82 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 83 84 // Beware! Here we leave the paths of the UNO API and descend into the 85 // depths of the core. Necessary for making the edit engine accessible. 86 if( pViewShell && pSdWindow ) 87 { 88 ::sd::View* pView = pViewShell->GetView(); 89 90 if (pView && pView->ISA(::sd::OutlineView)) 91 { 92 OutlinerView* pOutlineView = static_cast< ::sd::OutlineView*>( 93 pView)->GetViewByWindow( pSdWindow ); 94 SdrOutliner* pOutliner = 95 static_cast< ::sd::OutlineView*>(pView)->GetOutliner(); 96 97 if( pOutlineView && pOutliner ) 98 { 99 maTextHelper.SetEditSource( ::std::auto_ptr< SvxEditSource >( new AccessibleOutlineEditSource( 100 *pOutliner, *pView, *pOutlineView, *pSdWindow ) ) ); 101 } 102 } 103 } 104 } 105 106 107 AccessibleOutlineView::~AccessibleOutlineView (void) 108 { 109 OSL_TRACE ("~AccessibleOutlineView"); 110 } 111 112 113 void AccessibleOutlineView::Init (void) 114 { 115 // #105479# Set event source _before_ starting to listen 116 maTextHelper.SetEventSource(this); 117 118 AccessibleDocumentViewBase::Init (); 119 } 120 121 122 void AccessibleOutlineView::ViewForwarderChanged (ChangeType aChangeType, 123 const IAccessibleViewForwarder* pViewForwarder) 124 { 125 AccessibleDocumentViewBase::ViewForwarderChanged (aChangeType, pViewForwarder); 126 127 UpdateChildren(); 128 } 129 130 131 //===== XAccessibleContext ================================================== 132 133 sal_Int32 SAL_CALL 134 AccessibleOutlineView::getAccessibleChildCount (void) 135 throw (uno::RuntimeException) 136 { 137 ThrowIfDisposed (); 138 139 // forward 140 return maTextHelper.GetChildCount(); 141 } 142 143 144 uno::Reference<XAccessible> SAL_CALL 145 AccessibleOutlineView::getAccessibleChild (sal_Int32 nIndex) 146 throw (::com::sun::star::uno::RuntimeException) 147 { 148 ThrowIfDisposed (); 149 // Forward request to children manager. 150 return maTextHelper.GetChild(nIndex); 151 } 152 153 //IAccessibility2 Implementation 2009----- 154 #include <drawdoc.hxx> 155 ::rtl::OUString SAL_CALL 156 AccessibleOutlineView::getAccessibleName(void) 157 throw (::com::sun::star::uno::RuntimeException) 158 { 159 ::rtl::OUString sName = String( SdResId(SID_SD_A11Y_D_PRESENTATION) ); 160 ::sd::View* pSdView = static_cast< ::sd::View* >( maShapeTreeInfo.GetSdrView() ); 161 if ( pSdView ) 162 { 163 SdDrawDocument* pDoc = pSdView->GetDoc(); 164 if ( pDoc ) 165 { 166 rtl::OUString sFileName = pDoc->getDocAccTitle(); 167 if ( !sFileName.getLength() ) 168 { 169 ::sd::DrawDocShell* pDocSh = pSdView->GetDocSh(); 170 if ( pDocSh ) 171 { 172 sFileName = pDocSh->GetTitle( SFX_TITLE_APINAME ); 173 } 174 } 175 if ( sFileName.getLength() ) 176 { 177 sName = sFileName + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" - ")) + sName; 178 } 179 } 180 } 181 return sName; 182 } 183 //-----IAccessibility2 Implementation 2009 184 //===== XAccessibleEventBroadcaster ======================================== 185 186 void SAL_CALL AccessibleOutlineView::addEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException) 187 { 188 // delegate listener handling to children manager. 189 if ( ! IsDisposed()) 190 maTextHelper.AddEventListener(xListener); 191 //IAccessibility2 Implementation 2009----- 192 AccessibleContextBase::addEventListener(xListener); 193 //-----IAccessibility2 Implementation 2009 194 } 195 196 void SAL_CALL AccessibleOutlineView::removeEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException) 197 { 198 // forward 199 if ( ! IsDisposed()) 200 maTextHelper.RemoveEventListener(xListener); 201 //IAccessibility2 Implementation 2009----- 202 AccessibleContextBase::removeEventListener(xListener); 203 //-----IAccessibility2 Implementation 2009 204 } 205 206 //===== XServiceInfo ======================================================== 207 208 ::rtl::OUString SAL_CALL 209 AccessibleOutlineView::getImplementationName (void) 210 throw (::com::sun::star::uno::RuntimeException) 211 { 212 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleOutlineView")); 213 } 214 215 216 //===== XEventListener ====================================================== 217 218 void SAL_CALL 219 AccessibleOutlineView::disposing (const lang::EventObject& rEventObject) 220 throw (::com::sun::star::uno::RuntimeException) 221 { 222 AccessibleDocumentViewBase::disposing (rEventObject); 223 } 224 225 //===== protected internal ================================================== 226 227 void AccessibleOutlineView::FireEvent(const AccessibleEventObject& aEvent ) 228 { 229 // delegate listener handling to children manager. 230 maTextHelper.FireEvent(aEvent); 231 } 232 233 void AccessibleOutlineView::Activated (void) 234 { 235 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 236 237 // delegate listener handling to children manager. 238 maTextHelper.SetFocus(sal_True); 239 } 240 241 void AccessibleOutlineView::Deactivated (void) 242 { 243 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 244 245 // delegate listener handling to children manager. 246 maTextHelper.SetFocus(sal_False); 247 } 248 249 void SAL_CALL AccessibleOutlineView::disposing (void) 250 { 251 // dispose children 252 maTextHelper.Dispose(); 253 254 AccessibleDocumentViewBase::disposing (); 255 } 256 257 //===== XPropertyChangeListener ============================================= 258 259 void SAL_CALL 260 AccessibleOutlineView::propertyChange (const beans::PropertyChangeEvent& rEventObject) 261 throw (::com::sun::star::uno::RuntimeException) 262 { 263 ThrowIfDisposed (); 264 265 AccessibleDocumentViewBase::propertyChange (rEventObject); 266 267 OSL_TRACE ("AccessibleOutlineView::propertyChange"); 268 //add page switch event for slide show mode 269 if (rEventObject.PropertyName == ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("CurrentPage")) || 270 rEventObject.PropertyName == ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("PageChange")) ) 271 { 272 OSL_TRACE (" current page changed"); 273 274 // The current page changed. Update the children accordingly. 275 UpdateChildren(); 276 //IAccessibility2 Implementation 2009----- 277 CommitChange(AccessibleEventId::PAGE_CHANGED,rEventObject.NewValue,rEventObject.OldValue); 278 //-----IAccessibility2 Implementation 2009 279 } 280 else if (rEventObject.PropertyName == ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("VisibleArea"))) 281 { 282 OSL_TRACE (" visible area changed"); 283 284 // The visible area changed. Update the children accordingly. 285 UpdateChildren(); 286 } 287 else 288 { 289 OSL_TRACE (" unhandled"); 290 } 291 OSL_TRACE (" done"); 292 } 293 294 295 /// Create a name for this view. 296 ::rtl::OUString 297 AccessibleOutlineView::CreateAccessibleName (void) 298 throw (::com::sun::star::uno::RuntimeException) 299 { 300 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 301 302 return String( SdResId(SID_SD_A11Y_I_OUTLINEVIEW_N) ); 303 } 304 305 306 /** Create a description for this view. Use the model's description or URL 307 if a description is not available. 308 */ 309 ::rtl::OUString 310 AccessibleOutlineView::CreateAccessibleDescription (void) 311 throw (::com::sun::star::uno::RuntimeException) 312 { 313 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 314 315 return String( SdResId(SID_SD_A11Y_I_OUTLINEVIEW_D) ); 316 } 317 318 void AccessibleOutlineView::UpdateChildren() 319 { 320 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 321 322 // Update visible children 323 maTextHelper.UpdateChildren(); 324 } 325 326 } // end of namespace accessibility 327