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