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