bump product version to 5.0.4.1
[LibreOffice.git] / winaccessibility / source / UAccCOM / AccTable.cxx
blob8510a441514816a3da20570164c3bab2b988bb69
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 "UAccCOM.h"
25 #include "AccTable.h"
27 #include <vcl/svapp.hxx>
29 #include <com/sun/star/accessibility/XAccessible.hpp>
30 #include "MAccessible.h"
32 #include <com/sun/star/accessibility/XAccessibleTableSelection.hpp>
34 using namespace com::sun::star::accessibility;
35 using namespace com::sun::star::uno;
36 /**
37 * Gets accessible table cell.
39 * @param row the row of the specified cell.
40 * @param column the column of the specified cell.
41 * @param accessible the accessible object of the cell.
44 STDMETHODIMP CAccTable::get_accessibleAt(long row, long column, IUnknown * * accessible)
46 SolarMutexGuard g;
48 ENTER_PROTECTED_BLOCK
50 // #CHECK#
51 if(accessible == NULL)
52 return E_INVALIDARG;
53 // #CHECK XInterface#
54 if(!pRXTable.is())
55 return E_FAIL;
57 Reference<XAccessible> pRAcc = GetXInterface()->getAccessibleCellAt(row,column);
59 if(!pRAcc.is())
61 *accessible = NULL;
62 return E_FAIL;
65 IAccessible* pRet = NULL;
67 BOOL isTRUE = CMAccessible::get_IAccessibleFromXAccessible(pRAcc.get(), &pRet);
68 if(isTRUE)
70 *accessible = (IAccessible2 *)pRet;
71 pRet->AddRef();
72 return S_OK;
74 else if(pRAcc.is())
76 Reference<XAccessible> pxTable(GetXInterface(),UNO_QUERY);
78 CMAccessible::g_pAgent->InsertAccObj(pRAcc.get(),pxTable.get());
79 isTRUE = CMAccessible::get_IAccessibleFromXAccessible(pRAcc.get(), &pRet);
81 if(isTRUE)
83 *accessible = (IAccessible2 *)pRet;
84 pRet->AddRef();
85 return S_OK;
88 return E_FAIL;
90 LEAVE_PROTECTED_BLOCK
93 /**
94 * Gets accessible table caption.
96 * @param accessible the accessible object of table cpation.
98 STDMETHODIMP CAccTable::get_caption(IUnknown * *)
100 return E_NOTIMPL;
104 * Gets accessible column description (as string).
106 * @param column the column index.
107 * @param description the description of the specified column.
109 STDMETHODIMP CAccTable::get_columnDescription(long column, BSTR * description)
111 SolarMutexGuard g;
113 ENTER_PROTECTED_BLOCK
115 // #CHECK#
116 if(description == NULL)
117 return E_INVALIDARG;
119 // #CHECK XInterface#
120 if(!pRXTable.is())
121 return E_FAIL;
123 const ::rtl::OUString& ouStr = GetXInterface()->getAccessibleColumnDescription(column);
124 // #CHECK#
126 SAFE_SYSFREESTRING(*description);//??
127 *description = SysAllocString((OLECHAR*)ouStr.getStr());
128 if(description==NULL)
129 return E_FAIL;
130 return S_OK;
132 LEAVE_PROTECTED_BLOCK
136 * Gets number of columns spanned by table cell.
138 * @param row the row of the specified cell.
139 * @param column the column of the specified cell.
140 * @param spanColumns the column span of the specified cell.
142 STDMETHODIMP CAccTable::get_columnExtentAt(long row, long column, long * nColumnsSpanned)
144 SolarMutexGuard g;
146 ENTER_PROTECTED_BLOCK
148 XAccessibleTable *pXAccTable = GetXInterface();
150 // Check pointer.
151 if(nColumnsSpanned == NULL)
152 return E_INVALIDARG;
154 // Get Extent.
155 if(pXAccTable)
157 long lExt = pXAccTable->getAccessibleColumnExtentAt(row,column);
159 // Fill Extent struct.
160 *nColumnsSpanned = lExt;
161 return S_OK;
164 return E_FAIL;
166 LEAVE_PROTECTED_BLOCK
170 * Gets accessible column header.
172 * @param column the column index.
173 * @param accessible the accessible object of the specified column.
175 STDMETHODIMP CAccTable::get_columnHeader(IAccessibleTable __RPC_FAR *__RPC_FAR *accessibleTable, long *startingRowIndex)
177 SolarMutexGuard g;
179 ENTER_PROTECTED_BLOCK
181 // #CHECK#
182 if(accessibleTable == NULL || startingRowIndex == NULL)
183 return E_INVALIDARG;
185 // #CHECK XInterface#
186 if(!pRXTable.is())
187 return E_FAIL;
189 Reference<XAccessibleTable> pRColumnHeaderTable = GetXInterface()->getAccessibleColumnHeaders();
190 if(!pRColumnHeaderTable.is())
192 *accessibleTable = NULL;
193 return E_FAIL;
196 Reference<XAccessible> pRXColumnHeader(pRColumnHeaderTable,UNO_QUERY);
198 if(!pRXColumnHeader.is())
200 *accessibleTable = NULL;
201 return E_FAIL;
203 *startingRowIndex = 0 ;
205 IMAccessible* pIMacc = NULL;
206 HRESULT hr = createInstance<CMAccessible>(IID_IMAccessible, &pIMacc);
207 if (!SUCCEEDED(hr))
209 return E_FAIL;
211 pIMacc->SetXAccessible(
212 reinterpret_cast<hyper>(pRXColumnHeader.get()));
213 pIMacc->QueryInterface(IID_IAccessibleTable,(void **)accessibleTable);
215 return S_OK;
217 LEAVE_PROTECTED_BLOCK
221 * Gets total number of columns in table.
223 * @param columnCount the number of columns in table.
225 STDMETHODIMP CAccTable::get_nColumns(long * columnCount)
227 SolarMutexGuard g;
229 ENTER_PROTECTED_BLOCK
231 // #CHECK#
232 if(columnCount == NULL)
233 return E_INVALIDARG;
235 // #CHECK XInterface#
236 if(!pRXTable.is())
237 return E_FAIL;
239 *columnCount = GetXInterface()->getAccessibleColumnCount();
240 return S_OK;
242 LEAVE_PROTECTED_BLOCK
246 * Gets total number of rows in table.
248 * @param rowCount the number of rows in table.
250 STDMETHODIMP CAccTable::get_nRows(long * rowCount)
252 SolarMutexGuard g;
254 ENTER_PROTECTED_BLOCK
256 // #CHECK#
257 if(rowCount == NULL)
258 return E_INVALIDARG;
260 // #CHECK XInterface#
261 if(!pRXTable.is())
262 return E_FAIL;
264 *rowCount = GetXInterface()->getAccessibleRowCount();
265 return S_OK;
267 LEAVE_PROTECTED_BLOCK
271 * Gets total number of selected columns.
273 * @param columnCount the number of selected columns.
275 STDMETHODIMP CAccTable::get_nSelectedColumns(long * columnCount)
277 SolarMutexGuard g;
279 ENTER_PROTECTED_BLOCK
281 // #CHECK#
282 if(columnCount == NULL)
283 return E_INVALIDARG;
285 // #CHECK XInterface#
286 if(!pRXTable.is())
287 return E_FAIL;
289 Sequence<long> pSelected = GetXInterface()->getSelectedAccessibleColumns();
290 *columnCount = pSelected.getLength();
291 return S_OK;
293 LEAVE_PROTECTED_BLOCK
297 * Gets total number of selected rows.
299 * @param rowCount the number of selected rows.
301 STDMETHODIMP CAccTable::get_nSelectedRows(long * rowCount)
303 SolarMutexGuard g;
305 ENTER_PROTECTED_BLOCK
307 // #CHECK#
308 if(rowCount == NULL)
309 return E_INVALIDARG;
311 // #CHECK XInterface#
312 if(!pRXTable.is())
313 return E_FAIL;
315 Sequence<long> pSelected = GetXInterface()->getSelectedAccessibleRows();
316 *rowCount = pSelected.getLength();
317 return S_OK;
319 LEAVE_PROTECTED_BLOCK
323 * Gets accessible row description (as string).
325 * @param row the row index.
326 * @param description the description of the specified row.
328 STDMETHODIMP CAccTable::get_rowDescription(long row, BSTR * description)
330 SolarMutexGuard g;
332 ENTER_PROTECTED_BLOCK
334 // #CHECK#
335 if(description == NULL)
336 return E_INVALIDARG;
338 // #CHECK XInterface#
339 if(!pRXTable.is())
340 return E_FAIL;
342 const ::rtl::OUString& ouStr = GetXInterface()->getAccessibleRowDescription(row);
343 // #CHECK#
345 SAFE_SYSFREESTRING(*description);
346 *description = SysAllocString((OLECHAR*)ouStr.getStr());
347 if(description==NULL)
348 return E_FAIL;
350 return S_OK;
352 LEAVE_PROTECTED_BLOCK
356 * Gets number of rows spanned by a table cell.
358 * @param row the row of the specified cell.
359 * @param column the column of the specified cell.
360 * @param spanRows the row span of the specified cell.
362 STDMETHODIMP CAccTable::get_rowExtentAt(long row, long column, long * nRowsSpanned)
364 SolarMutexGuard g;
366 ENTER_PROTECTED_BLOCK
368 XAccessibleTable *pXAccTable = GetXInterface();
370 // Check pointer.
371 if(nRowsSpanned == NULL)
372 return E_INVALIDARG;
374 // Get Extent.
375 if(pXAccTable)
377 long lExt = GetXInterface()->getAccessibleRowExtentAt(row,column);
379 // Fill Extent struct.
380 *nRowsSpanned= lExt;
382 return S_OK;
385 return E_FAIL;
387 LEAVE_PROTECTED_BLOCK
391 * Gets accessible row header.
393 * @param row the row index.
394 * @param accessible the accessible object of the row header.
396 STDMETHODIMP CAccTable::get_rowHeader(IAccessibleTable __RPC_FAR *__RPC_FAR *accessibleTable, long *startingColumnIndex)
398 SolarMutexGuard g;
400 ENTER_PROTECTED_BLOCK
402 // #CHECK#
403 if(accessibleTable == NULL || startingColumnIndex == NULL)
404 return E_INVALIDARG;
406 // #CHECK XInterface#
407 if(!pRXTable.is())
408 return E_FAIL;
410 Reference<XAccessibleTable> pRRowHeaderTable = GetXInterface()->getAccessibleRowHeaders();
411 if(!pRRowHeaderTable.is())
413 *accessibleTable = NULL;
414 return E_FAIL;
417 Reference<XAccessible> pRXRowHeader(pRRowHeaderTable,UNO_QUERY);
419 if(!pRXRowHeader.is())
421 *accessibleTable = NULL;
422 return E_FAIL;
424 *startingColumnIndex = 0 ;
426 IMAccessible* pIMacc = NULL;
427 HRESULT hr = createInstance<CMAccessible>(IID_IMAccessible, &pIMacc);
428 if (!SUCCEEDED(hr))
430 return E_FAIL;
432 pIMacc->SetXAccessible(
433 reinterpret_cast<hyper>(pRXRowHeader.get()));
434 pIMacc->QueryInterface(IID_IAccessibleTable,(void **)accessibleTable);
436 return S_OK;
438 LEAVE_PROTECTED_BLOCK
442 * Gets list of row indexes currently selected (0-based).
444 * @param maxRows the max number of the rows.
445 * @param accessible the accessible object array of the selected rows.
446 * @param nRows the actual size of the accessible object array.
448 STDMETHODIMP CAccTable::get_selectedRows(long, long ** rows, long * nRows)
450 SolarMutexGuard g;
452 ENTER_PROTECTED_BLOCK
454 // #CHECK#
455 if(rows == NULL || nRows == NULL)
456 return E_INVALIDARG;
458 // #CHECK XInterface#
459 if(!pRXTable.is())
460 return E_FAIL;
462 Sequence<long> pSelected = GetXInterface()->getSelectedAccessibleRows();
463 long count = pSelected.getLength() ;
464 *nRows = count;
466 *rows = reinterpret_cast<long*>(CoTaskMemAlloc((count) * sizeof(long)));
467 // #CHECK Memory Allocation#
468 if(*rows == NULL)
470 return E_FAIL;
472 for(int i=0; i<count; i++)
473 (*rows)[i] = pSelected[i];
475 return S_OK;
477 LEAVE_PROTECTED_BLOCK
481 * Gets list of column indexes currently selected (0-based).
483 * @param maxColumns the max number of the columns.
484 * @param accessible the accessible object array of the selected columns.
485 * @param numColumns the actual size of accessible object array.
487 STDMETHODIMP CAccTable::get_selectedColumns(long, long ** columns, long * numColumns)
489 SolarMutexGuard g;
491 ENTER_PROTECTED_BLOCK
493 // #CHECK#
494 if(columns == NULL || numColumns == NULL)
495 return E_INVALIDARG;
497 // #CHECK XInterface#
498 if(!pRXTable.is())
499 return E_FAIL;
501 Sequence<long> pSelected = GetXInterface()->getSelectedAccessibleColumns();
502 long count = pSelected.getLength() ;
503 *numColumns = count;
505 *columns = reinterpret_cast<long*>(CoTaskMemAlloc((count) * sizeof(long)));
506 // #CHECK Memory Allocation#
507 if(*columns == NULL)
509 return E_FAIL;
511 for(int i=0; i<count; i++)
512 (*columns)[i] = pSelected[i];
514 return S_OK;
516 LEAVE_PROTECTED_BLOCK
520 * Gets accessible table summary.
522 * @param accessible the accessible object of the summary.
524 STDMETHODIMP CAccTable::get_summary(IUnknown * * accessible)
526 SolarMutexGuard g;
528 ENTER_PROTECTED_BLOCK
530 // #CHECK#
531 if(accessible == NULL)
532 return E_INVALIDARG;
534 // #CHECK XInterface#
535 if(!pRXTable.is())
537 return E_FAIL;
539 Reference<XAccessible> pRAcc = GetXInterface()->getAccessibleSummary();
541 IAccessible* pRet = NULL;
542 CMAccessible::get_IAccessibleFromXAccessible(pRAcc.get(), &pRet);
544 if(pRet)
546 *accessible = (IAccessible2 *)pRet;
547 pRet->AddRef();
548 return S_OK;
551 return E_FAIL;
553 LEAVE_PROTECTED_BLOCK
557 * Determines if table column is selected.
559 * @param column the column index.
560 * @param isSelected the result.
562 STDMETHODIMP CAccTable::get_isColumnSelected(long column, unsigned char * isSelected)
564 SolarMutexGuard g;
566 ENTER_PROTECTED_BLOCK
568 // #CHECK#
569 if(isSelected == NULL)
570 return E_INVALIDARG;
572 // #CHECK XInterface#
573 if(!pRXTable.is())
574 return E_FAIL;
576 *isSelected = GetXInterface()->isAccessibleColumnSelected(column);
577 return S_OK;
579 LEAVE_PROTECTED_BLOCK
583 * Determines if table row is selected.
585 * @param row the row index.
586 * @param isSelected the result.
588 STDMETHODIMP CAccTable::get_isRowSelected(long row, unsigned char * isSelected)
590 SolarMutexGuard g;
592 ENTER_PROTECTED_BLOCK
594 // #CHECK#
595 if(isSelected == NULL)
596 return E_INVALIDARG;
598 // #CHECK XInterface#
599 if(!pRXTable.is())
601 return E_FAIL;
603 *isSelected = GetXInterface()->isAccessibleRowSelected(row);
604 return S_OK;
606 LEAVE_PROTECTED_BLOCK
610 * Determines if table cell is selected.
612 * @param row the row index.
613 * @param column the column index.
614 * @param isSelected the result.
616 STDMETHODIMP CAccTable::get_isSelected(long row, long column, unsigned char * isSelected)
618 SolarMutexGuard g;
620 ENTER_PROTECTED_BLOCK
622 // #CHECK#
623 if(isSelected == NULL)
624 return E_INVALIDARG;
626 // #CHECK XInterface#
627 if(!pRXTable.is())
628 return E_FAIL;
630 *isSelected = GetXInterface()->isAccessibleSelected(row,column);
631 return S_OK;
633 LEAVE_PROTECTED_BLOCK
637 * Selects a row and unselect all previously selected rows.
639 * @param row the row index.
640 * @param success the result.
642 STDMETHODIMP CAccTable::selectRow(long row)
644 SolarMutexGuard g;
646 ENTER_PROTECTED_BLOCK
648 // Check XAccessibleTable reference.
649 if(!pRXTable.is())
650 return E_FAIL;
652 Reference<XAccessibleTableSelection> pRTableExtent(pRXTable, UNO_QUERY);
653 if(pRTableExtent.is())
655 pRTableExtent.get()->selectRow(row);
656 return S_OK;
658 else
660 // Get XAccessibleSelection.
661 Reference<XAccessibleSelection> pRSelection(GetXInterface(), UNO_QUERY);
662 if(!pRSelection.is())
663 return E_FAIL;
665 // Select row.
666 long lCol, lColumnCount;
667 lColumnCount = GetXInterface()->getAccessibleColumnCount();
668 for(lCol = 0; lCol < lColumnCount; lCol ++)
670 long lChildIndex = GetXInterface()->getAccessibleIndex(row, lCol);
671 pRSelection.get()->selectAccessibleChild(lChildIndex);
674 return S_OK;
677 LEAVE_PROTECTED_BLOCK
681 * Selects a column and unselect all previously selected columns.
683 * @param column the column index.
684 * @param success the result.
686 STDMETHODIMP CAccTable::selectColumn(long column)
688 SolarMutexGuard g;
690 ENTER_PROTECTED_BLOCK
692 // Check XAccessibleTable reference.
693 if(!pRXTable.is())
694 return E_FAIL;
696 Reference<XAccessibleTableSelection> pRTableExtent(GetXInterface(), UNO_QUERY);
697 if(pRTableExtent.is())
699 pRTableExtent.get()->selectColumn(column);
700 return S_OK;
702 else
704 // Get XAccessibleSelection.
705 Reference<XAccessibleSelection> pRSelection(pRXTable, UNO_QUERY);
706 if(!pRSelection.is())
707 return E_FAIL;
709 // Select column.
710 long lRow, lRowCount;
711 lRowCount = GetXInterface()->getAccessibleRowCount();
712 for(lRow = 0; lRow < lRowCount; lRow ++)
714 long lChildIndex = GetXInterface()->getAccessibleIndex(lRow, column);
715 pRSelection.get()->selectAccessibleChild(lChildIndex);
718 return S_OK;
720 // End of added.
722 LEAVE_PROTECTED_BLOCK
726 * Unselects one row, leaving other selected rows selected (if any).
728 * @param row the row index.
729 * @param success the result.
731 STDMETHODIMP CAccTable::unselectRow(long row)
733 SolarMutexGuard g;
735 ENTER_PROTECTED_BLOCK
737 // Check XAccessibleTable reference.
738 if(!pRXTable.is())
739 return E_FAIL;
741 Reference<XAccessibleTableSelection> pRTableExtent(GetXInterface(), UNO_QUERY);
742 if(pRTableExtent.is())
744 if(pRTableExtent.get()->unselectRow(row))
745 return S_OK;
746 else
747 return E_FAIL;
749 else
751 // Get XAccessibleSelection.
752 Reference<XAccessibleSelection> pRSelection(pRXTable, UNO_QUERY);
753 if(!pRSelection.is())
754 return E_FAIL;
756 // Select column.
757 long lColumn, lColumnCount;
758 lColumnCount = GetXInterface()->getAccessibleColumnCount();
759 for(lColumn = 0; lColumn < lColumnCount; lColumn ++)
761 long lChildIndex = GetXInterface()->getAccessibleIndex(row,lColumn);
762 pRSelection.get()->deselectAccessibleChild(lChildIndex);
765 return S_OK;
767 // End of added.
769 LEAVE_PROTECTED_BLOCK
773 * Unselects one column, leaving other selected columns selected (if any).
775 * @param column the column index.
776 * @param success the result.
778 STDMETHODIMP CAccTable::unselectColumn(long column)
780 SolarMutexGuard g;
782 ENTER_PROTECTED_BLOCK
784 // Check XAccessibleTable reference.
785 if(!pRXTable.is())
786 return E_FAIL;
788 Reference<XAccessibleTableSelection> pRTableExtent(GetXInterface(), UNO_QUERY);
789 if(pRTableExtent.is())
791 if(pRTableExtent.get()->unselectColumn(column))
792 return S_OK;
793 else
794 return E_FAIL;
796 else
798 // Get XAccessibleSelection.
799 Reference<XAccessibleSelection> pRSelection(pRXTable, UNO_QUERY);
800 if(!pRSelection.is())
801 return E_FAIL;
803 // Unselect columns.
804 long lRow, lRowCount;
805 lRowCount = GetXInterface()->getAccessibleRowCount();
807 for(lRow = 0; lRow < lRowCount; lRow ++)
809 long lChildIndex = GetXInterface()->getAccessibleIndex(lRow, column);
810 pRSelection.get()->deselectAccessibleChild(lChildIndex);
812 return S_OK;
815 LEAVE_PROTECTED_BLOCK
819 * Override of IUNOXWrapper.
821 * @param pXInterface the pointer of UNO interface.
823 STDMETHODIMP CAccTable::put_XInterface(hyper pXInterface)
825 // internal IUNOXWrapper - no mutex meeded
827 ENTER_PROTECTED_BLOCK
829 CUNOXWrapper::put_XInterface(pXInterface);
830 //special query.
831 if(pUNOInterface == NULL)
832 return E_INVALIDARG;
834 Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext();
835 if( !pRContext.is() )
836 return E_FAIL;
838 Reference<XAccessibleTable> pRXI(pRContext,UNO_QUERY);
839 if( !pRXI.is() )
840 pRXTable = NULL;
841 else
842 pRXTable = pRXI.get();
843 return S_OK;
845 LEAVE_PROTECTED_BLOCK
849 * Gets columnIndex of childIndex.
851 * @param childIndex childIndex
853 STDMETHODIMP CAccTable::get_columnIndex(long childIndex, long * columnIndex)
855 SolarMutexGuard g;
857 ENTER_PROTECTED_BLOCK
859 // #CHECK#
860 if(columnIndex == NULL)
861 return E_INVALIDARG;
863 // #CHECK XInterface#
864 if(!pRXTable.is())
865 return E_FAIL;
867 *columnIndex = GetXInterface()->getAccessibleColumn(childIndex);
868 return S_OK;
870 LEAVE_PROTECTED_BLOCK
873 * Gets rowIndex of childIndex.
875 * @param childIndex childIndex
877 STDMETHODIMP CAccTable::get_rowIndex(long childIndex, long * rowIndex)
879 SolarMutexGuard g;
881 ENTER_PROTECTED_BLOCK
883 // #CHECK#
884 if(rowIndex == NULL)
885 return E_INVALIDARG;
887 // #CHECK XInterface#
888 if(!pRXTable.is())
889 return E_FAIL;
891 *rowIndex = GetXInterface()->getAccessibleRow(childIndex);
892 return S_OK;
894 LEAVE_PROTECTED_BLOCK
897 * Gets childIndex of childIndex.
899 * @param childIndex childIndex
901 STDMETHODIMP CAccTable::get_childIndex(long RowIndex , long columnIndex, long * childIndex )
903 SolarMutexGuard g;
905 ENTER_PROTECTED_BLOCK
907 // #CHECK#
908 if(childIndex == NULL)
909 return E_INVALIDARG;
911 // #CHECK XInterface#
912 if(!pRXTable.is())
913 return E_FAIL;
915 *childIndex = GetXInterface()->getAccessibleIndex(RowIndex, columnIndex);
916 return S_OK;
918 LEAVE_PROTECTED_BLOCK
921 STDMETHODIMP CAccTable::get_rowColumnExtentsAtIndex(long,
922 long *,
923 long *,
924 long *,
925 long *,
926 boolean *)
928 return E_NOTIMPL;
931 STDMETHODIMP CAccTable::get_modelChange(IA2TableModelChange *)
933 return E_NOTIMPL;
936 // @brief Returns the total number of selected children
937 // @param [out] childCount
938 // Number of children currently selected
939 STDMETHODIMP CAccTable::get_nSelectedChildren(long *childCount)
941 SolarMutexGuard g;
943 ENTER_PROTECTED_BLOCK
945 // #CHECK#
946 if(childCount == NULL)
947 return E_INVALIDARG;
949 // #CHECK XInterface#
950 if(!pRXTable.is())
951 return E_FAIL;
953 Reference<XAccessibleSelection> pRSelection(GetXInterface(), UNO_QUERY);
954 if(!pRSelection.is())
955 return E_FAIL;
957 *childCount = pRSelection->getSelectedAccessibleChildCount();
958 return S_OK;
960 LEAVE_PROTECTED_BLOCK
963 // @brief Returns a list of child indexes currently selected (0-based).
964 // @param [in] maxChildren
965 // Max children requested (possibly from IAccessibleTable::nSelectedChildren)
966 // @param [out] children
967 // array of indexes of selected children (each index is 0-based)
968 // @param [out] nChildren
969 // Length of array (not more than maxChildren)
970 STDMETHODIMP CAccTable::get_selectedChildren(long, long **children, long *nChildren)
972 SolarMutexGuard g;
974 ENTER_PROTECTED_BLOCK
976 // #CHECK#
977 if(children == NULL || nChildren == NULL)
978 return E_INVALIDARG;
980 // #CHECK XInterface#
981 if(!pRXTable.is())
982 return E_FAIL;
984 Reference<XAccessibleSelection> pRSelection(GetXInterface(), UNO_QUERY);
985 if(!pRSelection.is())
986 return E_FAIL;
988 long childCount = pRSelection->getSelectedAccessibleChildCount() ;
990 *nChildren = childCount;
992 *children = reinterpret_cast<long*>(CoTaskMemAlloc((childCount) * sizeof(long)));
994 for( long i = 0; i< childCount; i++)
996 Reference<XAccessible> pRAcc = pRSelection->getSelectedAccessibleChild(i);
997 if(pRAcc.is())
999 Reference<XAccessibleContext> pRContext(pRAcc, UNO_QUERY);
1000 if( !pRContext.is() )
1001 return E_FAIL;
1003 long childIndex = pRContext->getAccessibleIndexInParent();
1004 (*children)[i] = childIndex;
1008 return S_OK;
1010 LEAVE_PROTECTED_BLOCK
1014 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */