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 #ifndef __ACCTABLE_H_
23 #define __ACCTABLE_H_
24 
25 #include "resource.h"       // main symbols
26 
27 #include <com/sun/star/uno/reference.hxx>
28 #include <com/sun/star/accessibility/XAccessibleTable.hpp>
29 #include "UNOXWrapper.h"
30 
31 /**
32  * CAccTable implements IAccessibleTable interface.
33  */
34 class ATL_NO_VTABLE CAccTable :
35             public CComObjectRoot,
36             public CComCoClass<CAccTable, &CLSID_AccTable>,
37             public IAccessibleTable,
38             public CUNOXWrapper
39 
40 {
41 public:
CAccTable()42     CAccTable()
43     {
44             }
~CAccTable()45     virtual ~CAccTable()
46     {
47             }
48 
49     BEGIN_COM_MAP(CAccTable)
COM_INTERFACE_ENTRY(IAccessibleTable)50     COM_INTERFACE_ENTRY(IAccessibleTable)
51     COM_INTERFACE_ENTRY(IUNOXWrapper)
52     COM_INTERFACE_ENTRY_FUNC_BLIND(NULL,_SmartQI)
53     END_COM_MAP()
54 
55     static HRESULT WINAPI _SmartQI(void* pv,
56                                    REFIID iid, void** ppvObject, DWORD)
57     {
58         return ((CAccTable*)pv)->SmartQI(iid,ppvObject);
59     }
60 
SmartQI(REFIID iid,void ** ppvObject)61     HRESULT SmartQI(REFIID iid, void** ppvObject)
62     {
63         if( m_pOuterUnknown )
64             return OuterQueryInterface(iid,ppvObject);
65         return E_FAIL;
66     }
67 
68     DECLARE_REGISTRY_RESOURCEID(IDR_ACCTABLE)
69 
70     // IAccessibleTable
71 public:
72     // IAccessibleTable
73 
74     // Gets accessible table cell.
75     STDMETHOD(get_accessibleAt)(long row, long column, IUnknown * * accessible);
76 
77     // Gets accessible table caption.
78     STDMETHOD(get_caption)(IUnknown * * accessible);
79 
80     // Gets accessible column description (as string).
81     STDMETHOD(get_columnDescription)(long column, BSTR * description);
82 
83     // Gets number of columns spanned by table cell.
84     STDMETHOD(get_columnExtentAt)(long row, long column, long * nColumnsSpanned);
85 
86     // Gets accessible column header.
87     STDMETHOD(get_columnHeader)(IAccessibleTable __RPC_FAR *__RPC_FAR *accessibleTable, long *startingRowIndex);
88 
89     // Gets total number of columns in table.
90     STDMETHOD(get_nColumns)(long * columnCount);
91 
92     // Gets total number of rows in table.
93     STDMETHOD(get_nRows)(long * rowCount);
94 
95     // Gets total number of selected columns.
96     STDMETHOD(get_nSelectedColumns)(long * columnCount);
97 
98     // Gets total number of selected rows.
99     STDMETHOD(get_nSelectedRows)(long * rowCount);
100 
101     // Gets accessible row description (as string).
102     STDMETHOD(get_rowDescription)(long row, BSTR * description);
103 
104     // Gets number of rows spanned by a table cell.
105     STDMETHOD(get_rowExtentAt)(long row, long column, long * nRowsSpanned);
106 
107     // Gets accessible row header.
108     STDMETHOD(get_rowHeader)(IAccessibleTable __RPC_FAR *__RPC_FAR *accessibleTable, long *startingColumnIndex);
109 
110     // Gets list of row indexes currently selected (0-based).
111     STDMETHOD(get_selectedRows)(long maxRows, long **rows, long * nRows);
112 
113     // Gets list of column indexes currently selected (0-based).
114     STDMETHOD(get_selectedColumns)(long maxColumns, long **columns, long * numColumns);
115 
116     // Gets accessible table summary.
117     STDMETHOD(get_summary)(IUnknown * * accessible);
118 
119     // Determines if table column is selected.
120     STDMETHOD(get_isColumnSelected)(long column, unsigned char * isSelected);
121 
122     // Determines if table row is selected.
123     STDMETHOD(get_isRowSelected)(long row, unsigned char * isSelected);
124 
125     // Determines if table cell is selected.
126     STDMETHOD(get_isSelected)(long row, long column, unsigned char * isSelected);
127 
128     // Selects a row and unselect all previously selected rows.
129     STDMETHOD(selectRow)(long row );
130 
131 
132     // Selects a column and unselect all previously selected columns.
133 
134     STDMETHOD(selectColumn)(long column);
135 
136     // Unselects one row, leaving other selected rows selected (if any).
137     STDMETHOD(unselectRow)(long row);
138 
139     // Unselects one column, leaving other selected columns selected (if any).
140     STDMETHOD(unselectColumn)(long column);
141 
142     //get Column index
143     STDMETHOD(get_columnIndex)(long childIndex, long * columnIndex);
144 
145     STDMETHOD(get_rowIndex)(long childIndex, long * rowIndex);
146 
147     STDMETHOD(get_childIndex)(long rowIndex,long columnIndex, long * childIndex);
148 
149     STDMETHOD(get_nSelectedChildren)(long *childCount);
150 
151     STDMETHOD(get_selectedChildren)(long maxChildren, long **children, long *nChildren);
152 
153     STDMETHOD(get_rowColumnExtentsAtIndex)( long index,
154                                             long  *row,
155                                             long  *column,
156                                             long  *rowExtents,
157                                             long  *columnExtents,
158                                             boolean  *isSelected) ;
159 
160     STDMETHOD(get_modelChange)(IA2TableModelChange  *modelChange);
161 
162     // Overide of IUNOXWrapper.
163     STDMETHOD(put_XInterface)(long pXInterface);
164 
165 private:
166 
167     com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleTable> pRXTable;
168 
GetXInterface()169     inline com::sun::star::accessibility::XAccessibleTable* GetXInterface()
170     {
171         return pRXTable.get();
172     }
173 };
174 
175 #endif //__ACCTABLE_H_
176