LCOV - code coverage report
Current view: top level - chart2/source/controller/accessibility - AccessibleChartElement.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 81 0.0 %
Date: 2014-04-14 Functions: 0 22 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "AccessibleChartElement.hxx"
      21             : #include "CharacterProperties.hxx"
      22             : #include "ObjectIdentifier.hxx"
      23             : #include "ObjectNameProvider.hxx"
      24             : #include "servicenames.hxx"
      25             : #include "macros.hxx"
      26             : 
      27             : #include <com/sun/star/awt/XDevice.hpp>
      28             : #include <com/sun/star/chart2/XTitle.hpp>
      29             : #include <com/sun/star/beans/XMultiPropertySet.hpp>
      30             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      31             : #include <com/sun/star/lang/XInitialization.hpp>
      32             : 
      33             : // for SolarMutex
      34             : #include <vcl/svapp.hxx>
      35             : #include <rtl/ustrbuf.hxx>
      36             : 
      37             : using namespace ::com::sun::star;
      38             : using namespace ::com::sun::star::accessibility;
      39             : 
      40             : using ::com::sun::star::uno::UNO_QUERY;
      41             : using ::com::sun::star::uno::Reference;
      42             : using ::com::sun::star::uno::Sequence;
      43             : using ::osl::MutexGuard;
      44             : using ::osl::ClearableMutexGuard;
      45             : using ::osl::ResettableMutexGuard;
      46             : using ::com::sun::star::uno::RuntimeException;
      47             : using ::com::sun::star::uno::Any;
      48             : 
      49             : namespace chart
      50             : {
      51             : 
      52           0 : AccessibleChartElement::AccessibleChartElement(
      53             :     const AccessibleElementInfo & rAccInfo,
      54             :     bool bMayHaveChildren,
      55             :     bool bAlwaysTransparent /* default: false */ ) :
      56             :         impl::AccessibleChartElement_Base( rAccInfo, bMayHaveChildren, bAlwaysTransparent ),
      57           0 :         m_bHasText( false )
      58             : {
      59           0 :     AddState( AccessibleStateType::TRANSIENT );
      60           0 : }
      61             : 
      62           0 : AccessibleChartElement::~AccessibleChartElement()
      63             : {
      64             :     OSL_ASSERT( CheckDisposeState( false /* don't throw exceptions */ ) );
      65           0 : }
      66             : 
      67             : // ________ protected ________
      68             : 
      69           0 : bool AccessibleChartElement::ImplUpdateChildren()
      70             : {
      71           0 :     bool bResult = false;
      72             :     Reference< chart2::XTitle > xTitle(
      73             :         ObjectIdentifier::getObjectPropertySet(
      74             :             GetInfo().m_aOID.getObjectCID(), Reference< chart2::XChartDocument >( GetInfo().m_xChartDocument )),
      75           0 :         uno::UNO_QUERY );
      76           0 :     m_bHasText = xTitle.is();
      77             : 
      78           0 :     if( m_bHasText )
      79             :     {
      80           0 :         InitTextEdit();
      81           0 :         bResult = true;
      82             :     }
      83             :     else
      84           0 :         bResult = AccessibleBase::ImplUpdateChildren();
      85             : 
      86           0 :     return bResult;
      87             : }
      88             : 
      89           0 : void AccessibleChartElement::InitTextEdit()
      90             : {
      91           0 :     if( ! m_xTextHelper.is())
      92             :     {
      93             :         // get hard reference
      94           0 :         Reference< view::XSelectionSupplier > xSelSupp( GetInfo().m_xSelectionSupplier );
      95             :         // get factory from selection supplier (controller)
      96           0 :         Reference< lang::XMultiServiceFactory > xFact( xSelSupp, uno::UNO_QUERY );
      97           0 :         if( xFact.is())
      98             :         {
      99             :             m_xTextHelper.set(
     100           0 :                 xFact->createInstance( CHART_ACCESSIBLE_TEXT_SERVICE_NAME ), uno::UNO_QUERY );
     101           0 :         }
     102             :     }
     103             : 
     104           0 :     if( m_xTextHelper.is())
     105             :         try
     106             :         {
     107           0 :             Reference< lang::XInitialization > xInit( m_xTextHelper, uno::UNO_QUERY_THROW );
     108           0 :             Sequence< uno::Any > aArgs( 3 );
     109           0 :             aArgs[0] <<= GetInfo().m_aOID.getObjectCID();
     110           0 :             aArgs[1] <<= Reference< XAccessible >( this );
     111           0 :             aArgs[2] <<= Reference< awt::XWindow >( GetInfo().m_xWindow );
     112           0 :             xInit->initialize( aArgs );
     113             :         }
     114           0 :         catch( const uno::Exception & ex )
     115             :         {
     116             :             ASSERT_EXCEPTION( ex );
     117             :         }
     118           0 : }
     119             : 
     120             : 
     121             : //             Interfaces
     122             : 
     123             : // ________ AccessibleBase::XAccessibleContext ________
     124           0 : Reference< XAccessible > AccessibleChartElement::ImplGetAccessibleChildById( sal_Int32 i ) const
     125             :     throw (lang::IndexOutOfBoundsException, RuntimeException)
     126             : {
     127           0 :     Reference< XAccessible > xResult;
     128             : 
     129           0 :     if( m_bHasText )
     130           0 :         xResult.set( m_xTextHelper->getAccessibleChild( i ));
     131             :     else
     132           0 :         xResult.set( AccessibleBase::ImplGetAccessibleChildById( i ));
     133             : 
     134           0 :     return xResult;
     135             : }
     136             : 
     137           0 : sal_Int32 AccessibleChartElement::ImplGetAccessibleChildCount() const
     138             :     throw (RuntimeException)
     139             : {
     140           0 :     if( m_bHasText )
     141             :     {
     142           0 :         if( m_xTextHelper.is())
     143           0 :             return m_xTextHelper->getAccessibleChildCount();
     144           0 :         return 0;
     145             :     }
     146             : 
     147           0 :     return AccessibleBase::ImplGetAccessibleChildCount();
     148             : }
     149             : 
     150             : // ________ XServiceInfo ________
     151           0 : OUString SAL_CALL AccessibleChartElement::getImplementationName()
     152             :     throw (RuntimeException, std::exception)
     153             : {
     154           0 :     return OUString( "AccessibleChartElement" );
     155             : }
     156             : 
     157             : // ________ AccessibleChartElement::XAccessibleContext (overloaded) ________
     158           0 : OUString SAL_CALL AccessibleChartElement::getAccessibleName()
     159             :     throw (::com::sun::star::uno::RuntimeException, std::exception)
     160             : {
     161             :     return ObjectNameProvider::getNameForCID(
     162           0 :         GetInfo().m_aOID.getObjectCID(), GetInfo().m_xChartDocument );
     163             : }
     164             : 
     165             : // ________ AccessibleChartElement::XAccessibleContext (overloaded) ________
     166           0 : OUString SAL_CALL AccessibleChartElement::getAccessibleDescription()
     167             :     throw (::com::sun::star::uno::RuntimeException, std::exception)
     168             : {
     169           0 :     return getToolTipText();
     170             : }
     171             : 
     172             : // ________ AccessibleChartElement::XAccessibleExtendedComponent ________
     173           0 : Reference< awt::XFont > SAL_CALL AccessibleChartElement::getFont()
     174             :     throw (uno::RuntimeException, std::exception)
     175             : {
     176           0 :     CheckDisposeState();
     177             : 
     178           0 :     Reference< awt::XFont > xFont;
     179             :     // using assignment for broken gcc 3.3
     180             :     Reference< awt::XDevice > xDevice = Reference< awt::XDevice >(
     181           0 :         Reference< awt::XWindow >( GetInfo().m_xWindow ), uno::UNO_QUERY );
     182             : 
     183           0 :     if( xDevice.is())
     184             :     {
     185             :         Reference< beans::XMultiPropertySet > xObjProp(
     186             :             ObjectIdentifier::getObjectPropertySet(
     187           0 :                 GetInfo().m_aOID.getObjectCID(), Reference< chart2::XChartDocument >( GetInfo().m_xChartDocument )), uno::UNO_QUERY );
     188             :         awt::FontDescriptor aDescr(
     189           0 :             CharacterProperties::createFontDescriptorFromPropertySet( xObjProp ));
     190           0 :         xFont = xDevice->getFont( aDescr );
     191             :     }
     192             : 
     193           0 :     return xFont;
     194             : }
     195             : 
     196           0 : OUString SAL_CALL AccessibleChartElement::getTitledBorderText()
     197             :     throw (uno::RuntimeException, std::exception)
     198             : {
     199           0 :     return OUString();
     200             : }
     201             : 
     202           0 : OUString SAL_CALL AccessibleChartElement::getToolTipText()
     203             :     throw (::com::sun::star::uno::RuntimeException, std::exception)
     204             : {
     205           0 :     CheckDisposeState();
     206             : 
     207             :     return ObjectNameProvider::getHelpText(
     208           0 :         GetInfo().m_aOID.getObjectCID(), Reference< chart2::XChartDocument >( GetInfo().m_xChartDocument ));
     209             : }
     210             : 
     211             : // ________ XAccessibleComponent ________
     212           0 : sal_Bool SAL_CALL AccessibleChartElement::containsPoint( const awt::Point& aPoint )
     213             :     throw (uno::RuntimeException, std::exception)
     214             : {
     215           0 :     return AccessibleBase::containsPoint( aPoint );
     216             : }
     217             : 
     218           0 : Reference< XAccessible > SAL_CALL AccessibleChartElement::getAccessibleAtPoint( const awt::Point& aPoint )
     219             :     throw (uno::RuntimeException, std::exception)
     220             : {
     221           0 :     return AccessibleBase::getAccessibleAtPoint( aPoint );
     222             : }
     223             : 
     224           0 : awt::Rectangle SAL_CALL AccessibleChartElement::getBounds()
     225             :     throw (uno::RuntimeException, std::exception)
     226             : {
     227           0 :     return AccessibleBase::getBounds();
     228             : }
     229             : 
     230           0 : awt::Point SAL_CALL AccessibleChartElement::getLocation()
     231             :     throw (uno::RuntimeException, std::exception)
     232             : {
     233           0 :     return AccessibleBase::getLocation();
     234             : }
     235             : 
     236           0 : awt::Point SAL_CALL AccessibleChartElement::getLocationOnScreen()
     237             :     throw (uno::RuntimeException, std::exception)
     238             : {
     239           0 :     return AccessibleBase::getLocationOnScreen();
     240             : }
     241             : 
     242           0 : awt::Size SAL_CALL AccessibleChartElement::getSize()
     243             :     throw (uno::RuntimeException, std::exception)
     244             : {
     245           0 :     return AccessibleBase::getSize();
     246             : }
     247             : 
     248           0 : void SAL_CALL AccessibleChartElement::grabFocus()
     249             :     throw (uno::RuntimeException, std::exception)
     250             : {
     251           0 :     return AccessibleBase::grabFocus();
     252             : }
     253             : 
     254           0 : sal_Int32 SAL_CALL AccessibleChartElement::getForeground()
     255             :     throw (uno::RuntimeException, std::exception)
     256             : {
     257           0 :     return AccessibleBase::getForeground();
     258             : }
     259             : 
     260           0 : sal_Int32 SAL_CALL AccessibleChartElement::getBackground()
     261             :     throw (uno::RuntimeException, std::exception)
     262             : {
     263           0 :     return AccessibleBase::getBackground();
     264             : }
     265             : 
     266             : } // namespace chart
     267             : 
     268             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10