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