1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright IBM Corporation 2010.
6  * Copyright 2000, 2010 Oracle and/or its affiliates.
7  *
8  * OpenOffice.org - a multi-platform office productivity suite
9  *
10  * This file is part of OpenOffice.org.
11  *
12  * OpenOffice.org is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 3
14  * only, as published by the Free Software Foundation.
15  *
16  * OpenOffice.org is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU Lesser General Public License version 3 for more details
20  * (a copy is included in the LICENSE file that accompanied this code).
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * version 3 along with OpenOffice.org.  If not, see
24  * <http://www.openoffice.org/license.html>
25  * for a copy of the LGPLv3 License.
26  *
27  ************************************************************************/
28 
29 /**
30  * AccTable.cpp : Implementation of CAccTable.
31  */
32 #include "stdafx.h"
33 #include "UAccCOM2.h"
34 #include "AccTable.h"
35 #include <com/sun/star/accessibility/XAccessible.hpp>
36 #include "MAccessible.h"
37 
38 #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLETABLEEXTENT_HPP_
39 #include <com/sun/star/accessibility/XAccessibleTableSelection.hpp>
40 #endif
41 
42 using namespace com::sun::star::accessibility;
43 using namespace com::sun::star::uno;
44 /**
45   * Gets accessible table cell.
46   *
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.
50   */
51 
52 STDMETHODIMP CAccTable::get_accessibleAt(long row, long column, IUnknown * * accessible)
53 {
54 
55 	CHECK_ENABLE_INF
56 
57     ENTER_PROTECTED_BLOCK
58 
59     // #CHECK#
60     if(accessible == NULL)
61         return E_INVALIDARG;
62     // #CHECK XInterface#
63     if(!pRXTable.is())
64         return E_FAIL;
65 
66     Reference<XAccessible> pRAcc = GetXInterface()->getAccessibleCellAt(row,column);
67 
68     if(!pRAcc.is())
69     {
70         *accessible = NULL;
71         return E_FAIL;
72     }
73 
74     IAccessible* pRet = NULL;
75 
76     BOOL isTRUE = CMAccessible::get_IAccessibleFromXAccessible((long)pRAcc.get(),&pRet);
77     if(isTRUE)
78     {
79         *accessible = (IAccessible2 *)pRet;
80         pRet->AddRef();
81         return S_OK;
82     }
83     else if(pRAcc.is())
84     {
85         Reference<XAccessible> pxTable(GetXInterface(),UNO_QUERY);
86 
87         CMAccessible::g_pAgent->InsertAccObj(pRAcc.get(),pxTable.get());
88         isTRUE = CMAccessible::get_IAccessibleFromXAccessible((long)pRAcc.get(),&pRet);
89 
90         if(isTRUE)
91         {
92             *accessible = (IAccessible2 *)pRet;
93             pRet->AddRef();
94             return S_OK;
95         }
96     }
97     return E_FAIL;
98 
99     LEAVE_PROTECTED_BLOCK
100 }
101 
102 /**
103   * Gets accessible table caption.
104   *
105   * @param    accessible    the accessible object of table cpation.
106   */
107 STDMETHODIMP CAccTable::get_caption(IUnknown * *)
108 {
109 
110 
111     ENTER_PROTECTED_BLOCK
112 
113     return E_NOTIMPL;
114 
115     LEAVE_PROTECTED_BLOCK
116 }
117 
118 /**
119   * Gets accessible column description (as string).
120   *
121   * @param    column        the column index.
122   * @param    description   the description of the specified column.
123   */
124 STDMETHODIMP CAccTable::get_columnDescription(long column, BSTR * description)
125 {
126 
127 	CHECK_ENABLE_INF
128 
129     ENTER_PROTECTED_BLOCK
130 
131     // #CHECK#
132     if(description == NULL)
133         return E_INVALIDARG;
134 
135     // #CHECK XInterface#
136     if(!pRXTable.is())
137         return E_FAIL;
138 
139     const ::rtl::OUString& ouStr = GetXInterface()->getAccessibleColumnDescription(column);
140     // #CHECK#
141 
142     SAFE_SYSFREESTRING(*description);//??
143     *description = SysAllocString((OLECHAR*)ouStr.getStr());
144     if(description==NULL)
145         return E_FAIL;
146     return S_OK;
147 
148     LEAVE_PROTECTED_BLOCK
149 }
150 
151 /**
152   * Gets number of columns spanned by table cell.
153   *
154   * @param    row            the row of the specified cell.
155   * @param    column         the column of the specified cell.
156   * @param    spanColumns    the column span of the specified cell.
157   */
158 STDMETHODIMP CAccTable::get_columnExtentAt(long row, long column, long * nColumnsSpanned)
159 {
160 
161 	CHECK_ENABLE_INF
162 
163     ENTER_PROTECTED_BLOCK
164 
165     XAccessibleTable	*pXAccTable = GetXInterface();
166 
167     // Check pointer.
168     if(nColumnsSpanned == NULL)
169         return E_INVALIDARG;
170 
171     // Get Extent.
172     if(pXAccTable)
173     {
174         long lExt = pXAccTable->getAccessibleColumnExtentAt(row,column);
175 
176         // Fill Extent struct.
177         *nColumnsSpanned = lExt;
178         return S_OK;
179     }
180 
181     return E_FAIL;
182 
183     LEAVE_PROTECTED_BLOCK
184 }
185 
186 /**
187   * Gets accessible column header.
188   *
189   * @param    column        the column index.
190   * @param    accessible    the accessible object of the specified column.
191   */
192 STDMETHODIMP CAccTable::get_columnHeader(IAccessibleTable __RPC_FAR *__RPC_FAR *accessibleTable, long *startingRowIndex)
193 {
194 
195 	CHECK_ENABLE_INF
196 
197     ENTER_PROTECTED_BLOCK
198 
199     // #CHECK#
200     if(accessibleTable == NULL || startingRowIndex == NULL)
201         return E_INVALIDARG;
202 
203     // #CHECK XInterface#
204     if(!pRXTable.is())
205         return E_FAIL;
206 
207     Reference<XAccessibleTable> pRColumnHeaderTable = GetXInterface()->getAccessibleColumnHeaders();
208     if(!pRColumnHeaderTable.is())
209     {
210         *accessibleTable = NULL;
211         return E_FAIL;
212     }
213 
214     Reference<XAccessible> pRXColumnHeader(pRColumnHeaderTable,UNO_QUERY);
215 
216     if(!pRXColumnHeader.is())
217     {
218         *accessibleTable = NULL;
219         return E_FAIL;
220     }
221     *startingRowIndex = 0 ;
222 
223     IAccessible* m_pIMacc = NULL;
224     HRESULT hr = 	CoCreateInstance( CLSID_MAccessible, NULL, CLSCTX_ALL ,
225                                     IID_IMAccessible,
226                                     (void **)&m_pIMacc
227                                   );
228     ((CMAccessible*)m_pIMacc)->SetXAccessible((long)pRXColumnHeader.get());
229     m_pIMacc->QueryInterface(IID_IAccessibleTable,(void **)accessibleTable);
230     if( SUCCEEDED(hr) )
231     {
232         return S_OK;
233     }
234 
235     return E_FAIL;
236 
237     LEAVE_PROTECTED_BLOCK
238 }
239 
240 /**
241   * Gets total number of columns in table.
242   *
243   * @param    columnCount    the number of columns in table.
244   */
245 STDMETHODIMP CAccTable::get_nColumns(long * columnCount)
246 {
247 
248 	CHECK_ENABLE_INF
249 
250     ENTER_PROTECTED_BLOCK
251 
252     // #CHECK#
253     if(columnCount == NULL)
254         return E_INVALIDARG;
255 
256     // #CHECK XInterface#
257     if(!pRXTable.is())
258         return E_FAIL;
259 
260     *columnCount = GetXInterface()->getAccessibleColumnCount();
261     return S_OK;
262 
263     LEAVE_PROTECTED_BLOCK
264 }
265 
266 /**
267   * Gets total number of rows in table.
268   *
269   * @param    rowCount    the number of rows in table.
270   */
271 STDMETHODIMP CAccTable::get_nRows(long * rowCount)
272 {
273 
274 	CHECK_ENABLE_INF
275 
276     ENTER_PROTECTED_BLOCK
277 
278     // #CHECK#
279     if(rowCount == NULL)
280         return E_INVALIDARG;
281 
282     // #CHECK XInterface#
283     if(!pRXTable.is())
284         return E_FAIL;
285 
286     *rowCount = GetXInterface()->getAccessibleRowCount();
287     return S_OK;
288 
289     LEAVE_PROTECTED_BLOCK
290 }
291 
292 /**
293   * Gets total number of selected columns.
294   *
295   * @param    columnCount    the number of selected columns.
296   */
297 STDMETHODIMP CAccTable::get_nSelectedColumns(long * columnCount)
298 {
299 
300 	CHECK_ENABLE_INF
301 
302     ENTER_PROTECTED_BLOCK
303 
304     // #CHECK#
305     if(columnCount == NULL)
306         return E_INVALIDARG;
307 
308     // #CHECK XInterface#
309     if(!pRXTable.is())
310         return E_FAIL;
311 
312     Sequence<long> pSelected = GetXInterface()->getSelectedAccessibleColumns();
313     *columnCount = pSelected.getLength();
314     return S_OK;
315 
316     LEAVE_PROTECTED_BLOCK
317 }
318 
319 /**
320   * Gets total number of selected rows.
321   *
322   * @param    rowCount    the number of selected rows.
323   */
324 STDMETHODIMP CAccTable::get_nSelectedRows(long * rowCount)
325 {
326 
327 	CHECK_ENABLE_INF
328 
329     ENTER_PROTECTED_BLOCK
330 
331     // #CHECK#
332     if(rowCount == NULL)
333         return E_INVALIDARG;
334 
335     // #CHECK XInterface#
336     if(!pRXTable.is())
337         return E_FAIL;
338 
339     Sequence<long> pSelected = GetXInterface()->getSelectedAccessibleRows();
340     *rowCount = pSelected.getLength();
341     return S_OK;
342 
343     LEAVE_PROTECTED_BLOCK
344 }
345 
346 /**
347   * Gets accessible row description (as string).
348   *
349   * @param    row            the row index.
350   * @param    description    the description of the specified row.
351   */
352 STDMETHODIMP CAccTable::get_rowDescription(long row, BSTR * description)
353 {
354 
355 	CHECK_ENABLE_INF
356 
357     ENTER_PROTECTED_BLOCK
358 
359     // #CHECK#
360     if(description == NULL)
361         return E_INVALIDARG;
362 
363     // #CHECK XInterface#
364     if(!pRXTable.is())
365         return E_FAIL;
366 
367     const ::rtl::OUString& ouStr = GetXInterface()->getAccessibleRowDescription(row);
368     // #CHECK#
369 
370     SAFE_SYSFREESTRING(*description);
371     *description = SysAllocString((OLECHAR*)ouStr.getStr());
372     if(description==NULL)
373         return E_FAIL;
374 
375     return S_OK;
376 
377     LEAVE_PROTECTED_BLOCK
378 }
379 
380 /**
381   * Gets number of rows spanned by a table cell.
382   *
383   * @param    row            the row of the specified cell.
384   * @param    column         the column of the specified cell.
385   * @param    spanRows       the row span of the specified cell.
386   */
387 STDMETHODIMP CAccTable::get_rowExtentAt(long row, long column, long * nRowsSpanned)
388 {
389 
390 	CHECK_ENABLE_INF
391 
392     ENTER_PROTECTED_BLOCK
393 
394     XAccessibleTable	*pXAccTable = GetXInterface();
395 
396     // Check pointer.
397     if(nRowsSpanned == NULL)
398         return E_INVALIDARG;
399 
400     // Get Extent.
401     if(pXAccTable)
402     {
403         long lExt = GetXInterface()->getAccessibleRowExtentAt(row,column);
404 
405         // Fill Extent struct.
406         *nRowsSpanned= lExt;
407 
408         return S_OK;
409     }
410 
411     return E_FAIL;
412 
413     LEAVE_PROTECTED_BLOCK
414 }
415 
416 /**
417   * Gets accessible row header.
418   *
419   * @param    row        the row index.
420   * @param    accessible the accessible object of the row header.
421   */
422 STDMETHODIMP CAccTable::get_rowHeader(IAccessibleTable __RPC_FAR *__RPC_FAR *accessibleTable, long *startingColumnIndex)
423 {
424 
425 	CHECK_ENABLE_INF
426 
427     ENTER_PROTECTED_BLOCK
428 
429     // #CHECK#
430     if(accessibleTable == NULL || startingColumnIndex == NULL)
431         return E_INVALIDARG;
432 
433     // #CHECK XInterface#
434     if(!pRXTable.is())
435         return E_FAIL;
436 
437     Reference<XAccessibleTable> pRRowHeaderTable = GetXInterface()->getAccessibleRowHeaders();
438     if(!pRRowHeaderTable.is())
439     {
440         *accessibleTable = NULL;
441         return E_FAIL;
442     }
443 
444     Reference<XAccessible> pRXRowHeader(pRRowHeaderTable,UNO_QUERY);
445 
446     if(!pRXRowHeader.is())
447     {
448         *accessibleTable = NULL;
449         return E_FAIL;
450     }
451     *startingColumnIndex = 0 ;
452 
453     IAccessible* m_pIMacc = NULL;
454     HRESULT hr = 	CoCreateInstance( CLSID_MAccessible, NULL, CLSCTX_ALL ,
455                                     IID_IMAccessible,
456                                     (void **)&m_pIMacc
457                                   );
458     ((CMAccessible*)m_pIMacc)->SetXAccessible((long)pRXRowHeader.get());
459     m_pIMacc->QueryInterface(IID_IAccessibleTable,(void **)accessibleTable);
460     if( SUCCEEDED(hr) )
461     {
462         return S_OK;
463     }
464 
465     return E_FAIL;
466 
467     LEAVE_PROTECTED_BLOCK
468 }
469 
470 /**
471   * Gets list of row indexes currently selected (0-based).
472   *
473   * @param    maxRows        the max number of the rows.
474   * @param    accessible     the accessible object array of the selected rows.
475   * @param    nRows          the actual size of the accessible object array.
476   */
477 STDMETHODIMP CAccTable::get_selectedRows(long, long ** rows, long * nRows)
478 {
479 
480 	CHECK_ENABLE_INF
481 
482     ENTER_PROTECTED_BLOCK
483 
484     // #CHECK#
485     if(rows == NULL || nRows == NULL)
486         return E_INVALIDARG;
487 
488     // #CHECK XInterface#
489     if(!pRXTable.is())
490         return E_FAIL;
491 
492     Sequence<long> pSelected = GetXInterface()->getSelectedAccessibleRows();
493     long count = pSelected.getLength() ;
494     *nRows = count;
495 
496     *rows = reinterpret_cast<long*>(CoTaskMemAlloc((count) * sizeof(long)));
497 	// #CHECK Memory Allocation#
498 	if(*rows == NULL)
499 	{
500 		return E_FAIL;
501 	}
502     for(int i=0; i<count; i++)
503         (*rows)[i] = pSelected[i];
504 
505     return S_OK;
506 
507     LEAVE_PROTECTED_BLOCK
508 }
509 
510 /**
511   * Gets list of column indexes currently selected (0-based).
512   *
513   * @param    maxColumns    the max number of the columns.
514   * @param    accessible    the accessible object array of the selected columns.
515   * @param    numColumns    the actual size of accessible object array.
516   */
517 STDMETHODIMP CAccTable::get_selectedColumns(long, long ** columns, long * numColumns)
518 {
519 
520 	CHECK_ENABLE_INF
521 
522     ENTER_PROTECTED_BLOCK
523 
524     // #CHECK#
525     if(columns == NULL || numColumns == NULL)
526         return E_INVALIDARG;
527 
528     // #CHECK XInterface#
529     if(!pRXTable.is())
530         return E_FAIL;
531 
532     Sequence<long> pSelected = GetXInterface()->getSelectedAccessibleColumns();
533     long count = pSelected.getLength() ;
534     *numColumns = count;
535 
536     *columns = reinterpret_cast<long*>(CoTaskMemAlloc((count) * sizeof(long)));
537 	// #CHECK Memory Allocation#
538 	if(*columns == NULL)
539 	{
540 		return E_FAIL;
541 	}
542     for(int i=0; i<count; i++)
543         (*columns)[i] = pSelected[i];
544 
545     return S_OK;
546 
547     LEAVE_PROTECTED_BLOCK
548 }
549 
550 /**
551   * Gets accessible table summary.
552   *
553   * @param    accessible   the accessible object of the summary.
554   */
555 STDMETHODIMP CAccTable::get_summary(IUnknown * * accessible)
556 {
557 
558 	CHECK_ENABLE_INF
559 
560     ENTER_PROTECTED_BLOCK
561 
562     // #CHECK#
563     if(accessible == NULL)
564         return E_INVALIDARG;
565 
566     // #CHECK XInterface#
567     if(!pRXTable.is())
568     {
569         return E_FAIL;
570     }
571     Reference<XAccessible> pRAcc = GetXInterface()->getAccessibleSummary();
572 
573     IAccessible* pRet = NULL;
574     BOOL isTRUE = CMAccessible::get_IAccessibleFromXAccessible((long)pRAcc.get(),&pRet);
575 
576     if(pRet)
577     {
578         *accessible = (IAccessible2 *)pRet;
579         pRet->AddRef();
580         return S_OK;
581     }
582 
583     return E_FAIL;
584 
585     LEAVE_PROTECTED_BLOCK
586 }
587 
588 /**
589   * Determines if table column is selected.
590   *
591   * @param    column        the column index.
592   * @param    isSelected    the result.
593   */
594 STDMETHODIMP CAccTable::get_isColumnSelected(long column, unsigned char * isSelected)
595 {
596 
597 	CHECK_ENABLE_INF
598 
599     ENTER_PROTECTED_BLOCK
600 
601     // #CHECK#
602     if(isSelected == NULL)
603         return E_INVALIDARG;
604 
605     // #CHECK XInterface#
606     if(!pRXTable.is())
607         return E_FAIL;
608 
609     *isSelected = GetXInterface()->isAccessibleColumnSelected(column);
610     return S_OK;
611 
612     LEAVE_PROTECTED_BLOCK
613 }
614 
615 /**
616   * Determines if table row is selected.
617   *
618   * @param    row           the row index.
619   * @param    isSelected    the result.
620   */
621 STDMETHODIMP CAccTable::get_isRowSelected(long row, unsigned char * isSelected)
622 {
623 
624 	CHECK_ENABLE_INF
625 
626     ENTER_PROTECTED_BLOCK
627 
628     // #CHECK#
629     if(isSelected == NULL)
630         return E_INVALIDARG;
631 
632     // #CHECK XInterface#
633     if(!pRXTable.is())
634     {
635         return E_FAIL;
636     }
637     *isSelected = GetXInterface()->isAccessibleRowSelected(row);
638     return S_OK;
639 
640     LEAVE_PROTECTED_BLOCK
641 }
642 
643 /**
644   * Determines if table cell is selected.
645   *
646   * @param    row            the row index.
647   * @param    column         the column index.
648   * @param    isSelected     the result.
649   */
650 STDMETHODIMP CAccTable::get_isSelected(long row, long column, unsigned char * isSelected)
651 {
652 
653 	CHECK_ENABLE_INF
654 
655     ENTER_PROTECTED_BLOCK
656 
657     // #CHECK#
658     if(isSelected == NULL)
659         return E_INVALIDARG;
660 
661     // #CHECK XInterface#
662     if(!pRXTable.is())
663         return E_FAIL;
664 
665     *isSelected = GetXInterface()->isAccessibleSelected(row,column);
666     return S_OK;
667 
668     LEAVE_PROTECTED_BLOCK
669 }
670 
671 /**
672   * Selects a row and unselect all previously selected rows.
673   *
674   * @param    row        the row index.
675   * @param    success    the result.
676   */
677 STDMETHODIMP CAccTable::selectRow(long row)
678 {
679 
680 	CHECK_ENABLE_INF
681 
682     ENTER_PROTECTED_BLOCK
683 
684     // Check XAccessibleTable reference.
685     if(!pRXTable.is())
686         return E_FAIL;
687 
688     Reference<XAccessibleTableSelection>		pRTableExtent(pRXTable, UNO_QUERY);
689     if(pRTableExtent.is())
690     {
691         pRTableExtent.get()->selectRow(row);
692         return S_OK;
693     }
694     else
695     {
696         // Get XAccessibleSelection.
697         Reference<XAccessibleSelection>		pRSelection(GetXInterface(), UNO_QUERY);
698         if(!pRSelection.is())
699             return E_FAIL;
700 
701         // Select row.
702         long			lCol, lColumnCount, lChildIndex;
703         lColumnCount = GetXInterface()->getAccessibleColumnCount();
704         for(lCol = 0; lCol < lColumnCount; lCol ++)
705         {
706             lChildIndex = GetXInterface()->getAccessibleIndex(row, lCol);
707             pRSelection.get()->selectAccessibleChild(lChildIndex);
708         }
709 
710         return S_OK;
711     }
712     return S_OK;
713 
714     LEAVE_PROTECTED_BLOCK
715 }
716 
717 /**
718   * Selects a column and unselect all previously selected columns.
719   *
720   * @param    column    the column index.
721   * @param    success   the result.
722   */
723 STDMETHODIMP CAccTable::selectColumn(long column)
724 {
725 
726 	CHECK_ENABLE_INF
727 
728     ENTER_PROTECTED_BLOCK
729 
730     // Check XAccessibleTable reference.
731     if(!pRXTable.is())
732         return E_FAIL;
733 
734     Reference<XAccessibleTableSelection>		pRTableExtent(GetXInterface(), UNO_QUERY);
735     if(pRTableExtent.is())
736     {
737         pRTableExtent.get()->selectColumn(column);
738         return S_OK;
739     }
740     else
741     {
742         // Get XAccessibleSelection.
743         Reference<XAccessibleSelection>		pRSelection(pRXTable, UNO_QUERY);
744         if(!pRSelection.is())
745             return E_FAIL;
746 
747         // Select column.
748         long			lRow, lRowCount, lChildIndex;
749         lRowCount = GetXInterface()->getAccessibleRowCount();
750         for(lRow = 0; lRow < lRowCount; lRow ++)
751         {
752             lChildIndex = GetXInterface()->getAccessibleIndex(lRow, column);
753             pRSelection.get()->selectAccessibleChild(lChildIndex);
754         }
755 
756         return S_OK;
757     }
758     return S_OK;
759     // End of added.
760 
761     LEAVE_PROTECTED_BLOCK
762 }
763 
764 /**
765   * Unselects one row, leaving other selected rows selected (if any).
766   *
767   * @param    row        the row index.
768   * @param    success    the result.
769   */
770 STDMETHODIMP CAccTable::unselectRow(long row)
771 {
772 
773 	CHECK_ENABLE_INF
774 
775     ENTER_PROTECTED_BLOCK
776 
777     // Check XAccessibleTable reference.
778     if(!pRXTable.is())
779         return E_FAIL;
780 
781     Reference<XAccessibleTableSelection>		pRTableExtent(GetXInterface(), UNO_QUERY);
782     if(pRTableExtent.is())
783     {
784         if(pRTableExtent.get()->unselectRow(row))
785             return S_OK;
786         else
787             return E_FAIL;
788     }
789     else
790     {
791         // Get XAccessibleSelection.
792         Reference<XAccessibleSelection>		pRSelection(pRXTable, UNO_QUERY);
793         if(!pRSelection.is())
794             return E_FAIL;
795 
796         // Select column.
797         long			lColumn, lColumnCount, lChildIndex;
798         lColumnCount = GetXInterface()->getAccessibleColumnCount();
799         for(lColumn = 0; lColumn < lColumnCount; lColumn ++)
800         {
801             lChildIndex = GetXInterface()->getAccessibleIndex(row,lColumn);
802             pRSelection.get()->deselectAccessibleChild(lChildIndex);
803         }
804 
805         return S_OK;
806     }
807     return S_OK;
808     // End of added.
809 
810     LEAVE_PROTECTED_BLOCK
811 }
812 
813 /**
814   * Unselects one column, leaving other selected columns selected (if any).
815   *
816   * @param    column    the column index.
817   * @param    success   the result.
818   */
819 STDMETHODIMP CAccTable::unselectColumn(long column)
820 {
821 
822 	CHECK_ENABLE_INF
823 
824     ENTER_PROTECTED_BLOCK
825 
826     // Check XAccessibleTable reference.
827     if(!pRXTable.is())
828         return E_FAIL;
829 
830     Reference<XAccessibleTableSelection>		pRTableExtent(GetXInterface(), UNO_QUERY);
831     if(pRTableExtent.is())
832     {
833         if(pRTableExtent.get()->unselectColumn(column))
834             return S_OK;
835         else
836             return E_FAIL;
837     }
838     else
839     {
840         // Get XAccessibleSelection.
841         Reference<XAccessibleSelection>		pRSelection(pRXTable, UNO_QUERY);
842         if(!pRSelection.is())
843             return E_FAIL;
844 
845         // Unselect columns.
846         long			lRow, lRowCount, lChildIndex;
847         lRowCount = GetXInterface()->getAccessibleRowCount();
848 
849         for(lRow = 0; lRow < lRowCount; lRow ++)
850         {
851             lChildIndex = GetXInterface()->getAccessibleIndex(lRow, column);
852             pRSelection.get()->deselectAccessibleChild(lChildIndex);
853         }
854         return S_OK;
855     }
856 
857     return S_OK;
858 
859     LEAVE_PROTECTED_BLOCK
860 }
861 
862 /**
863  * Overide of IUNOXWrapper.
864  *
865  * @param    pXInterface    the pointer of UNO interface.
866  */
867 STDMETHODIMP CAccTable::put_XInterface(long pXInterface)
868 {
869 
870 	CHECK_ENABLE_INF
871 
872     ENTER_PROTECTED_BLOCK
873 
874     CUNOXWrapper::put_XInterface(pXInterface);
875     //special query.
876     if(pUNOInterface == NULL)
877         return E_INVALIDARG;
878 
879     Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext();
880     if( !pRContext.is() )
881         return E_FAIL;
882 
883     Reference<XAccessibleTable> pRXI(pRContext,UNO_QUERY);
884     if( !pRXI.is() )
885         pRXTable = NULL;
886     else
887         pRXTable = pRXI.get();
888     return S_OK;
889 
890     LEAVE_PROTECTED_BLOCK
891 }
892 
893 /**
894   * Gets columnIndex of childIndex.
895   *
896   * @param    childIndex    childIndex
897   */
898 STDMETHODIMP CAccTable::get_columnIndex(long childIndex, long * columnIndex)
899 {
900 
901 	CHECK_ENABLE_INF
902 
903     ENTER_PROTECTED_BLOCK
904 
905     // #CHECK#
906     if(columnIndex == NULL)
907         return E_INVALIDARG;
908 
909     // #CHECK XInterface#
910     if(!pRXTable.is())
911         return E_FAIL;
912 
913     *columnIndex = GetXInterface()->getAccessibleColumn(childIndex);
914     return S_OK;
915 
916     LEAVE_PROTECTED_BLOCK
917 }
918 /**
919   * Gets rowIndex of childIndex.
920   *
921   * @param    childIndex    childIndex
922   */
923 STDMETHODIMP CAccTable::get_rowIndex(long childIndex, long * rowIndex)
924 {
925 
926 	CHECK_ENABLE_INF
927 
928     ENTER_PROTECTED_BLOCK
929 
930     // #CHECK#
931     if(rowIndex == NULL)
932         return E_INVALIDARG;
933 
934     // #CHECK XInterface#
935     if(!pRXTable.is())
936         return E_FAIL;
937 
938     *rowIndex = GetXInterface()->getAccessibleRow(childIndex);
939     return S_OK;
940 
941     LEAVE_PROTECTED_BLOCK
942 }
943 /**
944   * Gets childIndex of childIndex.
945   *
946   * @param    childIndex    childIndex
947   */
948 STDMETHODIMP CAccTable::get_childIndex(long RowIndex , long columnIndex, long * childIndex )
949 {
950 
951 	CHECK_ENABLE_INF
952 
953     ENTER_PROTECTED_BLOCK
954 
955     // #CHECK#
956     if(childIndex == NULL)
957         return E_INVALIDARG;
958 
959     // #CHECK XInterface#
960     if(!pRXTable.is())
961         return E_FAIL;
962 
963     *childIndex = GetXInterface()->getAccessibleIndex(RowIndex, columnIndex);
964     return S_OK;
965 
966     LEAVE_PROTECTED_BLOCK
967 }
968 
969 STDMETHODIMP CAccTable::get_rowColumnExtentsAtIndex(long,
970         long  *,
971         long  *,
972         long  *,
973         long  *,
974         boolean  *)
975 {
976 
977 	CHECK_ENABLE_INF
978 
979     ENTER_PROTECTED_BLOCK
980 
981     return E_NOTIMPL;
982 
983     LEAVE_PROTECTED_BLOCK
984 }
985 
986 STDMETHODIMP CAccTable::get_modelChange(IA2TableModelChange  *)
987 {
988 
989     return E_NOTIMPL;
990 }
991 
992 // @brief Returns the total number of selected children
993 //   @param [out] childCount
994 //    Number of children currently selected
995 STDMETHODIMP CAccTable::get_nSelectedChildren(long *childCount)
996 {
997 
998 	CHECK_ENABLE_INF
999 
1000     ENTER_PROTECTED_BLOCK
1001 
1002     // #CHECK#
1003     if(childCount == NULL)
1004         return E_INVALIDARG;
1005 
1006     // #CHECK XInterface#
1007     if(!pRXTable.is())
1008         return E_FAIL;
1009 
1010     Reference<XAccessibleSelection>		pRSelection(GetXInterface(), UNO_QUERY);
1011     if(!pRSelection.is())
1012         return E_FAIL;
1013 
1014     *childCount = pRSelection->getSelectedAccessibleChildCount();
1015     return S_OK;
1016 
1017     LEAVE_PROTECTED_BLOCK
1018 }
1019 
1020 // @brief Returns a list of child indexes currently selected (0-based).
1021 //   @param [in] maxChildren
1022 //    Max children requested (possibly from IAccessibleTable::nSelectedChildren)
1023 //   @param [out] children
1024 //    array of indexes of selected children (each index is 0-based)
1025 //   @param [out] nChildren
1026 //    Length of array (not more than maxChildren)
1027 STDMETHODIMP CAccTable::get_selectedChildren(long, long **children, long *nChildren)
1028 {
1029 
1030 	CHECK_ENABLE_INF
1031 
1032     ENTER_PROTECTED_BLOCK
1033 
1034     // #CHECK#
1035     if(children == NULL || nChildren == NULL)
1036         return E_INVALIDARG;
1037 
1038     // #CHECK XInterface#
1039     if(!pRXTable.is())
1040         return E_FAIL;
1041 
1042     Reference<XAccessibleSelection>		pRSelection(GetXInterface(), UNO_QUERY);
1043     if(!pRSelection.is())
1044         return E_FAIL;
1045 
1046     long childCount = pRSelection->getSelectedAccessibleChildCount() ;
1047 
1048     *nChildren = childCount;
1049 
1050     *children = reinterpret_cast<long*>(CoTaskMemAlloc((childCount) * sizeof(long)));
1051 
1052     for( long i = 0; i< childCount; i++)
1053     {
1054         Reference<XAccessible> pRAcc = pRSelection->getSelectedAccessibleChild(i);
1055         if(pRAcc.is())
1056         {
1057             Reference<XAccessibleContext> pRContext(pRAcc, UNO_QUERY);
1058             if( !pRContext.is() )
1059                 return E_FAIL;
1060 
1061             long childIndex = pRContext->getAccessibleIndexInParent();
1062             (*children)[i] = childIndex;
1063         }
1064     }
1065 
1066     return S_OK;
1067 
1068     LEAVE_PROTECTED_BLOCK
1069 
1070 }
1071