nss: upgrade to release 3.73
[LibreOffice.git] / winaccessibility / source / UAccCOM / AccTable.cxx
blob25ecb2ea84967ddf8f93b672744decb86ed42706
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 /**
21 * AccTable.cpp : Implementation of CAccTable.
23 #include "stdafx.h"
24 #include "AccTable.h"
26 #if defined __clang__
27 #pragma clang diagnostic push
28 #pragma clang diagnostic ignored "-Wnon-virtual-dtor"
29 #endif
30 #include <UAccCOM.h>
31 #if defined __clang__
32 #pragma clang diagnostic pop
33 #endif
35 #include <vcl/svapp.hxx>
36 #include <o3tl/char16_t2wchar_t.hxx>
38 #include <com/sun/star/accessibility/XAccessible.hpp>
39 #include "MAccessible.h"
41 #include <com/sun/star/accessibility/XAccessibleTableSelection.hpp>
43 using namespace com::sun::star::accessibility;
44 using namespace com::sun::star::uno;
45 /**
46 * Gets accessible table cell.
48 * @param row the row of the specified cell.
49 * @param column the column of the specified cell.
50 * @param accessible the accessible object of the cell.
53 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_accessibleAt(long row, long column, IUnknown * * accessible)
55 SolarMutexGuard g;
57 ENTER_PROTECTED_BLOCK
59 // #CHECK#
60 if(accessible == nullptr)
61 return E_INVALIDARG;
62 // #CHECK XInterface#
63 if(!pRXTable.is())
64 return E_FAIL;
66 Reference<XAccessible> pRAcc = GetXInterface()->getAccessibleCellAt(row,column);
68 if(!pRAcc.is())
70 *accessible = nullptr;
71 return E_FAIL;
74 IAccessible* pRet = nullptr;
76 bool isTRUE = CMAccessible::get_IAccessibleFromXAccessible(pRAcc.get(), &pRet);
77 if(isTRUE)
79 *accessible = static_cast<IAccessible2 *>(pRet);
80 pRet->AddRef();
81 return S_OK;
83 else if(pRAcc.is())
85 Reference<XAccessible> pxTable(GetXInterface(),UNO_QUERY);
87 CMAccessible::g_pAgent->InsertAccObj(pRAcc.get(),pxTable.get());
88 isTRUE = CMAccessible::get_IAccessibleFromXAccessible(pRAcc.get(), &pRet);
90 if(isTRUE)
92 *accessible = static_cast<IAccessible2 *>(pRet);
93 pRet->AddRef();
94 return S_OK;
97 return E_FAIL;
99 LEAVE_PROTECTED_BLOCK
103 * Gets accessible table caption.
105 * @param accessible the accessible object of table caption.
107 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_caption(IUnknown * *)
109 return E_NOTIMPL;
113 * Gets accessible column description (as string).
115 * @param column the column index.
116 * @param description the description of the specified column.
118 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_columnDescription(long column, BSTR * description)
120 SolarMutexGuard g;
122 ENTER_PROTECTED_BLOCK
124 // #CHECK#
125 if(description == nullptr)
126 return E_INVALIDARG;
128 // #CHECK XInterface#
129 if(!pRXTable.is())
130 return E_FAIL;
132 const OUString& ouStr = GetXInterface()->getAccessibleColumnDescription(column);
133 // #CHECK#
135 SAFE_SYSFREESTRING(*description);
136 *description = SysAllocString(o3tl::toW(ouStr.getStr()));
137 if (*description==nullptr)
138 return E_FAIL;
139 return S_OK;
141 LEAVE_PROTECTED_BLOCK
145 * Gets number of columns spanned by table cell.
147 * @param row the row of the specified cell.
148 * @param column the column of the specified cell.
149 * @param spanColumns the column span of the specified cell.
151 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_columnExtentAt(long row, long column, long * nColumnsSpanned)
153 SolarMutexGuard g;
155 ENTER_PROTECTED_BLOCK
157 XAccessibleTable *pXAccTable = GetXInterface();
159 // Check pointer.
160 if(nColumnsSpanned == nullptr)
161 return E_INVALIDARG;
163 // Get Extent.
164 if(pXAccTable)
166 long lExt = pXAccTable->getAccessibleColumnExtentAt(row,column);
168 // Fill Extent struct.
169 *nColumnsSpanned = lExt;
170 return S_OK;
173 return E_FAIL;
175 LEAVE_PROTECTED_BLOCK
179 * Gets accessible column header.
181 * @param column the column index.
182 * @param accessible the accessible object of the specified column.
184 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_columnHeader(IAccessibleTable __RPC_FAR *__RPC_FAR *accessibleTable, long *startingRowIndex)
186 SolarMutexGuard g;
188 ENTER_PROTECTED_BLOCK
190 // #CHECK#
191 if(accessibleTable == nullptr || startingRowIndex == nullptr)
192 return E_INVALIDARG;
194 // #CHECK XInterface#
195 if(!pRXTable.is())
196 return E_FAIL;
198 Reference<XAccessibleTable> pRColumnHeaderTable = GetXInterface()->getAccessibleColumnHeaders();
199 if(!pRColumnHeaderTable.is())
201 *accessibleTable = nullptr;
202 return E_FAIL;
205 Reference<XAccessible> pRXColumnHeader(pRColumnHeaderTable,UNO_QUERY);
207 if(!pRXColumnHeader.is())
209 *accessibleTable = nullptr;
210 return E_FAIL;
212 *startingRowIndex = 0 ;
214 IMAccessible* pIMacc = nullptr;
215 HRESULT hr = createInstance<CMAccessible>(IID_IMAccessible, &pIMacc);
216 if (!SUCCEEDED(hr))
218 return E_FAIL;
220 pIMacc->SetXAccessible(
221 reinterpret_cast<hyper>(pRXColumnHeader.get()));
222 pIMacc->QueryInterface(IID_IAccessibleTable,reinterpret_cast<void **>(accessibleTable));
224 return S_OK;
226 LEAVE_PROTECTED_BLOCK
230 * Gets total number of columns in table.
232 * @param columnCount the number of columns in table.
234 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_nColumns(long * columnCount)
236 SolarMutexGuard g;
238 ENTER_PROTECTED_BLOCK
240 // #CHECK#
241 if(columnCount == nullptr)
242 return E_INVALIDARG;
244 // #CHECK XInterface#
245 if(!pRXTable.is())
246 return E_FAIL;
248 *columnCount = GetXInterface()->getAccessibleColumnCount();
249 return S_OK;
251 LEAVE_PROTECTED_BLOCK
255 * Gets total number of rows in table.
257 * @param rowCount the number of rows in table.
259 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_nRows(long * rowCount)
261 SolarMutexGuard g;
263 ENTER_PROTECTED_BLOCK
265 // #CHECK#
266 if(rowCount == nullptr)
267 return E_INVALIDARG;
269 // #CHECK XInterface#
270 if(!pRXTable.is())
271 return E_FAIL;
273 *rowCount = GetXInterface()->getAccessibleRowCount();
274 return S_OK;
276 LEAVE_PROTECTED_BLOCK
280 * Gets total number of selected columns.
282 * @param columnCount the number of selected columns.
284 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_nSelectedColumns(long * columnCount)
286 SolarMutexGuard g;
288 ENTER_PROTECTED_BLOCK
290 // #CHECK#
291 if(columnCount == nullptr)
292 return E_INVALIDARG;
294 // #CHECK XInterface#
295 if(!pRXTable.is())
296 return E_FAIL;
298 Sequence<long> pSelected = GetXInterface()->getSelectedAccessibleColumns();
299 *columnCount = pSelected.getLength();
300 return S_OK;
302 LEAVE_PROTECTED_BLOCK
306 * Gets total number of selected rows.
308 * @param rowCount the number of selected rows.
310 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_nSelectedRows(long * rowCount)
312 SolarMutexGuard g;
314 ENTER_PROTECTED_BLOCK
316 // #CHECK#
317 if(rowCount == nullptr)
318 return E_INVALIDARG;
320 // #CHECK XInterface#
321 if(!pRXTable.is())
322 return E_FAIL;
324 Sequence<long> pSelected = GetXInterface()->getSelectedAccessibleRows();
325 *rowCount = pSelected.getLength();
326 return S_OK;
328 LEAVE_PROTECTED_BLOCK
332 * Gets accessible row description (as string).
334 * @param row the row index.
335 * @param description the description of the specified row.
337 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_rowDescription(long row, BSTR * description)
339 SolarMutexGuard g;
341 ENTER_PROTECTED_BLOCK
343 // #CHECK#
344 if(description == nullptr)
345 return E_INVALIDARG;
347 // #CHECK XInterface#
348 if(!pRXTable.is())
349 return E_FAIL;
351 const OUString& ouStr = GetXInterface()->getAccessibleRowDescription(row);
352 // #CHECK#
354 SAFE_SYSFREESTRING(*description);
355 *description = SysAllocString(o3tl::toW(ouStr.getStr()));
356 if (*description==nullptr)
357 return E_FAIL;
358 return S_OK;
360 LEAVE_PROTECTED_BLOCK
364 * Gets number of rows spanned by a table cell.
366 * @param row the row of the specified cell.
367 * @param column the column of the specified cell.
368 * @param spanRows the row span of the specified cell.
370 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_rowExtentAt(long row, long column, long * nRowsSpanned)
372 SolarMutexGuard g;
374 ENTER_PROTECTED_BLOCK
376 XAccessibleTable *pXAccTable = GetXInterface();
378 // Check pointer.
379 if(nRowsSpanned == nullptr)
380 return E_INVALIDARG;
382 // Get Extent.
383 if(pXAccTable)
385 long lExt = GetXInterface()->getAccessibleRowExtentAt(row,column);
387 // Fill Extent struct.
388 *nRowsSpanned= lExt;
390 return S_OK;
393 return E_FAIL;
395 LEAVE_PROTECTED_BLOCK
399 * Gets accessible row header.
401 * @param row the row index.
402 * @param accessible the accessible object of the row header.
404 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_rowHeader(IAccessibleTable __RPC_FAR *__RPC_FAR *accessibleTable, long *startingColumnIndex)
406 SolarMutexGuard g;
408 ENTER_PROTECTED_BLOCK
410 // #CHECK#
411 if(accessibleTable == nullptr || startingColumnIndex == nullptr)
412 return E_INVALIDARG;
414 // #CHECK XInterface#
415 if(!pRXTable.is())
416 return E_FAIL;
418 Reference<XAccessibleTable> pRRowHeaderTable = GetXInterface()->getAccessibleRowHeaders();
419 if(!pRRowHeaderTable.is())
421 *accessibleTable = nullptr;
422 return E_FAIL;
425 Reference<XAccessible> pRXRowHeader(pRRowHeaderTable,UNO_QUERY);
427 if(!pRXRowHeader.is())
429 *accessibleTable = nullptr;
430 return E_FAIL;
432 *startingColumnIndex = 0 ;
434 IMAccessible* pIMacc = nullptr;
435 HRESULT hr = createInstance<CMAccessible>(IID_IMAccessible, &pIMacc);
436 if (!SUCCEEDED(hr))
438 return E_FAIL;
440 pIMacc->SetXAccessible(
441 reinterpret_cast<hyper>(pRXRowHeader.get()));
442 pIMacc->QueryInterface(IID_IAccessibleTable,reinterpret_cast<void **>(accessibleTable));
444 return S_OK;
446 LEAVE_PROTECTED_BLOCK
450 * Gets list of row indexes currently selected (0-based).
452 * @param maxRows the max number of the rows.
453 * @param accessible the accessible object array of the selected rows.
454 * @param nRows the actual size of the accessible object array.
456 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_selectedRows(long, long ** rows, long * nRows)
458 SolarMutexGuard g;
460 ENTER_PROTECTED_BLOCK
462 // #CHECK#
463 if(rows == nullptr || nRows == nullptr)
464 return E_INVALIDARG;
466 // #CHECK XInterface#
467 if(!pRXTable.is())
468 return E_FAIL;
470 Sequence<long> pSelected = GetXInterface()->getSelectedAccessibleRows();
471 long count = pSelected.getLength() ;
472 *nRows = count;
474 *rows = static_cast<long*>(CoTaskMemAlloc(count * sizeof(long)));
475 // #CHECK Memory Allocation#
476 if(*rows == nullptr)
478 return E_FAIL;
480 for(int i=0; i<count; i++)
481 (*rows)[i] = pSelected[i];
483 return S_OK;
485 LEAVE_PROTECTED_BLOCK
489 * Gets list of column indexes currently selected (0-based).
491 * @param maxColumns the max number of the columns.
492 * @param accessible the accessible object array of the selected columns.
493 * @param numColumns the actual size of accessible object array.
495 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_selectedColumns(long, long ** columns, long * numColumns)
497 SolarMutexGuard g;
499 ENTER_PROTECTED_BLOCK
501 // #CHECK#
502 if(columns == nullptr || numColumns == nullptr)
503 return E_INVALIDARG;
505 // #CHECK XInterface#
506 if(!pRXTable.is())
507 return E_FAIL;
509 Sequence<long> pSelected = GetXInterface()->getSelectedAccessibleColumns();
510 long count = pSelected.getLength() ;
511 *numColumns = count;
513 *columns = static_cast<long*>(CoTaskMemAlloc(count * sizeof(long)));
514 // #CHECK Memory Allocation#
515 if(*columns == nullptr)
517 return E_FAIL;
519 for(int i=0; i<count; i++)
520 (*columns)[i] = pSelected[i];
522 return S_OK;
524 LEAVE_PROTECTED_BLOCK
528 * Gets accessible table summary.
530 * @param accessible the accessible object of the summary.
532 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_summary(IUnknown * * accessible)
534 SolarMutexGuard g;
536 ENTER_PROTECTED_BLOCK
538 // #CHECK#
539 if(accessible == nullptr)
540 return E_INVALIDARG;
542 // #CHECK XInterface#
543 if(!pRXTable.is())
545 return E_FAIL;
547 Reference<XAccessible> pRAcc = GetXInterface()->getAccessibleSummary();
549 IAccessible* pRet = nullptr;
550 CMAccessible::get_IAccessibleFromXAccessible(pRAcc.get(), &pRet);
552 if(pRet)
554 *accessible = static_cast<IAccessible2 *>(pRet);
555 pRet->AddRef();
556 return S_OK;
559 return E_FAIL;
561 LEAVE_PROTECTED_BLOCK
565 * Determines if table column is selected.
567 * @param column the column index.
568 * @param isSelected the result.
570 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_isColumnSelected(long column, boolean * isSelected)
572 SolarMutexGuard g;
574 ENTER_PROTECTED_BLOCK
576 // #CHECK#
577 if(isSelected == nullptr)
578 return E_INVALIDARG;
580 // #CHECK XInterface#
581 if(!pRXTable.is())
582 return E_FAIL;
584 *isSelected = GetXInterface()->isAccessibleColumnSelected(column);
585 return S_OK;
587 LEAVE_PROTECTED_BLOCK
591 * Determines if table row is selected.
593 * @param row the row index.
594 * @param isSelected the result.
596 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_isRowSelected(long row, boolean * isSelected)
598 SolarMutexGuard g;
600 ENTER_PROTECTED_BLOCK
602 // #CHECK#
603 if(isSelected == nullptr)
604 return E_INVALIDARG;
606 // #CHECK XInterface#
607 if(!pRXTable.is())
609 return E_FAIL;
611 *isSelected = GetXInterface()->isAccessibleRowSelected(row);
612 return S_OK;
614 LEAVE_PROTECTED_BLOCK
618 * Determines if table cell is selected.
620 * @param row the row index.
621 * @param column the column index.
622 * @param isSelected the result.
624 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_isSelected(long row, long column, boolean * isSelected)
626 SolarMutexGuard g;
628 ENTER_PROTECTED_BLOCK
630 // #CHECK#
631 if(isSelected == nullptr)
632 return E_INVALIDARG;
634 // #CHECK XInterface#
635 if(!pRXTable.is())
636 return E_FAIL;
638 *isSelected = GetXInterface()->isAccessibleSelected(row,column);
639 return S_OK;
641 LEAVE_PROTECTED_BLOCK
645 * Selects a row and unselect all previously selected rows.
647 * @param row the row index.
648 * @param success the result.
650 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::selectRow(long row)
652 SolarMutexGuard g;
654 ENTER_PROTECTED_BLOCK
656 // Check XAccessibleTable reference.
657 if(!pRXTable.is())
658 return E_FAIL;
660 Reference<XAccessibleTableSelection> pRTableExtent(pRXTable, UNO_QUERY);
661 if(pRTableExtent.is())
663 pRTableExtent->selectRow(row);
664 return S_OK;
666 else
668 // Get XAccessibleSelection.
669 Reference<XAccessibleSelection> pRSelection(GetXInterface(), UNO_QUERY);
670 if(!pRSelection.is())
671 return E_FAIL;
673 // Select row.
674 long lCol, lColumnCount;
675 lColumnCount = GetXInterface()->getAccessibleColumnCount();
676 for(lCol = 0; lCol < lColumnCount; lCol ++)
678 long lChildIndex = GetXInterface()->getAccessibleIndex(row, lCol);
679 pRSelection->selectAccessibleChild(lChildIndex);
682 return S_OK;
685 LEAVE_PROTECTED_BLOCK
689 * Selects a column and unselect all previously selected columns.
691 * @param column the column index.
692 * @param success the result.
694 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::selectColumn(long column)
696 SolarMutexGuard g;
698 ENTER_PROTECTED_BLOCK
700 // Check XAccessibleTable reference.
701 if(!pRXTable.is())
702 return E_FAIL;
704 Reference<XAccessibleTableSelection> pRTableExtent(GetXInterface(), UNO_QUERY);
705 if(pRTableExtent.is())
707 pRTableExtent->selectColumn(column);
708 return S_OK;
710 else
712 // Get XAccessibleSelection.
713 Reference<XAccessibleSelection> pRSelection(pRXTable, UNO_QUERY);
714 if(!pRSelection.is())
715 return E_FAIL;
717 // Select column.
718 long lRow, lRowCount;
719 lRowCount = GetXInterface()->getAccessibleRowCount();
720 for(lRow = 0; lRow < lRowCount; lRow ++)
722 long lChildIndex = GetXInterface()->getAccessibleIndex(lRow, column);
723 pRSelection->selectAccessibleChild(lChildIndex);
726 return S_OK;
728 // End of added.
730 LEAVE_PROTECTED_BLOCK
734 * Unselects one row, leaving other selected rows selected (if any).
736 * @param row the row index.
737 * @param success the result.
739 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::unselectRow(long row)
741 SolarMutexGuard g;
743 ENTER_PROTECTED_BLOCK
745 // Check XAccessibleTable reference.
746 if(!pRXTable.is())
747 return E_FAIL;
749 Reference<XAccessibleTableSelection> pRTableExtent(GetXInterface(), UNO_QUERY);
750 if(pRTableExtent.is())
752 if(pRTableExtent->unselectRow(row))
753 return S_OK;
754 else
755 return E_FAIL;
757 else
759 // Get XAccessibleSelection.
760 Reference<XAccessibleSelection> pRSelection(pRXTable, UNO_QUERY);
761 if(!pRSelection.is())
762 return E_FAIL;
764 // Select column.
765 long lColumn, lColumnCount;
766 lColumnCount = GetXInterface()->getAccessibleColumnCount();
767 for(lColumn = 0; lColumn < lColumnCount; lColumn ++)
769 long lChildIndex = GetXInterface()->getAccessibleIndex(row,lColumn);
770 pRSelection->deselectAccessibleChild(lChildIndex);
773 return S_OK;
775 // End of added.
777 LEAVE_PROTECTED_BLOCK
781 * Unselects one column, leaving other selected columns selected (if any).
783 * @param column the column index.
784 * @param success the result.
786 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::unselectColumn(long column)
788 SolarMutexGuard g;
790 ENTER_PROTECTED_BLOCK
792 // Check XAccessibleTable reference.
793 if(!pRXTable.is())
794 return E_FAIL;
796 Reference<XAccessibleTableSelection> pRTableExtent(GetXInterface(), UNO_QUERY);
797 if(pRTableExtent.is())
799 if(pRTableExtent->unselectColumn(column))
800 return S_OK;
801 else
802 return E_FAIL;
804 else
806 // Get XAccessibleSelection.
807 Reference<XAccessibleSelection> pRSelection(pRXTable, UNO_QUERY);
808 if(!pRSelection.is())
809 return E_FAIL;
811 // Unselect columns.
812 long lRow, lRowCount;
813 lRowCount = GetXInterface()->getAccessibleRowCount();
815 for(lRow = 0; lRow < lRowCount; lRow ++)
817 long lChildIndex = GetXInterface()->getAccessibleIndex(lRow, column);
818 pRSelection->deselectAccessibleChild(lChildIndex);
820 return S_OK;
823 LEAVE_PROTECTED_BLOCK
827 * Override of IUNOXWrapper.
829 * @param pXInterface the pointer of UNO interface.
831 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::put_XInterface(hyper pXInterface)
833 // internal IUNOXWrapper - no mutex meeded
835 ENTER_PROTECTED_BLOCK
837 CUNOXWrapper::put_XInterface(pXInterface);
838 //special query.
839 if(pUNOInterface == nullptr)
840 return E_INVALIDARG;
842 Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext();
843 if( !pRContext.is() )
844 return E_FAIL;
846 Reference<XAccessibleTable> pRXI(pRContext,UNO_QUERY);
847 if( !pRXI.is() )
848 pRXTable = nullptr;
849 else
850 pRXTable = pRXI.get();
851 return S_OK;
853 LEAVE_PROTECTED_BLOCK
857 * Gets columnIndex of childIndex.
859 * @param childIndex childIndex
861 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_columnIndex(long childIndex, long * columnIndex)
863 SolarMutexGuard g;
865 ENTER_PROTECTED_BLOCK
867 // #CHECK#
868 if(columnIndex == nullptr)
869 return E_INVALIDARG;
871 // #CHECK XInterface#
872 if(!pRXTable.is())
873 return E_FAIL;
875 *columnIndex = GetXInterface()->getAccessibleColumn(childIndex);
876 return S_OK;
878 LEAVE_PROTECTED_BLOCK
881 * Gets rowIndex of childIndex.
883 * @param childIndex childIndex
885 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_rowIndex(long childIndex, long * rowIndex)
887 SolarMutexGuard g;
889 ENTER_PROTECTED_BLOCK
891 // #CHECK#
892 if(rowIndex == nullptr)
893 return E_INVALIDARG;
895 // #CHECK XInterface#
896 if(!pRXTable.is())
897 return E_FAIL;
899 *rowIndex = GetXInterface()->getAccessibleRow(childIndex);
900 return S_OK;
902 LEAVE_PROTECTED_BLOCK
905 * Gets childIndex of childIndex.
907 * @param childIndex childIndex
909 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_childIndex(long RowIndex , long columnIndex, long * childIndex )
911 SolarMutexGuard g;
913 ENTER_PROTECTED_BLOCK
915 // #CHECK#
916 if(childIndex == nullptr)
917 return E_INVALIDARG;
919 // #CHECK XInterface#
920 if(!pRXTable.is())
921 return E_FAIL;
923 *childIndex = GetXInterface()->getAccessibleIndex(RowIndex, columnIndex);
924 return S_OK;
926 LEAVE_PROTECTED_BLOCK
929 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_rowColumnExtentsAtIndex(long,
930 long *,
931 long *,
932 long *,
933 long *,
934 boolean *)
936 return E_NOTIMPL;
939 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_modelChange(IA2TableModelChange *)
941 return E_NOTIMPL;
944 // @brief Returns the total number of selected children
945 // @param [out] childCount
946 // Number of children currently selected
947 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_nSelectedChildren(long *childCount)
949 SolarMutexGuard g;
951 ENTER_PROTECTED_BLOCK
953 // #CHECK#
954 if(childCount == nullptr)
955 return E_INVALIDARG;
957 // #CHECK XInterface#
958 if(!pRXTable.is())
959 return E_FAIL;
961 Reference<XAccessibleSelection> pRSelection(GetXInterface(), UNO_QUERY);
962 if(!pRSelection.is())
963 return E_FAIL;
965 *childCount = pRSelection->getSelectedAccessibleChildCount();
966 return S_OK;
968 LEAVE_PROTECTED_BLOCK
971 // @brief Returns a list of child indexes currently selected (0-based).
972 // @param [in] maxChildren
973 // Max children requested (possibly from IAccessibleTable::nSelectedChildren)
974 // @param [out] children
975 // array of indexes of selected children (each index is 0-based)
976 // @param [out] nChildren
977 // Length of array (not more than maxChildren)
978 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_selectedChildren(long, long **children, long *nChildren)
980 SolarMutexGuard g;
982 ENTER_PROTECTED_BLOCK
984 // #CHECK#
985 if(children == nullptr || nChildren == nullptr)
986 return E_INVALIDARG;
988 // #CHECK XInterface#
989 if(!pRXTable.is())
990 return E_FAIL;
992 Reference<XAccessibleSelection> pRSelection(GetXInterface(), UNO_QUERY);
993 if(!pRSelection.is())
994 return E_FAIL;
996 long childCount = pRSelection->getSelectedAccessibleChildCount() ;
998 *nChildren = childCount;
1000 *children = static_cast<long*>(CoTaskMemAlloc(childCount * sizeof(long)));
1002 for( long i = 0; i< childCount; i++)
1004 Reference<XAccessible> pRAcc = pRSelection->getSelectedAccessibleChild(i);
1005 if(pRAcc.is())
1007 Reference<XAccessibleContext> pRContext(pRAcc, UNO_QUERY);
1008 if( !pRContext.is() )
1009 return E_FAIL;
1011 long childIndex = pRContext->getAccessibleIndexInParent();
1012 (*children)[i] = childIndex;
1016 return S_OK;
1018 LEAVE_PROTECTED_BLOCK
1022 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */