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 #include <drawdoc.hxx> 154 ::rtl::OUString SAL_CALL 155 AccessibleOutlineView::getAccessibleName(void) 156 throw (::com::sun::star::uno::RuntimeException) 157 { 158 ::rtl::OUString sName = String( SdResId(SID_SD_A11Y_D_PRESENTATION) ); 159 ::sd::View* pSdView = static_cast< ::sd::View* >( maShapeTreeInfo.GetSdrView() ); 160 if ( pSdView ) 161 { 162 SdDrawDocument* pDoc = pSdView->GetDoc(); 163 if ( pDoc ) 164 { 165 rtl::OUString sFileName = pDoc->getDocAccTitle(); 166 if ( !sFileName.getLength() ) 167 { 168 ::sd::DrawDocShell* pDocSh = pSdView->GetDocSh(); 169 if ( pDocSh ) 170 { 171 sFileName = pDocSh->GetTitle( SFX_TITLE_APINAME ); 172 } 173 } 174 if ( sFileName.getLength() ) 175 { 176 sName = sFileName + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" - ")) + sName; 177 } 178 } 179 } 180 return sName; 181 } 182 //===== XAccessibleEventBroadcaster ======================================== 183 184 void SAL_CALL AccessibleOutlineView::addEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException) 185 { 186 // delegate listener handling to children manager. 187 if ( ! IsDisposed()) 188 maTextHelper.AddEventListener(xListener); 189 AccessibleContextBase::addEventListener(xListener); 190 } 191 192 void SAL_CALL AccessibleOutlineView::removeEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException) 193 { 194 // forward 195 if ( ! IsDisposed()) 196 maTextHelper.RemoveEventListener(xListener); 197 AccessibleContextBase::removeEventListener(xListener); 198 } 199 200 //===== XServiceInfo ======================================================== 201 202 ::rtl::OUString SAL_CALL 203 AccessibleOutlineView::getImplementationName (void) 204 throw (::com::sun::star::uno::RuntimeException) 205 { 206 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleOutlineView")); 207 } 208 209 210 //===== XEventListener ====================================================== 211 212 void SAL_CALL 213 AccessibleOutlineView::disposing (const lang::EventObject& rEventObject) 214 throw (::com::sun::star::uno::RuntimeException) 215 { 216 AccessibleDocumentViewBase::disposing (rEventObject); 217 } 218 219 //===== protected internal ================================================== 220 221 void AccessibleOutlineView::FireEvent(const AccessibleEventObject& aEvent ) 222 { 223 // delegate listener handling to children manager. 224 maTextHelper.FireEvent(aEvent); 225 } 226 227 void AccessibleOutlineView::Activated (void) 228 { 229 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 230 231 // delegate listener handling to children manager. 232 maTextHelper.SetFocus(sal_True); 233 } 234 235 void AccessibleOutlineView::Deactivated (void) 236 { 237 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 238 239 // delegate listener handling to children manager. 240 maTextHelper.SetFocus(sal_False); 241 } 242 243 void SAL_CALL AccessibleOutlineView::disposing (void) 244 { 245 // dispose children 246 maTextHelper.Dispose(); 247 248 AccessibleDocumentViewBase::disposing (); 249 } 250 251 //===== XPropertyChangeListener ============================================= 252 253 void SAL_CALL 254 AccessibleOutlineView::propertyChange (const beans::PropertyChangeEvent& rEventObject) 255 throw (::com::sun::star::uno::RuntimeException) 256 { 257 ThrowIfDisposed (); 258 259 AccessibleDocumentViewBase::propertyChange (rEventObject); 260 261 OSL_TRACE ("AccessibleOutlineView::propertyChange"); 262 //add page switch event for slide show mode 263 if (rEventObject.PropertyName == ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("CurrentPage")) || 264 rEventObject.PropertyName == ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("PageChange")) ) 265 { 266 OSL_TRACE (" current page changed"); 267 268 // The current page changed. Update the children accordingly. 269 UpdateChildren(); 270 CommitChange(AccessibleEventId::PAGE_CHANGED,rEventObject.NewValue,rEventObject.OldValue); 271 } 272 else if (rEventObject.PropertyName == ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("VisibleArea"))) 273 { 274 OSL_TRACE (" visible area changed"); 275 276 // The visible area changed. Update the children accordingly. 277 UpdateChildren(); 278 } 279 else 280 { 281 OSL_TRACE (" unhandled"); 282 } 283 OSL_TRACE (" done"); 284 } 285 286 287 /// Create a name for this view. 288 ::rtl::OUString 289 AccessibleOutlineView::CreateAccessibleName (void) 290 throw (::com::sun::star::uno::RuntimeException) 291 { 292 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 293 294 return String( SdResId(SID_SD_A11Y_I_OUTLINEVIEW_N) ); 295 } 296 297 298 /** Create a description for this view. Use the model's description or URL 299 if a description is not available. 300 */ 301 ::rtl::OUString 302 AccessibleOutlineView::CreateAccessibleDescription (void) 303 throw (::com::sun::star::uno::RuntimeException) 304 { 305 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 306 307 return String( SdResId(SID_SD_A11Y_I_OUTLINEVIEW_D) ); 308 } 309 310 void AccessibleOutlineView::UpdateChildren() 311 { 312 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 313 314 // Update visible children 315 maTextHelper.UpdateChildren(); 316 } 317 318 } // end of namespace accessibility 319