Avoid potential negative array index access to cached text.
[LibreOffice.git] / winaccessibility / source / UAccCOM / AccTable.h
blobd5805c3c0b468b901da73a9f5f1ac47b525c5f44
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 #pragma once
22 #include "Resource.h" // main symbols
24 #include <com/sun/star/uno/Reference.hxx>
25 #include <com/sun/star/accessibility/XAccessibleTable.hpp>
26 #include "UNOXWrapper.h"
28 /**
29 * CAccTable implements the IAccessibleTable and IAccessibleTable2 interfaces.
31 class ATL_NO_VTABLE CAccTable :
32 public CComObjectRoot,
33 public CComCoClass<CAccTable, &CLSID_AccTable>,
34 public IAccessibleTable,
35 public IAccessibleTable2,
36 public CUNOXWrapper
39 public:
40 CAccTable()
43 virtual ~CAccTable()
47 BEGIN_COM_MAP(CAccTable)
48 COM_INTERFACE_ENTRY(IAccessibleTable)
49 COM_INTERFACE_ENTRY(IAccessibleTable2)
50 COM_INTERFACE_ENTRY(IUNOXWrapper)
51 COM_INTERFACE_ENTRY_FUNC_BLIND(0,SmartQI_)
52 #if defined __clang__
53 #pragma clang diagnostic push
54 #pragma clang diagnostic ignored "-Winconsistent-missing-override"
55 #endif
56 END_COM_MAP()
57 #if defined __clang__
58 #pragma clang diagnostic pop
59 #endif
61 static HRESULT WINAPI SmartQI_(void* pv,
62 REFIID iid, void** ppvObject, DWORD_PTR)
64 return static_cast<CAccTable*>(pv)->SmartQI(iid,ppvObject);
67 HRESULT SmartQI(REFIID iid, void** ppvObject)
69 if( m_pOuterUnknown )
70 return OuterQueryInterface(iid,ppvObject);
71 return E_FAIL;
74 DECLARE_NO_REGISTRY()
76 public:
77 // IAccessibleTable and IAccessibleTable2
79 // Gets accessible table cell (IAccessibleTable version).
80 STDMETHOD(get_accessibleAt)(long row, long column, IUnknown * * accessible) override;
82 // Gets accessible table cell (IAccessibleTable2 version).
83 STDMETHOD(get_cellAt)(long row, long column, IUnknown * * cell) override;
85 // Gets accessible table caption.
86 STDMETHOD(get_caption)(IUnknown * * accessible) override;
88 // Gets accessible column description (as string).
89 STDMETHOD(get_columnDescription)(long column, BSTR * description) override;
91 // Gets number of columns spanned by table cell.
92 STDMETHOD(get_columnExtentAt)(long row, long column, long * nColumnsSpanned) override;
94 // Gets accessible column header.
95 STDMETHOD(get_columnHeader)(IAccessibleTable __RPC_FAR *__RPC_FAR *accessibleTable, long *startingRowIndex) override;
97 // Gets total number of columns in table.
98 STDMETHOD(get_nColumns)(long * columnCount) override;
100 // Gets total number of rows in table.
101 STDMETHOD(get_nRows)(long * rowCount) override;
103 // Gets total number of selected columns.
104 STDMETHOD(get_nSelectedColumns)(long * columnCount) override;
106 // Gets total number of selected rows.
107 STDMETHOD(get_nSelectedRows)(long * rowCount) override;
109 // Gets accessible row description (as string).
110 STDMETHOD(get_rowDescription)(long row, BSTR * description) override;
112 // Gets number of rows spanned by a table cell.
113 STDMETHOD(get_rowExtentAt)(long row, long column, long * nRowsSpanned) override;
115 // Gets accessible row header.
116 STDMETHOD(get_rowHeader)(IAccessibleTable __RPC_FAR *__RPC_FAR *accessibleTable, long *startingColumnIndex) override;
118 // Gets list of row indexes currently selected (0-based).
119 STDMETHOD(get_selectedRows)(long **rows, long * nRows) override;
120 STDMETHOD(get_selectedRows)(long maxRows, long **rows, long * nRows) override;
122 // Gets list of column indexes currently selected (0-based).
123 STDMETHOD(get_selectedColumns)(long **columns, long * numColumns) override;
124 STDMETHOD(get_selectedColumns)(long maxColumns, long **columns, long * numColumns) override;
126 // Gets accessible table summary.
127 STDMETHOD(get_summary)(IUnknown * * accessible) override;
129 // Determines if table column is selected.
130 STDMETHOD(get_isColumnSelected)(long column, boolean * isSelected) override;
132 // Determines if table row is selected.
133 STDMETHOD(get_isRowSelected)(long row, boolean * isSelected) override;
135 // Determines if table cell is selected.
136 STDMETHOD(get_isSelected)(long row, long column, boolean * isSelected) override;
138 // Selects a row and unselect all previously selected rows.
139 STDMETHOD(selectRow)(long row ) override;
142 // Selects a column and unselect all previously selected columns.
144 STDMETHOD(selectColumn)(long column) override;
146 // Unselects one row, leaving other selected rows selected (if any).
147 STDMETHOD(unselectRow)(long row) override;
149 // Unselects one column, leaving other selected columns selected (if any).
150 STDMETHOD(unselectColumn)(long column) override;
152 //get Column index
153 STDMETHOD(get_columnIndex)(long childIndex, long * columnIndex) override;
155 STDMETHOD(get_rowIndex)(long childIndex, long * rowIndex) override;
157 STDMETHOD(get_childIndex)(long rowIndex,long columnIndex, long * childIndex) override;
159 // get total number of selected cells
160 STDMETHOD(get_nSelectedChildren)(long *childCount) override;
161 STDMETHOD(get_nSelectedCells)(long *childCount) override;
163 STDMETHOD(get_selectedChildren)(long maxChildren, long **children, long *nChildren) override;
165 // Returns a list of accessibles currently selected
166 STDMETHOD(get_selectedCells)(IUnknown * * * cells, long *nSelectedCells) override;
168 STDMETHOD(get_rowColumnExtentsAtIndex)( long index,
169 long *row,
170 long *column,
171 long *rowExtents,
172 long *columnExtents,
173 boolean *isSelected) override;
175 STDMETHOD(get_modelChange)(IA2TableModelChange *modelChange) override;
177 // Override of IUNOXWrapper.
178 STDMETHOD(put_XInterface)(hyper pXInterface) override;
180 private:
181 css::uno::Reference<css::accessibility::XAccessibleTable> pRXTable;
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */