LibreOffice Module sc (master) 1
AccessibleCsvControl.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <memory>
21#include <sal/config.h>
22
23#include <utility>
24
26#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
27#include <com/sun/star/accessibility/AccessibleStateType.hpp>
28#include <com/sun/star/accessibility/AccessibleEventId.hpp>
29#include <com/sun/star/accessibility/AccessibleTextType.hpp>
30#include <com/sun/star/accessibility/AccessibleTableModelChange.hpp>
31#include <com/sun/star/accessibility/AccessibleTableModelChangeType.hpp>
32#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
35#include <scitems.hxx>
36#include <editeng/fontitem.hxx>
37#include <editeng/fhgtitem.hxx>
38#include <editeng/langitem.hxx>
39#include <csvtablebox.hxx>
40#include <csvcontrol.hxx>
41#include <csvruler.hxx>
42#include <csvgrid.hxx>
43#include <AccessibleText.hxx>
44#include <editsrc.hxx>
45#include <scresid.hxx>
46#include <strings.hrc>
47#include <scmod.hxx>
48#include <svtools/colorcfg.hxx>
49#include <vcl/svapp.hxx>
50#include <vcl/settings.hxx>
51
52using ::utl::AccessibleRelationSetHelper;
53using ::accessibility::AccessibleStaticTextBase;
54using ::com::sun::star::uno::Any;
55using ::com::sun::star::uno::Reference;
56using ::com::sun::star::uno::Sequence;
57using ::com::sun::star::uno::RuntimeException;
58using ::com::sun::star::uno::XInterface;
59using ::com::sun::star::lang::IndexOutOfBoundsException;
60using ::com::sun::star::beans::PropertyValue;
61using namespace ::com::sun::star::accessibility;
62
65
68
70 : mpControl(&rControl)
71{
72}
73
75{
76 ensureDisposed();
77}
78
80{
81 SolarMutexGuard aGuard;
82 mpControl = nullptr;
83 comphelper::OAccessibleComponentHelper::disposing();
84}
85
86// XAccessibleComponent -------------------------------------------------------
87
88Reference< XAccessible > SAL_CALL ScAccessibleCsvControl::getAccessibleAtPoint( const css::awt::Point& /* rPoint */ )
89{
90 ensureAlive();
91 return nullptr;
92}
93
95{
96 SolarMutexGuard aGuard;
97 ensureAlive();
99}
100
101// events ---------------------------------------------------------------------
102
104{
105 Any aOldAny, aNewAny;
106 if (bFocused)
107 aNewAny <<= AccessibleStateType::FOCUSED;
108 else
109 aOldAny <<= AccessibleStateType::FOCUSED;
110 NotifyAccessibleEvent(AccessibleEventId::STATE_CHANGED, aOldAny, aNewAny);
111}
112
114{
115 OSL_FAIL( "ScAccessibleCsvControl::SendCaretEvent - Illegal call" );
116}
117
119{
120 NotifyAccessibleEvent(AccessibleEventId::VISIBLE_DATA_CHANGED, Any(), Any());
121}
122
124{
125 NotifyAccessibleEvent(AccessibleEventId::SELECTION_CHANGED, Any(), Any());
126}
127
128void ScAccessibleCsvControl::SendTableUpdateEvent( sal_uInt32 /* nFirstColumn */, sal_uInt32 /* nLastColumn */, bool /* bAllRows */ )
129{
130 OSL_FAIL( "ScAccessibleCsvControl::SendTableUpdateEvent - Illegal call" );
131}
132
133void ScAccessibleCsvControl::SendInsertColumnEvent( sal_uInt32 /* nFirstColumn */, sal_uInt32 /* nLastColumn */ )
134{
135 OSL_FAIL( "ScAccessibleCsvControl::SendInsertColumnEvent - Illegal call" );
136}
137
138void ScAccessibleCsvControl::SendRemoveColumnEvent( sal_uInt32 /* nFirstColumn */, sal_uInt32 /* nLastColumn */ )
139{
140 OSL_FAIL( "ScAccessibleCsvControl::SendRemoveColumnEvent - Illegal call" );
141}
142
143// helpers --------------------------------------------------------------------
144
146{
147 SolarMutexGuard aGuard;
148 ensureAlive();
149 Size aOutSize(implGetControl().GetOutputSizePixel());
150 return css::awt::Rectangle(0, 0, aOutSize.Width(), aOutSize.Height());
151}
152
154{
155 assert(mpControl && "ScAccessibleCsvControl::implGetControl - missing control");
156 return *mpControl;
157}
158
160{
161 SolarMutexGuard aGuard;
162 sal_Int64 nStateSet = 0;
163 if (isAlive())
164 {
165 const ScCsvControl& rCtrl = implGetControl();
166 nStateSet |= AccessibleStateType::OPAQUE;
167 if( rCtrl.IsEnabled() )
168 nStateSet |= AccessibleStateType::ENABLED;
169 if( rCtrl.IsReallyVisible() )
170 nStateSet |= AccessibleStateType::SHOWING;
171 if( rCtrl.IsVisible() )
172 nStateSet |= AccessibleStateType::VISIBLE;
173 }
174 else
175 nStateSet |= AccessibleStateType::DEFUNC;
176 return nStateSet;
177}
178
179// Ruler ======================================================================
180
182static sal_Int32 lcl_GetApiPos( sal_Int32 nRulerPos )
183{
184 sal_Int32 nApiPos = nRulerPos;
185 sal_Int32 nStart = (nRulerPos - 1) / 10;
186 sal_Int32 nExp = 1;
187 while( nStart >= nExp )
188 {
189 nApiPos += nStart - nExp + 1;
190 nExp *= 10;
191 }
192 return ::std::max( nApiPos, static_cast<sal_Int32>(0) );
193}
194
196static sal_Int32 lcl_GetRulerPos( sal_Int32 nApiPos )
197{
198 sal_Int32 nDiv = 10;
199 sal_Int32 nExp = 10;
200 sal_Int32 nRulerPos = 0;
201 sal_Int32 nApiBase = 0;
202 sal_Int32 nApiLimit = 10;
203 while( nApiPos >= nApiLimit )
204 {
205 ++nDiv;
206 nRulerPos = nExp;
207 nExp *= 10;
208 nApiBase = nApiLimit;
209 nApiLimit = lcl_GetApiPos( nExp );
210 }
211 sal_Int32 nRelPos = nApiPos - nApiBase;
212 return nRulerPos + nRelPos / nDiv * 10 + ::std::max<sal_Int32>( nRelPos % nDiv - nDiv + 10, 0 );
213}
214
216static sal_Int32 lcl_ExpandSequence( Sequence< PropertyValue >& rSeq, sal_Int32 nExp )
217{
218 OSL_ENSURE( nExp > 0, "lcl_ExpandSequence - invalid value" );
219 rSeq.realloc( rSeq.getLength() + nExp );
220 return rSeq.getLength() - nExp;
221}
222
224static void lcl_FillProperty( PropertyValue& rVal, const OUString& rPropName, const SfxPoolItem& rItem, sal_uInt8 nMID )
225{
226 rVal.Name = rPropName;
227 rItem.QueryValue( rVal.Value, nMID );
228}
229
231static void lcl_FillFontAttributes( Sequence< PropertyValue >& rSeq, const vcl::Font& rFont )
232{
233 SvxFontItem aFontItem( rFont.GetFamilyType(), rFont.GetFamilyName(), rFont.GetStyleName(), rFont.GetPitch(), rFont.GetCharSet(), ATTR_FONT );
234 SvxFontHeightItem aHeightItem( rFont.GetFontSize().Height(), 100, ATTR_FONT_HEIGHT );
235 SvxLanguageItem aLangItem( rFont.GetLanguage(), ATTR_FONT_LANGUAGE );
236
237 sal_Int32 nIndex = lcl_ExpandSequence( rSeq, 7 );
238 auto pSeq = rSeq.getArray();
239 lcl_FillProperty( pSeq[ nIndex++ ], "CharFontName", aFontItem, MID_FONT_FAMILY_NAME );
240 lcl_FillProperty( pSeq[ nIndex++ ], "CharFontFamily", aFontItem, MID_FONT_FAMILY );
241 lcl_FillProperty( pSeq[ nIndex++ ], "CharFontStyleName", aFontItem, MID_FONT_STYLE_NAME );
242 lcl_FillProperty( pSeq[ nIndex++ ], "CharFontCharSet", aFontItem, MID_FONT_PITCH );
243 lcl_FillProperty( pSeq[ nIndex++ ], "CharFontPitch", aFontItem, MID_FONT_CHAR_SET );
244 lcl_FillProperty( pSeq[ nIndex++ ], "CharHeight", aHeightItem, MID_FONTHEIGHT );
245 lcl_FillProperty( pSeq[ nIndex++ ], "CharLocale", aLangItem, MID_LANG_LOCALE );
246}
247
249 : ImplInheritanceHelper(rRuler)
250{
252}
253
255{
256 ensureDisposed();
257}
258
259// XAccessibleComponent -----------------------------------------------------
260
262{
263 SolarMutexGuard aGuard;
264 ensureAlive();
265 return sal_Int32(Application::GetSettings().GetStyleSettings().GetLabelTextColor());
266}
267
269{
270 SolarMutexGuard aGuard;
271 ensureAlive();
272 return sal_Int32(Application::GetSettings().GetStyleSettings().GetFaceColor());
273}
274
275// XAccessibleContext ---------------------------------------------------------
276
278{
279 ensureAlive();
280 return 0;
281}
282
283Reference< XAccessible > SAL_CALL ScAccessibleCsvRuler::getAccessibleChild( sal_Int64 /* nIndex */ )
284{
285 ensureAlive();
286 throw IndexOutOfBoundsException();
287}
288
289Reference< XAccessibleRelationSet > SAL_CALL ScAccessibleCsvRuler::getAccessibleRelationSet()
290{
291 SolarMutexGuard aGuard;
292 ensureAlive();
293 rtl::Reference<AccessibleRelationSetHelper> pRelationSet = new AccessibleRelationSetHelper();
294
295 ScCsvRuler& rRuler = implGetRuler();
296 ScCsvTableBox* pTableBox = rRuler.GetTableBox();
297 ScCsvGrid& rGrid = pTableBox->GetGrid();
298
299 css::uno::Reference<css::accessibility::XAccessible> xAccObj(static_cast<ScAccessibleCsvGrid*>(rGrid.GetAccessible()));
300 if( xAccObj.is() )
301 {
302 Sequence< Reference< XInterface > > aSeq{ xAccObj };
303 pRelationSet->AddRelation( AccessibleRelation( AccessibleRelationType::CONTROLLER_FOR, aSeq ) );
304 }
305
306 return pRelationSet;
307}
308
310{
311 SolarMutexGuard aGuard;
312 sal_Int64 nStateSet = implCreateStateSet();
313 if( isAlive() )
314 {
315 nStateSet |= AccessibleStateType::FOCUSABLE;
316 nStateSet |= AccessibleStateType::SINGLE_LINE;
317 if( implGetRuler().HasFocus() )
318 nStateSet |= AccessibleStateType::FOCUSED;
319 }
320 return nStateSet;
321}
322
323// XAccessibleText ------------------------------------------------------------
324
326{
327 SolarMutexGuard aGuard;
328 ensureAlive();
329 return lcl_GetApiPos( implGetRuler().GetRulerCursorPos() );
330}
331
333{
334 SolarMutexGuard aGuard;
335 ensureAlive();
337 ScCsvRuler& rRuler = implGetRuler();
338 sal_Int32 nOldCursor = rRuler.GetRulerCursorPos();
340 return rRuler.GetRulerCursorPos() != nOldCursor;
341}
342
344{
345 SolarMutexGuard aGuard;
346 ensureAlive();
348 return maBuffer[nIndex];
349}
350
351Sequence< PropertyValue > SAL_CALL ScAccessibleCsvRuler::getCharacterAttributes( sal_Int32 nIndex,
352 const css::uno::Sequence< OUString >& /* aRequestedAttributes */ )
353{
354 SolarMutexGuard aGuard;
355 ensureAlive();
357 Sequence< PropertyValue > aSeq;
358 lcl_FillFontAttributes( aSeq, implGetRuler().GetDrawingArea()->get_ref_device().GetFont() );
359 return aSeq;
360}
361
362css::awt::Rectangle SAL_CALL ScAccessibleCsvRuler::getCharacterBounds( sal_Int32 nIndex )
363{
364 SolarMutexGuard aGuard;
365 ensureAlive();
367 ScCsvRuler& rRuler = implGetRuler();
368 Point aPos( rRuler.GetX( lcl_GetRulerPos( nIndex ) ) - rRuler.GetCharWidth() / 2, 0 );
369 css::awt::Rectangle aRect( aPos.X(), aPos.Y(), rRuler.GetCharWidth(), rRuler.GetOutputSizePixel().Height() );
370 // do not return rectangle out of window
371 sal_Int32 nWidth = rRuler.GetOutputSizePixel().Width();
372 if( aRect.X >= nWidth )
373 throw IndexOutOfBoundsException();
374 if( aRect.X + aRect.Width > nWidth )
375 aRect.Width = nWidth - aRect.X;
376 return aRect;
377}
378
380{
381 SolarMutexGuard aGuard;
382 ensureAlive();
383 return implGetTextLength();
384}
385
386sal_Int32 SAL_CALL ScAccessibleCsvRuler::getIndexAtPoint( const css::awt::Point& rPoint )
387{
388 SolarMutexGuard aGuard;
389 ensureAlive();
390 ScCsvRuler& rRuler = implGetRuler();
391 // use object's coordinate system, convert to API position
392 return lcl_GetApiPos( ::std::clamp( rRuler.GetPosFromX( rPoint.X ), sal_Int32(0), rRuler.GetPosCount() ) );
393}
394
396{
397 ensureAlive();
398 return OUString();
399}
400
402{
403 ensureAlive();
404 return -1;
405}
406
408{
409 ensureAlive();
410 return -1;
411}
412
413sal_Bool SAL_CALL ScAccessibleCsvRuler::setSelection( sal_Int32 /* nStartIndex */, sal_Int32 /* nEndIndex */ )
414{
415 ensureAlive();
416 return false;
417}
418
420{
421 SolarMutexGuard aGuard;
422 ensureAlive();
423 return OUString( maBuffer.getStr(), implGetTextLength() );
424}
425
426OUString SAL_CALL ScAccessibleCsvRuler::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
427{
428 SolarMutexGuard aGuard;
429 ensureAlive();
430 ensureValidRange( nStartIndex, nEndIndex );
431 return OUString( maBuffer.getStr() + nStartIndex, nEndIndex - nStartIndex );
432}
433
434TextSegment SAL_CALL ScAccessibleCsvRuler::getTextAtIndex( sal_Int32 nIndex, sal_Int16 nTextType )
435{
436 SolarMutexGuard aGuard;
437 ensureAlive();
438
439 TextSegment aResult;
440 aResult.SegmentStart = -1;
441 aResult.SegmentEnd = -1;
442
443 if( (nIndex == implGetTextLength()) && (nTextType != AccessibleTextType::LINE) )
444 return aResult;
445
447
448 OUStringBuffer aResultText; // will be assigned to aResult.SegmentText below
449 sal_Int32 nRulerPos = lcl_GetRulerPos( nIndex );
450
451 switch( nTextType )
452 {
453 // single character
454 case AccessibleTextType::CHARACTER:
455 {
456 aResult.SegmentStart = nIndex;
457 aResultText.append(maBuffer[nIndex]);
458 }
459 break;
460
461 // entire number or single dot/line
462 case AccessibleTextType::WORD:
463 case AccessibleTextType::GLYPH:
464 aResult.SegmentStart = nIndex;
465 if( nRulerPos % 10 )
466 aResultText.append(maBuffer[nIndex]);
467 else
468 aResultText.append( nRulerPos ); // string representation of sal_Int32!!!
469 break;
470
471 // entire text
472 case AccessibleTextType::SENTENCE:
473 case AccessibleTextType::PARAGRAPH:
474 case AccessibleTextType::LINE:
475 aResult.SegmentStart = 0;
476 aResultText.append( maBuffer.getStr(), implGetTextLength() );
477 break;
478
479 // equal-formatted text
480 case AccessibleTextType::ATTRIBUTE_RUN:
481 {
482 sal_Int32 nFirstIndex = implGetFirstEqualFormatted( nIndex );
483 sal_Int32 nLastIndex = implGetLastEqualFormatted( nIndex );
484 aResult.SegmentStart = nFirstIndex;
485 aResultText.append( maBuffer.getStr() + nFirstIndex, nLastIndex - nFirstIndex + 1 );
486 }
487 break;
488
489 default:
490 throw RuntimeException();
491 }
492
493 aResult.SegmentText = aResultText.makeStringAndClear();
494 aResult.SegmentEnd = aResult.SegmentStart + aResult.SegmentText.getLength();
495 return aResult;
496}
497
498TextSegment SAL_CALL ScAccessibleCsvRuler::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 nTextType )
499{
500 SolarMutexGuard aGuard;
501 ensureAlive();
503
504 TextSegment aResult;
505 aResult.SegmentStart = -1;
506 aResult.SegmentEnd = -1;
507
508 sal_Int32 nRulerPos = lcl_GetRulerPos( nIndex );
509
510 switch( nTextType )
511 {
512 // single character
513 case AccessibleTextType::CHARACTER:
514 if( nIndex > 0 )
515 aResult = getTextAtIndex( nIndex - 1, nTextType );
516 // else empty
517 break;
518
519 // entire number or single dot/line
520 case AccessibleTextType::WORD:
521 case AccessibleTextType::GLYPH:
522 if( nRulerPos > 0 )
523 aResult = getTextAtIndex( lcl_GetApiPos( nRulerPos - 1 ), nTextType );
524 // else empty
525 break;
526
527 // entire text
528 case AccessibleTextType::SENTENCE:
529 case AccessibleTextType::PARAGRAPH:
530 case AccessibleTextType::LINE:
531 // empty
532 break;
533
534 // equal-formatted text
535 case AccessibleTextType::ATTRIBUTE_RUN:
536 {
537 sal_Int32 nFirstIndex = implGetFirstEqualFormatted( nIndex );
538 if( nFirstIndex > 0 )
539 aResult = getTextAtIndex( nFirstIndex - 1, nTextType );
540 // else empty
541 }
542 break;
543
544 default:
545 throw RuntimeException();
546 }
547 return aResult;
548}
549
550TextSegment SAL_CALL ScAccessibleCsvRuler::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 nTextType )
551{
552 SolarMutexGuard aGuard;
553 ensureAlive();
555
556 TextSegment aResult;
557 aResult.SegmentStart = -1;
558 aResult.SegmentEnd = -1;
559
560 sal_Int32 nRulerPos = lcl_GetRulerPos( nIndex );
561 sal_Int32 nLastValid = implGetTextLength();
562
563 switch( nTextType )
564 {
565 // single character
566 case AccessibleTextType::CHARACTER:
567 if( nIndex < nLastValid )
568 aResult = getTextAtIndex( nIndex + 1, nTextType );
569 // else empty
570 break;
571
572 // entire number or single dot/line
573 case AccessibleTextType::WORD:
574 case AccessibleTextType::GLYPH:
575 if( nRulerPos < implGetRuler().GetPosCount() )
576 aResult = getTextAtIndex( lcl_GetApiPos( nRulerPos + 1 ), nTextType );
577 // else empty
578 break;
579
580 // entire text
581 case AccessibleTextType::SENTENCE:
582 case AccessibleTextType::PARAGRAPH:
583 case AccessibleTextType::LINE:
584 // empty
585 break;
586
587 // equal-formatted text
588 case AccessibleTextType::ATTRIBUTE_RUN:
589 {
590 sal_Int32 nLastIndex = implGetLastEqualFormatted( nIndex );
591 if( nLastIndex < nLastValid )
592 aResult = getTextAtIndex( nLastIndex + 1, nTextType );
593 // else empty
594 }
595 break;
596
597 default:
598 throw RuntimeException();
599 }
600 return aResult;
601}
602
603sal_Bool SAL_CALL ScAccessibleCsvRuler::copyText( sal_Int32 /* nStartIndex */, sal_Int32 /* nEndIndex */ )
604{
605 ensureAlive();
606 return false;
607}
608
609sal_Bool SAL_CALL ScAccessibleCsvRuler::scrollSubstringTo( sal_Int32 /* nStartIndex */, sal_Int32/* nEndIndex */, AccessibleScrollType /* aScrollType */ )
610{
611 return false;
612}
613
614// events ---------------------------------------------------------------------
615
617{
618 sal_Int32 nPos = implGetRuler().GetRulerCursorPos();
619 if (nPos != CSV_POS_INVALID)
620 {
621 Any aOldValue, aNewValue;
622 aNewValue <<= nPos;
623 NotifyAccessibleEvent( AccessibleEventId::CARET_CHANGED, aOldValue, aNewValue );
624 }
625}
626
627// helpers --------------------------------------------------------------------
628
630{
631 return ScResId( STR_ACC_CSVRULER_NAME );
632}
633
635{
636 return ScResId( STR_ACC_CSVRULER_DESCR );
637}
638
639void ScAccessibleCsvRuler::ensureValidIndex( sal_Int32 nIndex ) const
640{
641 if( (nIndex < 0) || (nIndex >= implGetTextLength()) )
642 throw IndexOutOfBoundsException();
643}
644
646{
647 if( (nIndex < 0) || (nIndex > implGetTextLength()) )
648 throw IndexOutOfBoundsException();
649}
650
651void ScAccessibleCsvRuler::ensureValidRange( sal_Int32& rnStartIndex, sal_Int32& rnEndIndex ) const
652{
653 if( rnStartIndex > rnEndIndex )
654 ::std::swap( rnStartIndex, rnEndIndex );
655 if( (rnStartIndex < 0) || (rnEndIndex > implGetTextLength()) )
656 throw IndexOutOfBoundsException();
657}
658
660{
661 return static_cast< ScCsvRuler& >( implGetControl() );
662}
663
665{
666 SolarMutexGuard aGuard;
667 ensureAlive();
668 // extend existing string buffer to new ruler size
669 sal_Int32 nRulerCount = implGetRuler().GetPosCount();
670 sal_Int32 nRulerPos = lcl_GetRulerPos( maBuffer.getLength() );
671 for( ; nRulerPos <= nRulerCount; ++nRulerPos ) // include last position
672 {
673 switch( nRulerPos % 10 )
674 {
675 case 0: maBuffer.append( nRulerPos ); break;
676 case 5: maBuffer.append( cRulerLine ); break;
677 default: maBuffer.append( cRulerDot );
678 }
679 }
680}
681
683{
684 return lcl_GetApiPos( implGetRuler().GetPosCount() + 1 );
685}
686
687bool ScAccessibleCsvRuler::implHasSplit( sal_Int32 nApiPos )
688{
689 sal_Int32 nRulerPos = lcl_GetRulerPos( nApiPos );
690 return implGetRuler().HasSplit( nRulerPos ) && (nApiPos == lcl_GetApiPos( nRulerPos ));
691}
692
694{
695 bool bSplit = implHasSplit( nApiPos );
696 while( (nApiPos > 0) && (implHasSplit( nApiPos - 1 ) == bSplit) )
697 --nApiPos;
698 return nApiPos;
699}
700
702{
703 bool bSplit = implHasSplit( nApiPos );
704 sal_Int32 nLength = implGetTextLength();
705 while( (nApiPos < nLength - 1) && (implHasSplit( nApiPos + 1 ) == bSplit) )
706 ++nApiPos;
707 return nApiPos;
708}
709
710css::uno::Reference<css::accessibility::XAccessible> SAL_CALL ScAccessibleCsvRuler::getAccessibleParent()
711{
712 return implGetControl().GetDrawingArea()->get_accessible_parent();
713}
714
715// Grid =======================================================================
716
718static sal_Int32 lcl_GetApiColumn( sal_uInt32 nGridColumn )
719{
720 return (nGridColumn != CSV_COLUMN_HEADER) ? static_cast< sal_Int32 >( nGridColumn + 1 ) : 0;
721}
722
724static sal_uInt32 lcl_GetGridColumn( sal_Int32 nApiColumn )
725{
726 return (nApiColumn > 0) ? static_cast< sal_uInt32 >( nApiColumn - 1 ) : CSV_COLUMN_HEADER;
727}
728
730 : ImplInheritanceHelper(rGrid)
731{
732}
733
735{
736 ensureDisposed();
737}
738
740{
741 SolarMutexGuard aGuard;
742 for (auto& rEntry : maAccessibleChildren)
743 rEntry.second->dispose();
744 maAccessibleChildren.clear();
746}
747
748// XAccessibleComponent -------------------------------------------------------
749
750Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getAccessibleAtPoint( const css::awt::Point& rPoint )
751{
752 Reference< XAccessible > xRet;
753 if( containsPoint( rPoint ) )
754 {
755 SolarMutexGuard aGuard;
756 ensureAlive();
757
758 const ScCsvGrid& rGrid = implGetGrid();
759 // #102679#; use <= instead of <, because the offset is the size and not the point
760 sal_Int32 nColumn = ((rGrid.GetFirstX() <= rPoint.X) && (rPoint.X <= rGrid.GetLastX())) ?
761 lcl_GetApiColumn( rGrid.GetColumnFromX( rPoint.X ) ) : 0;
762 sal_Int32 nRow = (rPoint.Y >= rGrid.GetHdrHeight()) ?
763 (rGrid.GetLineFromY( rPoint.Y ) - rGrid.GetFirstVisLine() + 1) : 0;
764 xRet = getAccessibleCell(nRow, nColumn);
765 }
766 return xRet;
767}
768
770{
771 SolarMutexGuard aGuard;
772 ensureAlive();
773 return sal_Int32(Application::GetSettings().GetStyleSettings().GetButtonTextColor());
774}
775
777{
778 SolarMutexGuard aGuard;
779 ensureAlive();
780 return sal_Int32(SC_MOD()->GetColorConfig().GetColorValue( ::svtools::DOCCOLOR ).nColor);
781}
782
783// XAccessibleContext ---------------------------------------------------------
784
786{
787 SolarMutexGuard aGuard;
788 ensureAlive();
789 return implGetCellCount();
790}
791
792Reference<XAccessible> ScAccessibleCsvGrid::getAccessibleCell(sal_Int32 nRow, sal_Int32 nColumn)
793{
794 sal_Int64 nIndex = implGetIndex(nRow, nColumn);
795
796 XAccessibleSet::iterator aI = maAccessibleChildren.lower_bound(nIndex);
797 if (aI != maAccessibleChildren.end() && !(maAccessibleChildren.key_comp()(nIndex, aI->first)))
798 {
799 // key already exists
800 return aI->second;
801 }
802 // key does not exist
804 maAccessibleChildren.insert(aI, XAccessibleSet::value_type(nIndex, xNew));
805 return xNew;
806}
807
808Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getAccessibleChild( sal_Int64 nIndex )
809{
810 SolarMutexGuard aGuard;
811 ensureAlive();
813
815}
816
817Reference< XAccessibleRelationSet > SAL_CALL ScAccessibleCsvGrid::getAccessibleRelationSet()
818{
819 SolarMutexGuard aGuard;
820 ensureAlive();
821 rtl::Reference<AccessibleRelationSetHelper> pRelationSet = new AccessibleRelationSetHelper();
822
823 ScCsvGrid& rGrid = implGetGrid();
824 ScCsvTableBox* pTableBox = rGrid.GetTableBox();
825 ScCsvRuler& rRuler = pTableBox->GetRuler();
826
827 if (rRuler.IsVisible())
828 {
829 css::uno::Reference<css::accessibility::XAccessible> xAccObj(static_cast<ScAccessibleCsvGrid*>(rRuler.GetAccessible()));
830 if( xAccObj.is() )
831 {
832 Sequence< Reference< XInterface > > aSeq{ xAccObj };
833 pRelationSet->AddRelation( AccessibleRelation( AccessibleRelationType::CONTROLLED_BY, aSeq ) );
834 }
835 }
836
837 return pRelationSet;
838}
839
841{
842 SolarMutexGuard aGuard;
843 sal_Int64 nStateSet = implCreateStateSet();
844 if( isAlive() )
845 {
846 nStateSet |= AccessibleStateType::FOCUSABLE;
847 nStateSet |= AccessibleStateType::MULTI_SELECTABLE;
848 nStateSet |= AccessibleStateType::MANAGES_DESCENDANTS;
849 if( implGetGrid().HasFocus() )
850 nStateSet |= AccessibleStateType::FOCUSED;
851 }
852 else
853 nStateSet |= AccessibleStateType::DEFUNC;
854 return nStateSet;
855}
856
857// XAccessibleTable -----------------------------------------------------------
858
860{
861 SolarMutexGuard aGuard;
862 ensureAlive();
863 return implGetRowCount();
864}
865
867{
868 SolarMutexGuard aGuard;
869 ensureAlive();
870 return implGetColumnCount();
871}
872
873OUString SAL_CALL ScAccessibleCsvGrid::getAccessibleRowDescription( sal_Int32 nRow )
874{
875 SolarMutexGuard aGuard;
876 ensureAlive();
877 ensureValidPosition( nRow, 0 );
878 return implGetCellText( nRow, 0 );
879}
880
881OUString SAL_CALL ScAccessibleCsvGrid::getAccessibleColumnDescription( sal_Int32 nColumn )
882{
883 SolarMutexGuard aGuard;
884 ensureAlive();
885 ensureValidPosition( 0, nColumn );
886 return implGetCellText( 0, nColumn );
887}
888
889sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
890{
891 ensureAlive();
892 ensureValidPosition( nRow, nColumn );
893 return 1;
894}
895
896sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
897{
898 ensureAlive();
899 ensureValidPosition( nRow, nColumn );
900 return 1;
901}
902
903Reference< XAccessibleTable > SAL_CALL ScAccessibleCsvGrid::getAccessibleRowHeaders()
904{
905 ensureAlive();
906 return nullptr;
907}
908
909Reference< XAccessibleTable > SAL_CALL ScAccessibleCsvGrid::getAccessibleColumnHeaders()
910{
911 ensureAlive();
912 return nullptr;
913}
914
916{
917 ensureAlive();
918 return Sequence< sal_Int32 >();
919}
920
922{
923 SolarMutexGuard aGuard;
924 ensureAlive();
925
926 ScCsvGrid& rGrid = implGetGrid();
927 Sequence< sal_Int32 > aSeq( implGetColumnCount() );
928 auto pSeq = aSeq.getArray();
929
930 sal_Int32 nSeqIx = 0;
931 sal_uInt32 nColIx = rGrid.GetFirstSelected();
932 for( ; nColIx != CSV_COLUMN_INVALID; ++nSeqIx, nColIx = rGrid.GetNextSelected( nColIx ) )
933 pSeq[ nSeqIx ] = lcl_GetApiColumn( nColIx );
934
935 aSeq.realloc( nSeqIx );
936 return aSeq;
937}
938
940{
941 ensureAlive();
942 return false;
943}
944
946{
947 SolarMutexGuard aGuard;
948 ensureAlive();
949 ensureValidIndex( nColumn );
950 return implIsColumnSelected( nColumn );
951}
952
953Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn )
954{
955 SolarMutexGuard aGuard;
956 ensureAlive();
957 ensureValidPosition( nRow, nColumn );
958 return getAccessibleCell(nRow, nColumn);
959}
960
961Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getAccessibleCaption()
962{
963 ensureAlive();
964 return nullptr;
965}
966
967Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getAccessibleSummary()
968{
969 ensureAlive();
970 return nullptr;
971}
972
973sal_Bool SAL_CALL ScAccessibleCsvGrid::isAccessibleSelected( sal_Int32 /* nRow */, sal_Int32 nColumn )
974{
975 return isAccessibleColumnSelected( nColumn );
976}
977
978sal_Int64 SAL_CALL ScAccessibleCsvGrid::getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn )
979{
980 SolarMutexGuard aGuard;
981 ensureAlive();
982 ensureValidPosition( nRow, nColumn );
983 return implGetIndex( nRow, nColumn );
984}
985
986sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleRow( sal_Int64 nChildIndex )
987{
988 SolarMutexGuard aGuard;
989 ensureAlive();
990 ensureValidIndex( nChildIndex );
991 return implGetRow( nChildIndex );
992}
993
994sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleColumn( sal_Int64 nChildIndex )
995{
996 SolarMutexGuard aGuard;
997 ensureAlive();
998 ensureValidIndex( nChildIndex );
999 return implGetColumn( nChildIndex );
1000}
1001
1002// XAccessibleSelection -------------------------------------------------------
1003
1004void SAL_CALL ScAccessibleCsvGrid::selectAccessibleChild( sal_Int64 nChildIndex )
1005{
1006 SolarMutexGuard aGuard;
1007 ensureAlive();
1008 ensureValidIndex( nChildIndex );
1009 sal_Int32 nColumn = implGetColumn( nChildIndex );
1010 if( nChildIndex == 0 )
1012 else
1013 implSelectColumn( nColumn, true );
1014}
1015
1017{
1018 SolarMutexGuard aGuard;
1019 ensureAlive();
1020 ensureValidIndex( nChildIndex );
1021 sal_Int32 nColumn = implGetColumn( nChildIndex );
1022 return implIsColumnSelected( nColumn );
1023}
1024
1026{
1027 SolarMutexGuard aGuard;
1028 ensureAlive();
1029 implGetGrid().SelectAll( false );
1030}
1031
1033{
1035}
1036
1038{
1039 SolarMutexGuard aGuard;
1040 ensureAlive();
1041 return static_cast<sal_Int64>(implGetRowCount()) * static_cast<sal_Int64>(implGetSelColumnCount());
1042}
1043
1044Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex )
1045{
1046 SolarMutexGuard aGuard;
1047 ensureAlive();
1048 sal_Int32 nColumns = implGetSelColumnCount();
1049 if( nColumns == 0 )
1050 throw IndexOutOfBoundsException();
1051
1052 sal_Int32 nRow = nSelectedChildIndex / nColumns;
1053 sal_Int32 nColumn = implGetSelColumn( nSelectedChildIndex % nColumns );
1054 return getAccessibleCellAt( nRow, nColumn );
1055}
1056
1057void SAL_CALL ScAccessibleCsvGrid::deselectAccessibleChild( sal_Int64 nSelectedChildIndex )
1058{
1059 SolarMutexGuard aGuard;
1060 ensureAlive();
1061 ensureValidIndex(nSelectedChildIndex);
1062 sal_Int32 nColumns = implGetSelColumnCount();
1063 if( nColumns == 0 )
1064 throw IndexOutOfBoundsException();
1065
1066 sal_Int32 nColumn = implGetSelColumn( nSelectedChildIndex % nColumns );
1067 ensureValidPosition( nSelectedChildIndex / nColumns, nColumn );
1068 if( nColumn > 0 )
1069 implSelectColumn( nColumn, false );
1070}
1071
1072// events ---------------------------------------------------------------------
1073
1075{
1077 Any aOldAny, aNewAny;
1078 (bFocused ? aNewAny : aOldAny) <<=
1079 getAccessibleCellAt( 0, lcl_GetApiColumn( implGetGrid().GetFocusColumn() ) );
1080 NotifyAccessibleEvent(AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldAny, aNewAny);
1081}
1082
1083void ScAccessibleCsvGrid::SendTableUpdateEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows )
1084{
1085 if( nFirstColumn <= nLastColumn )
1086 {
1087 AccessibleTableModelChange aModelChange(
1088 AccessibleTableModelChangeType::UPDATE, 0, bAllRows ? implGetRowCount() - 1 : 0,
1089 lcl_GetApiColumn( nFirstColumn ), lcl_GetApiColumn( nLastColumn ) );
1090 Any aOldAny, aNewAny;
1091 aNewAny <<= aModelChange;
1092 NotifyAccessibleEvent(AccessibleEventId::TABLE_MODEL_CHANGED, aOldAny, aNewAny);
1093 }
1094}
1095
1096void ScAccessibleCsvGrid::SendInsertColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn )
1097{
1098 if( nFirstColumn <= nLastColumn )
1099 {
1100 AccessibleTableModelChange aModelChange(
1101 AccessibleTableModelChangeType::COLUMNS_INSERTED, -1, -1,
1102 lcl_GetApiColumn( nFirstColumn ), lcl_GetApiColumn( nLastColumn ) );
1103 Any aOldAny, aNewAny;
1104 aNewAny <<= aModelChange;
1105 NotifyAccessibleEvent(AccessibleEventId::TABLE_MODEL_CHANGED, aOldAny, aNewAny);
1106 }
1107}
1108
1109void ScAccessibleCsvGrid::SendRemoveColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn )
1110{
1111 if( nFirstColumn <= nLastColumn )
1112 {
1113 AccessibleTableModelChange aModelChange(
1114 AccessibleTableModelChangeType::COLUMNS_REMOVED, -1, -1,
1115 lcl_GetApiColumn( nFirstColumn ), lcl_GetApiColumn( nLastColumn ) );
1116 Any aOldAny, aNewAny;
1117 aNewAny <<= aModelChange;
1118 NotifyAccessibleEvent(AccessibleEventId::TABLE_MODEL_CHANGED, aOldAny, aNewAny);
1119 }
1120}
1121
1122// helpers --------------------------------------------------------------------
1123
1125{
1126 return ScResId( STR_ACC_CSVGRID_NAME );
1127}
1128
1130{
1131 return ScResId( STR_ACC_CSVGRID_DESCR );
1132}
1133
1134void ScAccessibleCsvGrid::ensureValidIndex( sal_Int64 nIndex ) const
1135{
1136 if( (nIndex < 0) || (nIndex >= implGetCellCount()) )
1137 throw IndexOutOfBoundsException();
1138}
1139
1140void ScAccessibleCsvGrid::ensureValidPosition( sal_Int32 nRow, sal_Int32 nColumn ) const
1141{
1142 if( (nRow < 0) || (nRow >= implGetRowCount()) || (nColumn < 0) || (nColumn >= implGetColumnCount()) )
1143 throw IndexOutOfBoundsException();
1144}
1145
1147{
1148 return static_cast< ScCsvGrid& >( implGetControl() );
1149}
1150
1151bool ScAccessibleCsvGrid::implIsColumnSelected( sal_Int32 nColumn ) const
1152{
1153 return (nColumn > 0) && implGetGrid().IsSelected( lcl_GetGridColumn( nColumn ) );
1154}
1155
1156void ScAccessibleCsvGrid::implSelectColumn( sal_Int32 nColumn, bool bSelect )
1157{
1158 if( nColumn > 0 )
1159 implGetGrid().Select( lcl_GetGridColumn( nColumn ), bSelect );
1160}
1161
1163{
1164 return static_cast< sal_Int32 >( implGetGrid().GetLastVisLine() - implGetGrid().GetFirstVisLine() + 2 );
1165}
1166
1168{
1169 return static_cast< sal_Int32 >( implGetGrid().GetColumnCount() + 1 );
1170}
1171
1173{
1174 ScCsvGrid& rGrid = implGetGrid();
1175 sal_Int32 nCount = 0;
1176 for( sal_uInt32 nColIx = rGrid.GetFirstSelected(); nColIx != CSV_COLUMN_INVALID; nColIx = rGrid.GetNextSelected( nColIx ) )
1177 ++nCount;
1178 return nCount;
1179}
1180
1181sal_Int32 ScAccessibleCsvGrid::implGetSelColumn( sal_Int32 nSelColumn ) const
1182{
1183 ScCsvGrid& rGrid = implGetGrid();
1184 sal_Int32 nColumn = 0;
1185 for( sal_uInt32 nColIx = rGrid.GetFirstSelected(); nColIx != CSV_COLUMN_INVALID; nColIx = rGrid.GetNextSelected( nColIx ) )
1186 {
1187 if( nColumn == nSelColumn )
1188 return static_cast< sal_Int32 >( nColIx + 1 );
1189 ++nColumn;
1190 }
1191 return 0;
1192}
1193
1194OUString ScAccessibleCsvGrid::implGetCellText( sal_Int32 nRow, sal_Int32 nColumn ) const
1195{
1196 ScCsvGrid& rGrid = implGetGrid();
1197 sal_Int32 nLine = nRow + rGrid.GetFirstVisLine() - 1;
1198 OUString aCellStr;
1199 if( (nColumn > 0) && (nRow > 0) )
1200 aCellStr = rGrid.GetCellText( lcl_GetGridColumn( nColumn ), nLine );
1201 else if( nRow > 0 )
1202 aCellStr = OUString::number( nLine + 1 );
1203 else if( nColumn > 0 )
1204 aCellStr = rGrid.GetColumnTypeName( lcl_GetGridColumn( nColumn ) );
1205 return aCellStr;
1206}
1207
1209{
1210 return new ScAccessibleCsvCell(implGetGrid(), implGetCellText(nRow, nColumn), nRow, nColumn);
1211}
1212
1213css::uno::Reference<css::accessibility::XAccessible> SAL_CALL ScAccessibleCsvGrid::getAccessibleParent()
1214{
1215 return implGetControl().GetDrawingArea()->get_accessible_parent();
1216}
1217
1219 ScCsvGrid& rGrid,
1220 OUString aCellText,
1221 sal_Int32 nRow, sal_Int32 nColumn ) :
1222 ImplInheritanceHelper( rGrid ),
1223 AccessibleStaticTextBase( SvxEditSourcePtr() ),
1224 maCellText(std::move( aCellText )),
1225 mnLine( nRow ? (nRow + rGrid.GetFirstVisLine() - 1) : CSV_LINE_HEADER ),
1226 mnColumn( lcl_GetGridColumn( nColumn ) ),
1227 mnIndex( nRow * (rGrid.GetColumnCount() + 1) + nColumn )
1228{
1230}
1231
1233{
1234}
1235
1237{
1238 SolarMutexGuard aGuard;
1241}
1242
1243// XAccessibleComponent -------------------------------------------------------
1244
1246{
1247 SolarMutexGuard aGuard;
1248 ensureAlive();
1249 ScCsvGrid& rGrid = implGetGrid();
1251}
1252
1254{
1255 SolarMutexGuard aGuard;
1256 ensureAlive();
1257 return sal_Int32(Application::GetSettings().GetStyleSettings().GetButtonTextColor());
1258}
1259
1261{
1262 SolarMutexGuard aGuard;
1263 ensureAlive();
1264 return sal_Int32(SC_MOD()->GetColorConfig().GetColorValue( ::svtools::DOCCOLOR ).nColor);
1265}
1266
1267// XAccessibleContext -----------------------------------------------------
1268
1270{
1271 return AccessibleStaticTextBase::getAccessibleChildCount();
1272}
1273
1274Reference< XAccessible > SAL_CALL ScAccessibleCsvCell::getAccessibleChild( sal_Int64 nIndex )
1275{
1276 return AccessibleStaticTextBase::getAccessibleChild( nIndex );
1277}
1278
1280{
1281 SolarMutexGuard aGuard;
1282 ensureAlive();
1283 return mnIndex;
1284}
1285
1286Reference< XAccessibleRelationSet > SAL_CALL ScAccessibleCsvCell::getAccessibleRelationSet()
1287{
1288 SolarMutexGuard aGuard;
1289 ensureAlive();
1290 return new AccessibleRelationSetHelper();
1291}
1292
1294{
1295 SolarMutexGuard aGuard;
1296 sal_Int64 nStateSet = implCreateStateSet();
1297 if( isAlive() )
1298 {
1299 const ScCsvGrid& rGrid = implGetGrid();
1300 nStateSet |= AccessibleStateType::SINGLE_LINE;
1302 nStateSet |= AccessibleStateType::SELECTABLE;
1303 if( rGrid.HasFocus() && (rGrid.GetFocusColumn() == mnColumn) && (mnLine == CSV_LINE_HEADER) )
1304 nStateSet |= AccessibleStateType::ACTIVE;
1305 if( rGrid.IsSelected( mnColumn ) )
1306 nStateSet |= AccessibleStateType::SELECTED;
1307 }
1308 return nStateSet;
1309}
1310
1311// XInterface -----------------------------------------------------------------
1312
1313IMPLEMENT_FORWARD_XINTERFACE2( ScAccessibleCsvCell, ImplInheritanceHelper, AccessibleStaticTextBase )
1314
1315// XTypeProvider --------------------------------------------------------------
1316
1317IMPLEMENT_FORWARD_XTYPEPROVIDER2( ScAccessibleCsvCell, ImplInheritanceHelper, AccessibleStaticTextBase )
1318
1319// helpers --------------------------------------------------------------------
1320
1321OUString SAL_CALL ScAccessibleCsvCell::getAccessibleName()
1322{
1323 return maCellText;
1324}
1325
1327{
1328 return OUString();
1329}
1330
1332{
1333 return static_cast< ScCsvGrid& >( implGetControl() );
1334}
1335
1337{
1338 ScCsvGrid& rGrid = implGetGrid();
1339 return Point(
1340 (mnColumn == CSV_COLUMN_HEADER) ? rGrid.GetHdrX() : rGrid.GetColumnX( mnColumn ),
1341 (mnLine == CSV_LINE_HEADER) ? 0 : rGrid.GetY( mnLine ) );
1342}
1343
1344sal_uInt32 ScAccessibleCsvCell::implCalcPixelWidth(sal_uInt32 nChars) const
1345{
1346 ScCsvGrid& rGrid = implGetGrid();
1347 return rGrid.GetCharWidth() * nChars;
1348}
1349
1351{
1352 ScCsvGrid& rGrid = implGetGrid();
1353 return Size(
1355 (mnLine == CSV_LINE_HEADER) ? rGrid.GetHdrHeight() : rGrid.GetLineHeight() );
1356}
1357
1359{
1360 ScCsvGrid& rGrid = implGetGrid();
1361 tools::Rectangle aClipRect( Point( 0, 0 ), rGrid.GetOutputSizePixel() );
1363 {
1364 aClipRect.SetLeft( rGrid.GetFirstX() );
1365 aClipRect.SetRight( rGrid.GetLastX() );
1366 }
1367 if( mnLine != CSV_LINE_HEADER )
1368 aClipRect.SetTop( rGrid.GetHdrHeight() );
1369
1371 aRect.Intersection( aClipRect );
1372 if( aRect.IsEmpty() )
1373 aRect.SetSize( Size( -1, -1 ) );
1374
1375 return css::awt::Rectangle(aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight());
1376}
1377
1378::std::unique_ptr< SvxEditSource > ScAccessibleCsvCell::implCreateEditSource()
1379{
1380 ScCsvGrid& rGrid = implGetGrid();
1381
1382 ::std::unique_ptr< SvxEditSource > pEditSource( new ScAccessibilityEditSource( std::make_unique<ScAccessibleCsvTextData>(&rGrid.GetDrawingArea()->get_ref_device(), rGrid.GetEditEngine(), maCellText, implGetRealSize()) ) );
1383 return pEditSource;
1384}
1385
1386css::uno::Reference<css::accessibility::XAccessible> SAL_CALL ScAccessibleCsvCell::getAccessibleParent()
1387{
1388 ScCsvGrid& rGrid = implGetGrid();
1389
1390 ScAccessibleCsvGrid* pAcc = static_cast<ScAccessibleCsvGrid*>(rGrid.GetAccessible());
1391
1392 return pAcc;
1393}
1394
1395/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static sal_Int32 lcl_GetApiPos(sal_Int32 nRulerPos)
Converts a ruler cursor position to API text index.
const sal_Unicode cRulerDot
const sal_uInt32 CSV_COLUMN_HEADER
static sal_uInt32 lcl_GetGridColumn(sal_Int32 nApiColumn)
Converts an API columnm index to a ScCsvGrid column index.
static sal_Int32 lcl_GetApiColumn(sal_uInt32 nGridColumn)
Converts a grid columnm index to an API column index.
const sal_Int32 CSV_LINE_HEADER
const sal_Unicode cRulerLine
static void lcl_FillProperty(PropertyValue &rVal, const OUString &rPropName, const SfxPoolItem &rItem, sal_uInt8 nMID)
Fills the property value rVal with the specified name and value from the item.
static sal_Int32 lcl_GetRulerPos(sal_Int32 nApiPos)
Converts an API text index to a ruler cursor position.
static sal_Int32 lcl_ExpandSequence(Sequence< PropertyValue > &rSeq, sal_Int32 nExp)
Expands the sequence's size and returns the base index of the new inserted elements.
static void lcl_FillFontAttributes(Sequence< PropertyValue > &rSeq, const vcl::Font &rFont)
Fills the sequence with all font attributes of rFont.
static const AllSettings & GetSettings()
Accessible class representing a cell of the CSV grid control.
virtual ~ScAccessibleCsvCell() override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int64 nIndex) override
Returns the specified child.
virtual sal_Int32 SAL_CALL getForeground() override
virtual OUString SAL_CALL getAccessibleDescription() override
sal_Int32 mnIndex
The grid column index (core index).
ScAccessibleCsvCell(ScCsvGrid &rGrid, OUString aCellText, sal_Int32 nRow, sal_Int32 nColumn)
The index of the cell in the table.
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override
Returns the relation to the ruler control.
Point implGetRealPos() const
Returns the pixel position of the cell (rel.
Size implGetRealSize() const
Returns the pixel size of the cell, regardless of visibility.
sal_uInt32 implCalcPixelWidth(sal_uInt32 nChars) const
Returns the width of the character count.
sal_uInt32 mnColumn
The grid line index (core index).
ScCsvGrid & implGetGrid() const
Returns the VCL grid control.
::std::unique_ptr< SvxEditSource > implCreateEditSource()
Creates the edit source the text helper needs.
virtual css::awt::Rectangle implGetBounds() override
Returns the bounding box of the cell relative in the table.
virtual void SAL_CALL grabFocus() override
Sets the focus to the column of this cell.
virtual sal_Int32 SAL_CALL getBackground() override
sal_Int32 mnLine
The text contents of this cell.
virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override
Returns the index of this cell in the table.
virtual void SAL_CALL disposing() override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
virtual sal_Int64 SAL_CALL getAccessibleChildCount() override
Returns the child count.
virtual sal_Int64 SAL_CALL getAccessibleStateSet() override
Returns the current set of states.
::std::unique_ptr< SvxEditSource > SvxEditSourcePtr
virtual void SAL_CALL grabFocus() override
void SendVisibleEvent()
Sends a visible area changed event to all listeners.
virtual void SendInsertColumnEvent(sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn)
Sends a table model changed event for an inserted column to all listeners.
virtual void SendCaretEvent()
Sends a caret changed event to all listeners.
void SendSelectionEvent()
Sends a selection changed event to all listeners.
virtual css::awt::Rectangle implGetBounds() override
ScAccessibleCsvControl(ScCsvControl &rControl)
Pointer to the VCL control.
virtual void SendTableUpdateEvent(sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows)
Sends a table model changed event for changed cell contents to all listeners.
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &aPoint) override
virtual ~ScAccessibleCsvControl() override
virtual void SendRemoveColumnEvent(sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn)
Sends a table model changed event for a removed column to all listeners.
virtual void SendFocusEvent(bool bFocused)
Sends a GetFocus or LoseFocus event to all listeners.
ScCsvControl & implGetControl() const
Returns the VCL control.
virtual void SAL_CALL disposing() override
sal_Int64 implCreateStateSet()
Creates a StateSet and fills it with DEFUNC, OPAQUE, ENABLED, SHOWING and VISIBLE.
Accessible class representing the CSV grid control.
virtual sal_Bool SAL_CALL isAccessibleRowSelected(sal_Int32 nRow) override
Returns true, if the specified row is selected.
virtual void SAL_CALL clearAccessibleSelection() override
Deselects all cells.
virtual sal_Bool SAL_CALL isAccessibleColumnSelected(sal_Int32 nColumn) override
Returns true, if the specified column is selected.
virtual void SendRemoveColumnEvent(sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn) override
Sends a table model changed event for a removed column to all listeners.
virtual void SAL_CALL selectAccessibleChild(sal_Int64 nChildIndex) override
Selects the specified child (selects the entire column or the entire table).
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleSummary() override
Returns the summary description object of the table.
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCaption() override
Returns the caption object of the table.
void implSelectColumn(sal_Int32 nColumn, bool bSelect)
Selects the specified column (including header).
virtual void SendFocusEvent(bool bFocused) override
Sends a GetFocus or LoseFocus event to all listeners.
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleColumnHeaders() override
Returns the column headers as an AccessibleTable.
virtual sal_Int32 SAL_CALL getForeground() override
virtual OUString SAL_CALL getAccessibleRowDescription(sal_Int32 nRow) override
Returns the description of the specified row in the table.
sal_Int32 implGetRow(sal_Int64 nIndex) const
Returns the row index from cell index (including header).
virtual void SAL_CALL selectAllAccessibleChildren() override
Selects all cells.
virtual OUString SAL_CALL getAccessibleName() override
sal_Int32 implGetSelColumn(sal_Int32 nSelColumn) const
Returns the absolute column index of the nSelColumn-th selected column.
virtual sal_Int64 SAL_CALL getAccessibleChildCount() override
Returns the child count (count of cells in the table).
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &rPoint) override
Returns the cell at the specified point.
virtual void SendInsertColumnEvent(sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn) override
Sends a table model changed event for an inserted column to all listeners.
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild(sal_Int64 nSelectedChildIndex) override
Returns the child with the specified index in all selected children.
virtual sal_Bool SAL_CALL isAccessibleChildSelected(sal_Int64 nChildIndex) override
Returns true, if the specified child is selected.
OUString implGetCellText(sal_Int32 nRow, sal_Int32 nColumn) const
Returns the contents of the specified cell (including header).
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
sal_Int32 implGetRowCount() const
Returns the count of visible rows in the table (including header).
sal_Int32 implGetColumnCount() const
Returns the total column count in the table (including header).
void ensureValidPosition(sal_Int32 nRow, sal_Int32 nColumn) const
@Throws css::lang::IndexOutOfBoundsException if the specified position is invalid.
virtual ~ScAccessibleCsvGrid() override
sal_Int64 implGetCellCount() const
Returns the total cell count in the table (including header).
void ensureValidIndex(sal_Int64 nIndex) const
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleColumns() override
Returns the selected columns as a sequence.
virtual void SendTableUpdateEvent(sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows) override
Sends a table model changed event for changed cell contents to all listeners.
virtual sal_Int32 SAL_CALL getAccessibleColumnCount() override
Returns the number of columns in the table.
virtual sal_Int64 SAL_CALL getAccessibleStateSet() override
Returns the current set of states.
virtual sal_Int32 SAL_CALL getBackground() override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn) override
Returns the accessible cell object at the specified position.
virtual void SAL_CALL deselectAccessibleChild(sal_Int64 nSelectedChildIndex) override
Deselects the child with the specified index in all selected children.
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleRows() override
Returns the selected rows as a sequence.
ScAccessibleCsvGrid(ScCsvGrid &rGrid)
virtual OUString SAL_CALL getAccessibleColumnDescription(sal_Int32 nColumn) override
Returns the description text of the specified column in the table.
virtual sal_Int64 SAL_CALL getAccessibleIndex(sal_Int32 nRow, sal_Int32 nColumn) override
Returns the child index of the cell at the specified position.
css::uno::Reference< css::accessibility::XAccessible > getAccessibleCell(sal_Int32 nRow, sal_Int32 nColumn)
virtual OUString SAL_CALL getAccessibleDescription() override
virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt(sal_Int32 nRow, sal_Int32 nColumn) override
Returns the number of rows occupied at a specified row and column.
virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt(sal_Int32 nRow, sal_Int32 nColumn) override
Returns the number of rows occupied at a specified row and column.
virtual sal_Bool SAL_CALL isAccessibleSelected(sal_Int32 nRow, sal_Int32 nColumn) override
Returns true, if the cell at a specified position is selected.
virtual sal_Int32 SAL_CALL getAccessibleRowCount() override
Returns the number of rows in the table.
bool implIsColumnSelected(sal_Int32 nColumn) const
Returns true, if the specified column (including header) is selected.
sal_Int64 implGetIndex(sal_Int32 nRow, sal_Int32 nColumn) const
Returns the child index from cell position (including header).
ScCsvGrid & implGetGrid() const
Returns the VCL grid control.
virtual sal_Int64 SAL_CALL getSelectedAccessibleChildCount() override
Returns the count of selected children.
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleRowHeaders() override
Returns the row headers as an AccessibleTable.
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override
Returns the relation to the ruler control.
sal_Int32 implGetColumn(sal_Int64 nIndex) const
Returns the column index from cell index (including header).
rtl::Reference< ScAccessibleCsvCell > implCreateCellObj(sal_Int32 nRow, sal_Int32 nColumn)
Creates a new accessible object of the specified cell.
sal_Int32 implGetSelColumnCount() const
Returns the count of selected columns in the table.
virtual void SAL_CALL disposing() override
virtual sal_Int32 SAL_CALL getAccessibleRow(sal_Int64 nChildIndex) override
Returns the row index of the specified child.
XAccessibleSet maAccessibleChildren
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int64 nIndex) override
Returns the specified child cell.
virtual sal_Int32 SAL_CALL getAccessibleColumn(sal_Int64 nChildIndex) override
Returns the column index of the specified child.
sal_Int32 implGetTextLength() const
Returns the character count of the text.
virtual css::accessibility::TextSegment SAL_CALL getTextBehindIndex(sal_Int32 nIndex, sal_Int16 aTextType) override
virtual sal_Int64 SAL_CALL getAccessibleStateSet() override
Returns the current set of states.
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override
Returns the relation to the grid control.
virtual sal_Int32 SAL_CALL getBackground() override
virtual sal_Bool SAL_CALL setCaretPosition(sal_Int32 nIndex) override
Sets the position of the caret.
bool implHasSplit(sal_Int32 nApiPos)
Returns true, if the character at the specified index has a split.
virtual sal_Int32 SAL_CALL getIndexAtPoint(const css::awt::Point &rPoint) override
Returns the character index at the specified coordinate (object's coordinate system).
void ensureValidIndex(sal_Int32 nIndex) const
void constructStringBuffer()
Builds the entire string buffer.
virtual OUString SAL_CALL getSelectedText() override
Returns the selected text (ruler returns empty string).
virtual sal_Int32 SAL_CALL getSelectionStart() override
Returns the start index of the selection (ruler returns -1).
virtual css::accessibility::TextSegment SAL_CALL getTextAtIndex(sal_Int32 nIndex, sal_Int16 aTextType) override
Returns the specified text portion.
virtual OUString SAL_CALL getAccessibleName() override
void ensureValidIndexWithEnd(sal_Int32 nIndex) const
virtual OUString SAL_CALL getTextRange(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
Returns the specified range [Start,End) of the text.
virtual ~ScAccessibleCsvRuler() override
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCharacterAttributes(sal_Int32 nIndex, const css::uno::Sequence< OUString > &aRequestedAttributes) override
Returns the attributes of the specified character.
virtual OUString SAL_CALL getText() override
Returns the entire text.
ScCsvRuler & implGetRuler() const
Returns the VCL ruler control.
virtual css::awt::Rectangle SAL_CALL getCharacterBounds(sal_Int32 nIndex) override
Returns the screen coordinates of the specified character.
virtual sal_Int64 SAL_CALL getAccessibleChildCount() override
Returns the child count (the ruler does not have children).
virtual sal_Int32 SAL_CALL getCaretPosition() override
Return the position of the caret.
virtual sal_Bool SAL_CALL scrollSubstringTo(sal_Int32 nStartIndex, sal_Int32 nEndIndex, css::accessibility::AccessibleScrollType aScrollType) override
sal_Int32 implGetLastEqualFormatted(sal_Int32 nApiPos)
Returns the last character index with equal formatting as at nApiPos.
virtual OUString SAL_CALL getAccessibleDescription() override
virtual sal_Int32 SAL_CALL getForeground() override
virtual sal_Int32 SAL_CALL getCharacterCount() override
Returns the count of characters.
virtual void SendCaretEvent() override
Sends a caret changed event to all listeners.
virtual css::accessibility::TextSegment SAL_CALL getTextBeforeIndex(sal_Int32 nIndex, sal_Int16 aTextType) override
virtual sal_Bool SAL_CALL setSelection(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
Selects a part of the text (ruler does nothing).
ScAccessibleCsvRuler(ScCsvRuler &rRuler)
Contains the text representation of the ruler.
void ensureValidRange(sal_Int32 &rnStartIndex, sal_Int32 &rnEndIndex) const
virtual sal_Int32 SAL_CALL getSelectionEnd() override
Returns the end index of the selection (ruler returns -1).
sal_Int32 implGetFirstEqualFormatted(sal_Int32 nApiPos)
Returns the first character index with equal formatting as at nApiPos.
virtual sal_Bool SAL_CALL copyText(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override
Copies the specified text range into the clipboard (ruler does nothing).
virtual sal_Unicode SAL_CALL getCharacter(sal_Int32 nIndex) override
Returns the specified character.
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int64 nIndex) override
Throws an exception (the ruler does not have children).
Base class for the CSV ruler and the data grid control.
Definition: csvcontrol.hxx:223
void Execute(ScCsvCmdType eType, sal_Int32 nParam1=CSV_POS_INVALID, sal_Int32 nParam2=CSV_POS_INVALID)
Executes a command by calling command handler.
Definition: csvcontrol.cxx:152
sal_Int32 GetPosCount() const
Returns the number of available positions.
Definition: csvcontrol.hxx:300
sal_Int32 GetPosFromX(sal_Int32 nX) const
Returns position from output coordinate.
Definition: csvcontrol.cxx:200
sal_Int32 GetLastVisLine() const
Returns index of last visible line.
Definition: csvcontrol.cxx:210
sal_Int32 GetRulerCursorPos() const
Returns the ruler cursor position.
Definition: csvcontrol.hxx:356
sal_Int32 GetCharWidth() const
Returns the width of one character column.
Definition: csvcontrol.hxx:318
sal_Int32 GetLineHeight() const
Returns the height of one line.
Definition: csvcontrol.hxx:349
sal_Int32 GetFirstVisLine() const
Returns index of first visible line.
Definition: csvcontrol.hxx:335
sal_Int32 GetHdrWidth() const
Returns the width of the header column.
Definition: csvcontrol.hxx:316
sal_Int32 GetX(sal_Int32 nPos) const
Returns output X coordinate of the specified position.
Definition: csvcontrol.cxx:195
sal_Int32 GetLineFromY(sal_Int32 nY) const
Returns line index from output coordinate.
Definition: csvcontrol.cxx:235
sal_Int32 GetHdrHeight() const
Returns the height of the header line.
Definition: csvcontrol.hxx:347
sal_Int32 GetLastX() const
Returns the X position of the last pixel of the data area.
Definition: csvcontrol.cxx:190
sal_Int32 GetHdrX() const
Returns the start position of the header column.
Definition: csvcontrol.cxx:180
sal_Int32 GetFirstX() const
Returns the X position of the first pixel of the data area.
Definition: csvcontrol.cxx:185
ScAccessibleCsvControl * GetAccessible()
Definition: csvcontrol.hxx:258
sal_Int32 GetY(sal_Int32 nLine) const
Returns output Y coordinate of the specified line.
Definition: csvcontrol.cxx:230
A data grid control for the CSV import dialog.
Definition: csvgrid.hxx:58
sal_Int32 GetColumnPos(sal_uInt32 nColIndex) const
Returns start position of the column with the specified index.
Definition: csvgrid.hxx:166
void SelectAll(bool bSelect=true)
Selects or deselects all columns.
Definition: csvgrid.cxx:701
sal_Int32 GetColumnWidth(sal_uInt32 nColIndex) const
Returns the character width of the column with the specified index.
Definition: csvgrid.cxx:493
sal_Int32 GetColumnX(sal_uInt32 nColIndex) const
Returns X coordinate of the specified column.
Definition: csvgrid.cxx:476
sal_uInt32 GetFocusColumn() const
Returns index of the focused column.
Definition: csvgrid.hxx:219
sal_uInt32 GetNextSelected(sal_uInt32 nFromIndex) const
Returns index of the first selected column really after nFromIndex.
Definition: csvgrid.cxx:646
void Select(sal_uInt32 nColIndex, bool bSelect=true)
Selects or deselects the specified column.
Definition: csvgrid.cxx:655
ScCsvTableBox * GetTableBox()
Definition: csvgrid.hxx:97
EditEngine * GetEditEngine()
Returns a pointer to the used edit engine.
Definition: csvgrid.cxx:1096
sal_uInt32 GetFirstSelected() const
Returns index of the first selected column.
Definition: csvgrid.cxx:641
sal_uInt32 GetColumnCount() const
Returns the number of columns.
Definition: csvgrid.hxx:149
bool IsSelected(sal_uInt32 nColIndex) const
Returns true, if the specified column is selected.
Definition: csvgrid.cxx:636
OUString GetCellText(sal_uInt32 nColIndex, sal_Int32 nLine) const
Returns the text of the specified cell.
Definition: csvgrid.cxx:865
OUString GetColumnTypeName(sal_uInt32 nColIndex) const
Returns the UI type name of the specified column.
Definition: csvgrid.cxx:562
sal_uInt32 GetColumnFromX(sal_Int32 nX) const
Returns column index from output coordinate.
Definition: csvgrid.cxx:481
A ruler control for the CSV import dialog.
Definition: csvruler.hxx:33
bool HasSplit(sal_Int32 nPos) const
Returns true if at position nPos is a split.
Definition: csvruler.hxx:99
ScCsvTableBox * GetTableBox()
Definition: csvruler.hxx:61
The control in the CSV import dialog that contains a ruler and a data grid to visualize and modify th...
Definition: csvtablebox.hxx:44
ScCsvGrid & GetGrid()
Definition: csvtablebox.hxx:81
ScCsvRuler & GetRuler()
Definition: csvtablebox.hxx:80
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
void SetEditSource(::std::unique_ptr< SvxEditSource > &&pEditSource)
constexpr tools::Long GetWidth() const
constexpr void SetLeft(tools::Long v)
constexpr void SetTop(tools::Long v)
constexpr tools::Long Top() const
void SetSize(const Size &)
constexpr void SetRight(tools::Long v)
constexpr tools::Long GetHeight() const
tools::Rectangle & Intersection(const tools::Rectangle &rRect)
constexpr tools::Long Left() const
constexpr bool IsEmpty() const
FontFamily GetFamilyType()
const OUString & GetStyleName() const
const OUString & GetFamilyName() const
const Size & GetFontSize() const
LanguageType GetLanguage() const
FontPitch GetPitch()
rtl_TextEncoding GetCharSet() const
weld::DrawingArea * GetDrawingArea() const
Size const & GetOutputSizePixel() const
virtual OutputDevice & get_ref_device()=0
@ CSVCMD_MOVEGRIDCURSOR
Move ruler cursor to new position. [position].
Definition: csvcontrol.hxx:178
@ CSVCMD_MOVERULERCURSOR
Change data line pixel height. [height in pixel}.
Definition: csvcontrol.hxx:177
const sal_uInt32 CSV_COLUMN_INVALID
Definition: csvgrid.hxx:38
const sal_Int32 CSV_POS_INVALID
Constant for an invalid ruler position.
Definition: csvsplits.hxx:29
int nCount
sal_Int32 nIndex
sal_uInt16 nPos
Sequence< sal_Int8 > aSeq
#define MID_LANG_LOCALE
#define MID_FONT_PITCH
#define MID_FONT_CHAR_SET
#define MID_FONTHEIGHT
#define MID_FONT_FAMILY
#define MID_FONT_FAMILY_NAME
#define MID_FONT_STYLE_NAME
IMPLEMENT_FORWARD_XTYPEPROVIDER2(ChildWindowPane, ChildWindowPaneInterfaceBase, Pane)
IMPLEMENT_FORWARD_XINTERFACE2(ChildWindowPane, ChildWindowPaneInterfaceBase, Pane)
vcl::Font GetFont(vcl::Font const &rFont, DrawModeFlags nDrawMode, StyleSettings const &rStyleSettings)
bool isAlive()
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
constexpr TypedWhichId< SvxFontHeightItem > ATTR_FONT_HEIGHT(101)
constexpr TypedWhichId< SvxFontItem > ATTR_FONT(100)
constexpr TypedWhichId< SvxLanguageItem > ATTR_FONT_LANGUAGE(110)
#define SC_MOD()
Definition: scmod.hxx:249
sal_uInt32 mnIndex
unsigned char sal_uInt8
unsigned char sal_Bool
sal_uInt16 sal_Unicode
sal_Int32 nLength