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 //===== XAccessibleEventBroadcaster ======================================== 154 155 void SAL_CALL AccessibleOutlineView::addEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException) 156 { 157 // delegate listener handling to children manager. 158 if ( ! IsDisposed()) 159 maTextHelper.AddEventListener(xListener); 160 } 161 162 void SAL_CALL AccessibleOutlineView::removeEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException) 163 { 164 // forward 165 if ( ! IsDisposed()) 166 maTextHelper.RemoveEventListener(xListener); 167 } 168 169 //===== XServiceInfo ======================================================== 170 171 ::rtl::OUString SAL_CALL 172 AccessibleOutlineView::getImplementationName (void) 173 throw (::com::sun::star::uno::RuntimeException) 174 { 175 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleOutlineView")); 176 } 177 178 179 //===== XEventListener ====================================================== 180 181 void SAL_CALL 182 AccessibleOutlineView::disposing (const lang::EventObject& rEventObject) 183 throw (::com::sun::star::uno::RuntimeException) 184 { 185 AccessibleDocumentViewBase::disposing (rEventObject); 186 } 187 188 //===== protected internal ================================================== 189 190 void AccessibleOutlineView::FireEvent(const AccessibleEventObject& aEvent ) 191 { 192 // delegate listener handling to children manager. 193 maTextHelper.FireEvent(aEvent); 194 } 195 196 void AccessibleOutlineView::Activated (void) 197 { 198 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 199 200 // delegate listener handling to children manager. 201 maTextHelper.SetFocus(sal_True); 202 } 203 204 void AccessibleOutlineView::Deactivated (void) 205 { 206 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 207 208 // delegate listener handling to children manager. 209 maTextHelper.SetFocus(sal_False); 210 } 211 212 void SAL_CALL AccessibleOutlineView::disposing (void) 213 { 214 // dispose children 215 maTextHelper.Dispose(); 216 217 AccessibleDocumentViewBase::disposing (); 218 } 219 220 //===== XPropertyChangeListener ============================================= 221 222 void SAL_CALL 223 AccessibleOutlineView::propertyChange (const beans::PropertyChangeEvent& rEventObject) 224 throw (::com::sun::star::uno::RuntimeException) 225 { 226 ThrowIfDisposed (); 227 228 AccessibleDocumentViewBase::propertyChange (rEventObject); 229 230 OSL_TRACE ("AccessibleOutlineView::propertyChange"); 231 if (rEventObject.PropertyName == ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("CurrentPage"))) 232 { 233 OSL_TRACE (" current page changed"); 234 235 // The current page changed. Update the children accordingly. 236 UpdateChildren(); 237 } 238 else if (rEventObject.PropertyName == ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("VisibleArea"))) 239 { 240 OSL_TRACE (" visible area changed"); 241 242 // The visible area changed. Update the children accordingly. 243 UpdateChildren(); 244 } 245 else 246 { 247 OSL_TRACE (" unhandled"); 248 } 249 OSL_TRACE (" done"); 250 } 251 252 253 /// Create a name for this view. 254 ::rtl::OUString 255 AccessibleOutlineView::CreateAccessibleName (void) 256 throw (::com::sun::star::uno::RuntimeException) 257 { 258 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 259 260 return String( SdResId(SID_SD_A11Y_I_OUTLINEVIEW_N) ); 261 } 262 263 264 /** Create a description for this view. Use the model's description or URL 265 if a description is not available. 266 */ 267 ::rtl::OUString 268 AccessibleOutlineView::CreateAccessibleDescription (void) 269 throw (::com::sun::star::uno::RuntimeException) 270 { 271 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 272 273 return String( SdResId(SID_SD_A11Y_I_OUTLINEVIEW_D) ); 274 } 275 276 void AccessibleOutlineView::UpdateChildren() 277 { 278 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 279 280 // Update visible children 281 maTextHelper.UpdateChildren(); 282 } 283 284 } // end of namespace accessibility 285