Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / winaccessibility / source / UAccCOM / AccTable.cxx
blob4ccc2541c15b4a8168984421aaf727d354c0c328
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>
37 #include <com/sun/star/accessibility/XAccessible.hpp>
38 #include "MAccessible.h"
40 #include <com/sun/star/accessibility/XAccessibleTableSelection.hpp>
42 using namespace com::sun::star::accessibility;
43 using namespace com::sun::star::uno;
44 /**
45 * Gets accessible table cell.
47 * @param row the row of the specified cell.
48 * @param column the column of the specified cell.
49 * @param accessible the accessible object of the cell.
52 STDMETHODIMP CAccTable::get_accessibleAt(long row, long column, IUnknown * * accessible)
54 SolarMutexGuard g;
56 ENTER_PROTECTED_BLOCK
58 // #CHECK#
59 if(accessible == NULL)
60 return E_INVALIDARG;
61 // #CHECK XInterface#
62 if(!pRXTable.is())
63 return E_FAIL;
65 Reference<XAccessible> pRAcc = GetXInterface()->getAccessibleCellAt(row,column);
67 if(!pRAcc.is())
69 *accessible = NULL;
70 return E_FAIL;
73 IAccessible* pRet = NULL;
75 BOOL isTRUE = CMAccessible::get_IAccessibleFromXAccessible(pRAcc.get(), &pRet);
76 if(isTRUE)
78 *accessible = (IAccessible2 *)pRet;
79 pRet->AddRef();
80 return S_OK;
82 else if(pRAcc.is())
84 Reference<XAccessible> pxTable(GetXInterface(),UNO_QUERY);
86 CMAccessible::g_pAgent->InsertAccObj(pRAcc.get(),pxTable.get());
87 isTRUE = CMAccessible::get_IAccessibleFromXAccessible(pRAcc.get(), &pRet);
89 if(isTRUE)
91 *accessible = (IAccessible2 *)pRet;
92 pRet->AddRef();
93 return S_OK;
96 return E_FAIL;
98 LEAVE_PROTECTED_BLOCK
102 * Gets accessible table caption.
104 * @param accessible the accessible object of table caption.
106 STDMETHODIMP CAccTable::get_caption(IUnknown * *)
108 return E_NOTIMPL;
112 * Gets accessible column description (as string).
114 * @param column the column index.
115 * @param description the description of the specified column.
117 STDMETHODIMP CAccTable::get_columnDescription(long column, BSTR * description)
119 SolarMutexGuard g;
121 ENTER_PROTECTED_BLOCK
123 // #CHECK#
124 if(description == NULL)
125 return E_INVALIDARG;
127 // #CHECK XInterface#
128 if(!pRXTable.is())
129 return E_FAIL;
131 const ::rtl::OUString& ouStr = GetXInterface()->getAccessibleColumnDescription(column);
132 // #CHECK#
134 SAFE_SYSFREESTRING(*description);//??
135 *description = SysAllocString((OLECHAR*)ouStr.getStr());
136 if(description==NULL)
137 return E_FAIL;
138 return S_OK;
140 LEAVE_PROTECTED_BLOCK
144 * Gets number of columns spanned by table cell.
146 * @param row the row of the specified cell.
147 * @param column the column of the specified cell.
148 * @param spanColumns the column span of the specified cell.
150 STDMETHODIMP CAccTable::get_columnExtentAt(long row, long column, long * nColumnsSpanned)
152 SolarMutexGuard g;
154 ENTER_PROTECTED_BLOCK
156 XAccessibleTable *pXAccTable = GetXInterface();
158 // Check pointer.
159 if(nColumnsSpanned == NULL)
160 return E_INVALIDARG;
162 // Get Extent.
163 if(pXAccTable)
165 long lExt = pXAccTable->getAccessibleColumnExtentAt(row,column);
167 // Fill Extent struct.
168 *nColumnsSpanned = lExt;
169 return S_OK;
172 return E_FAIL;
174 LEAVE_PROTECTED_BLOCK
178 * Gets accessible column header.
180 * @param column the column index.
181 * @param accessible the accessible object of the specified column.
183 STDMETHODIMP CAccTable::get_columnHeader(IAccessibleTable __RPC_FAR *__RPC_FAR *accessibleTable, long *startingRowIndex)
185 SolarMutexGuard g;
187 ENTER_PROTECTED_BLOCK
189 // #CHECK#
190 if(accessibleTable == NULL || startingRowIndex == NULL)
191 return E_INVALIDARG;
193 // #CHECK XInterface#
194 if(!pRXTable.is())
195 return E_FAIL;
197 Reference<XAccessibleTable> pRColumnHeaderTable = GetXInterface()->getAccessibleColumnHeaders();
198 if(!pRColumnHeaderTable.is())
200 *accessibleTable = NULL;
201 return E_FAIL;
204 Reference<XAccessible> pRXColumnHeader(pRColumnHeaderTable,UNO_QUERY);
206 if(!pRXColumnHeader.is())
208 *accessibleTable = NULL;
209 return E_FAIL;
211 *startingRowIndex = 0 ;
213 IMAccessible* pIMacc = NULL;
214 HRESULT hr = createInstance<CMAccessible>(IID_IMAccessible, &pIMacc);
215 if (!SUCCEEDED(hr))
217 return E_FAIL;
219 pIMacc->SetXAccessible(
220 reinterpret_cast<hyper>(pRXColumnHeader.get()));
221 pIMacc->QueryInterface(IID_IAccessibleTable,(void **)accessibleTable);
223 return S_OK;
225 LEAVE_PROTECTED_BLOCK
229 * Gets total number of columns in table.
231 * @param columnCount the number of columns in table.
233 STDMETHODIMP CAccTable::get_nColumns(long * columnCount)
235 SolarMutexGuard g;
237 ENTER_PROTECTED_BLOCK
239 // #CHECK#
240 if(columnCount == NULL)
241 return E_INVALIDARG;
243 // #CHECK XInterface#
244 if(!pRXTable.is())
245 return E_FAIL;
247 *columnCount = GetXInterface()->getAccessibleColumnCount();
248 return S_OK;
250 LEAVE_PROTECTED_BLOCK
254 * Gets total number of rows in table.
256 * @param rowCount the number of rows in table.
258 STDMETHODIMP CAccTable::get_nRows(long * rowCount)
260 SolarMutexGuard g;
262 ENTER_PROTECTED_BLOCK
264 // #CHECK#
265 if(rowCount == NULL)
266 return E_INVALIDARG;
268 // #CHECK XInterface#
269 if(!pRXTable.is())
270 return E_FAIL;
272 *rowCount = GetXInterface()->getAccessibleRowCount();
273 return S_OK;
275 LEAVE_PROTECTED_BLOCK
279 * Gets total number of selected columns.
281 * @param columnCount the number of selected columns.
283 STDMETHODIMP CAccTable::get_nSelectedColumns(long * columnCount)
285 SolarMutexGuard g;
287 ENTER_PROTECTED_BLOCK
289 // #CHECK#
290 if(columnCount == NULL)
291 return E_INVALIDARG;
293 // #CHECK XInterface#
294 if(!pRXTable.is())
295 return E_FAIL;
297 Sequence<long> pSelected = GetXInterface()->getSelectedAccessibleColumns();
298 *columnCount = pSelected.getLength();
299 return S_OK;
301 LEAVE_PROTECTED_BLOCK
305 * Gets total number of selected rows.
307 * @param rowCount the number of selected rows.
309 STDMETHODIMP CAccTable::get_nSelectedRows(long * rowCount)
311 SolarMutexGuard g;
313 ENTER_PROTECTED_BLOCK
315 // #CHECK#
316 if(rowCount == NULL)
317 return E_INVALIDARG;
319 // #CHECK XInterface#
320 if(!pRXTable.is())
321 return E_FAIL;
323 Sequence<long> pSelected = GetXInterface()->getSelectedAccessibleRows();
324 *rowCount = pSelected.getLength();
325 return S_OK;
327 LEAVE_PROTECTED_BLOCK
331 * Gets accessible row description (as string).
333 * @param row the row index.
334 * @param description the description of the specified row.
336 STDMETHODIMP CAccTable::get_rowDescription(long row, BSTR * description)
338 SolarMutexGuard g;
340 ENTER_PROTECTED_BLOCK
342 // #CHECK#
343 if(description == NULL)
344 return E_INVALIDARG;
346 // #CHECK XInterface#
347 if(!pRXTable.is())
348 return E_FAIL;
350 const ::rtl::OUString& ouStr = GetXInterface()->getAccessibleRowDescription(row);
351 // #CHECK#
353 SAFE_SYSFREESTRING(*description);
354 *description = SysAllocString((OLECHAR*)ouStr.getStr());
355 if(description==NULL)
356 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 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 == NULL)
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 STDMETHODIMP CAccTable::get_rowHeader(IAccessibleTable __RPC_FAR *__RPC_FAR *accessibleTable, long *startingColumnIndex)
406 SolarMutexGuard g;
408 ENTER_PROTECTED_BLOCK
410 // #CHECK#
411 if(accessibleTable == NULL || startingColumnIndex == NULL)
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 = NULL;
422 return E_FAIL;
425 Reference<XAccessible> pRXRowHeader(pRRowHeaderTable,UNO_QUERY);
427 if(!pRXRowHeader.is())
429 *accessibleTable = NULL;
430 return E_FAIL;
432 *startingColumnIndex = 0 ;
434 IMAccessible* pIMacc = NULL;
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,(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 STDMETHODIMP CAccTable::get_selectedRows(long, long ** rows, long * nRows)
458 SolarMutexGuard g;
460 ENTER_PROTECTED_BLOCK
462 // #CHECK#
463 if(rows == NULL || nRows == NULL)
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 = reinterpret_cast<long*>(CoTaskMemAlloc((count) * sizeof(long)));
475 // #CHECK Memory Allocation#
476 if(*rows == NULL)
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 STDMETHODIMP CAccTable::get_selectedColumns(long, long ** columns, long * numColumns)
497 SolarMutexGuard g;
499 ENTER_PROTECTED_BLOCK
501 // #CHECK#
502 if(columns == NULL || numColumns == NULL)
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 = reinterpret_cast<long*>(CoTaskMemAlloc((count) * sizeof(long)));
514 // #CHECK Memory Allocation#
515 if(*columns == NULL)
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 STDMETHODIMP CAccTable::get_summary(IUnknown * * accessible)
534 SolarMutexGuard g;
536 ENTER_PROTECTED_BLOCK
538 // #CHECK#
539 if(accessible == NULL)
540 return E_INVALIDARG;
542 // #CHECK XInterface#
543 if(!pRXTable.is())
545 return E_FAIL;
547 Reference<XAccessible> pRAcc = GetXInterface()->getAccessibleSummary();
549 IAccessible* pRet = NULL;
550 CMAccessible::get_IAccessibleFromXAccessible(pRAcc.get(), &pRet);
552 if(pRet)
554 *accessible = (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 STDMETHODIMP CAccTable::get_isColumnSelected(long column, unsigned char * isSelected)
572 SolarMutexGuard g;
574 ENTER_PROTECTED_BLOCK
576 // #CHECK#
577 if(isSelected == NULL)
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 STDMETHODIMP CAccTable::get_isRowSelected(long row, unsigned char * isSelected)
598 SolarMutexGuard g;
600 ENTER_PROTECTED_BLOCK
602 // #CHECK#
603 if(isSelected == NULL)
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 STDMETHODIMP CAccTable::get_isSelected(long row, long column, unsigned char * isSelected)
626 SolarMutexGuard g;
628 ENTER_PROTECTED_BLOCK
630 // #CHECK#
631 if(isSelected == NULL)
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 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.get()->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.get()->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 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.get()->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.get()->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 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.get()->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.get()->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 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.get()->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.get()->deselectAccessibleChild(lChildIndex);
820 return S_OK;
823 LEAVE_PROTECTED_BLOCK
827 * Override of IUNOXWrapper.
829 * @param pXInterface the pointer of UNO interface.
831 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 == NULL)
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 = NULL;
849 else
850 pRXTable = pRXI.get();
851 return S_OK;
853 LEAVE_PROTECTED_BLOCK
857 * Gets columnIndex of childIndex.
859 * @param childIndex childIndex
861 STDMETHODIMP CAccTable::get_columnIndex(long childIndex, long * columnIndex)
863 SolarMutexGuard g;
865 ENTER_PROTECTED_BLOCK
867 // #CHECK#
868 if(columnIndex == NULL)
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 STDMETHODIMP CAccTable::get_rowIndex(long childIndex, long * rowIndex)
887 SolarMutexGuard g;
889 ENTER_PROTECTED_BLOCK
891 // #CHECK#
892 if(rowIndex == NULL)
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 STDMETHODIMP CAccTable::get_childIndex(long RowIndex , long columnIndex, long * childIndex )
911 SolarMutexGuard g;
913 ENTER_PROTECTED_BLOCK
915 // #CHECK#
916 if(childIndex == NULL)
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 STDMETHODIMP CAccTable::get_rowColumnExtentsAtIndex(long,
930 long *,
931 long *,
932 long *,
933 long *,
934 boolean *)
936 return E_NOTIMPL;
939 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 STDMETHODIMP CAccTable::get_nSelectedChildren(long *childCount)
949 SolarMutexGuard g;
951 ENTER_PROTECTED_BLOCK
953 // #CHECK#
954 if(childCount == NULL)
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 STDMETHODIMP CAccTable::get_selectedChildren(long, long **children, long *nChildren)
980 SolarMutexGuard g;
982 ENTER_PROTECTED_BLOCK
984 // #CHECK#
985 if(children == NULL || nChildren == NULL)
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 = reinterpret_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: */