LibreOffice Module winaccessibility (master) 1
AccTable.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
23#include "stdafx.h"
24#include <UAccCOM.h>
25#include "AccTable.h"
26
27#include <sal/log.hxx>
28#include <vcl/svapp.hxx>
30
31#include <com/sun/star/accessibility/XAccessible.hpp>
32#include "MAccessible.h"
33
34#include <com/sun/star/accessibility/XAccessibleTableSelection.hpp>
35
36using namespace com::sun::star::accessibility;
37using namespace com::sun::star::uno;
46COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_accessibleAt(long row, long column, IUnknown * * accessible)
47{
49
50 try {
51
52 // #CHECK#
53 if(accessible == nullptr)
54 return E_INVALIDARG;
55 // #CHECK XInterface#
56 if(!pRXTable.is())
57 return E_FAIL;
58
59 Reference<XAccessible> pRAcc = pRXTable->getAccessibleCellAt(row, column);
60
61 if(!pRAcc.is())
62 {
63 *accessible = nullptr;
64 return E_FAIL;
65 }
66
67 IAccessible* pRet = nullptr;
68
69 bool isTRUE = CMAccessible::get_IAccessibleFromXAccessible(pRAcc.get(), &pRet);
70 if(isTRUE)
71 {
72 *accessible = pRet;
73 pRet->AddRef();
74 return S_OK;
75 }
76 else if(pRAcc.is())
77 {
78 Reference<XAccessible> pxTable(pRXTable, UNO_QUERY);
79
80 CMAccessible::g_pAgent->InsertAccObj(pRAcc.get(),pxTable.get());
81 isTRUE = CMAccessible::get_IAccessibleFromXAccessible(pRAcc.get(), &pRet);
82
83 if(isTRUE)
84 {
85 *accessible = pRet;
86 pRet->AddRef();
87 return S_OK;
88 }
89 }
90 return E_FAIL;
91
92 } catch(...) { return E_FAIL; }
93}
94
95COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_cellAt(long row, long column, IUnknown * * cell)
96{
97 return get_accessibleAt(row, column, cell);
98}
99
105COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_caption(IUnknown * *)
106{
107 return E_NOTIMPL;
108}
109
116COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_columnDescription(long column, BSTR * description)
117{
119
120 try {
121
122 // #CHECK#
123 if(description == nullptr)
124 return E_INVALIDARG;
125
126 // #CHECK XInterface#
127 if(!pRXTable.is())
128 return E_FAIL;
129
130 const OUString& ouStr = pRXTable->getAccessibleColumnDescription(column);
131 // #CHECK#
132
133 SysFreeString(*description);
134 *description = SysAllocString(o3tl::toW(ouStr.getStr()));
135 if (*description==nullptr)
136 return E_FAIL;
137 return S_OK;
138
139 } catch(...) { return E_FAIL; }
140}
141
149COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_columnExtentAt(long row, long column, long * nColumnsSpanned)
150{
152
153 try {
154
155 // Check pointer.
156 if(nColumnsSpanned == nullptr)
157 return E_INVALIDARG;
158
159 if(!pRXTable.is())
160 return E_FAIL;
161
162 *nColumnsSpanned = pRXTable->getAccessibleColumnExtentAt(row, column);
163 return S_OK;
164
165 } catch(...) { return E_FAIL; }
166}
167
174COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_columnHeader(IAccessibleTable __RPC_FAR *__RPC_FAR *accessibleTable, long *startingRowIndex)
175{
177
178 try {
179
180 // #CHECK#
181 if(accessibleTable == nullptr || startingRowIndex == nullptr)
182 return E_INVALIDARG;
183
184 // #CHECK XInterface#
185 if(!pRXTable.is())
186 return E_FAIL;
187
188 Reference<XAccessibleTable> pRColumnHeaderTable = pRXTable->getAccessibleColumnHeaders();
189 if(!pRColumnHeaderTable.is())
190 {
191 *accessibleTable = nullptr;
192 return E_FAIL;
193 }
194
195 Reference<XAccessible> pRXColumnHeader(pRColumnHeaderTable,UNO_QUERY);
196
197 if(!pRXColumnHeader.is())
198 {
199 *accessibleTable = nullptr;
200 return E_FAIL;
201 }
202 *startingRowIndex = 0 ;
203
204 IMAccessible* pIMacc = nullptr;
205 HRESULT hr = createInstance<CMAccessible>(IID_IMAccessible, &pIMacc);
206 if (!SUCCEEDED(hr))
207 {
208 return E_FAIL;
209 }
210 pIMacc->SetXAccessible(
211 reinterpret_cast<hyper>(pRXColumnHeader.get()));
212 pIMacc->QueryInterface(IID_IAccessibleTable,reinterpret_cast<void **>(accessibleTable));
213
214 return S_OK;
215
216 } catch(...) { return E_FAIL; }
217}
218
224COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_nColumns(long * columnCount)
225{
227
228 try {
229
230 // #CHECK#
231 if(columnCount == nullptr)
232 return E_INVALIDARG;
233
234 // #CHECK XInterface#
235 if(!pRXTable.is())
236 return E_FAIL;
237
238 *columnCount = pRXTable->getAccessibleColumnCount();
239 return S_OK;
240
241 } catch(...) { return E_FAIL; }
242}
243
249COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_nRows(long * rowCount)
250{
252
253 try {
254
255 // #CHECK#
256 if(rowCount == nullptr)
257 return E_INVALIDARG;
258
259 // #CHECK XInterface#
260 if(!pRXTable.is())
261 return E_FAIL;
262
263 *rowCount = pRXTable->getAccessibleRowCount();
264 return S_OK;
265
266 } catch(...) { return E_FAIL; }
267}
268
274COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_nSelectedColumns(long * columnCount)
275{
277
278 try {
279
280 // #CHECK#
281 if(columnCount == nullptr)
282 return E_INVALIDARG;
283
284 // #CHECK XInterface#
285 if(!pRXTable.is())
286 return E_FAIL;
287
288 Sequence<long> pSelected = pRXTable->getSelectedAccessibleColumns();
289 *columnCount = pSelected.getLength();
290 return S_OK;
291
292 } catch(...) { return E_FAIL; }
293}
294
300COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_nSelectedRows(long * rowCount)
301{
303
304 try {
305
306 // #CHECK#
307 if(rowCount == nullptr)
308 return E_INVALIDARG;
309
310 // #CHECK XInterface#
311 if(!pRXTable.is())
312 return E_FAIL;
313
314 Sequence<long> pSelected = pRXTable->getSelectedAccessibleRows();
315 *rowCount = pSelected.getLength();
316 return S_OK;
317
318 } catch(...) { return E_FAIL; }
319}
320
327COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_rowDescription(long row, BSTR * description)
328{
330
331 try {
332
333 // #CHECK#
334 if(description == nullptr)
335 return E_INVALIDARG;
336
337 // #CHECK XInterface#
338 if(!pRXTable.is())
339 return E_FAIL;
340
341 const OUString& ouStr = pRXTable->getAccessibleRowDescription(row);
342 // #CHECK#
343
344 SysFreeString(*description);
345 *description = SysAllocString(o3tl::toW(ouStr.getStr()));
346 if (*description==nullptr)
347 return E_FAIL;
348 return S_OK;
349
350 } catch(...) { return E_FAIL; }
351}
352
360COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_rowExtentAt(long row, long column, long * nRowsSpanned)
361{
363
364 try {
365
366 // Check pointer.
367 if(nRowsSpanned == nullptr)
368 return E_INVALIDARG;
369
370 if(!pRXTable.is())
371 return E_FAIL;
372
373 *nRowsSpanned= pRXTable->getAccessibleRowExtentAt(row, column);
374
375 return S_OK;
376
377 } catch(...) { return E_FAIL; }
378}
379
386COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_rowHeader(IAccessibleTable __RPC_FAR *__RPC_FAR *accessibleTable, long *startingColumnIndex)
387{
389
390 try {
391
392 // #CHECK#
393 if(accessibleTable == nullptr || startingColumnIndex == nullptr)
394 return E_INVALIDARG;
395
396 // #CHECK XInterface#
397 if(!pRXTable.is())
398 return E_FAIL;
399
400 Reference<XAccessibleTable> pRRowHeaderTable = pRXTable->getAccessibleRowHeaders();
401 if(!pRRowHeaderTable.is())
402 {
403 *accessibleTable = nullptr;
404 return E_FAIL;
405 }
406
407 Reference<XAccessible> pRXRowHeader(pRRowHeaderTable,UNO_QUERY);
408
409 if(!pRXRowHeader.is())
410 {
411 *accessibleTable = nullptr;
412 return E_FAIL;
413 }
414 *startingColumnIndex = 0 ;
415
416 IMAccessible* pIMacc = nullptr;
417 HRESULT hr = createInstance<CMAccessible>(IID_IMAccessible, &pIMacc);
418 if (!SUCCEEDED(hr))
419 {
420 return E_FAIL;
421 }
422 pIMacc->SetXAccessible(
423 reinterpret_cast<hyper>(pRXRowHeader.get()));
424 pIMacc->QueryInterface(IID_IAccessibleTable,reinterpret_cast<void **>(accessibleTable));
425
426 return S_OK;
427
428 } catch(...) { return E_FAIL; }
429}
430
437COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_selectedRows(long** rows, long* nRows)
438{
440
441 try {
442
443 // #CHECK#
444 if(rows == nullptr || nRows == nullptr)
445 return E_INVALIDARG;
446
447 // #CHECK XInterface#
448 if(!pRXTable.is())
449 return E_FAIL;
450
451 Sequence<long> pSelected = pRXTable->getSelectedAccessibleRows();
452 long count = pSelected.getLength() ;
453 *nRows = count;
454
455 *rows = static_cast<long*>(CoTaskMemAlloc(count * sizeof(long)));
456 // #CHECK Memory Allocation#
457 if(*rows == nullptr)
458 {
459 return E_FAIL;
460 }
461 for(int i=0; i<count; i++)
462 (*rows)[i] = pSelected[i];
463
464 return S_OK;
465
466 } catch(...) { return E_FAIL; }
467}
468
476COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_selectedRows(long, long ** rows, long * nRows)
477{
478 return get_selectedRows(rows, nRows);
479}
480
487COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_selectedColumns(long ** columns, long * numColumns)
488{
490
491 try {
492
493 // #CHECK#
494 if(columns == nullptr || numColumns == nullptr)
495 return E_INVALIDARG;
496
497 // #CHECK XInterface#
498 if(!pRXTable.is())
499 return E_FAIL;
500
501 Sequence<long> pSelected = pRXTable->getSelectedAccessibleColumns();
502 long count = pSelected.getLength() ;
503 *numColumns = count;
504
505 *columns = static_cast<long*>(CoTaskMemAlloc(count * sizeof(long)));
506 // #CHECK Memory Allocation#
507 if(*columns == nullptr)
508 {
509 return E_FAIL;
510 }
511 for(int i=0; i<count; i++)
512 (*columns)[i] = pSelected[i];
513
514 return S_OK;
515
516 } catch(...) { return E_FAIL; }
517}
518
526COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_selectedColumns(long, long ** columns, long * numColumns)
527{
528 return get_selectedColumns(columns, numColumns);
529}
530
536COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_summary(IUnknown * * accessible)
537{
539
540 try {
541
542 // #CHECK#
543 if(accessible == nullptr)
544 return E_INVALIDARG;
545
546 // #CHECK XInterface#
547 if(!pRXTable.is())
548 return E_FAIL;
549
550 Reference<XAccessible> pRAcc = pRXTable->getAccessibleSummary();
551
552 IAccessible* pRet = nullptr;
554
555 if(pRet)
556 {
557 *accessible = pRet;
558 pRet->AddRef();
559 return S_OK;
560 }
561
562 return E_FAIL;
563
564 } catch(...) { return E_FAIL; }
565}
566
573COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_isColumnSelected(long column, boolean * isSelected)
574{
576
577 try {
578
579 // #CHECK#
580 if(isSelected == nullptr)
581 return E_INVALIDARG;
582
583 // #CHECK XInterface#
584 if(!pRXTable.is())
585 return E_FAIL;
586
587 *isSelected = pRXTable->isAccessibleColumnSelected(column);
588 return S_OK;
589
590 } catch(...) { return E_FAIL; }
591}
592
599COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_isRowSelected(long row, boolean * isSelected)
600{
602
603 try {
604
605 // #CHECK#
606 if(isSelected == nullptr)
607 return E_INVALIDARG;
608
609 // #CHECK XInterface#
610 if(!pRXTable.is())
611 return E_FAIL;
612
613 *isSelected = pRXTable->isAccessibleRowSelected(row);
614 return S_OK;
615
616 } catch(...) { return E_FAIL; }
617}
618
626COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_isSelected(long row, long column, boolean * isSelected)
627{
629
630 try {
631
632 // #CHECK#
633 if(isSelected == nullptr)
634 return E_INVALIDARG;
635
636 // #CHECK XInterface#
637 if(!pRXTable.is())
638 return E_FAIL;
639
640 *isSelected = pRXTable->isAccessibleSelected(row, column);
641 return S_OK;
642
643 } catch(...) { return E_FAIL; }
644}
645
652COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::selectRow(long row)
653{
655
656 try {
657
658 // Check XAccessibleTable reference.
659 if(!pRXTable.is())
660 return E_FAIL;
661
662 Reference<XAccessibleTableSelection> pRTableExtent(pRXTable, UNO_QUERY);
663 if(pRTableExtent.is())
664 {
665 pRTableExtent->selectRow(row);
666 return S_OK;
667 }
668 else
669 {
670 // Get XAccessibleSelection.
671 Reference<XAccessibleSelection> pRSelection(pRXTable, UNO_QUERY);
672 if(!pRSelection.is())
673 return E_FAIL;
674
675 // Select row.
676 long lCol, lColumnCount;
677 lColumnCount = pRXTable->getAccessibleColumnCount();
678 for(lCol = 0; lCol < lColumnCount; lCol ++)
679 {
680 sal_Int64 nChildIndex = pRXTable->getAccessibleIndex(row, lCol);
681 pRSelection->selectAccessibleChild(nChildIndex);
682 }
683
684 return S_OK;
685 }
686
687 } catch(...) { return E_FAIL; }
688}
689
696COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::selectColumn(long column)
697{
699
700 try {
701
702 // Check XAccessibleTable reference.
703 if(!pRXTable.is())
704 return E_FAIL;
705
706 Reference<XAccessibleTableSelection> pRTableExtent(pRXTable, UNO_QUERY);
707 if(pRTableExtent.is())
708 {
709 pRTableExtent->selectColumn(column);
710 return S_OK;
711 }
712 else
713 {
714 // Get XAccessibleSelection.
715 Reference<XAccessibleSelection> pRSelection(pRXTable, UNO_QUERY);
716 if(!pRSelection.is())
717 return E_FAIL;
718
719 // Select column.
720 long lRow, lRowCount;
721 lRowCount = pRXTable->getAccessibleRowCount();
722 for(lRow = 0; lRow < lRowCount; lRow ++)
723 {
724 sal_Int64 nChildIndex = pRXTable->getAccessibleIndex(lRow, column);
725 pRSelection->selectAccessibleChild(nChildIndex);
726 }
727
728 return S_OK;
729 }
730 // End of added.
731
732 } catch(...) { return E_FAIL; }
733}
734
741COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::unselectRow(long row)
742{
744
745 try {
746
747 // Check XAccessibleTable reference.
748 if(!pRXTable.is())
749 return E_FAIL;
750
751 Reference<XAccessibleTableSelection> pRTableExtent(pRXTable, UNO_QUERY);
752 if(pRTableExtent.is())
753 {
754 if(pRTableExtent->unselectRow(row))
755 return S_OK;
756 else
757 return E_FAIL;
758 }
759 else
760 {
761 // Get XAccessibleSelection.
762 Reference<XAccessibleSelection> pRSelection(pRXTable, UNO_QUERY);
763 if(!pRSelection.is())
764 return E_FAIL;
765
766 // Select column.
767 long lColumn, lColumnCount;
768 lColumnCount = pRXTable->getAccessibleColumnCount();
769 for(lColumn = 0; lColumn < lColumnCount; lColumn ++)
770 {
771 sal_Int64 nChildIndex = pRXTable->getAccessibleIndex(row, lColumn);
772 pRSelection->deselectAccessibleChild(nChildIndex);
773 }
774
775 return S_OK;
776 }
777 // End of added.
778
779 } catch(...) { return E_FAIL; }
780}
781
788COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::unselectColumn(long column)
789{
791
792 try {
793
794 // Check XAccessibleTable reference.
795 if(!pRXTable.is())
796 return E_FAIL;
797
798 Reference<XAccessibleTableSelection> pRTableExtent(pRXTable, UNO_QUERY);
799 if(pRTableExtent.is())
800 {
801 if(pRTableExtent->unselectColumn(column))
802 return S_OK;
803 else
804 return E_FAIL;
805 }
806 else
807 {
808 // Get XAccessibleSelection.
809 Reference<XAccessibleSelection> pRSelection(pRXTable, UNO_QUERY);
810 if(!pRSelection.is())
811 return E_FAIL;
812
813 // Unselect columns.
814 long lRow, lRowCount;
815 lRowCount = pRXTable->getAccessibleRowCount();
816
817 for(lRow = 0; lRow < lRowCount; lRow ++)
818 {
819 sal_Int64 nChildIndex = pRXTable->getAccessibleIndex(lRow, column);
820 pRSelection->deselectAccessibleChild(nChildIndex);
821 }
822 return S_OK;
823 }
824
825 } catch(...) { return E_FAIL; }
826}
827
833COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::put_XInterface(hyper pXInterface)
834{
835 // internal IUNOXWrapper - no mutex meeded
836
837 try {
838
839 CUNOXWrapper::put_XInterface(pXInterface);
840 //special query.
841 if(pUNOInterface == nullptr)
842 return E_INVALIDARG;
843
844 Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext();
845 if( !pRContext.is() )
846 return E_FAIL;
847
848 Reference<XAccessibleTable> pRXI(pRContext,UNO_QUERY);
849 if( !pRXI.is() )
850 pRXTable = nullptr;
851 else
852 pRXTable = pRXI.get();
853 return S_OK;
854
855 } catch(...) { return E_FAIL; }
856}
857
858
864COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_columnIndex(long childIndex, long * columnIndex)
865{
867
868 try {
869
870 // #CHECK#
871 if(columnIndex == nullptr)
872 return E_INVALIDARG;
873
874 // #CHECK XInterface#
875 if(!pRXTable.is())
876 return E_FAIL;
877
878 *columnIndex = pRXTable->getAccessibleColumn(childIndex);
879 return S_OK;
880
881 } catch(...) { return E_FAIL; }
882}
888COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_rowIndex(long childIndex, long * rowIndex)
889{
891
892 try {
893
894 // #CHECK#
895 if(rowIndex == nullptr)
896 return E_INVALIDARG;
897
898 // #CHECK XInterface#
899 if(!pRXTable.is())
900 return E_FAIL;
901
902 *rowIndex = pRXTable->getAccessibleRow(childIndex);
903 return S_OK;
904
905 } catch(...) { return E_FAIL; }
906}
907
913COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_childIndex(long RowIndex , long columnIndex, long * childIndex )
914{
916
917 try {
918
919 // #CHECK#
920 if(childIndex == nullptr)
921 return E_INVALIDARG;
922
923 // #CHECK XInterface#
924 if(!pRXTable.is())
925 return E_FAIL;
926
927 sal_Int64 nIndex = pRXTable->getAccessibleIndex(RowIndex, columnIndex);
928 if (nIndex > std::numeric_limits<long>::max())
929 {
930 // use -2 when the child index is too large to fit into 32 bit to neither use the
931 // valid index of another child nor -1, which is more commonly used to indicate that
932 // a child is no more inside of a parent or invalid otherwise
933 SAL_WARN("vcl.qt", "CAccTable::get_childIndex: Child index exceeds maximum long value, "
934 "returning -2.");
935 nIndex = -2;
936 }
938 return S_OK;
939
940 } catch(...) { return E_FAIL; }
941}
942
943COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_rowColumnExtentsAtIndex(long,
944 long *,
945 long *,
946 long *,
947 long *,
948 boolean *)
949{
950 return E_NOTIMPL;
951}
952
953COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_modelChange(IA2TableModelChange *)
954{
955 return E_NOTIMPL;
956}
957
958// @brief Returns the total number of selected children
959// @param [out] childCount
960// Number of children currently selected
961COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_nSelectedChildren(long *childCount)
962{
964
965 try {
966
967 // #CHECK#
968 if(childCount == nullptr)
969 return E_INVALIDARG;
970
971 // #CHECK XInterface#
972 if(!pRXTable.is())
973 return E_FAIL;
974
975 Reference<XAccessibleSelection> pRSelection(pRXTable, UNO_QUERY);
976 if(!pRSelection.is())
977 return E_FAIL;
978
979 sal_Int64 nSelected = pRSelection->getSelectedAccessibleChildCount();
980 if (nSelected > std::numeric_limits<long>::max())
981 {
982 SAL_WARN("iacc2", "CAccTable::get_nSelectedChildren: Selected item count exceeds maximum long value, "
983 "using max long.");
984 nSelected = std::numeric_limits<long>::max();
985 }
986 *childCount = nSelected;
987 return S_OK;
988
989 } catch(...) { return E_FAIL; }
990}
991
992
993
994COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_nSelectedCells(long *cellCount)
995{
996 return get_nSelectedChildren(cellCount);
997}
998
999// @brief Returns a list of child indexes currently selected (0-based).
1000// @param [in] maxChildren
1001// Max children requested (possibly from IAccessibleTable::nSelectedChildren)
1002// @param [out] children
1003// array of indexes of selected children (each index is 0-based)
1004// @param [out] nChildren
1005// Length of array (not more than maxChildren)
1006COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_selectedChildren(long, long **children, long *nChildren)
1007{
1009
1010 try {
1011
1012 // #CHECK#
1013 if(children == nullptr || nChildren == nullptr)
1014 return E_INVALIDARG;
1015
1016 // #CHECK XInterface#
1017 if(!pRXTable.is())
1018 return E_FAIL;
1019
1020 Reference<XAccessibleSelection> pRSelection(pRXTable, UNO_QUERY);
1021 if(!pRSelection.is())
1022 return E_FAIL;
1023
1024 sal_Int64 nChildCount = pRSelection->getSelectedAccessibleChildCount();
1025 if (nChildCount > std::numeric_limits<long>::max())
1026 {
1027 SAL_WARN("iacc2", "CAccTable::get_selectedChildren: Selected child count exceeds maximum long value, "
1028 "using max long.");
1029 nChildCount = std::numeric_limits<long>::max();
1030 }
1031
1032 *nChildren = nChildCount;
1033 *children = static_cast<long*>(CoTaskMemAlloc(nChildCount * sizeof(long)));
1034
1035 for( sal_Int64 i = 0; i< nChildCount; i++)
1036 {
1037 Reference<XAccessible> pRAcc = pRSelection->getSelectedAccessibleChild(i);
1038 if(pRAcc.is())
1039 {
1040 Reference<XAccessibleContext> pRContext(pRAcc, UNO_QUERY);
1041 if( !pRContext.is() )
1042 return E_FAIL;
1043
1044
1045 sal_Int64 nChildIndex = pRContext->getAccessibleIndexInParent();
1046 if (nChildIndex > std::numeric_limits<long>::max())
1047 {
1048 SAL_WARN("iacc2", "CAccTable::get_selectedChildren: Child index exceeds maximum long value, "
1049 "using max long.");
1050 nChildIndex = std::numeric_limits<long>::max();
1051 }
1052 (*children)[i] = nChildIndex;
1053 }
1054 }
1055
1056 return S_OK;
1057
1058 } catch(...) { return E_FAIL; }
1059
1060}
1061
1070COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_selectedCells(IUnknown * * * cells, long *nSelectedCells)
1071{
1073
1074 try {
1075
1076 if (cells == nullptr || nSelectedCells == nullptr)
1077 return E_INVALIDARG;
1078
1079 if (!pRXTable.is())
1080 return E_FAIL;
1081
1082 Reference<XAccessibleSelection> xSelection(pRXTable, UNO_QUERY);
1083 if (!xSelection.is())
1084 return E_FAIL;
1085
1086 sal_Int64 nSelected = xSelection->getSelectedAccessibleChildCount();
1087 if (nSelected > std::numeric_limits<long>::max())
1088 {
1089 SAL_WARN("iacc2", "CAccTable::get_selectedCells: Selected cell count exceeds maximum long value, "
1090 "using max long.");
1091 nSelected = std::numeric_limits<long>::max();
1092 }
1093 *nSelectedCells = nSelected;
1094
1095 *cells = static_cast<IUnknown**>(CoTaskMemAlloc(nSelected * sizeof(IUnknown*)));
1096
1097 for (sal_Int64 i = 0; i < nSelected; i++)
1098 {
1099 Reference<XAccessible> xAcc = xSelection->getSelectedAccessibleChild(i);
1100 assert(xAcc.is());
1101
1102 IAccessible* pIAccessible;
1103 bool bOK = CMAccessible::get_IAccessibleFromXAccessible(xAcc.get(), &pIAccessible);
1104
1105 if (!bOK)
1106 {
1107 Reference<XAccessible> xTable(pRXTable, UNO_QUERY);
1108 CMAccessible::g_pAgent->InsertAccObj(xAcc.get(), xTable.get());
1109 bOK = CMAccessible::get_IAccessibleFromXAccessible(xAcc.get(), &pIAccessible);
1110 }
1111
1112 assert(bOK && "Couldn't retrieve IAccessible object");
1113
1114 pIAccessible->AddRef();
1115 (*cells)[i] = pIAccessible;
1116 }
1117
1118 return S_OK;
1119
1120 } catch(...) { return E_FAIL; }
1121}
1122
1123/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool InsertAccObj(css::accessibility::XAccessible *pXAcc, css::accessibility::XAccessible *pParentXAcc, HWND hWnd=nullptr)
When a new UNO XAccessible object is found by listener, we create a corresponding com object and inse...
STDMETHOD() get_caption(IUnknown **accessible) override
Gets accessible table caption.
Definition: AccTable.cxx:105
STDMETHOD() get_rowColumnExtentsAtIndex(long index, long *row, long *column, long *rowExtents, long *columnExtents, boolean *isSelected) override
Definition: AccTable.cxx:943
STDMETHOD() get_summary(IUnknown **accessible) override
Gets accessible table summary.
Definition: AccTable.cxx:536
STDMETHOD() selectColumn(long column) override
Selects a column and unselect all previously selected columns.
Definition: AccTable.cxx:696
STDMETHOD() unselectColumn(long column) override
Unselects one column, leaving other selected columns selected (if any).
Definition: AccTable.cxx:788
STDMETHOD() put_XInterface(hyper pXInterface) override
Override of IUNOXWrapper.
Definition: AccTable.cxx:833
STDMETHOD() get_selectedChildren(long maxChildren, long **children, long *nChildren) override
Definition: AccTable.cxx:1006
STDMETHOD() get_selectedColumns(long **columns, long *numColumns) override
Gets list of column indexes currently selected (0-based).
Definition: AccTable.cxx:487
STDMETHOD() get_columnHeader(IAccessibleTable __RPC_FAR *__RPC_FAR *accessibleTable, long *startingRowIndex) override
Gets accessible column header.
Definition: AccTable.cxx:174
STDMETHOD() get_cellAt(long row, long column, IUnknown **cell) override
Definition: AccTable.cxx:95
STDMETHOD() get_selectedRows(long **rows, long *nRows) override
Gets list of row indexes currently selected (0-based).
Definition: AccTable.cxx:437
STDMETHOD() get_nColumns(long *columnCount) override
Gets total number of columns in table.
Definition: AccTable.cxx:224
STDMETHOD() get_isColumnSelected(long column, boolean *isSelected) override
Determines if table column is selected.
Definition: AccTable.cxx:573
STDMETHOD() get_selectedCells(IUnknown ***cells, long *nSelectedCells) override
Returns a list of accessibles currently selected.
Definition: AccTable.cxx:1070
STDMETHOD() selectRow(long row) override
Selects a row and unselect all previously selected rows.
Definition: AccTable.cxx:652
css::uno::Reference< css::accessibility::XAccessibleTable > pRXTable
Definition: AccTable.h:181
STDMETHOD() get_nSelectedCells(long *childCount) override
Definition: AccTable.cxx:994
STDMETHOD() get_columnDescription(long column, BSTR *description) override
Gets accessible column description (as string).
Definition: AccTable.cxx:116
STDMETHOD() get_columnIndex(long childIndex, long *columnIndex) override
Gets columnIndex of childIndex.
Definition: AccTable.cxx:864
STDMETHOD() get_rowHeader(IAccessibleTable __RPC_FAR *__RPC_FAR *accessibleTable, long *startingColumnIndex) override
Gets accessible row header.
Definition: AccTable.cxx:386
STDMETHOD() get_rowExtentAt(long row, long column, long *nRowsSpanned) override
Gets number of rows spanned by a table cell.
Definition: AccTable.cxx:360
STDMETHOD() unselectRow(long row) override
Unselects one row, leaving other selected rows selected (if any).
Definition: AccTable.cxx:741
STDMETHOD() get_childIndex(long rowIndex, long columnIndex, long *childIndex) override
Gets childIndex of childIndex.
Definition: AccTable.cxx:913
STDMETHOD() get_modelChange(IA2TableModelChange *modelChange) override
Definition: AccTable.cxx:953
STDMETHOD() get_rowDescription(long row, BSTR *description) override
Gets accessible row description (as string).
Definition: AccTable.cxx:327
STDMETHOD() get_nSelectedChildren(long *childCount) override
Definition: AccTable.cxx:961
STDMETHOD() get_accessibleAt(long row, long column, IUnknown **accessible) override
Gets accessible table cell.
Definition: AccTable.cxx:46
STDMETHOD() get_columnExtentAt(long row, long column, long *nColumnsSpanned) override
Gets number of columns spanned by table cell.
Definition: AccTable.cxx:149
STDMETHOD() get_nRows(long *rowCount) override
Gets total number of rows in table.
Definition: AccTable.cxx:249
STDMETHOD() get_nSelectedRows(long *rowCount) override
Gets total number of selected rows.
Definition: AccTable.cxx:300
STDMETHOD() get_isSelected(long row, long column, boolean *isSelected) override
Determines if table cell is selected.
Definition: AccTable.cxx:626
STDMETHOD() get_rowIndex(long childIndex, long *rowIndex) override
Gets rowIndex of childIndex.
Definition: AccTable.cxx:888
STDMETHOD() get_isRowSelected(long row, boolean *isSelected) override
Determines if table row is selected.
Definition: AccTable.cxx:599
STDMETHOD() get_nSelectedColumns(long *columnCount) override
Gets total number of selected columns.
Definition: AccTable.cxx:274
static bool get_IAccessibleFromXAccessible(css::accessibility::XAccessible *pXAcc, IAccessible **ppIA)
static AccObjectManagerAgent * g_pAgent
Definition: MAccessible.h:207
STDMETHOD() put_XInterface(hyper pXInterface) override
Definition: UNOXWrapper.cxx:27
css::accessibility::XAccessible * pUNOInterface
Definition: UNOXWrapper.h:34
long nSelectedCells
Returns the total number of selected cells.
This interface gives access to a two-dimensional table.
long childIndex([in] long rowIndex,[in] long columnIndex)
Translates the given row and column indexes into the corresponding cell index.
long rowIndex([in] long cellIndex)
Translates the given cell index into a row index.
long columnIndex([in] long cellIndex)
Translates the given cell index into the corresponding column index.
long nRows
Returns the total number of rows in table.
boolean isSelected([in] long row,[in] long column)
Returns a boolean value indicating whether the specified cell is selected.
HRESULT SetXAccessible(hyper XAccessible)
sal_Int32 nIndex
#define SAL_WARN(area, stream)
int i
return hr
A structure defining the type of and extents of changes made to a table.