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_chart2.hxx" 26 27 #include "AccessibleChartElement.hxx" 28 #include "CharacterProperties.hxx" 29 #include "ObjectIdentifier.hxx" 30 #include "ObjectNameProvider.hxx" 31 #include "servicenames.hxx" 32 #include "macros.hxx" 33 34 #include <com/sun/star/awt/XDevice.hpp> 35 #include <com/sun/star/chart2/XTitle.hpp> 36 #include <com/sun/star/beans/XMultiPropertySet.hpp> 37 #include <com/sun/star/accessibility/AccessibleStateType.hpp> 38 #include <com/sun/star/lang/XInitialization.hpp> 39 40 // for SolarMutex 41 #include <vcl/svapp.hxx> 42 #include <rtl/ustrbuf.hxx> 43 44 // #ifndef _RTL_UUID_H_ 45 // #include <rtl/uuid.h> 46 // #endif 47 // #ifndef _CPPUHELPER_QUERYINTERFACE_HXX_ 48 // #include <cppuhelper/queryinterface.hxx> 49 // #endif 50 // #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ 51 // #include <toolkit/helper/vclunohelper.hxx> 52 // #endif 53 // #ifndef _SV_WINDOW_HXX 54 // #include <vcl/window.hxx> 55 // #endif 56 57 // #ifndef _SVX_ACCESSILE_TEXT_HELPER_HXX_ 58 // #include <svx/AccessibleTextHelper.hxx> 59 // #endif 60 61 using namespace ::com::sun::star; 62 using namespace ::com::sun::star::accessibility; 63 64 using ::com::sun::star::uno::UNO_QUERY; 65 using ::rtl::OUString; 66 using ::rtl::OUStringBuffer; 67 using ::com::sun::star::uno::Reference; 68 using ::com::sun::star::uno::Sequence; 69 using ::osl::MutexGuard; 70 using ::osl::ClearableMutexGuard; 71 using ::osl::ResettableMutexGuard; 72 using ::com::sun::star::uno::RuntimeException; 73 using ::com::sun::star::uno::Any; 74 75 namespace chart 76 { 77 78 AccessibleChartElement::AccessibleChartElement( 79 const AccessibleElementInfo & rAccInfo, 80 bool bMayHaveChildren, 81 bool bAlwaysTransparent /* default: false */ ) : 82 impl::AccessibleChartElement_Base( rAccInfo, bMayHaveChildren, bAlwaysTransparent ), 83 m_bHasText( false ) 84 { 85 AddState( AccessibleStateType::TRANSIENT ); 86 } 87 88 AccessibleChartElement::~AccessibleChartElement() 89 { 90 OSL_ASSERT( CheckDisposeState( false /* don't throw exceptions */ ) ); 91 } 92 93 // ________ protected ________ 94 95 bool AccessibleChartElement::ImplUpdateChildren() 96 { 97 bool bResult = false; 98 Reference< chart2::XTitle > xTitle( 99 ObjectIdentifier::getObjectPropertySet( 100 GetInfo().m_aOID.getObjectCID(), Reference< chart2::XChartDocument >( GetInfo().m_xChartDocument )), 101 uno::UNO_QUERY ); 102 m_bHasText = xTitle.is(); 103 104 if( m_bHasText ) 105 { 106 InitTextEdit(); 107 bResult = true; 108 } 109 else 110 bResult = AccessibleBase::ImplUpdateChildren(); 111 112 return bResult; 113 } 114 115 void AccessibleChartElement::InitTextEdit() 116 { 117 if( ! m_xTextHelper.is()) 118 { 119 // get hard reference 120 Reference< view::XSelectionSupplier > xSelSupp( GetInfo().m_xSelectionSupplier ); 121 // get factory from selection supplier (controller) 122 Reference< lang::XMultiServiceFactory > xFact( xSelSupp, uno::UNO_QUERY ); 123 if( xFact.is()) 124 { 125 m_xTextHelper.set( 126 xFact->createInstance( CHART_ACCESSIBLE_TEXT_SERVICE_NAME ), uno::UNO_QUERY ); 127 } 128 } 129 130 if( m_xTextHelper.is()) 131 try 132 { 133 Reference< lang::XInitialization > xInit( m_xTextHelper, uno::UNO_QUERY_THROW ); 134 Sequence< uno::Any > aArgs( 3 ); 135 aArgs[0] <<= GetInfo().m_aOID.getObjectCID(); 136 aArgs[1] <<= Reference< XAccessible >( this ); 137 aArgs[2] <<= Reference< awt::XWindow >( GetInfo().m_xWindow ); 138 xInit->initialize( aArgs ); 139 } 140 catch( const uno::Exception & ex ) 141 { 142 ASSERT_EXCEPTION( ex ); 143 } 144 } 145 // OSL_ASSERT( m_pTextHelper == 0 ); 146 147 // // /-- solar 148 // ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 149 // Window* pWindow( VCLUnoHelper::GetWindow( GetInfo().m_xWindow )); 150 // if( pWindow ) 151 // { 152 // // we need ChartController::m_pDrawViewWrapper here 153 // SdrView * pView = 0; 154 // if( pView ) 155 // { 156 // SdrObject * pTextObj = m_pDrawViewWrapper->getTextEditObject(); 157 // if( pTextObj ) 158 // { 159 // SvxEditSource * pEditSource = new SvxEditSource( pTextObj, pView, pWindow ); 160 // m_pTextHelper = new ::accessibility::AccessibleTextHelper( 161 // ::std::auto_ptr< SvxEditSource >( pEditSource )); 162 // if( m_pTextHelper ) 163 // m_pTextHelper->SetEventSource( this ); 164 // } 165 // } 166 // } 167 // // \-- solar 168 // } 169 170 // ____________________________________ 171 // ____________________________________ 172 // 173 // Interfaces 174 // ____________________________________ 175 // ____________________________________ 176 177 // ________ AccessibleBase::XAccessibleContext ________ 178 Reference< XAccessible > AccessibleChartElement::ImplGetAccessibleChildById( sal_Int32 i ) const 179 throw (lang::IndexOutOfBoundsException, RuntimeException) 180 { 181 Reference< XAccessible > xResult; 182 183 if( m_bHasText ) 184 { 185 xResult.set( m_xTextHelper->getAccessibleChild( i )); 186 // /-- solar 187 // ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 188 // if( m_pTextHelper ) 189 // xResult.set( m_pTextHelper->GetChild( i ) ); 190 // \-- solar 191 } 192 else 193 xResult.set( AccessibleBase::ImplGetAccessibleChildById( i )); 194 195 return xResult; 196 } 197 198 sal_Int32 AccessibleChartElement::ImplGetAccessibleChildCount() const 199 throw (RuntimeException) 200 { 201 if( m_bHasText ) 202 { 203 if( m_xTextHelper.is()) 204 return m_xTextHelper->getAccessibleChildCount(); 205 return 0; 206 } 207 208 return AccessibleBase::ImplGetAccessibleChildCount(); 209 } 210 211 // ________ XServiceInfo ________ 212 OUString SAL_CALL AccessibleChartElement::getImplementationName() 213 throw (RuntimeException) 214 { 215 return OUString( RTL_CONSTASCII_USTRINGPARAM( "AccessibleChartElement" )); 216 } 217 218 // ________ AccessibleChartElement::XAccessibleContext (overloaded) ________ 219 OUString SAL_CALL AccessibleChartElement::getAccessibleName() 220 throw (::com::sun::star::uno::RuntimeException) 221 { 222 return ObjectNameProvider::getNameForCID( 223 GetInfo().m_aOID.getObjectCID(), GetInfo().m_xChartDocument ); 224 } 225 226 // ________ AccessibleChartElement::XAccessibleContext (overloaded) ________ 227 OUString SAL_CALL AccessibleChartElement::getAccessibleDescription() 228 throw (::com::sun::star::uno::RuntimeException) 229 { 230 return getToolTipText(); 231 } 232 233 // ________ AccessibleChartElement::XAccessibleExtendedComponent ________ 234 Reference< awt::XFont > SAL_CALL AccessibleChartElement::getFont() 235 throw (uno::RuntimeException) 236 { 237 CheckDisposeState(); 238 239 Reference< awt::XFont > xFont; 240 // using assignment for broken gcc 3.3 241 Reference< awt::XDevice > xDevice = Reference< awt::XDevice >( 242 Reference< awt::XWindow >( GetInfo().m_xWindow ), uno::UNO_QUERY ); 243 244 if( xDevice.is()) 245 { 246 Reference< beans::XMultiPropertySet > xObjProp( 247 ObjectIdentifier::getObjectPropertySet( 248 GetInfo().m_aOID.getObjectCID(), Reference< chart2::XChartDocument >( GetInfo().m_xChartDocument )), uno::UNO_QUERY ); 249 awt::FontDescriptor aDescr( 250 CharacterProperties::createFontDescriptorFromPropertySet( xObjProp )); 251 xFont = xDevice->getFont( aDescr ); 252 } 253 254 return xFont; 255 } 256 257 OUString SAL_CALL AccessibleChartElement::getTitledBorderText() 258 throw (uno::RuntimeException) 259 { 260 return OUString(); 261 } 262 263 OUString SAL_CALL AccessibleChartElement::getToolTipText() 264 throw (::com::sun::star::uno::RuntimeException) 265 { 266 CheckDisposeState(); 267 268 return ObjectNameProvider::getHelpText( 269 GetInfo().m_aOID.getObjectCID(), Reference< chart2::XChartDocument >( GetInfo().m_xChartDocument )); 270 } 271 272 // ________ XAccessibleComponent ________ 273 sal_Bool SAL_CALL AccessibleChartElement::containsPoint( const awt::Point& aPoint ) 274 throw (uno::RuntimeException) 275 { 276 return AccessibleBase::containsPoint( aPoint ); 277 } 278 279 Reference< XAccessible > SAL_CALL AccessibleChartElement::getAccessibleAtPoint( const awt::Point& aPoint ) 280 throw (uno::RuntimeException) 281 { 282 return AccessibleBase::getAccessibleAtPoint( aPoint ); 283 } 284 285 awt::Rectangle SAL_CALL AccessibleChartElement::getBounds() 286 throw (uno::RuntimeException) 287 { 288 return AccessibleBase::getBounds(); 289 } 290 291 awt::Point SAL_CALL AccessibleChartElement::getLocation() 292 throw (uno::RuntimeException) 293 { 294 return AccessibleBase::getLocation(); 295 } 296 297 awt::Point SAL_CALL AccessibleChartElement::getLocationOnScreen() 298 throw (uno::RuntimeException) 299 { 300 return AccessibleBase::getLocationOnScreen(); 301 } 302 303 awt::Size SAL_CALL AccessibleChartElement::getSize() 304 throw (uno::RuntimeException) 305 { 306 return AccessibleBase::getSize(); 307 } 308 309 void SAL_CALL AccessibleChartElement::grabFocus() 310 throw (uno::RuntimeException) 311 { 312 return AccessibleBase::grabFocus(); 313 } 314 315 sal_Int32 SAL_CALL AccessibleChartElement::getForeground() 316 throw (uno::RuntimeException) 317 { 318 return AccessibleBase::getForeground(); 319 } 320 321 sal_Int32 SAL_CALL AccessibleChartElement::getBackground() 322 throw (uno::RuntimeException) 323 { 324 return AccessibleBase::getBackground(); 325 } 326 327 328 } // namespace chart 329