LCOV - code coverage report
Current view: top level - libreoffice/chart2/source/controller/accessibility - AccessibleChartElement.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 81 0.0 %
Date: 2012-12-27 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             : 
      21             : #include "AccessibleChartElement.hxx"
      22             : #include "CharacterProperties.hxx"
      23             : #include "ObjectIdentifier.hxx"
      24             : #include "ObjectNameProvider.hxx"
      25             : #include "servicenames.hxx"
      26             : #include "macros.hxx"
      27             : 
      28             : #include <com/sun/star/awt/XDevice.hpp>
      29             : #include <com/sun/star/chart2/XTitle.hpp>
      30             : #include <com/sun/star/beans/XMultiPropertySet.hpp>
      31             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      32             : #include <com/sun/star/lang/XInitialization.hpp>
      33             : 
      34             : // for SolarMutex
      35             : #include <vcl/svapp.hxx>
      36             : #include <rtl/ustrbuf.hxx>
      37             : 
      38             : using namespace ::com::sun::star;
      39             : using namespace ::com::sun::star::accessibility;
      40             : 
      41             : using ::com::sun::star::uno::UNO_QUERY;
      42             : using ::rtl::OUString;
      43             : using ::rtl::OUStringBuffer;
      44             : using ::com::sun::star::uno::Reference;
      45             : using ::com::sun::star::uno::Sequence;
      46             : using ::osl::MutexGuard;
      47             : using ::osl::ClearableMutexGuard;
      48             : using ::osl::ResettableMutexGuard;
      49             : using ::com::sun::star::uno::RuntimeException;
      50             : using ::com::sun::star::uno::Any;
      51             : 
      52             : namespace chart
      53             : {
      54             : 
      55           0 : AccessibleChartElement::AccessibleChartElement(
      56             :     const AccessibleElementInfo & rAccInfo,
      57             :     bool bMayHaveChildren,
      58             :     bool bAlwaysTransparent /* default: false */ ) :
      59             :         impl::AccessibleChartElement_Base( rAccInfo, bMayHaveChildren, bAlwaysTransparent ),
      60           0 :         m_bHasText( false )
      61             : {
      62           0 :     AddState( AccessibleStateType::TRANSIENT );
      63           0 : }
      64             : 
      65           0 : AccessibleChartElement::~AccessibleChartElement()
      66             : {
      67             :     OSL_ASSERT( CheckDisposeState( false /* don't throw exceptions */ ) );
      68           0 : }
      69             : 
      70             : // ________ protected ________
      71             : 
      72           0 : bool AccessibleChartElement::ImplUpdateChildren()
      73             : {
      74           0 :     bool bResult = false;
      75             :     Reference< chart2::XTitle > xTitle(
      76             :         ObjectIdentifier::getObjectPropertySet(
      77             :             GetInfo().m_aOID.getObjectCID(), Reference< chart2::XChartDocument >( GetInfo().m_xChartDocument )),
      78           0 :         uno::UNO_QUERY );
      79           0 :     m_bHasText = xTitle.is();
      80             : 
      81           0 :     if( m_bHasText )
      82             :     {
      83           0 :         InitTextEdit();
      84           0 :         bResult = true;
      85             :     }
      86             :     else
      87           0 :         bResult = AccessibleBase::ImplUpdateChildren();
      88             : 
      89           0 :     return bResult;
      90             : }
      91             : 
      92           0 : void AccessibleChartElement::InitTextEdit()
      93             : {
      94           0 :     if( ! m_xTextHelper.is())
      95             :     {
      96             :         // get hard reference
      97           0 :         Reference< view::XSelectionSupplier > xSelSupp( GetInfo().m_xSelectionSupplier );
      98             :         // get factory from selection supplier (controller)
      99           0 :         Reference< lang::XMultiServiceFactory > xFact( xSelSupp, uno::UNO_QUERY );
     100           0 :         if( xFact.is())
     101             :         {
     102             :             m_xTextHelper.set(
     103           0 :                 xFact->createInstance( CHART_ACCESSIBLE_TEXT_SERVICE_NAME ), uno::UNO_QUERY );
     104           0 :         }
     105             :     }
     106             : 
     107           0 :     if( m_xTextHelper.is())
     108             :         try
     109             :         {
     110           0 :             Reference< lang::XInitialization > xInit( m_xTextHelper, uno::UNO_QUERY_THROW );
     111           0 :             Sequence< uno::Any > aArgs( 3 );
     112           0 :             aArgs[0] <<= GetInfo().m_aOID.getObjectCID();
     113           0 :             aArgs[1] <<= Reference< XAccessible >( this );
     114           0 :             aArgs[2] <<= Reference< awt::XWindow >( GetInfo().m_xWindow );
     115           0 :             xInit->initialize( aArgs );
     116             :         }
     117           0 :         catch( const uno::Exception & ex )
     118             :         {
     119             :             ASSERT_EXCEPTION( ex );
     120             :         }
     121           0 : }
     122             : 
     123             : // ____________________________________
     124             : // ____________________________________
     125             : //
     126             : //             Interfaces
     127             : // ____________________________________
     128             : // ____________________________________
     129             : 
     130             : // ________ AccessibleBase::XAccessibleContext ________
     131           0 : Reference< XAccessible > AccessibleChartElement::ImplGetAccessibleChildById( sal_Int32 i ) const
     132             :     throw (lang::IndexOutOfBoundsException, RuntimeException)
     133             : {
     134           0 :     Reference< XAccessible > xResult;
     135             : 
     136           0 :     if( m_bHasText )
     137           0 :         xResult.set( m_xTextHelper->getAccessibleChild( i ));
     138             :     else
     139           0 :         xResult.set( AccessibleBase::ImplGetAccessibleChildById( i ));
     140             : 
     141           0 :     return xResult;
     142             : }
     143             : 
     144           0 : sal_Int32 AccessibleChartElement::ImplGetAccessibleChildCount() const
     145             :     throw (RuntimeException)
     146             : {
     147           0 :     if( m_bHasText )
     148             :     {
     149           0 :         if( m_xTextHelper.is())
     150           0 :             return m_xTextHelper->getAccessibleChildCount();
     151           0 :         return 0;
     152             :     }
     153             : 
     154           0 :     return AccessibleBase::ImplGetAccessibleChildCount();
     155             : }
     156             : 
     157             : // ________ XServiceInfo ________
     158           0 : OUString SAL_CALL AccessibleChartElement::getImplementationName()
     159             :     throw (RuntimeException)
     160             : {
     161           0 :     return OUString( RTL_CONSTASCII_USTRINGPARAM( "AccessibleChartElement" ));
     162             : }
     163             : 
     164             : // ________ AccessibleChartElement::XAccessibleContext (overloaded) ________
     165           0 : OUString SAL_CALL AccessibleChartElement::getAccessibleName()
     166             :     throw (::com::sun::star::uno::RuntimeException)
     167             : {
     168             :     return ObjectNameProvider::getNameForCID(
     169           0 :         GetInfo().m_aOID.getObjectCID(), GetInfo().m_xChartDocument );
     170             : }
     171             : 
     172             : // ________ AccessibleChartElement::XAccessibleContext (overloaded) ________
     173           0 : OUString SAL_CALL AccessibleChartElement::getAccessibleDescription()
     174             :     throw (::com::sun::star::uno::RuntimeException)
     175             : {
     176           0 :     return getToolTipText();
     177             : }
     178             : 
     179             : // ________ AccessibleChartElement::XAccessibleExtendedComponent ________
     180           0 : Reference< awt::XFont > SAL_CALL AccessibleChartElement::getFont()
     181             :     throw (uno::RuntimeException)
     182             : {
     183           0 :     CheckDisposeState();
     184             : 
     185           0 :     Reference< awt::XFont > xFont;
     186             :     // using assignment for broken gcc 3.3
     187             :     Reference< awt::XDevice > xDevice = Reference< awt::XDevice >(
     188           0 :         Reference< awt::XWindow >( GetInfo().m_xWindow ), uno::UNO_QUERY );
     189             : 
     190           0 :     if( xDevice.is())
     191             :     {
     192             :         Reference< beans::XMultiPropertySet > xObjProp(
     193             :             ObjectIdentifier::getObjectPropertySet(
     194           0 :                 GetInfo().m_aOID.getObjectCID(), Reference< chart2::XChartDocument >( GetInfo().m_xChartDocument )), uno::UNO_QUERY );
     195             :         awt::FontDescriptor aDescr(
     196           0 :             CharacterProperties::createFontDescriptorFromPropertySet( xObjProp ));
     197           0 :         xFont = xDevice->getFont( aDescr );
     198             :     }
     199             : 
     200           0 :     return xFont;
     201             : }
     202             : 
     203           0 : OUString SAL_CALL AccessibleChartElement::getTitledBorderText()
     204             :     throw (uno::RuntimeException)
     205             : {
     206           0 :     return OUString();
     207             : }
     208             : 
     209           0 : OUString SAL_CALL AccessibleChartElement::getToolTipText()
     210             :     throw (::com::sun::star::uno::RuntimeException)
     211             : {
     212           0 :     CheckDisposeState();
     213             : 
     214             :     return ObjectNameProvider::getHelpText(
     215           0 :         GetInfo().m_aOID.getObjectCID(), Reference< chart2::XChartDocument >( GetInfo().m_xChartDocument ));
     216             : }
     217             : 
     218             : // ________ XAccessibleComponent ________
     219           0 : sal_Bool SAL_CALL AccessibleChartElement::containsPoint( const awt::Point& aPoint )
     220             :     throw (uno::RuntimeException)
     221             : {
     222           0 :     return AccessibleBase::containsPoint( aPoint );
     223             : }
     224             : 
     225           0 : Reference< XAccessible > SAL_CALL AccessibleChartElement::getAccessibleAtPoint( const awt::Point& aPoint )
     226             :     throw (uno::RuntimeException)
     227             : {
     228           0 :     return AccessibleBase::getAccessibleAtPoint( aPoint );
     229             : }
     230             : 
     231           0 : awt::Rectangle SAL_CALL AccessibleChartElement::getBounds()
     232             :     throw (uno::RuntimeException)
     233             : {
     234           0 :     return AccessibleBase::getBounds();
     235             : }
     236             : 
     237           0 : awt::Point SAL_CALL AccessibleChartElement::getLocation()
     238             :     throw (uno::RuntimeException)
     239             : {
     240           0 :     return AccessibleBase::getLocation();
     241             : }
     242             : 
     243           0 : awt::Point SAL_CALL AccessibleChartElement::getLocationOnScreen()
     244             :     throw (uno::RuntimeException)
     245             : {
     246           0 :     return AccessibleBase::getLocationOnScreen();
     247             : }
     248             : 
     249           0 : awt::Size SAL_CALL AccessibleChartElement::getSize()
     250             :     throw (uno::RuntimeException)
     251             : {
     252           0 :     return AccessibleBase::getSize();
     253             : }
     254             : 
     255           0 : void SAL_CALL AccessibleChartElement::grabFocus()
     256             :     throw (uno::RuntimeException)
     257             : {
     258           0 :     return AccessibleBase::grabFocus();
     259             : }
     260             : 
     261           0 : sal_Int32 SAL_CALL AccessibleChartElement::getForeground()
     262             :     throw (uno::RuntimeException)
     263             : {
     264           0 :     return AccessibleBase::getForeground();
     265             : }
     266             : 
     267           0 : sal_Int32 SAL_CALL AccessibleChartElement::getBackground()
     268             :     throw (uno::RuntimeException)
     269             : {
     270           0 :     return AccessibleBase::getBackground();
     271             : }
     272             : 
     273             : 
     274             : } // namespace chart
     275             : 
     276             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10