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