Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / accessibility / source / extended / AccessibleGridControlHeader.cxx
blob3c6a2edb9a5a16aaca664bfd9c9b555ba80dfaca
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 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
21 #include <extended/AccessibleGridControlHeader.hxx>
22 #include <extended/AccessibleGridControlHeaderCell.hxx>
23 #include <toolkit/helper/convert.hxx>
24 #include <vcl/accessibletable.hxx>
25 #include <vcl/svapp.hxx>
27 using ::com::sun::star::uno::Reference;
28 using ::com::sun::star::uno::Sequence;
30 using namespace ::com::sun::star::uno;
31 using namespace ::com::sun::star;
32 using namespace ::com::sun::star::lang;
33 using namespace ::com::sun::star::accessibility;
34 using namespace ::vcl;
35 using namespace ::vcl::table;
38 namespace accessibility {
41 AccessibleGridControlHeader::AccessibleGridControlHeader(
42 const Reference< XAccessible >& rxParent,
43 ::vcl::table::IAccessibleTable& rTable,
44 ::vcl::table::AccessibleTableControlObjType eObjType):
45 AccessibleGridControlTableBase( rxParent, rTable, eObjType )
47 OSL_ENSURE( isRowBar() || isColumnBar(),
48 "extended/AccessibleGridControlHeaderBar - invalid object type" );
51 // XAccessibleContext ---------------------------------------------------------
53 Reference< XAccessible > SAL_CALL
54 AccessibleGridControlHeader::getAccessibleChild( sal_Int64 nChildIndex )
56 SolarMutexGuard aSolarGuard;
58 if (nChildIndex<0 || nChildIndex>=getAccessibleChildCount())
59 throw IndexOutOfBoundsException();
60 ensureIsAlive();
61 Reference< XAccessible > xChild;
62 if(m_eObjType == vcl::table::TCTYPE_COLUMNHEADERBAR)
64 rtl::Reference<AccessibleGridControlHeaderCell> pColHeaderCell = new AccessibleGridControlHeaderCell(nChildIndex, this, m_aTable, vcl::table::TCTYPE_COLUMNHEADERCELL);
65 xChild = pColHeaderCell;
67 else if(m_eObjType == vcl::table::TCTYPE_ROWHEADERBAR)
69 rtl::Reference<AccessibleGridControlHeaderCell> pRowHeaderCell = new AccessibleGridControlHeaderCell(nChildIndex, this, m_aTable, vcl::table::TCTYPE_ROWHEADERCELL);
70 xChild = pRowHeaderCell;
72 return xChild;
75 sal_Int64 SAL_CALL AccessibleGridControlHeader::getAccessibleIndexInParent()
77 SolarMutexGuard aSolarGuard;
79 ensureIsAlive();
80 if(m_eObjType == vcl::table::TCTYPE_ROWHEADERBAR && m_aTable.HasColHeader())
81 return 1;
82 else
83 return 0;
86 // XAccessibleComponent -------------------------------------------------------
88 Reference< XAccessible > SAL_CALL
89 AccessibleGridControlHeader::getAccessibleAtPoint( const awt::Point& rPoint )
91 SolarMutexGuard aSolarGuard;
93 ensureIsAlive();
95 sal_Int32 nRow = 0;
96 sal_Int32 nColumnPos = 0;
97 bool bConverted = m_aTable.ConvertPointToCellAddress(nRow, nColumnPos, VCLPoint(rPoint));
98 return bConverted ? implGetChild( nRow, nColumnPos ) : Reference< XAccessible >();
101 void SAL_CALL AccessibleGridControlHeader::grabFocus()
103 ensureIsAlive();
104 // focus on header not supported
107 // XAccessibleTable -----------------------------------------------------------
109 OUString SAL_CALL AccessibleGridControlHeader::getAccessibleRowDescription( sal_Int32 nRow )
111 SolarMutexGuard aSolarGuard;
113 ensureIsAlive();
114 ensureIsValidRow( nRow );
115 return OUString(); // no headers in headers
118 OUString SAL_CALL AccessibleGridControlHeader::getAccessibleColumnDescription( sal_Int32 nColumn )
120 SolarMutexGuard aSolarGuard;
122 ensureIsAlive();
123 ensureIsValidColumn( nColumn );
124 return OUString(); // no headers in headers
127 Reference< XAccessibleTable > SAL_CALL AccessibleGridControlHeader::getAccessibleRowHeaders()
129 SolarMutexGuard g;
131 ensureIsAlive();
132 return nullptr; // no headers in headers
135 Reference< XAccessibleTable > SAL_CALL AccessibleGridControlHeader::getAccessibleColumnHeaders()
137 SolarMutexGuard g;
139 ensureIsAlive();
140 return nullptr; // no headers in headers
142 //not selectable
143 Sequence< sal_Int32 > SAL_CALL AccessibleGridControlHeader::getSelectedAccessibleRows()
145 return {};
147 //columns aren't selectable
148 Sequence< sal_Int32 > SAL_CALL AccessibleGridControlHeader::getSelectedAccessibleColumns()
150 return {};
152 //row headers not selectable
153 sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleRowSelected( sal_Int32 /*nRow*/ )
155 return false;
157 //columns aren't selectable
158 sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleColumnSelected( sal_Int32 )
160 return false;
162 //not implemented
163 Reference< XAccessible > SAL_CALL AccessibleGridControlHeader::getAccessibleCellAt(
164 sal_Int32 /*nRow*/, sal_Int32 /*nColumn*/ )
166 return nullptr;
168 // not selectable
169 sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleSelected(
170 sal_Int32 /*nRow*/, sal_Int32 /*nColumn */)
172 return false;
175 // XServiceInfo ---------------------------------------------------------------
177 OUString SAL_CALL AccessibleGridControlHeader::getImplementationName()
179 return "com.sun.star.accessibility.AccessibleGridControlHeader";
182 Sequence< sal_Int8 > SAL_CALL AccessibleGridControlHeader::getImplementationId()
184 return css::uno::Sequence<sal_Int8>();
187 // internal virtual methods ---------------------------------------------------
189 tools::Rectangle AccessibleGridControlHeader::implGetBoundingBox()
191 vcl::Window* pParent = m_aTable.GetAccessibleParentWindow();
192 tools::Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( pParent ) );
193 tools::Rectangle aHeaderRect (m_aTable.calcHeaderRect(isColumnBar()));
194 if(isColumnBar())
195 return tools::Rectangle(aGridRect.TopLeft(), Size(aGridRect.getOpenWidth(),aHeaderRect.getOpenHeight()));
196 else
197 return tools::Rectangle(aGridRect.TopLeft(), Size(aHeaderRect.getOpenWidth(),aGridRect.getOpenHeight()));
201 tools::Rectangle AccessibleGridControlHeader::implGetBoundingBoxOnScreen()
203 tools::Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( nullptr ) );
204 tools::Rectangle aHeaderRect (m_aTable.calcHeaderRect(isColumnBar()));
205 if(isColumnBar())
206 return tools::Rectangle(aGridRect.TopLeft(), Size(aGridRect.getOpenWidth(),aHeaderRect.getOpenHeight()));
207 else
208 return tools::Rectangle(aGridRect.TopLeft(), Size(aHeaderRect.getOpenWidth(),aGridRect.getOpenHeight()));
211 // internal helper methods ----------------------------------------------------
212 Reference< XAccessible > AccessibleGridControlHeader::implGetChild(
213 sal_Int32 nRow, sal_uInt32 nColumnPos )
215 Reference< XAccessible > xChild;
216 if(m_eObjType == vcl::table::TCTYPE_COLUMNHEADERBAR)
218 rtl::Reference<AccessibleGridControlHeaderCell> pColHeaderCell = new AccessibleGridControlHeaderCell(nColumnPos, this, m_aTable, vcl::table::TCTYPE_COLUMNHEADERCELL);
219 xChild = pColHeaderCell;
221 else if(m_eObjType == vcl::table::TCTYPE_ROWHEADERBAR)
223 rtl::Reference<AccessibleGridControlHeaderCell> pRowHeaderCell = new AccessibleGridControlHeaderCell(nRow, this, m_aTable, vcl::table::TCTYPE_ROWHEADERCELL);
224 xChild = pRowHeaderCell;
226 return xChild;
229 } // namespace accessibility
231 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */