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