LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/Accessibility - AccessibleCsvControl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 804 0.1 %
Date: 2013-07-09 Functions: 2 162 1.2 %
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 "AccessibleCsvControl.hxx"
      21             : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      22             : #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
      23             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      24             : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      25             : #include <com/sun/star/accessibility/AccessibleTextType.hpp>
      26             : #include <com/sun/star/accessibility/AccessibleTableModelChange.hpp>
      27             : #include <com/sun/star/accessibility/AccessibleTableModelChangeType.hpp>
      28             : #include <tools/debug.hxx>
      29             : #include <toolkit/helper/convert.hxx>
      30             : #include <unotools/accessiblerelationsethelper.hxx>
      31             : #include <unotools/accessiblestatesethelper.hxx>
      32             : #include <comphelper/sequence.hxx>
      33             : #include <comphelper/servicehelper.hxx>
      34             : #include "scitems.hxx"
      35             : #include <editeng/fontitem.hxx>
      36             : #include <editeng/fhgtitem.hxx>
      37             : #include <editeng/langitem.hxx>
      38             : #include "csvcontrol.hxx"
      39             : #include "csvruler.hxx"
      40             : #include "csvgrid.hxx"
      41             : #include "AccessibleText.hxx"
      42             : #include "editsrc.hxx"
      43             : #include "scresid.hxx"
      44             : #include "sc.hrc"
      45             : #include "scmod.hxx"
      46             : #include <svtools/colorcfg.hxx>
      47             : #include <vcl/svapp.hxx>
      48             : // ause
      49             : #include "editutil.hxx"
      50             : 
      51             : using ::utl::AccessibleRelationSetHelper;
      52             : using ::utl::AccessibleStateSetHelper;
      53             : using ::accessibility::AccessibleStaticTextBase;
      54             : using ::com::sun::star::uno::Any;
      55             : using ::com::sun::star::uno::Reference;
      56             : using ::com::sun::star::uno::Sequence;
      57             : using ::com::sun::star::uno::RuntimeException;
      58             : using ::com::sun::star::uno::XInterface;
      59             : using ::com::sun::star::lang::DisposedException;
      60             : using ::com::sun::star::lang::IndexOutOfBoundsException;
      61             : using ::com::sun::star::lang::IllegalArgumentException;
      62             : using ::com::sun::star::beans::PropertyValue;
      63             : using namespace ::com::sun::star::accessibility;
      64             : 
      65             : 
      66             : // ----------------------------------------------------------------------------
      67             : 
      68             : const sal_uInt16 nRulerRole         = AccessibleRole::TEXT;
      69             : const sal_uInt16 nGridRole          = AccessibleRole::TABLE;
      70             : const sal_uInt16 nCellRole          = AccessibleRole::TEXT;
      71             : 
      72             : #define RULER_IMPL_NAME             "ScAccessibleCsvRuler"
      73             : #define GRID_IMPL_NAME              "ScAccessibleCsvGrid"
      74             : #define CELL_IMPL_NAME              "ScAccessibleCsvCell"
      75             : 
      76             : const sal_Unicode cRulerDot         = '.';
      77             : const sal_Unicode cRulerLine        = '|';
      78             : 
      79             : const sal_Int32 CSV_LINE_HEADER     = CSV_POS_INVALID;
      80             : const sal_uInt32 CSV_COLUMN_HEADER  = CSV_COLUMN_INVALID;
      81             : 
      82             : 
      83             : // CSV base control ===========================================================
      84             : 
      85             : DBG_NAME( ScAccessibleCsvControl )
      86             : 
      87           0 : ScAccessibleCsvControl::ScAccessibleCsvControl(
      88             :         const Reference< XAccessible >& rxParent,
      89             :         ScCsvControl& rControl,
      90             :         sal_uInt16 nRole ) :
      91             :     ScAccessibleContextBase( rxParent, nRole ),
      92           0 :     mpControl( &rControl )
      93             : {
      94             :     DBG_CTOR( ScAccessibleCsvControl, NULL );
      95           0 : }
      96             : 
      97           0 : ScAccessibleCsvControl::~ScAccessibleCsvControl()
      98             : {
      99             :     DBG_DTOR( ScAccessibleCsvControl, NULL );
     100           0 :     implDispose();
     101           0 : }
     102             : 
     103           0 : void SAL_CALL ScAccessibleCsvControl::disposing()
     104             : {
     105           0 :     SolarMutexGuard aGuard;
     106           0 :     mpControl = NULL;
     107           0 :     ScAccessibleContextBase::disposing();
     108           0 : }
     109             : 
     110             : 
     111             : // XAccessibleComponent -------------------------------------------------------
     112             : 
     113           0 : Reference< XAccessible > SAL_CALL ScAccessibleCsvControl::getAccessibleAtPoint( const AwtPoint& /* rPoint */ )
     114             :         throw( RuntimeException )
     115             : {
     116           0 :     ensureAlive();
     117           0 :     return NULL;
     118             : }
     119             : 
     120           0 : sal_Bool SAL_CALL ScAccessibleCsvControl::isVisible() throw( RuntimeException )
     121             : {
     122           0 :     SolarMutexGuard aGuard;
     123           0 :     ensureAlive();
     124           0 :     return implGetControl().IsVisible();
     125             : }
     126             : 
     127           0 : void SAL_CALL ScAccessibleCsvControl::grabFocus() throw( RuntimeException )
     128             : {
     129           0 :     SolarMutexGuard aGuard;
     130           0 :     ensureAlive();
     131           0 :     implGetControl().GrabFocus();
     132           0 : }
     133             : 
     134             : 
     135             : // events ---------------------------------------------------------------------
     136             : 
     137           0 : void ScAccessibleCsvControl::SendFocusEvent( bool bFocused )
     138             : {
     139           0 :     if( bFocused )
     140           0 :         CommitFocusGained();
     141             :     else
     142           0 :         CommitFocusLost();
     143           0 : }
     144             : 
     145           0 : void ScAccessibleCsvControl::SendCaretEvent()
     146             : {
     147             :     OSL_FAIL( "ScAccessibleCsvControl::SendCaretEvent - Illegal call" );
     148           0 : }
     149             : 
     150           0 : void ScAccessibleCsvControl::SendVisibleEvent()
     151             : {
     152           0 :     AccessibleEventObject aEvent;
     153           0 :     aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED;
     154           0 :     aEvent.Source = Reference< XAccessible >( this );
     155           0 :     CommitChange( aEvent );
     156           0 : }
     157             : 
     158           0 : void ScAccessibleCsvControl::SendSelectionEvent()
     159             : {
     160           0 :     AccessibleEventObject aEvent;
     161           0 :     aEvent.EventId = AccessibleEventId::SELECTION_CHANGED;
     162           0 :     aEvent.Source = Reference< XAccessible >( this );
     163           0 :     CommitChange( aEvent );
     164           0 : }
     165             : 
     166           0 : void ScAccessibleCsvControl::SendTableUpdateEvent( sal_uInt32 /* nFirstColumn */, sal_uInt32 /* nLastColumn */, bool /* bAllRows */ )
     167             : {
     168             :     OSL_FAIL( "ScAccessibleCsvControl::SendTableUpdateEvent - Illegal call" );
     169           0 : }
     170             : 
     171           0 : void ScAccessibleCsvControl::SendInsertColumnEvent( sal_uInt32 /* nFirstColumn */, sal_uInt32 /* nLastColumn */ )
     172             : {
     173             :     OSL_FAIL( "ScAccessibleCsvControl::SendInsertColumnEvent - Illegal call" );
     174           0 : }
     175             : 
     176           0 : void ScAccessibleCsvControl::SendRemoveColumnEvent( sal_uInt32 /* nFirstColumn */, sal_uInt32 /* nLastColumn */ )
     177             : {
     178             :     OSL_FAIL( "ScAccessibleCsvControl::SendRemoveColumnEvent - Illegal call" );
     179           0 : }
     180             : 
     181             : 
     182             : // helpers --------------------------------------------------------------------
     183             : 
     184           0 : Rectangle ScAccessibleCsvControl::GetBoundingBoxOnScreen() const throw( RuntimeException )
     185             : {
     186           0 :     SolarMutexGuard aGuard;
     187           0 :     ensureAlive();
     188           0 :     return implGetControl().GetWindowExtentsRelative( NULL );
     189             : }
     190             : 
     191           0 : Rectangle ScAccessibleCsvControl::GetBoundingBox() const throw( RuntimeException )
     192             : {
     193           0 :     SolarMutexGuard aGuard;
     194           0 :     ensureAlive();
     195           0 :     return implGetControl().GetWindowExtentsRelative( implGetControl().GetAccessibleParentWindow() );
     196             : }
     197             : 
     198           0 : void ScAccessibleCsvControl::ensureAlive() const throw( DisposedException )
     199             : {
     200           0 :     if( !implIsAlive() )
     201           0 :         throw DisposedException();
     202           0 : }
     203             : 
     204           0 : ScCsvControl& ScAccessibleCsvControl::implGetControl() const
     205             : {
     206             :     OSL_ENSURE( mpControl, "ScAccessibleCsvControl::implGetControl - missing control" );
     207           0 :     return *mpControl;
     208             : }
     209             : 
     210           0 : Reference< XAccessible > ScAccessibleCsvControl::implGetChildByRole(
     211             :         const Reference< XAccessible >& rxParentObj, sal_uInt16 nRole ) throw( RuntimeException )
     212             : {
     213           0 :     Reference< XAccessible > xAccObj;
     214           0 :     if( rxParentObj.is() )
     215             :     {
     216           0 :         Reference< XAccessibleContext > xParentCtxt = rxParentObj->getAccessibleContext();
     217           0 :         if( xParentCtxt.is() )
     218             :         {
     219           0 :             sal_Int32 nCount = xParentCtxt->getAccessibleChildCount();
     220           0 :             sal_Int32 nIndex = 0;
     221           0 :             while( !xAccObj.is() && (nIndex < nCount) )
     222             :             {
     223           0 :                 Reference< XAccessible > xCurrObj = xParentCtxt->getAccessibleChild( nIndex );
     224           0 :                 if( xCurrObj.is() )
     225             :                 {
     226           0 :                     Reference< XAccessibleContext > xCurrCtxt = xCurrObj->getAccessibleContext();
     227           0 :                     if( xCurrCtxt.is() && (xCurrCtxt->getAccessibleRole() == nRole) )
     228           0 :                         xAccObj = xCurrObj;
     229             :                 }
     230           0 :                 ++nIndex;
     231           0 :             }
     232           0 :         }
     233             :     }
     234           0 :     return xAccObj;
     235             : }
     236             : 
     237           0 : AccessibleStateSetHelper* ScAccessibleCsvControl::implCreateStateSet()
     238             : {
     239           0 :     SolarMutexGuard aGuard;
     240           0 :     AccessibleStateSetHelper* pStateSet = new AccessibleStateSetHelper();
     241           0 :     if( implIsAlive() )
     242             :     {
     243           0 :         const ScCsvControl& rCtrl = implGetControl();
     244           0 :         pStateSet->AddState( AccessibleStateType::OPAQUE );
     245           0 :         if( rCtrl.IsEnabled() )
     246           0 :             pStateSet->AddState( AccessibleStateType::ENABLED );
     247           0 :         if( isShowing() )
     248           0 :             pStateSet->AddState( AccessibleStateType::SHOWING );
     249           0 :         if( isVisible() )
     250           0 :             pStateSet->AddState( AccessibleStateType::VISIBLE );
     251             :     }
     252             :     else
     253           0 :         pStateSet->AddState( AccessibleStateType::DEFUNC );
     254           0 :     return pStateSet;
     255             : }
     256             : 
     257           0 : void ScAccessibleCsvControl::implDispose()
     258             : {
     259           0 :     if( implIsAlive() )
     260             :     {
     261             :         // prevent multiple call of dtor
     262           0 :         osl_atomic_increment( &m_refCount );
     263           0 :         dispose();
     264             :     }
     265           0 : }
     266             : 
     267           0 : Point ScAccessibleCsvControl::implGetAbsPos( const Point& rPos ) const
     268             : {
     269           0 :     return rPos + implGetControl().GetWindowExtentsRelative( NULL ).TopLeft();
     270             : }
     271             : 
     272             : 
     273             : // Ruler ======================================================================
     274             : 
     275             : /** Converts a ruler cursor position to API text index. */
     276           0 : static sal_Int32 lcl_GetApiPos( sal_Int32 nRulerPos )
     277             : {
     278           0 :     sal_Int32 nApiPos = nRulerPos;
     279           0 :     sal_Int32 nStart = (nRulerPos - 1) / 10;
     280           0 :     sal_Int32 nExp = 1;
     281           0 :     while( nStart >= nExp )
     282             :     {
     283           0 :         nApiPos += nStart - nExp + 1;
     284           0 :         nExp *= 10;
     285             :     }
     286           0 :     return ::std::max( nApiPos, static_cast<sal_Int32>(0) );
     287             : }
     288             : 
     289             : /** Converts an API text index to a ruler cursor position. */
     290           0 : static sal_Int32 lcl_GetRulerPos( sal_Int32 nApiPos )
     291             : {
     292           0 :     sal_Int32 nDiv = 10;
     293           0 :     sal_Int32 nExp = 10;
     294           0 :     sal_Int32 nRulerPos = 0;
     295           0 :     sal_Int32 nApiBase = 0;
     296           0 :     sal_Int32 nApiLimit = 10;
     297           0 :     while( nApiPos >= nApiLimit )
     298             :     {
     299           0 :         ++nDiv;
     300           0 :         nRulerPos = nExp;
     301           0 :         nExp *= 10;
     302           0 :         nApiBase = nApiLimit;
     303           0 :         nApiLimit = lcl_GetApiPos( nExp );
     304             :     }
     305           0 :     sal_Int32 nRelPos = nApiPos - nApiBase;
     306           0 :     return nRulerPos + nRelPos / nDiv * 10 + ::std::max( nRelPos % nDiv - nDiv + 10L, 0L );
     307             : }
     308             : 
     309             : /** Expands the sequence's size and returns the base index of the new inserted elements. */
     310           0 : static inline sal_Int32 lcl_ExpandSequence( Sequence< PropertyValue >& rSeq, sal_Int32 nExp )
     311             : {
     312             :     OSL_ENSURE( nExp > 0, "lcl_ExpandSequence - invalid value" );
     313           0 :     rSeq.realloc( rSeq.getLength() + nExp );
     314           0 :     return rSeq.getLength() - nExp;
     315             : }
     316             : 
     317             : /** Fills the property value rVal with the specified name and value from the item. */
     318           0 : static inline void lcl_FillProperty( PropertyValue& rVal, const OUString& rPropName, const SfxPoolItem& rItem, sal_uInt8 nMID )
     319             : {
     320           0 :     rVal.Name = rPropName;
     321           0 :     rItem.QueryValue( rVal.Value, nMID );
     322           0 : }
     323             : 
     324             : /** Fills the sequence with all font attributes of rFont. */
     325           0 : static void lcl_FillFontAttributes( Sequence< PropertyValue >& rSeq, const Font& rFont )
     326             : {
     327           0 :     SvxFontItem aFontItem( rFont.GetFamily(), rFont.GetName(), rFont.GetStyleName(), rFont.GetPitch(), rFont.GetCharSet(), ATTR_FONT );
     328           0 :     SvxFontHeightItem aHeightItem( rFont.GetSize().Height(), 100, ATTR_FONT_HEIGHT );
     329           0 :     SvxLanguageItem aLangItem( rFont.GetLanguage(), ATTR_FONT_LANGUAGE );
     330             : 
     331           0 :     sal_Int32 nIndex = lcl_ExpandSequence( rSeq, 7 );
     332           0 :     lcl_FillProperty( rSeq[ nIndex++ ], "CharFontName",      aFontItem,   MID_FONT_FAMILY_NAME );
     333           0 :     lcl_FillProperty( rSeq[ nIndex++ ], "CharFontFamily",    aFontItem,   MID_FONT_FAMILY );
     334           0 :     lcl_FillProperty( rSeq[ nIndex++ ], "CharFontStyleName", aFontItem,   MID_FONT_STYLE_NAME );
     335           0 :     lcl_FillProperty( rSeq[ nIndex++ ], "CharFontCharSet",   aFontItem,   MID_FONT_PITCH );
     336           0 :     lcl_FillProperty( rSeq[ nIndex++ ], "CharFontPitch",     aFontItem,   MID_FONT_CHAR_SET );
     337           0 :     lcl_FillProperty( rSeq[ nIndex++ ], "CharHeight",        aHeightItem, MID_FONTHEIGHT );
     338           0 :     lcl_FillProperty( rSeq[ nIndex++ ], "CharLocale",        aLangItem,   MID_LANG_LOCALE );
     339           0 : }
     340             : 
     341             : 
     342             : 
     343             : // ----------------------------------------------------------------------------
     344             : 
     345             : DBG_NAME( ScAccessibleCsvRuler )
     346             : 
     347           0 : ScAccessibleCsvRuler::ScAccessibleCsvRuler( ScCsvRuler& rRuler ) :
     348           0 :     ScAccessibleCsvControl( rRuler.GetAccessibleParentWindow()->GetAccessible(), rRuler, nRulerRole )
     349             : {
     350             :     DBG_CTOR( ScAccessibleCsvRuler, NULL );
     351           0 :     constructStringBuffer();
     352           0 : }
     353             : 
     354           0 : ScAccessibleCsvRuler::~ScAccessibleCsvRuler()
     355             : {
     356             :     DBG_DTOR( ScAccessibleCsvRuler, NULL );
     357           0 :     implDispose();
     358           0 : }
     359             : 
     360             : // XAccessibleComponent -----------------------------------------------------
     361             : 
     362           0 : sal_Int32 SAL_CALL ScAccessibleCsvRuler::getForeground(  )
     363             :     throw (RuntimeException)
     364             : {
     365           0 :     SolarMutexGuard aGuard;
     366           0 :     ensureAlive();
     367           0 :     return implGetRuler().GetSettings().GetStyleSettings().GetLabelTextColor().GetColor();
     368             : }
     369             : 
     370           0 : sal_Int32 SAL_CALL ScAccessibleCsvRuler::getBackground(  )
     371             :     throw (RuntimeException)
     372             : {
     373           0 :     SolarMutexGuard aGuard;
     374           0 :     ensureAlive();
     375           0 :     return implGetRuler().GetSettings().GetStyleSettings().GetFaceColor().GetColor();
     376             : }
     377             : 
     378             : // XAccessibleContext ---------------------------------------------------------
     379             : 
     380           0 : sal_Int32 SAL_CALL ScAccessibleCsvRuler::getAccessibleChildCount() throw( RuntimeException )
     381             : {
     382           0 :     ensureAlive();
     383           0 :     return 0;
     384             : }
     385             : 
     386           0 : Reference< XAccessible > SAL_CALL ScAccessibleCsvRuler::getAccessibleChild( sal_Int32 /* nIndex */ )
     387             :         throw( IndexOutOfBoundsException, RuntimeException )
     388             : {
     389           0 :     ensureAlive();
     390           0 :     throw IndexOutOfBoundsException();
     391             : }
     392             : 
     393           0 : Reference< XAccessibleRelationSet > SAL_CALL ScAccessibleCsvRuler::getAccessibleRelationSet()
     394             :         throw( RuntimeException )
     395             : {
     396           0 :     SolarMutexGuard aGuard;
     397           0 :     ensureAlive();
     398           0 :     AccessibleRelationSetHelper* pRelationSet = new AccessibleRelationSetHelper();
     399           0 :     Reference< XAccessible > xAccObj = implGetChildByRole( getAccessibleParent(), nGridRole );
     400           0 :     if( xAccObj.is() )
     401             :     {
     402           0 :         Sequence< Reference< XInterface > > aSeq( 1 );
     403           0 :         aSeq[ 0 ] = xAccObj;
     404           0 :         pRelationSet->AddRelation( AccessibleRelation( AccessibleRelationType::CONTROLLER_FOR, aSeq ) );
     405             :     }
     406           0 :     return pRelationSet;
     407             : }
     408             : 
     409           0 : Reference< XAccessibleStateSet > SAL_CALL ScAccessibleCsvRuler::getAccessibleStateSet()
     410             :         throw( RuntimeException )
     411             : {
     412           0 :     SolarMutexGuard aGuard;
     413           0 :     AccessibleStateSetHelper* pStateSet = implCreateStateSet();
     414           0 :     if( implIsAlive() )
     415             :     {
     416           0 :         pStateSet->AddState( AccessibleStateType::FOCUSABLE );
     417           0 :         pStateSet->AddState( AccessibleStateType::SINGLE_LINE );
     418           0 :         if( implGetRuler().HasFocus() )
     419           0 :             pStateSet->AddState( AccessibleStateType::FOCUSED );
     420             :     }
     421           0 :     return pStateSet;
     422             : }
     423             : 
     424             : 
     425             : // XAccessibleText ------------------------------------------------------------
     426             : 
     427           0 : sal_Int32 SAL_CALL ScAccessibleCsvRuler::getCaretPosition() throw( RuntimeException )
     428             : {
     429           0 :     SolarMutexGuard aGuard;
     430           0 :     ensureAlive();
     431           0 :     return lcl_GetApiPos( implGetRuler().GetRulerCursorPos() );
     432             : }
     433             : 
     434           0 : sal_Bool SAL_CALL ScAccessibleCsvRuler::setCaretPosition( sal_Int32 nIndex )
     435             :         throw( IndexOutOfBoundsException, RuntimeException )
     436             : {
     437           0 :     SolarMutexGuard aGuard;
     438           0 :     ensureAlive();
     439           0 :     ensureValidIndex( nIndex );
     440           0 :     ScCsvRuler& rRuler = implGetRuler();
     441           0 :     sal_Int32 nOldCursor = rRuler.GetRulerCursorPos();
     442           0 :     rRuler.Execute( CSVCMD_MOVERULERCURSOR, lcl_GetRulerPos( nIndex ) );
     443           0 :     return rRuler.GetRulerCursorPos() != nOldCursor;
     444             : }
     445             : 
     446           0 : sal_Unicode SAL_CALL ScAccessibleCsvRuler::getCharacter( sal_Int32 nIndex )
     447             :         throw( IndexOutOfBoundsException, RuntimeException )
     448             : {
     449           0 :     SolarMutexGuard aGuard;
     450           0 :     ensureAlive();
     451           0 :     ensureValidIndex( nIndex );
     452           0 :     return maBuffer[nIndex];
     453             : }
     454             : 
     455           0 : Sequence< PropertyValue > SAL_CALL ScAccessibleCsvRuler::getCharacterAttributes( sal_Int32 nIndex,
     456             :             const ::com::sun::star::uno::Sequence< OUString >& /* aRequestedAttributes */ )
     457             :         throw( IndexOutOfBoundsException, RuntimeException )
     458             : {
     459           0 :     SolarMutexGuard aGuard;
     460           0 :     ensureAlive();
     461           0 :     ensureValidIndexWithEnd( nIndex );
     462           0 :     Sequence< PropertyValue > aSeq;
     463           0 :     lcl_FillFontAttributes( aSeq, implGetRuler().GetFont() );
     464           0 :     return aSeq;
     465             : }
     466             : 
     467           0 : ScAccessibleCsvRuler::AwtRectangle SAL_CALL ScAccessibleCsvRuler::getCharacterBounds( sal_Int32 nIndex )
     468             :         throw( IndexOutOfBoundsException, RuntimeException )
     469             : {
     470           0 :     SolarMutexGuard aGuard;
     471           0 :     ensureAlive();
     472           0 :     ensureValidIndexWithEnd( nIndex );
     473           0 :     ScCsvRuler& rRuler = implGetRuler();
     474           0 :     Point aPos( rRuler.GetX( lcl_GetRulerPos( nIndex ) ) - rRuler.GetCharWidth() / 2, 0 );
     475           0 :     AwtRectangle aRect( aPos.X(), aPos.Y(), rRuler.GetCharWidth(), rRuler.GetSizePixel().Height() );
     476             :     // do not return rectangle out of window
     477           0 :     sal_Int32 nWidth = rRuler.GetOutputSizePixel().Width();
     478           0 :     if( aRect.X >= nWidth )
     479           0 :         throw IndexOutOfBoundsException();
     480           0 :     if( aRect.X + aRect.Width > nWidth )
     481           0 :         aRect.Width = nWidth - aRect.X;
     482           0 :     return aRect;
     483             : }
     484             : 
     485           0 : sal_Int32 SAL_CALL ScAccessibleCsvRuler::getCharacterCount() throw( RuntimeException )
     486             : {
     487           0 :     SolarMutexGuard aGuard;
     488           0 :     ensureAlive();
     489           0 :     return implGetTextLength();
     490             : }
     491             : 
     492           0 : sal_Int32 SAL_CALL ScAccessibleCsvRuler::getIndexAtPoint( const AwtPoint& rPoint )
     493             :         throw( RuntimeException )
     494             : {
     495           0 :     SolarMutexGuard aGuard;
     496           0 :     ensureAlive();
     497           0 :     ScCsvRuler& rRuler = implGetRuler();
     498             :     // use object's coordinate system, convert to API position
     499           0 :     return lcl_GetApiPos( ::std::min( ::std::max( rRuler.GetPosFromX( rPoint.X ), static_cast<sal_Int32>(0) ), rRuler.GetPosCount() ) );
     500             : }
     501             : 
     502           0 : OUString SAL_CALL ScAccessibleCsvRuler::getSelectedText() throw( RuntimeException )
     503             : {
     504           0 :     ensureAlive();
     505           0 :     return OUString();
     506             : }
     507             : 
     508           0 : sal_Int32 SAL_CALL ScAccessibleCsvRuler::getSelectionStart() throw( RuntimeException )
     509             : {
     510           0 :     ensureAlive();
     511           0 :     return -1;
     512             : }
     513             : 
     514           0 : sal_Int32 SAL_CALL ScAccessibleCsvRuler::getSelectionEnd() throw( RuntimeException )
     515             : {
     516           0 :     ensureAlive();
     517           0 :     return -1;
     518             : }
     519             : 
     520           0 : sal_Bool SAL_CALL ScAccessibleCsvRuler::setSelection( sal_Int32 /* nStartIndex */, sal_Int32 /* nEndIndex */ )
     521             :         throw( IndexOutOfBoundsException, RuntimeException )
     522             : {
     523           0 :     ensureAlive();
     524           0 :     return false;
     525             : }
     526             : 
     527           0 : OUString SAL_CALL ScAccessibleCsvRuler::getText() throw( RuntimeException )
     528             : {
     529           0 :     SolarMutexGuard aGuard;
     530           0 :     ensureAlive();
     531           0 :     return OUString( maBuffer.getStr(), implGetTextLength() );
     532             : }
     533             : 
     534           0 : OUString SAL_CALL ScAccessibleCsvRuler::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
     535             :         throw( IndexOutOfBoundsException, RuntimeException )
     536             : {
     537           0 :     SolarMutexGuard aGuard;
     538           0 :     ensureAlive();
     539           0 :     ensureValidRange( nStartIndex, nEndIndex );
     540           0 :     return OUString( maBuffer.getStr() + nStartIndex, nEndIndex - nStartIndex );
     541             : }
     542             : 
     543           0 : TextSegment SAL_CALL ScAccessibleCsvRuler::getTextAtIndex( sal_Int32 nIndex, sal_Int16 nTextType )
     544             :         throw( IndexOutOfBoundsException, IllegalArgumentException, RuntimeException )
     545             : {
     546           0 :     SolarMutexGuard aGuard;
     547           0 :     ensureAlive();
     548             : 
     549           0 :     TextSegment aResult;
     550           0 :     aResult.SegmentStart = -1;
     551           0 :     aResult.SegmentEnd = -1;
     552             : 
     553           0 :     if( (nIndex == implGetTextLength()) && (nTextType != AccessibleTextType::LINE) )
     554           0 :         return aResult;
     555             : 
     556           0 :     ensureValidIndex( nIndex );
     557             : 
     558           0 :     OUStringBuffer aResultText;     // will be assigned to aResult.SegmentText below
     559           0 :     sal_Int32 nRulerPos = lcl_GetRulerPos( nIndex );
     560             : 
     561           0 :     switch( nTextType )
     562             :     {
     563             :         // single character
     564             :         case AccessibleTextType::CHARACTER:
     565             :         {
     566           0 :             aResult.SegmentStart = nIndex;
     567           0 :             aResultText.append(maBuffer[nIndex]);
     568             :         }
     569           0 :         break;
     570             : 
     571             :         // entire number or single dot/line
     572             :         case AccessibleTextType::WORD:
     573             :         case AccessibleTextType::GLYPH:
     574           0 :             aResult.SegmentStart = nIndex;
     575           0 :             if( nRulerPos % 10 )
     576           0 :                 aResultText.append(maBuffer[nIndex]);
     577             :             else
     578           0 :                 aResultText.append( nRulerPos );    // string representation of sal_Int32!!!
     579           0 :         break;
     580             : 
     581             :         // entire text
     582             :         case AccessibleTextType::SENTENCE:
     583             :         case AccessibleTextType::PARAGRAPH:
     584             :         case AccessibleTextType::LINE:
     585           0 :             aResult.SegmentStart = 0;
     586           0 :             aResultText.append( maBuffer.getStr(), implGetTextLength() );
     587           0 :         break;
     588             : 
     589             :         // equal-formatted text
     590             :         case AccessibleTextType::ATTRIBUTE_RUN:
     591             :         {
     592           0 :             sal_Int32 nFirstIndex = implGetFirstEqualFormatted( nIndex );
     593           0 :             sal_Int32 nLastIndex = implGetLastEqualFormatted( nIndex );
     594           0 :             aResult.SegmentStart = nFirstIndex;
     595           0 :             aResultText.append( maBuffer.getStr() + nFirstIndex, nLastIndex - nFirstIndex + 1 );
     596             :         }
     597           0 :         break;
     598             : 
     599             :         default:
     600           0 :             throw RuntimeException();
     601             :     }
     602             : 
     603           0 :     aResult.SegmentText = aResultText.makeStringAndClear();
     604           0 :     aResult.SegmentEnd = aResult.SegmentStart + aResult.SegmentText.getLength();
     605           0 :     return aResult;
     606             : }
     607             : 
     608           0 : TextSegment SAL_CALL ScAccessibleCsvRuler::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 nTextType )
     609             :         throw( IndexOutOfBoundsException, IllegalArgumentException, RuntimeException )
     610             : {
     611           0 :     SolarMutexGuard aGuard;
     612           0 :     ensureAlive();
     613           0 :     ensureValidIndexWithEnd( nIndex );
     614             : 
     615           0 :     TextSegment aResult;
     616           0 :     aResult.SegmentStart = -1;
     617           0 :     aResult.SegmentEnd = -1;
     618             : 
     619           0 :     sal_Int32 nRulerPos = lcl_GetRulerPos( nIndex );
     620             : 
     621           0 :     switch( nTextType )
     622             :     {
     623             :         // single character
     624             :         case AccessibleTextType::CHARACTER:
     625           0 :             if( nIndex > 0 )
     626           0 :                 aResult = getTextAtIndex( nIndex - 1, nTextType );
     627             :             // else empty
     628           0 :         break;
     629             : 
     630             :         // entire number or single dot/line
     631             :         case AccessibleTextType::WORD:
     632             :         case AccessibleTextType::GLYPH:
     633           0 :             if( nRulerPos > 0 )
     634           0 :                 aResult = getTextAtIndex( lcl_GetApiPos( nRulerPos - 1 ), nTextType );
     635             :             // else empty
     636           0 :         break;
     637             : 
     638             :         // entire text
     639             :         case AccessibleTextType::SENTENCE:
     640             :         case AccessibleTextType::PARAGRAPH:
     641             :         case AccessibleTextType::LINE:
     642             :             // empty
     643           0 :         break;
     644             : 
     645             :         // equal-formatted text
     646             :         case AccessibleTextType::ATTRIBUTE_RUN:
     647             :         {
     648           0 :             sal_Int32 nFirstIndex = implGetFirstEqualFormatted( nIndex );
     649           0 :             if( nFirstIndex > 0 )
     650           0 :                 aResult = getTextAtIndex( nFirstIndex - 1, nTextType );
     651             :             // else empty
     652             :         }
     653           0 :         break;
     654             : 
     655             :         default:
     656           0 :             throw RuntimeException();
     657             :     }
     658           0 :     return aResult;
     659             : }
     660             : 
     661           0 : TextSegment SAL_CALL ScAccessibleCsvRuler::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 nTextType )
     662             :         throw( IndexOutOfBoundsException, IllegalArgumentException, RuntimeException )
     663             : {
     664           0 :     SolarMutexGuard aGuard;
     665           0 :     ensureAlive();
     666           0 :     ensureValidIndexWithEnd( nIndex );
     667             : 
     668           0 :     TextSegment aResult;
     669           0 :     aResult.SegmentStart = -1;
     670           0 :     aResult.SegmentEnd = -1;
     671             : 
     672           0 :     sal_Int32 nRulerPos = lcl_GetRulerPos( nIndex );
     673           0 :     sal_Int32 nLastValid = implGetTextLength();
     674             : 
     675           0 :     switch( nTextType )
     676             :     {
     677             :         // single character
     678             :         case AccessibleTextType::CHARACTER:
     679           0 :             if( nIndex < nLastValid )
     680           0 :                 aResult = getTextAtIndex( nIndex + 1, nTextType );
     681             :             // else empty
     682           0 :         break;
     683             : 
     684             :         // entire number or single dot/line
     685             :         case AccessibleTextType::WORD:
     686             :         case AccessibleTextType::GLYPH:
     687           0 :             if( nRulerPos < implGetRuler().GetPosCount() )
     688           0 :                 aResult = getTextAtIndex( lcl_GetApiPos( nRulerPos + 1 ), nTextType );
     689             :             // else empty
     690           0 :         break;
     691             : 
     692             :         // entire text
     693             :         case AccessibleTextType::SENTENCE:
     694             :         case AccessibleTextType::PARAGRAPH:
     695             :         case AccessibleTextType::LINE:
     696             :             // empty
     697           0 :         break;
     698             : 
     699             :         // equal-formatted text
     700             :         case AccessibleTextType::ATTRIBUTE_RUN:
     701             :         {
     702           0 :             sal_Int32 nLastIndex = implGetLastEqualFormatted( nIndex );
     703           0 :             if( nLastIndex < nLastValid )
     704           0 :                 aResult = getTextAtIndex( nLastIndex + 1, nTextType );
     705             :             // else empty
     706             :         }
     707           0 :         break;
     708             : 
     709             :         default:
     710           0 :             throw RuntimeException();
     711             :     }
     712           0 :     return aResult;
     713             : }
     714             : 
     715           0 : sal_Bool SAL_CALL ScAccessibleCsvRuler::copyText( sal_Int32 /* nStartIndex */, sal_Int32 /* nEndIndex */ )
     716             :         throw( IndexOutOfBoundsException, RuntimeException )
     717             : {
     718           0 :     ensureAlive();
     719           0 :     return false;
     720             : }
     721             : 
     722             : 
     723             : // XInterface -----------------------------------------------------------------
     724             : 
     725           0 : Any SAL_CALL ScAccessibleCsvRuler::queryInterface( const ::com::sun::star::uno::Type& rType )
     726             :         throw( RuntimeException )
     727             : {
     728           0 :     Any aAny( ScAccessibleCsvRulerImpl::queryInterface( rType ) );
     729           0 :     return aAny.hasValue() ? aAny : ScAccessibleCsvControl::queryInterface( rType );
     730             : }
     731             : 
     732           0 : void SAL_CALL ScAccessibleCsvRuler::acquire() throw ()
     733             : {
     734           0 :     ScAccessibleCsvControl::acquire();
     735           0 : }
     736             : 
     737           0 : void SAL_CALL ScAccessibleCsvRuler::release() throw ()
     738             : {
     739           0 :     ScAccessibleCsvControl::release();
     740           0 : }
     741             : 
     742             : 
     743             : // XServiceInfo ---------------------------------------------------------------
     744             : 
     745           0 : OUString SAL_CALL ScAccessibleCsvRuler::getImplementationName() throw( RuntimeException )
     746             : {
     747           0 :     return OUString( RULER_IMPL_NAME );
     748             : }
     749             : 
     750             : 
     751             : // XTypeProvider --------------------------------------------------------------
     752             : 
     753           0 : Sequence< ::com::sun::star::uno::Type > SAL_CALL ScAccessibleCsvRuler::getTypes() throw( RuntimeException )
     754             : {
     755           0 :     Sequence< ::com::sun::star::uno::Type > aSeq( 1 );
     756           0 :     aSeq[ 0 ] = getCppuType( static_cast< const Reference< XAccessibleText >* >( NULL ) );
     757           0 :     return ::comphelper::concatSequences( ScAccessibleCsvControl::getTypes(), aSeq );
     758             : }
     759             : 
     760             : namespace
     761             : {
     762             :     class theScAccessibleCsvRulerImplementationId : public rtl::Static< UnoTunnelIdInit, theScAccessibleCsvRulerImplementationId > {};
     763             : }
     764             : 
     765           0 : Sequence< sal_Int8 > SAL_CALL ScAccessibleCsvRuler::getImplementationId() throw( RuntimeException )
     766             : {
     767           0 :     return theScAccessibleCsvRulerImplementationId::get().getSeq();
     768             : }
     769             : 
     770             : 
     771             : // events ---------------------------------------------------------------------
     772             : 
     773           0 : void ScAccessibleCsvRuler::SendCaretEvent()
     774             : {
     775           0 :     sal_Int32 nPos = implGetRuler().GetRulerCursorPos();
     776           0 :     if( nPos != CSV_POS_INVALID )
     777             :     {
     778           0 :         AccessibleEventObject aEvent;
     779           0 :         aEvent.EventId = AccessibleEventId::CARET_CHANGED;
     780           0 :         aEvent.Source = Reference< XAccessible >( this );
     781           0 :         aEvent.NewValue <<= nPos;
     782           0 :         CommitChange( aEvent );
     783             :     }
     784           0 : }
     785             : 
     786             : 
     787             : // helpers --------------------------------------------------------------------
     788             : 
     789           0 : OUString SAL_CALL ScAccessibleCsvRuler::createAccessibleName() throw( RuntimeException )
     790             : {
     791           0 :     return String( ScResId( STR_ACC_CSVRULER_NAME ) );
     792             : }
     793             : 
     794           0 : OUString SAL_CALL ScAccessibleCsvRuler::createAccessibleDescription() throw( RuntimeException )
     795             : {
     796           0 :     return String( ScResId( STR_ACC_CSVRULER_DESCR ) );
     797             : }
     798             : 
     799           0 : void ScAccessibleCsvRuler::ensureValidIndex( sal_Int32 nIndex ) const
     800             :         throw( IndexOutOfBoundsException )
     801             : {
     802           0 :     if( (nIndex < 0) || (nIndex >= implGetTextLength()) )
     803           0 :         throw IndexOutOfBoundsException();
     804           0 : }
     805             : 
     806           0 : void ScAccessibleCsvRuler::ensureValidIndexWithEnd( sal_Int32 nIndex ) const
     807             :         throw( IndexOutOfBoundsException )
     808             : {
     809           0 :     if( (nIndex < 0) || (nIndex > implGetTextLength()) )
     810           0 :         throw IndexOutOfBoundsException();
     811           0 : }
     812             : 
     813           0 : void ScAccessibleCsvRuler::ensureValidRange( sal_Int32& rnStartIndex, sal_Int32& rnEndIndex ) const
     814             :         throw( IndexOutOfBoundsException )
     815             : {
     816           0 :     if( rnStartIndex > rnEndIndex )
     817           0 :         ::std::swap( rnStartIndex, rnEndIndex );
     818           0 :     if( (rnStartIndex < 0) || (rnEndIndex > implGetTextLength()) )
     819           0 :         throw IndexOutOfBoundsException();
     820           0 : }
     821             : 
     822           0 : ScCsvRuler& ScAccessibleCsvRuler::implGetRuler() const
     823             : {
     824           0 :     return static_cast< ScCsvRuler& >( implGetControl() );
     825             : }
     826             : 
     827           0 : void ScAccessibleCsvRuler::constructStringBuffer() throw( RuntimeException )
     828             : {
     829           0 :     SolarMutexGuard aGuard;
     830           0 :     ensureAlive();
     831             :     // extend existing string buffer to new ruler size
     832           0 :     sal_Int32 nRulerCount = implGetRuler().GetPosCount();
     833           0 :     sal_Int32 nRulerPos = lcl_GetRulerPos( maBuffer.getLength() );
     834           0 :     for( ; nRulerPos <= nRulerCount; ++nRulerPos ) // include last position
     835             :     {
     836           0 :         switch( nRulerPos % 10 )
     837             :         {
     838           0 :             case 0:     maBuffer.append( nRulerPos );   break;
     839           0 :             case 5:     maBuffer.append( cRulerLine );  break;
     840           0 :             default:    maBuffer.append( cRulerDot );
     841             :         }
     842           0 :     }
     843           0 : }
     844             : 
     845           0 : sal_Int32 ScAccessibleCsvRuler::implGetTextLength() const
     846             : {
     847           0 :     return lcl_GetApiPos( implGetRuler().GetPosCount() + 1 );
     848             : }
     849             : 
     850           0 : bool ScAccessibleCsvRuler::implHasSplit( sal_Int32 nApiPos )
     851             : {
     852           0 :     sal_Int32 nRulerPos = lcl_GetRulerPos( nApiPos );
     853           0 :     return implGetRuler().HasSplit( nRulerPos ) && (nApiPos == lcl_GetApiPos( nRulerPos ));
     854             : }
     855             : 
     856           0 : sal_Int32 ScAccessibleCsvRuler::implGetFirstEqualFormatted( sal_Int32 nApiPos )
     857             : {
     858           0 :     bool bSplit = implHasSplit( nApiPos );
     859           0 :     while( (nApiPos > 0) && (implHasSplit( nApiPos - 1 ) == bSplit) )
     860           0 :         --nApiPos;
     861           0 :     return nApiPos;
     862             : }
     863             : 
     864           0 : sal_Int32 ScAccessibleCsvRuler::implGetLastEqualFormatted( sal_Int32 nApiPos )
     865             : {
     866           0 :     bool bSplit = implHasSplit( nApiPos );
     867           0 :     sal_Int32 nLength = implGetTextLength();
     868           0 :     while( (nApiPos < nLength - 1) && (implHasSplit( nApiPos + 1 ) == bSplit) )
     869           0 :         ++nApiPos;
     870           0 :     return nApiPos;
     871             : }
     872             : 
     873             : 
     874             : // Grid =======================================================================
     875             : 
     876             : /** Converts a grid columnm index to an API column index. */
     877           0 : static inline sal_Int32 lcl_GetApiColumn( sal_uInt32 nGridColumn )
     878             : {
     879           0 :     return (nGridColumn != CSV_COLUMN_HEADER) ? static_cast< sal_Int32 >( nGridColumn + 1 ) : 0;
     880             : }
     881             : 
     882             : /** Converts an API columnm index to a ScCsvGrid column index. */
     883           0 : static inline sal_uInt32 lcl_GetGridColumn( sal_Int32 nApiColumn )
     884             : {
     885           0 :     return (nApiColumn > 0) ? static_cast< sal_uInt32 >( nApiColumn - 1 ) : CSV_COLUMN_HEADER;
     886             : }
     887             : 
     888             : 
     889             : // ----------------------------------------------------------------------------
     890             : 
     891             : DBG_NAME( ScAccessibleCsvGrid )
     892             : 
     893           0 : ScAccessibleCsvGrid::ScAccessibleCsvGrid( ScCsvGrid& rGrid ) :
     894           0 :     ScAccessibleCsvControl( rGrid.GetAccessibleParentWindow()->GetAccessible(), rGrid, nGridRole )
     895             : {
     896             :     DBG_CTOR( ScAccessibleCsvGrid, NULL );
     897           0 : }
     898             : 
     899           0 : ScAccessibleCsvGrid::~ScAccessibleCsvGrid()
     900             : {
     901             :     DBG_DTOR( ScAccessibleCsvGrid, NULL );
     902           0 :     implDispose();
     903           0 : }
     904             : 
     905             : 
     906             : // XAccessibleComponent -------------------------------------------------------
     907             : 
     908           0 : Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getAccessibleAtPoint( const AwtPoint& rPoint )
     909             :         throw( RuntimeException )
     910             : {
     911           0 :     Reference< XAccessible > xRet;
     912           0 :     if( containsPoint( rPoint ) )
     913             :     {
     914           0 :         SolarMutexGuard aGuard;
     915           0 :         ensureAlive();
     916             : 
     917           0 :         const ScCsvGrid& rGrid = implGetGrid();
     918             :         // #102679#; use <= instead of <, because the offset is the size and not the point
     919           0 :         sal_Int32 nColumn = ((rGrid.GetFirstX() <= rPoint.X) && (rPoint.X <= rGrid.GetLastX())) ?
     920           0 :             lcl_GetApiColumn( rGrid.GetColumnFromX( rPoint.X ) ) : 0;
     921           0 :         sal_Int32 nRow = (rPoint.Y >= rGrid.GetHdrHeight()) ?
     922           0 :             (rGrid.GetLineFromY( rPoint.Y ) - rGrid.GetFirstVisLine() + 1) : 0;
     923           0 :         xRet = implCreateCellObj( nRow, nColumn );
     924             :     }
     925           0 :     return xRet;
     926             : }
     927             : 
     928           0 : sal_Int32 SAL_CALL ScAccessibleCsvGrid::getForeground(  )
     929             : throw (RuntimeException)
     930             : {
     931           0 :     SolarMutexGuard aGuard;
     932           0 :     ensureAlive();
     933           0 :     return implGetGrid().GetSettings().GetStyleSettings().GetButtonTextColor().GetColor();
     934             : }
     935             : 
     936           0 : sal_Int32 SAL_CALL ScAccessibleCsvGrid::getBackground(  )
     937             : throw (RuntimeException)
     938             : {
     939           0 :     SolarMutexGuard aGuard;
     940           0 :     ensureAlive();
     941           0 :     return SC_MOD()->GetColorConfig().GetColorValue( ::svtools::DOCCOLOR ).nColor;
     942             : }
     943             : 
     944             : // XAccessibleContext ---------------------------------------------------------
     945             : 
     946           0 : sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleChildCount() throw( RuntimeException )
     947             : {
     948           0 :     SolarMutexGuard aGuard;
     949           0 :     ensureAlive();
     950           0 :     return implGetCellCount();
     951             : }
     952             : 
     953           0 : Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getAccessibleChild( sal_Int32 nIndex )
     954             :         throw( IndexOutOfBoundsException, RuntimeException )
     955             : {
     956           0 :     SolarMutexGuard aGuard;
     957           0 :     ensureAlive();
     958           0 :     ensureValidIndex( nIndex );
     959           0 :     return implCreateCellObj( implGetRow( nIndex ), implGetColumn( nIndex ) );
     960             : }
     961             : 
     962           0 : Reference< XAccessibleRelationSet > SAL_CALL ScAccessibleCsvGrid::getAccessibleRelationSet()
     963             :         throw( RuntimeException )
     964             : {
     965           0 :     SolarMutexGuard aGuard;
     966           0 :     ensureAlive();
     967           0 :     AccessibleRelationSetHelper* pRelationSet = new AccessibleRelationSetHelper();
     968           0 :     Reference< XAccessible > xAccObj = implGetChildByRole( getAccessibleParent(), nRulerRole );
     969           0 :     if( xAccObj.is() )
     970             :     {
     971           0 :         Sequence< Reference< XInterface > > aSeq( 1 );
     972           0 :         aSeq[ 0 ] = xAccObj;
     973           0 :         pRelationSet->AddRelation( AccessibleRelation( AccessibleRelationType::CONTROLLED_BY, aSeq ) );
     974             :     }
     975           0 :     return pRelationSet;
     976             : }
     977             : 
     978           0 : Reference< XAccessibleStateSet > SAL_CALL ScAccessibleCsvGrid::getAccessibleStateSet()
     979             :         throw( RuntimeException )
     980             : {
     981           0 :     SolarMutexGuard aGuard;
     982           0 :     AccessibleStateSetHelper* pStateSet = implCreateStateSet();
     983           0 :     if( implIsAlive() )
     984             :     {
     985           0 :         pStateSet->AddState( AccessibleStateType::FOCUSABLE );
     986           0 :         pStateSet->AddState( AccessibleStateType::MULTI_SELECTABLE );
     987           0 :         pStateSet->AddState( AccessibleStateType::MANAGES_DESCENDANTS );
     988           0 :         if( implGetGrid().HasFocus() )
     989           0 :             pStateSet->AddState( AccessibleStateType::FOCUSED );
     990             :     }
     991             :     else
     992           0 :         pStateSet->AddState( AccessibleStateType::DEFUNC );
     993           0 :     return pStateSet;
     994             : }
     995             : 
     996             : 
     997             : // XAccessibleTable -----------------------------------------------------------
     998             : 
     999           0 : sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleRowCount() throw( RuntimeException )
    1000             : {
    1001           0 :     SolarMutexGuard aGuard;
    1002           0 :     ensureAlive();
    1003           0 :     return implGetRowCount();
    1004             : }
    1005             : 
    1006           0 : sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleColumnCount() throw( RuntimeException )
    1007             : {
    1008           0 :     SolarMutexGuard aGuard;
    1009           0 :     ensureAlive();
    1010           0 :     return implGetColumnCount();
    1011             : }
    1012             : 
    1013           0 : OUString SAL_CALL ScAccessibleCsvGrid::getAccessibleRowDescription( sal_Int32 nRow )
    1014             :         throw( IndexOutOfBoundsException, RuntimeException )
    1015             : {
    1016           0 :     SolarMutexGuard aGuard;
    1017           0 :     ensureAlive();
    1018           0 :     ensureValidPosition( nRow, 0 );
    1019           0 :     return implGetCellText( nRow, 0 );
    1020             : }
    1021             : 
    1022           0 : OUString SAL_CALL ScAccessibleCsvGrid::getAccessibleColumnDescription( sal_Int32 nColumn )
    1023             :         throw( IndexOutOfBoundsException, RuntimeException )
    1024             : {
    1025           0 :     SolarMutexGuard aGuard;
    1026           0 :     ensureAlive();
    1027           0 :     ensureValidPosition( 0, nColumn );
    1028           0 :     return implGetCellText( 0, nColumn );
    1029             : }
    1030             : 
    1031           0 : sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
    1032             :         throw( IndexOutOfBoundsException, RuntimeException )
    1033             : {
    1034           0 :     ensureAlive();
    1035           0 :     ensureValidPosition( nRow, nColumn );
    1036           0 :     return 1;
    1037             : }
    1038             : 
    1039           0 : sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
    1040             :         throw( IndexOutOfBoundsException, RuntimeException )
    1041             : {
    1042           0 :     ensureAlive();
    1043           0 :     ensureValidPosition( nRow, nColumn );
    1044           0 :     return 1;
    1045             : }
    1046             : 
    1047           0 : Reference< XAccessibleTable > SAL_CALL ScAccessibleCsvGrid::getAccessibleRowHeaders()
    1048             :         throw( RuntimeException )
    1049             : {
    1050           0 :     ensureAlive();
    1051           0 :     return NULL;
    1052             : }
    1053             : 
    1054           0 : Reference< XAccessibleTable > SAL_CALL ScAccessibleCsvGrid::getAccessibleColumnHeaders()
    1055             :         throw( RuntimeException )
    1056             : {
    1057           0 :     ensureAlive();
    1058           0 :     return NULL;
    1059             : }
    1060             : 
    1061           0 : Sequence< sal_Int32 > SAL_CALL ScAccessibleCsvGrid::getSelectedAccessibleRows()
    1062             :         throw( RuntimeException )
    1063             : {
    1064           0 :     ensureAlive();
    1065           0 :     return Sequence< sal_Int32 >();
    1066             : }
    1067             : 
    1068           0 : Sequence< sal_Int32 > SAL_CALL ScAccessibleCsvGrid::getSelectedAccessibleColumns()
    1069             :         throw( RuntimeException )
    1070             : {
    1071           0 :     SolarMutexGuard aGuard;
    1072           0 :     ensureAlive();
    1073             : 
    1074           0 :     ScCsvGrid& rGrid = implGetGrid();
    1075           0 :     Sequence< sal_Int32 > aSeq( implGetColumnCount() );
    1076             : 
    1077           0 :     sal_Int32 nSeqIx = 0;
    1078           0 :     sal_uInt32 nColIx = rGrid.GetFirstSelected();
    1079           0 :     for( ; nColIx != CSV_COLUMN_INVALID; ++nSeqIx, nColIx = rGrid.GetNextSelected( nColIx ) )
    1080           0 :         aSeq[ nSeqIx ] = lcl_GetApiColumn( nColIx );
    1081             : 
    1082           0 :     aSeq.realloc( nSeqIx );
    1083           0 :     return aSeq;
    1084             : }
    1085             : 
    1086           0 : sal_Bool SAL_CALL ScAccessibleCsvGrid::isAccessibleRowSelected( sal_Int32 /* nRow */ )
    1087             :         throw( IndexOutOfBoundsException, RuntimeException )
    1088             : {
    1089           0 :     ensureAlive();
    1090           0 :     return false;
    1091             : }
    1092             : 
    1093           0 : sal_Bool SAL_CALL ScAccessibleCsvGrid::isAccessibleColumnSelected( sal_Int32 nColumn )
    1094             :         throw( IndexOutOfBoundsException, RuntimeException )
    1095             : {
    1096           0 :     SolarMutexGuard aGuard;
    1097           0 :     ensureAlive();
    1098           0 :     ensureValidIndex( nColumn );
    1099           0 :     return implIsColumnSelected( nColumn );
    1100             : }
    1101             : 
    1102           0 : Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn )
    1103             :         throw( IndexOutOfBoundsException, RuntimeException )
    1104             : {
    1105           0 :     SolarMutexGuard aGuard;
    1106           0 :     ensureAlive();
    1107           0 :     ensureValidPosition( nRow, nColumn );
    1108           0 :     return implCreateCellObj( nRow, nColumn );
    1109             : }
    1110             : 
    1111           0 : Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getAccessibleCaption()
    1112             :         throw( RuntimeException )
    1113             : {
    1114           0 :     ensureAlive();
    1115           0 :     return NULL;
    1116             : }
    1117             : 
    1118           0 : Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getAccessibleSummary()
    1119             :         throw( RuntimeException )
    1120             : {
    1121           0 :     ensureAlive();
    1122           0 :     return NULL;
    1123             : }
    1124             : 
    1125           0 : sal_Bool SAL_CALL ScAccessibleCsvGrid::isAccessibleSelected( sal_Int32 /* nRow */, sal_Int32 nColumn )
    1126             :         throw( IndexOutOfBoundsException, RuntimeException )
    1127             : {
    1128           0 :     return isAccessibleColumnSelected( nColumn );
    1129             : }
    1130             : 
    1131           0 : sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn )
    1132             :         throw( IndexOutOfBoundsException, RuntimeException )
    1133             : {
    1134           0 :     SolarMutexGuard aGuard;
    1135           0 :     ensureAlive();
    1136           0 :     ensureValidPosition( nRow, nColumn );
    1137           0 :     return implGetIndex( nRow, nColumn );
    1138             : }
    1139             : 
    1140           0 : sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleRow( sal_Int32 nChildIndex )
    1141             :         throw( IndexOutOfBoundsException, RuntimeException )
    1142             : {
    1143           0 :     SolarMutexGuard aGuard;
    1144           0 :     ensureAlive();
    1145           0 :     ensureValidIndex( nChildIndex );
    1146           0 :     return implGetRow( nChildIndex );
    1147             : }
    1148             : 
    1149           0 : sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleColumn( sal_Int32 nChildIndex )
    1150             :         throw( IndexOutOfBoundsException, RuntimeException )
    1151             : {
    1152           0 :     SolarMutexGuard aGuard;
    1153           0 :     ensureAlive();
    1154           0 :     ensureValidIndex( nChildIndex );
    1155           0 :     return implGetColumn( nChildIndex );
    1156             : }
    1157             : 
    1158             : 
    1159             : // XAccessibleSelection -------------------------------------------------------
    1160             : 
    1161           0 : void SAL_CALL ScAccessibleCsvGrid::selectAccessibleChild( sal_Int32 nChildIndex )
    1162             :         throw( IndexOutOfBoundsException, RuntimeException )
    1163             : {
    1164           0 :     SolarMutexGuard aGuard;
    1165           0 :     ensureAlive();
    1166           0 :     ensureValidIndex( nChildIndex );
    1167           0 :     sal_Int32 nColumn = implGetColumn( nChildIndex );
    1168           0 :     if( nChildIndex == 0 )
    1169           0 :         implGetGrid().SelectAll();
    1170             :     else
    1171           0 :         implSelectColumn( nColumn, true );
    1172           0 : }
    1173             : 
    1174           0 : sal_Bool SAL_CALL ScAccessibleCsvGrid::isAccessibleChildSelected( sal_Int32 nChildIndex )
    1175             :         throw( IndexOutOfBoundsException, RuntimeException )
    1176             : {
    1177           0 :     SolarMutexGuard aGuard;
    1178           0 :     ensureAlive();
    1179           0 :     ensureValidIndex( nChildIndex );
    1180           0 :     sal_Int32 nColumn = implGetColumn( nChildIndex );
    1181           0 :     return implIsColumnSelected( nColumn );
    1182             : }
    1183             : 
    1184           0 : void SAL_CALL ScAccessibleCsvGrid::clearAccessibleSelection() throw( RuntimeException )
    1185             : {
    1186           0 :     SolarMutexGuard aGuard;
    1187           0 :     ensureAlive();
    1188           0 :     implGetGrid().SelectAll( false );
    1189           0 : }
    1190             : 
    1191           0 : void SAL_CALL ScAccessibleCsvGrid::selectAllAccessibleChildren() throw( RuntimeException )
    1192             : {
    1193           0 :     selectAccessibleChild( 0 );
    1194           0 : }
    1195             : 
    1196           0 : sal_Int32 SAL_CALL ScAccessibleCsvGrid::getSelectedAccessibleChildCount() throw( RuntimeException )
    1197             : {
    1198           0 :     SolarMutexGuard aGuard;
    1199           0 :     ensureAlive();
    1200           0 :     return implGetRowCount() * implGetSelColumnCount();
    1201             : }
    1202             : 
    1203           0 : Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
    1204             :         throw( IndexOutOfBoundsException, RuntimeException )
    1205             : {
    1206           0 :     SolarMutexGuard aGuard;
    1207           0 :     ensureAlive();
    1208           0 :     sal_Int32 nColumns = implGetSelColumnCount();
    1209           0 :     if( nColumns == 0 )
    1210           0 :         throw IndexOutOfBoundsException();
    1211             : 
    1212           0 :     sal_Int32 nRow = nSelectedChildIndex / nColumns;
    1213           0 :     sal_Int32 nColumn = implGetSelColumn( nSelectedChildIndex % nColumns );
    1214           0 :     return getAccessibleCellAt( nRow, nColumn );
    1215             : }
    1216             : 
    1217           0 : void SAL_CALL ScAccessibleCsvGrid::deselectAccessibleChild( sal_Int32 nSelectedChildIndex )
    1218             :         throw( IndexOutOfBoundsException, RuntimeException )
    1219             : {
    1220           0 :     SolarMutexGuard aGuard;
    1221           0 :     ensureAlive();
    1222           0 :     sal_Int32 nColumns = implGetSelColumnCount();
    1223           0 :     if( nColumns == 0 )
    1224           0 :         throw IndexOutOfBoundsException();
    1225             : 
    1226           0 :     sal_Int32 nColumn = implGetSelColumn( nSelectedChildIndex % nColumns );
    1227           0 :     ensureValidPosition( nSelectedChildIndex / nColumns, nColumn );
    1228           0 :     if( nColumn > 0 )
    1229           0 :         implSelectColumn( nColumn, false );
    1230           0 : }
    1231             : 
    1232             : 
    1233             : // XInterface -----------------------------------------------------------------
    1234             : 
    1235           0 : Any SAL_CALL ScAccessibleCsvGrid::queryInterface( const ::com::sun::star::uno::Type& rType )
    1236             :         throw( RuntimeException )
    1237             : {
    1238           0 :     Any aAny( ScAccessibleCsvGridImpl::queryInterface( rType ) );
    1239           0 :     return aAny.hasValue() ? aAny : ScAccessibleCsvControl::queryInterface( rType );
    1240             : }
    1241             : 
    1242           0 : void SAL_CALL ScAccessibleCsvGrid::acquire() throw ()
    1243             : {
    1244           0 :     ScAccessibleCsvControl::acquire();
    1245           0 : }
    1246             : 
    1247           0 : void SAL_CALL ScAccessibleCsvGrid::release() throw ()
    1248             : {
    1249           0 :     ScAccessibleCsvControl::release();
    1250           0 : }
    1251             : 
    1252             : 
    1253             : // XServiceInfo ---------------------------------------------------------------
    1254             : 
    1255           0 : OUString SAL_CALL ScAccessibleCsvGrid::getImplementationName() throw( RuntimeException )
    1256             : {
    1257           0 :     return OUString( GRID_IMPL_NAME );
    1258             : }
    1259             : 
    1260             : 
    1261             : // XTypeProvider --------------------------------------------------------------
    1262             : 
    1263           0 : Sequence< ::com::sun::star::uno::Type > SAL_CALL ScAccessibleCsvGrid::getTypes() throw( RuntimeException )
    1264             : {
    1265           0 :     Sequence< ::com::sun::star::uno::Type > aSeq( 2 );
    1266           0 :     aSeq[ 0 ] = getCppuType( static_cast< const Reference< XAccessibleTable >* >( NULL ) );
    1267           0 :     aSeq[ 1 ] = getCppuType( static_cast< const Reference< XAccessibleSelection >* >( NULL ) );
    1268           0 :     return ::comphelper::concatSequences( ScAccessibleCsvControl::getTypes(), aSeq );
    1269             : }
    1270             : 
    1271             : namespace
    1272             : {
    1273             :     class theScAccessibleCsvGridImplementationId  : public rtl::Static< UnoTunnelIdInit, theScAccessibleCsvGridImplementationId > {};
    1274             : }
    1275             : 
    1276           0 : Sequence< sal_Int8 > SAL_CALL ScAccessibleCsvGrid::getImplementationId() throw( RuntimeException )
    1277             : {
    1278           0 :     return theScAccessibleCsvGridImplementationId::get().getSeq();
    1279             : }
    1280             : 
    1281             : 
    1282             : // events ---------------------------------------------------------------------
    1283             : 
    1284           0 : void ScAccessibleCsvGrid::SendFocusEvent( bool bFocused )
    1285             : {
    1286           0 :     ScAccessibleCsvControl::SendFocusEvent( bFocused );
    1287             : 
    1288           0 :     AccessibleEventObject aEvent;
    1289           0 :     aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED;
    1290           0 :     aEvent.Source = Reference< XAccessible >( this );
    1291           0 :     (bFocused ? aEvent.NewValue : aEvent.OldValue) <<=
    1292           0 :         getAccessibleCellAt( 0, lcl_GetApiColumn( implGetGrid().GetFocusColumn() ) );
    1293           0 :     CommitChange( aEvent );
    1294           0 : }
    1295             : 
    1296           0 : void ScAccessibleCsvGrid::SendTableUpdateEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows )
    1297             : {
    1298           0 :     if( nFirstColumn <= nLastColumn )
    1299             :     {
    1300             :         AccessibleTableModelChange aModelChange(
    1301           0 :             AccessibleTableModelChangeType::UPDATE, 0, bAllRows ? implGetRowCount() - 1 : 0,
    1302           0 :             lcl_GetApiColumn( nFirstColumn ), lcl_GetApiColumn( nLastColumn ) );
    1303           0 :         AccessibleEventObject aEvent;
    1304           0 :         aEvent.EventId = AccessibleEventId::TABLE_MODEL_CHANGED;
    1305           0 :         aEvent.Source = Reference< XAccessible >( this );
    1306           0 :         aEvent.NewValue <<= aModelChange;
    1307           0 :         CommitChange( aEvent );
    1308             :     }
    1309           0 : }
    1310             : 
    1311           0 : void ScAccessibleCsvGrid::SendInsertColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn )
    1312             : {
    1313           0 :     if( nFirstColumn <= nLastColumn )
    1314             :     {
    1315             :         AccessibleTableModelChange aModelChange(
    1316           0 :             AccessibleTableModelChangeType::INSERT, 0, implGetRowCount() - 1,
    1317           0 :             lcl_GetApiColumn( nFirstColumn ), lcl_GetApiColumn( nLastColumn ) );
    1318           0 :         AccessibleEventObject aEvent;
    1319           0 :         aEvent.EventId = AccessibleEventId::TABLE_MODEL_CHANGED;
    1320           0 :         aEvent.Source = Reference< XAccessible >( this );
    1321           0 :         aEvent.NewValue <<= aModelChange;
    1322           0 :         CommitChange( aEvent );
    1323             :     }
    1324           0 : }
    1325             : 
    1326           0 : void ScAccessibleCsvGrid::SendRemoveColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn )
    1327             : {
    1328           0 :     if( nFirstColumn <= nLastColumn )
    1329             :     {
    1330             :         AccessibleTableModelChange aModelChange(
    1331           0 :             AccessibleTableModelChangeType::DELETE, 0, implGetRowCount() - 1,
    1332           0 :             lcl_GetApiColumn( nFirstColumn ), lcl_GetApiColumn( nLastColumn ) );
    1333           0 :         AccessibleEventObject aEvent;
    1334           0 :         aEvent.EventId = AccessibleEventId::TABLE_MODEL_CHANGED;
    1335           0 :         aEvent.Source = Reference< XAccessible >( this );
    1336           0 :         aEvent.NewValue <<= aModelChange;
    1337           0 :         CommitChange( aEvent );
    1338             :     }
    1339           0 : }
    1340             : 
    1341             : 
    1342             : // helpers --------------------------------------------------------------------
    1343             : 
    1344           0 : OUString SAL_CALL ScAccessibleCsvGrid::createAccessibleName() throw( RuntimeException )
    1345             : {
    1346           0 :     return String( ScResId( STR_ACC_CSVGRID_NAME ) );
    1347             : }
    1348             : 
    1349           0 : OUString SAL_CALL ScAccessibleCsvGrid::createAccessibleDescription() throw( RuntimeException )
    1350             : {
    1351           0 :     return String( ScResId( STR_ACC_CSVGRID_DESCR ) );
    1352             : }
    1353             : 
    1354           0 : void ScAccessibleCsvGrid::ensureValidIndex( sal_Int32 nIndex ) const
    1355             :         throw( IndexOutOfBoundsException )
    1356             : {
    1357           0 :     if( (nIndex < 0) || (nIndex >= implGetCellCount()) )
    1358           0 :         throw IndexOutOfBoundsException();
    1359           0 : }
    1360             : 
    1361           0 : void ScAccessibleCsvGrid::ensureValidPosition( sal_Int32 nRow, sal_Int32 nColumn ) const
    1362             :         throw( IndexOutOfBoundsException )
    1363             : {
    1364           0 :     if( (nRow < 0) || (nRow >= implGetRowCount()) || (nColumn < 0) || (nColumn >= implGetColumnCount()) )
    1365           0 :         throw IndexOutOfBoundsException();
    1366           0 : }
    1367             : 
    1368           0 : ScCsvGrid& ScAccessibleCsvGrid::implGetGrid() const
    1369             : {
    1370           0 :     return static_cast< ScCsvGrid& >( implGetControl() );
    1371             : }
    1372             : 
    1373           0 : bool ScAccessibleCsvGrid::implIsColumnSelected( sal_Int32 nColumn ) const
    1374             : {
    1375           0 :     return (nColumn > 0) && implGetGrid().IsSelected( lcl_GetGridColumn( nColumn ) );
    1376             : }
    1377             : 
    1378           0 : void ScAccessibleCsvGrid::implSelectColumn( sal_Int32 nColumn, bool bSelect )
    1379             : {
    1380           0 :     if( nColumn > 0 )
    1381           0 :         implGetGrid().Select( lcl_GetGridColumn( nColumn ), bSelect );
    1382           0 : }
    1383             : 
    1384           0 : sal_Int32 ScAccessibleCsvGrid::implGetRowCount() const
    1385             : {
    1386           0 :     return static_cast< sal_Int32 >( implGetGrid().GetLastVisLine() - implGetGrid().GetFirstVisLine() + 2 );
    1387             : }
    1388             : 
    1389           0 : sal_Int32 ScAccessibleCsvGrid::implGetColumnCount() const
    1390             : {
    1391           0 :     return static_cast< sal_Int32 >( implGetGrid().GetColumnCount() + 1 );
    1392             : }
    1393             : 
    1394           0 : sal_Int32 ScAccessibleCsvGrid::implGetSelColumnCount() const
    1395             : {
    1396           0 :     ScCsvGrid& rGrid = implGetGrid();
    1397           0 :     sal_Int32 nCount = 0;
    1398           0 :     for( sal_uInt32 nColIx = rGrid.GetFirstSelected(); nColIx != CSV_COLUMN_INVALID; nColIx = rGrid.GetNextSelected( nColIx ) )
    1399           0 :         ++nCount;
    1400           0 :     return nCount;
    1401             : }
    1402             : 
    1403           0 : sal_Int32 ScAccessibleCsvGrid::implGetSelColumn( sal_Int32 nSelColumn ) const
    1404             : {
    1405           0 :     ScCsvGrid& rGrid = implGetGrid();
    1406           0 :     sal_Int32 nColumn = 0;
    1407           0 :     for( sal_uInt32 nColIx = rGrid.GetFirstSelected(); nColIx != CSV_COLUMN_INVALID; nColIx = rGrid.GetNextSelected( nColIx ) )
    1408             :     {
    1409           0 :         if( nColumn == nSelColumn )
    1410           0 :             return static_cast< sal_Int32 >( nColIx + 1 );
    1411           0 :         ++nColumn;
    1412             :     }
    1413           0 :     return 0;
    1414             : }
    1415             : 
    1416           0 : String ScAccessibleCsvGrid::implGetCellText( sal_Int32 nRow, sal_Int32 nColumn ) const
    1417             : {
    1418           0 :     ScCsvGrid& rGrid = implGetGrid();
    1419           0 :     sal_Int32 nLine = nRow + rGrid.GetFirstVisLine() - 1;
    1420           0 :     String aCellStr;
    1421           0 :     if( (nColumn > 0) && (nRow > 0) )
    1422           0 :         aCellStr = rGrid.GetCellText( lcl_GetGridColumn( nColumn ), nLine );
    1423           0 :     else if( nRow > 0 )
    1424           0 :         aCellStr = OUString::number( nLine + 1L );
    1425           0 :     else if( nColumn > 0 )
    1426           0 :         aCellStr = rGrid.GetColumnTypeName( lcl_GetGridColumn( nColumn ) );
    1427           0 :     return aCellStr;
    1428             : }
    1429             : 
    1430             : 
    1431           0 : ScAccessibleCsvControl* ScAccessibleCsvGrid::implCreateCellObj( sal_Int32 nRow, sal_Int32 nColumn ) const
    1432             : {
    1433           0 :     return new ScAccessibleCsvCell( implGetGrid(), implGetCellText( nRow, nColumn ), nRow, nColumn );
    1434             : }
    1435             : 
    1436             : 
    1437             : // ============================================================================
    1438             : 
    1439             : DBG_NAME( ScAccessibleCsvCell )
    1440             : 
    1441           0 : ScAccessibleCsvCell::ScAccessibleCsvCell(
    1442             :         ScCsvGrid& rGrid,
    1443             :         const String& rCellText,
    1444             :         sal_Int32 nRow, sal_Int32 nColumn ) :
    1445             :     ScAccessibleCsvControl( rGrid.GetAccessible(), rGrid, nCellRole ),
    1446             :     AccessibleStaticTextBase( SvxEditSourcePtr( NULL ) ),
    1447             :     maCellText( rCellText ),
    1448           0 :     mnLine( nRow ? (nRow + rGrid.GetFirstVisLine() - 1) : CSV_LINE_HEADER ),
    1449           0 :     mnColumn( lcl_GetGridColumn( nColumn ) ),
    1450           0 :     mnIndex( nRow * (rGrid.GetColumnCount() + 1) + nColumn )
    1451             : {
    1452             :     DBG_CTOR( ScAccessibleCsvCell, NULL );
    1453           0 :     SetEditSource( implCreateEditSource() );
    1454           0 : }
    1455             : 
    1456           0 : ScAccessibleCsvCell::~ScAccessibleCsvCell()
    1457             : {
    1458             :     DBG_DTOR( ScAccessibleCsvCell, NULL );
    1459           0 : }
    1460             : 
    1461           0 : void SAL_CALL ScAccessibleCsvCell::disposing()
    1462             : {
    1463           0 :     SolarMutexGuard aGuard;
    1464           0 :     SetEditSource( SvxEditSourcePtr( NULL ) );
    1465           0 :     ScAccessibleCsvControl::disposing();
    1466           0 : }
    1467             : 
    1468             : 
    1469             : // XAccessibleComponent -------------------------------------------------------
    1470             : 
    1471           0 : void SAL_CALL ScAccessibleCsvCell::grabFocus() throw( RuntimeException )
    1472             : {
    1473           0 :     SolarMutexGuard aGuard;
    1474           0 :     ensureAlive();
    1475           0 :     ScCsvGrid& rGrid = implGetGrid();
    1476           0 :     rGrid.Execute( CSVCMD_MOVEGRIDCURSOR, rGrid.GetColumnPos( mnColumn ) );
    1477           0 : }
    1478             : 
    1479           0 : sal_Int32 SAL_CALL ScAccessibleCsvCell::getForeground(  )
    1480             : throw (RuntimeException)
    1481             : {
    1482           0 :     SolarMutexGuard aGuard;
    1483           0 :     ensureAlive();
    1484           0 :     return implGetGrid().GetSettings().GetStyleSettings().GetButtonTextColor().GetColor();
    1485             : }
    1486             : 
    1487           0 : sal_Int32 SAL_CALL ScAccessibleCsvCell::getBackground(  )
    1488             : throw (RuntimeException)
    1489             : {
    1490           0 :     SolarMutexGuard aGuard;
    1491           0 :     ensureAlive();
    1492           0 :     return SC_MOD()->GetColorConfig().GetColorValue( ::svtools::DOCCOLOR ).nColor;
    1493             : }
    1494             : 
    1495             : // XAccessibleContext -----------------------------------------------------
    1496             : 
    1497           0 : sal_Int32 SAL_CALL ScAccessibleCsvCell::getAccessibleChildCount() throw( RuntimeException )
    1498             : {
    1499           0 :     return AccessibleStaticTextBase::getAccessibleChildCount();
    1500             : }
    1501             : 
    1502           0 : Reference< XAccessible > SAL_CALL ScAccessibleCsvCell::getAccessibleChild( sal_Int32 nIndex )
    1503             :         throw( IndexOutOfBoundsException, RuntimeException )
    1504             : {
    1505           0 :     return AccessibleStaticTextBase::getAccessibleChild( nIndex );
    1506             : }
    1507             : 
    1508           0 : sal_Int32 SAL_CALL ScAccessibleCsvCell::getAccessibleIndexInParent() throw( RuntimeException )
    1509             : {
    1510           0 :     SolarMutexGuard aGuard;
    1511           0 :     ensureAlive();
    1512           0 :     return mnIndex;
    1513             : }
    1514             : 
    1515           0 : Reference< XAccessibleRelationSet > SAL_CALL ScAccessibleCsvCell::getAccessibleRelationSet()
    1516             :         throw( RuntimeException )
    1517             : {
    1518           0 :     SolarMutexGuard aGuard;
    1519           0 :     ensureAlive();
    1520           0 :     return new AccessibleRelationSetHelper();
    1521             : }
    1522             : 
    1523           0 : Reference< XAccessibleStateSet > SAL_CALL ScAccessibleCsvCell::getAccessibleStateSet()
    1524             :         throw( RuntimeException )
    1525             : {
    1526           0 :     SolarMutexGuard aGuard;
    1527           0 :     AccessibleStateSetHelper* pStateSet = implCreateStateSet();
    1528           0 :     if( implIsAlive() )
    1529             :     {
    1530           0 :         const ScCsvGrid& rGrid = implGetGrid();
    1531           0 :         pStateSet->AddState( AccessibleStateType::SINGLE_LINE );
    1532           0 :         if( mnColumn != CSV_COLUMN_HEADER )
    1533           0 :             pStateSet->AddState( AccessibleStateType::SELECTABLE );
    1534           0 :         if( rGrid.HasFocus() && (rGrid.GetFocusColumn() == mnColumn) && (mnLine == CSV_LINE_HEADER) )
    1535           0 :             pStateSet->AddState( AccessibleStateType::ACTIVE );
    1536           0 :         if( rGrid.IsSelected( mnColumn ) )
    1537           0 :             pStateSet->AddState( AccessibleStateType::SELECTED );
    1538             :     }
    1539           0 :     return pStateSet;
    1540             : }
    1541             : 
    1542             : // XInterface -----------------------------------------------------------------
    1543             : 
    1544           0 : IMPLEMENT_FORWARD_XINTERFACE2( ScAccessibleCsvCell, ScAccessibleCsvControl, AccessibleStaticTextBase )
    1545             : 
    1546             : // XTypeProvider --------------------------------------------------------------
    1547             : 
    1548           0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( ScAccessibleCsvCell, ScAccessibleCsvControl, AccessibleStaticTextBase )
    1549             : 
    1550             : // XServiceInfo ---------------------------------------------------------------
    1551             : 
    1552           0 : OUString SAL_CALL ScAccessibleCsvCell::getImplementationName() throw( RuntimeException )
    1553             : {
    1554           0 :     return OUString( CELL_IMPL_NAME );
    1555             : }
    1556             : 
    1557             : // helpers --------------------------------------------------------------------
    1558             : 
    1559           0 : Rectangle ScAccessibleCsvCell::GetBoundingBoxOnScreen() const throw( RuntimeException )
    1560             : {
    1561           0 :     SolarMutexGuard aGuard;
    1562           0 :     ensureAlive();
    1563           0 :     Rectangle aRect( implGetBoundingBox() );
    1564           0 :     aRect.SetPos( implGetAbsPos( aRect.TopLeft() ) );
    1565           0 :     return aRect;
    1566             : }
    1567             : 
    1568           0 : Rectangle ScAccessibleCsvCell::GetBoundingBox() const throw( RuntimeException )
    1569             : {
    1570           0 :     SolarMutexGuard aGuard;
    1571           0 :     ensureAlive();
    1572           0 :     return implGetBoundingBox();
    1573             : }
    1574             : 
    1575           0 : OUString SAL_CALL ScAccessibleCsvCell::createAccessibleName() throw( RuntimeException )
    1576             : {
    1577           0 :     return maCellText;
    1578             : }
    1579             : 
    1580           0 : OUString SAL_CALL ScAccessibleCsvCell::createAccessibleDescription() throw( RuntimeException )
    1581             : {
    1582           0 :     return OUString();
    1583             : }
    1584             : 
    1585           0 : ScCsvGrid& ScAccessibleCsvCell::implGetGrid() const
    1586             : {
    1587           0 :     return static_cast< ScCsvGrid& >( implGetControl() );
    1588             : }
    1589             : 
    1590           0 : Point ScAccessibleCsvCell::implGetRealPos() const
    1591             : {
    1592           0 :     ScCsvGrid& rGrid = implGetGrid();
    1593             :     return Point(
    1594           0 :         (mnColumn == CSV_COLUMN_HEADER) ? rGrid.GetHdrX() : rGrid.GetColumnX( mnColumn ),
    1595           0 :         (mnLine == CSV_LINE_HEADER) ? 0 : rGrid.GetY( mnLine ) );
    1596             : }
    1597             : 
    1598           0 : sal_uInt32 ScAccessibleCsvCell::implCalcPixelWidth(sal_uInt32 nChars) const
    1599             : {
    1600           0 :     ScCsvGrid& rGrid = implGetGrid();
    1601           0 :     return rGrid.GetCharWidth() * nChars;
    1602             : }
    1603             : 
    1604           0 : Size ScAccessibleCsvCell::implGetRealSize() const
    1605             : {
    1606           0 :     ScCsvGrid& rGrid = implGetGrid();
    1607             :     return Size(
    1608           0 :         (mnColumn == CSV_COLUMN_HEADER) ? rGrid.GetHdrWidth() : implCalcPixelWidth( rGrid.GetColumnWidth( mnColumn ) ),
    1609           0 :         (mnLine == CSV_LINE_HEADER) ? rGrid.GetHdrHeight() : rGrid.GetLineHeight() );
    1610             : }
    1611             : 
    1612           0 : Rectangle ScAccessibleCsvCell::implGetBoundingBox() const
    1613             : {
    1614           0 :     ScCsvGrid& rGrid = implGetGrid();
    1615           0 :     Rectangle aClipRect( Point( 0, 0 ), rGrid.GetSizePixel() );
    1616           0 :     if( mnColumn != CSV_COLUMN_HEADER )
    1617             :     {
    1618           0 :         aClipRect.Left() = rGrid.GetFirstX();
    1619           0 :         aClipRect.Right() = rGrid.GetLastX();
    1620             :     }
    1621           0 :     if( mnLine != CSV_LINE_HEADER )
    1622           0 :          aClipRect.Top() = rGrid.GetHdrHeight();
    1623             : 
    1624           0 :     Rectangle aRect( implGetRealPos(), implGetRealSize() );
    1625           0 :     aRect.Intersection( aClipRect );
    1626           0 :     if( (aRect.GetWidth() <= 0) || (aRect.GetHeight() <= 0) )
    1627           0 :         aRect.SetSize( Size( -1, -1 ) );
    1628           0 :     return aRect;
    1629             : }
    1630             : 
    1631             : SAL_WNODEPRECATED_DECLARATIONS_PUSH
    1632           0 : ::std::auto_ptr< SvxEditSource > ScAccessibleCsvCell::implCreateEditSource()
    1633             : {
    1634           0 :     ScCsvGrid& rGrid = implGetGrid();
    1635           0 :     Rectangle aBoundRect( implGetBoundingBox() );
    1636           0 :     aBoundRect -= implGetRealPos();
    1637             : 
    1638             :     ::std::auto_ptr< ScAccessibleTextData > pCsvTextData( new ScAccessibleCsvTextData(
    1639           0 :         &rGrid, rGrid.GetEditEngine(), maCellText, aBoundRect, implGetRealSize() ) );
    1640             : 
    1641           0 :     ::std::auto_ptr< SvxEditSource > pEditSource( new ScAccessibilityEditSource( pCsvTextData ) );
    1642           0 :     return pEditSource;
    1643             : }
    1644          93 : SAL_WNODEPRECATED_DECLARATIONS_POP
    1645             : 
    1646             : // ============================================================================
    1647             : 
    1648             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10