LCOV - code coverage report
Current view: top level - libreoffice/accessibility/source/extended - AccessibleBrowseBoxTableCell.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 155 0.0 %
Date: 2012-12-27 Functions: 0 34 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 "accessibility/extended/AccessibleBrowseBoxTableCell.hxx"
      22             : #include <svtools/accessibletableprovider.hxx>
      23             : #include "accessibility/extended/AccessibleBrowseBox.hxx"
      24             : #include <tools/gen.hxx>
      25             : #include <toolkit/helper/vclunohelper.hxx>
      26             : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      27             : 
      28             : namespace accessibility
      29             : {
      30             :     namespace
      31             :     {
      32           0 :         static void checkIndex_Impl( sal_Int32 _nIndex, const OUString& _sText ) throw (::com::sun::star::lang::IndexOutOfBoundsException)
      33             :         {
      34           0 :             if ( _nIndex >= _sText.getLength() )
      35           0 :                 throw ::com::sun::star::lang::IndexOutOfBoundsException();
      36           0 :         }
      37             : 
      38           0 :         static sal_Int32 getIndex_Impl( sal_Int32 _nRow, sal_uInt16 _nColumn, sal_uInt16 _nColumnCount )
      39             :         {
      40           0 :             return _nRow * _nColumnCount + _nColumn;
      41             :         }
      42             :     }
      43             :     using namespace ::com::sun::star::lang;
      44             :     using namespace utl;
      45             :     using namespace comphelper;
      46             :     using ::accessibility::AccessibleBrowseBox;
      47             :     using namespace ::com::sun::star::uno;
      48             :     using ::com::sun::star::accessibility::XAccessible;
      49             :     using namespace ::com::sun::star::accessibility;
      50             :     using namespace ::svt;
      51             : 
      52             : 
      53             :     // implementation of a table cell
      54           0 :     OUString AccessibleBrowseBoxTableCell::implGetText()
      55             :     {
      56           0 :         ensureIsAlive();
      57           0 :         return mpBrowseBox->GetAccessibleCellText( getRowPos(), static_cast< sal_uInt16 >( getColumnPos() ) );
      58             :     }
      59             : 
      60           0 :     ::com::sun::star::lang::Locale AccessibleBrowseBoxTableCell::implGetLocale()
      61             :     {
      62           0 :         ensureIsAlive();
      63           0 :         return mpBrowseBox->GetAccessible()->getAccessibleContext()->getLocale();
      64             :     }
      65             : 
      66           0 :     void AccessibleBrowseBoxTableCell::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
      67             :     {
      68           0 :         nStartIndex = 0;
      69           0 :         nEndIndex = 0;
      70           0 :     }
      71             : 
      72           0 :     AccessibleBrowseBoxTableCell::AccessibleBrowseBoxTableCell(const Reference<XAccessible >& _rxParent,
      73             :                                 IAccessibleTableProvider& _rBrowseBox,
      74             :                                 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& _xFocusWindow,
      75             :                                 sal_Int32 _nRowPos,
      76             :                                 sal_uInt16 _nColPos,
      77             :                                 sal_Int32 _nOffset )
      78           0 :         :AccessibleBrowseBoxCell( _rxParent, _rBrowseBox, _xFocusWindow, _nRowPos, _nColPos )
      79             :     {
      80           0 :         m_nOffset = ( OFFSET_DEFAULT == _nOffset ) ? (sal_Int32)BBINDEX_FIRSTCONTROL : _nOffset;
      81           0 :         sal_Int32 nIndex = getIndex_Impl( _nRowPos, _nColPos, _rBrowseBox.GetColumnCount() );
      82           0 :        setAccessibleName( _rBrowseBox.GetAccessibleObjectName( BBTYPE_TABLECELL, nIndex ) );
      83           0 :        setAccessibleDescription( _rBrowseBox.GetAccessibleObjectDescription( BBTYPE_TABLECELL, nIndex ) );
      84             :         // Need to register as event listener
      85           0 :         Reference< XComponent > xComponent(_rxParent, UNO_QUERY);
      86           0 :         if( xComponent.is() )
      87           0 :             xComponent->addEventListener(static_cast< XEventListener *> (this));
      88           0 :     }
      89             : 
      90           0 :     void AccessibleBrowseBoxTableCell::nameChanged( const OUString& rNewName, const OUString& rOldName )
      91             :     {
      92           0 :         implSetName( rNewName );
      93           0 :         Any aOldValue, aNewValue;
      94           0 :         aOldValue <<= rOldName;
      95           0 :         aNewValue <<= rNewName;
      96           0 :         commitEvent( AccessibleEventId::NAME_CHANGED, aOldValue, aNewValue );
      97           0 :     }
      98             : 
      99             :     // XInterface -------------------------------------------------------------
     100             : 
     101             :     /** Queries for a new interface. */
     102           0 :     ::com::sun::star::uno::Any SAL_CALL AccessibleBrowseBoxTableCell::queryInterface(
     103             :             const ::com::sun::star::uno::Type& rType )
     104             :         throw ( ::com::sun::star::uno::RuntimeException )
     105             :     {
     106           0 :         Any aRet = AccessibleBrowseBoxCell::queryInterface(rType);
     107           0 :         if ( !aRet.hasValue() )
     108           0 :             aRet = AccessibleTextHelper_BASE::queryInterface(rType);
     109           0 :         return aRet;
     110             :     }
     111             : 
     112             :     /** Aquires the object (calls acquire() on base class). */
     113           0 :     void SAL_CALL AccessibleBrowseBoxTableCell::acquire() throw ()
     114             :     {
     115           0 :         AccessibleBrowseBoxCell::acquire();
     116           0 :     }
     117             : 
     118             :     /** Releases the object (calls release() on base class). */
     119           0 :     void SAL_CALL AccessibleBrowseBoxTableCell::release() throw ()
     120             :     {
     121           0 :         AccessibleBrowseBoxCell::release();
     122           0 :     }
     123             : 
     124           0 :     ::com::sun::star::awt::Rectangle SAL_CALL AccessibleBrowseBoxTableCell::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     125             :     {
     126           0 :         SolarMutexGuard aSolarGuard;
     127           0 :         ::osl::MutexGuard aGuard( getOslMutex() );
     128             : 
     129           0 :         ensureIsAlive();
     130           0 :         if ( !implIsValidIndex( nIndex, implGetText().getLength() ) )
     131           0 :             throw IndexOutOfBoundsException();
     132             : 
     133           0 :         ::com::sun::star::awt::Rectangle aRect;
     134             : 
     135           0 :         if ( mpBrowseBox )
     136             :         {
     137           0 :             aRect = AWTRectangle( mpBrowseBox->GetFieldCharacterBounds( getRowPos(), getColumnPos(), nIndex ) );
     138             :         }
     139             : 
     140           0 :         return aRect;
     141             :     }
     142             : 
     143           0 :     sal_Int32 SAL_CALL AccessibleBrowseBoxTableCell::getIndexAtPoint( const ::com::sun::star::awt::Point& _aPoint ) throw (RuntimeException)
     144             :     {
     145             :         //! TODO CTL bidi
     146             :         // OSL_FAIL("Need to be done by base class!");
     147           0 :         SolarMutexGuard aSolarGuard;
     148           0 :         ::osl::MutexGuard aGuard( getOslMutex() );
     149           0 :         ensureIsAlive();
     150             : 
     151           0 :         return mpBrowseBox->GetFieldIndexAtPoint( getRowPos(), getColumnPos(), VCLPoint( _aPoint ) );
     152             :     }
     153             : 
     154             :     /** @return
     155             :             The name of this class.
     156             :     */
     157           0 :     OUString SAL_CALL AccessibleBrowseBoxTableCell::getImplementationName()
     158             :         throw ( ::com::sun::star::uno::RuntimeException )
     159             :     {
     160           0 :         return OUString( "com.sun.star.comp.svtools.AccessibleBrowseBoxTableCell" );
     161             :     }
     162             : 
     163             :     /** @return  The count of visible children. */
     164           0 :     sal_Int32 SAL_CALL AccessibleBrowseBoxTableCell::getAccessibleChildCount()
     165             :         throw ( ::com::sun::star::uno::RuntimeException )
     166             :     {
     167           0 :         return 0;
     168             :     }
     169             : 
     170             :     /** @return  The XAccessible interface of the specified child. */
     171             :     ::com::sun::star::uno::Reference<
     172             :         ::com::sun::star::accessibility::XAccessible > SAL_CALL
     173           0 :         AccessibleBrowseBoxTableCell::getAccessibleChild( sal_Int32 )
     174             :             throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
     175             :                     ::com::sun::star::uno::RuntimeException )
     176             :     {
     177           0 :         throw ::com::sun::star::lang::IndexOutOfBoundsException();
     178             :     }
     179             : 
     180             :     /** Creates a new AccessibleStateSetHelper and fills it with states of the
     181             :         current object.
     182             :         @return
     183             :             A filled AccessibleStateSetHelper.
     184             :     */
     185           0 :     ::utl::AccessibleStateSetHelper* AccessibleBrowseBoxTableCell::implCreateStateSetHelper()
     186             :     {
     187           0 :         SolarMutexGuard aSolarGuard;
     188           0 :         ::osl::MutexGuard aGuard( getOslMutex() );
     189             : 
     190           0 :         ::utl::AccessibleStateSetHelper* pStateSetHelper = new ::utl::AccessibleStateSetHelper;
     191             : 
     192           0 :         if( isAlive() )
     193             :         {
     194             :             // SHOWING done with mxParent
     195           0 :             if( implIsShowing() )
     196           0 :                 pStateSetHelper->AddState( AccessibleStateType::SHOWING );
     197             : 
     198           0 :             mpBrowseBox->FillAccessibleStateSetForCell( *pStateSetHelper, getRowPos(), static_cast< sal_uInt16 >( getColumnPos() ) );
     199             :         }
     200             :         else
     201           0 :             pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
     202             : 
     203           0 :         return pStateSetHelper;
     204             :     }
     205             : 
     206             : 
     207             :     // XAccessible ------------------------------------------------------------
     208             : 
     209             :     /** @return  The XAccessibleContext interface of this object. */
     210           0 :     Reference< XAccessibleContext > SAL_CALL AccessibleBrowseBoxTableCell::getAccessibleContext() throw ( RuntimeException )
     211             :     {
     212           0 :         ensureIsAlive();
     213           0 :         return this;
     214             :     }
     215             : 
     216             :     // XAccessibleContext -----------------------------------------------------
     217             : 
     218           0 :     sal_Int32 SAL_CALL AccessibleBrowseBoxTableCell::getAccessibleIndexInParent()
     219             :             throw ( ::com::sun::star::uno::RuntimeException )
     220             :     {
     221           0 :         SolarMutexGuard aSolarGuard;
     222           0 :         ::osl::MutexGuard aGuard( getOslMutex() );
     223           0 :         ensureIsAlive();
     224             : 
     225           0 :         return /*BBINDEX_FIRSTCONTROL*/ m_nOffset + ( getRowPos() * mpBrowseBox->GetColumnCount() ) + getColumnPos();
     226             :     }
     227             : 
     228           0 :     sal_Int32 SAL_CALL AccessibleBrowseBoxTableCell::getCaretPosition(  ) throw (::com::sun::star::uno::RuntimeException)
     229             :     {
     230           0 :         return -1;
     231             :     }
     232           0 :     sal_Bool SAL_CALL AccessibleBrowseBoxTableCell::setCaretPosition ( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
     233             :     {
     234           0 :         SolarMutexGuard aSolarGuard;
     235           0 :         ::osl::MutexGuard aGuard( getOslMutex() );
     236             : 
     237           0 :         if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) )
     238           0 :             throw IndexOutOfBoundsException();
     239             : 
     240           0 :         return sal_False;
     241             :     }
     242           0 :     sal_Unicode SAL_CALL AccessibleBrowseBoxTableCell::getCharacter( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
     243             :     {
     244           0 :         SolarMutexGuard aSolarGuard;
     245           0 :         ::osl::MutexGuard aGuard( getOslMutex() );
     246           0 :         return OCommonAccessibleText::getCharacter( nIndex );
     247             :     }
     248           0 :     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL AccessibleBrowseBoxTableCell::getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< OUString >& ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
     249             :     {
     250           0 :         SolarMutexGuard aSolarGuard;
     251           0 :         ::osl::MutexGuard aGuard( getOslMutex() );
     252             : 
     253           0 :         OUString sText( implGetText() );
     254             : 
     255           0 :         if ( !implIsValidIndex( nIndex, sText.getLength() ) )
     256           0 :             throw IndexOutOfBoundsException();
     257             : 
     258           0 :         return ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >();
     259             :     }
     260           0 :     sal_Int32 SAL_CALL AccessibleBrowseBoxTableCell::getCharacterCount(  ) throw (::com::sun::star::uno::RuntimeException)
     261             :     {
     262           0 :         SolarMutexGuard aSolarGuard;
     263           0 :         ::osl::MutexGuard aGuard( getOslMutex() );
     264           0 :         return OCommonAccessibleText::getCharacterCount(  );
     265             :     }
     266             : 
     267           0 :     OUString SAL_CALL AccessibleBrowseBoxTableCell::getSelectedText(  ) throw (::com::sun::star::uno::RuntimeException)
     268             :     {
     269           0 :         SolarMutexGuard aSolarGuard;
     270           0 :         ::osl::MutexGuard aGuard( getOslMutex() );
     271           0 :         return OCommonAccessibleText::getSelectedText(  );
     272             :     }
     273           0 :     sal_Int32 SAL_CALL AccessibleBrowseBoxTableCell::getSelectionStart(  ) throw (::com::sun::star::uno::RuntimeException)
     274             :     {
     275           0 :         SolarMutexGuard aSolarGuard;
     276           0 :         ::osl::MutexGuard aGuard( getOslMutex() );
     277           0 :         return OCommonAccessibleText::getSelectionStart(  );
     278             :     }
     279           0 :     sal_Int32 SAL_CALL AccessibleBrowseBoxTableCell::getSelectionEnd(  ) throw (::com::sun::star::uno::RuntimeException)
     280             :     {
     281           0 :         SolarMutexGuard aSolarGuard;
     282           0 :         ::osl::MutexGuard aGuard( getOslMutex() );
     283           0 :         return OCommonAccessibleText::getSelectionEnd(  );
     284             :     }
     285           0 :     sal_Bool SAL_CALL AccessibleBrowseBoxTableCell::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
     286             :     {
     287           0 :         SolarMutexGuard aSolarGuard;
     288           0 :         ::osl::MutexGuard aGuard( getOslMutex() );
     289           0 :         if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
     290           0 :             throw IndexOutOfBoundsException();
     291             : 
     292           0 :         return sal_False;
     293             :     }
     294           0 :     OUString SAL_CALL AccessibleBrowseBoxTableCell::getText(  ) throw (::com::sun::star::uno::RuntimeException)
     295             :     {
     296           0 :         SolarMutexGuard aSolarGuard;
     297           0 :         ::osl::MutexGuard aGuard( getOslMutex() );
     298           0 :         return OCommonAccessibleText::getText(  );
     299             :     }
     300           0 :     OUString SAL_CALL AccessibleBrowseBoxTableCell::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
     301             :     {
     302           0 :         SolarMutexGuard aSolarGuard;
     303           0 :         ::osl::MutexGuard aGuard( getOslMutex() );
     304           0 :         return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex );
     305             :     }
     306           0 :     ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleBrowseBoxTableCell::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
     307             :     {
     308           0 :         SolarMutexGuard aSolarGuard;
     309           0 :         ::osl::MutexGuard aGuard( getOslMutex() );
     310           0 :         return OCommonAccessibleText::getTextAtIndex( nIndex ,aTextType);
     311             :     }
     312           0 :     ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleBrowseBoxTableCell::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
     313             :     {
     314           0 :         SolarMutexGuard aSolarGuard;
     315           0 :         ::osl::MutexGuard aGuard( getOslMutex() );
     316           0 :         return OCommonAccessibleText::getTextBeforeIndex( nIndex ,aTextType);
     317             :     }
     318           0 :     ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleBrowseBoxTableCell::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
     319             :     {
     320           0 :         SolarMutexGuard aSolarGuard;
     321           0 :         ::osl::MutexGuard aGuard( getOslMutex() );
     322           0 :         return OCommonAccessibleText::getTextBehindIndex( nIndex ,aTextType);
     323             :     }
     324           0 :     sal_Bool SAL_CALL AccessibleBrowseBoxTableCell::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
     325             :     {
     326           0 :         SolarMutexGuard aSolarGuard;
     327           0 :         ::osl::MutexGuard aGuard( getOslMutex() );
     328           0 :         OUString sText = implGetText();
     329           0 :         checkIndex_Impl( nStartIndex, sText );
     330           0 :         checkIndex_Impl( nEndIndex, sText );
     331             : 
     332             :         //!!! don't know how to put a string into the clipboard
     333           0 :         return sal_False;
     334             :     }
     335           0 :     void AccessibleBrowseBoxTableCell::disposing( const EventObject& _rSource ) throw (RuntimeException)
     336             :     {
     337           0 :             if ( _rSource.Source == mxParent )
     338             :             {
     339           0 :                     dispose();
     340             :             }
     341           0 :     }
     342             : 
     343             : }
     344             : 
     345             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10