Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / accessibility / source / extended / AccessibleBrowseBoxHeaderCell.cxx
blob619e7780947ea3f45e919c53597a3966f28ff26d
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 .
21 #include <extended/AccessibleBrowseBoxHeaderCell.hxx>
22 #include <vcl/accessibletableprovider.hxx>
23 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
24 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
26 namespace accessibility
28 using namespace ::com::sun::star::accessibility;
29 using namespace ::com::sun::star::lang;
30 using namespace ::com::sun::star::uno;
32 AccessibleBrowseBoxHeaderCell::AccessibleBrowseBoxHeaderCell(sal_Int32 _nColumnRowId,
33 const Reference< XAccessible >& rxParent,
34 vcl::IAccessibleTableProvider& rBrowseBox,
35 const css::uno::Reference< css::awt::XWindow >& _xFocusWindow,
36 AccessibleBrowseBoxObjType eObjType)
37 : BrowseBoxAccessibleElement(rxParent,
38 rBrowseBox,
39 _xFocusWindow,
40 eObjType,
41 rBrowseBox.GetAccessibleObjectName( eObjType ,_nColumnRowId),
42 rBrowseBox.GetAccessibleObjectDescription( eObjType ,_nColumnRowId))
43 , m_nColumnRowId(_nColumnRowId)
46 /** Return a bitset of states of the current object.
48 sal_Int64 AccessibleBrowseBoxHeaderCell::implCreateStateSet()
50 SolarMethodGuard aGuard( getMutex() );
52 sal_Int64 nStateSet = 0;
54 if( isAlive() )
56 // SHOWING done with mxParent
57 if( implIsShowing() )
58 nStateSet |= AccessibleStateType::SHOWING;
60 mpBrowseBox->FillAccessibleStateSet( nStateSet, getType() );
61 nStateSet |= AccessibleStateType::VISIBLE;
62 nStateSet |= AccessibleStateType::FOCUSABLE;
63 nStateSet |= AccessibleStateType::TRANSIENT;
64 nStateSet |= AccessibleStateType::SELECTABLE;
66 bool bSelected = isRowBarCell() ? mpBrowseBox->IsRowSelected(m_nColumnRowId) : mpBrowseBox->IsColumnSelected(m_nColumnRowId);
67 if ( bSelected )
68 nStateSet |= AccessibleStateType::SELECTED;
70 else
71 nStateSet |= AccessibleStateType::DEFUNC;
73 return nStateSet;
76 /** @return
77 The count of visible children.
79 sal_Int64 SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleChildCount()
81 return 0;
85 /** @return
86 The XAccessible interface of the specified child.
88 Reference<XAccessible > SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleChild( sal_Int64 )
90 throw IndexOutOfBoundsException();
94 /** Grabs the focus to the column header. */
95 void SAL_CALL AccessibleBrowseBoxHeaderCell::grabFocus()
97 SolarMethodGuard aGuard(getMutex());
98 ensureIsAlive();
100 if ( isRowBarCell() )
101 mpBrowseBox->SelectRow(m_nColumnRowId);
102 else
103 mpBrowseBox->SelectColumn(static_cast<sal_uInt16>(m_nColumnRowId)); //!!!
106 /** @return
107 The name of this class.
109 OUString SAL_CALL AccessibleBrowseBoxHeaderCell::getImplementationName()
111 return "com.sun.star.comp.svtools.AccessibleBrowseBoxHeaderCell";
114 namespace
116 tools::Rectangle getRectangle(vcl::IAccessibleTableProvider* _pBrowseBox,sal_Int32 _nRowColIndex, bool _bOnScreen,bool _bRowBar)
118 sal_Int32 nRow = 0;
119 sal_uInt16 nCol = static_cast<sal_uInt16>(_nRowColIndex);
120 if ( _bRowBar )
122 nRow = _nRowColIndex + 1;
123 nCol = 0;
126 tools::Rectangle aRet(_pBrowseBox->GetFieldRectPixelAbs( nRow , nCol, true, _bOnScreen));
127 return tools::Rectangle(aRet.TopLeft() - Point(0,aRet.GetHeight()),aRet.GetSize());
131 tools::Rectangle AccessibleBrowseBoxHeaderCell::implGetBoundingBox()
133 return getRectangle(mpBrowseBox,m_nColumnRowId,false,isRowBarCell());
137 tools::Rectangle AccessibleBrowseBoxHeaderCell::implGetBoundingBoxOnScreen()
139 return getRectangle(mpBrowseBox,m_nColumnRowId,true,isRowBarCell());
142 sal_Int64 SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleIndexInParent()
144 ::osl::MutexGuard aGuard( getMutex() );
145 ensureIsAlive();
146 sal_Int64 nIndex = m_nColumnRowId;
147 if ( mpBrowseBox->HasRowHeader() )
148 --nIndex;
149 return nIndex;
152 } // namespace accessibility
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */