tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / accessibility / source / extended / AccessibleBrowseBoxHeaderCell.cxx
blobc7e8ce1605cfaf4c4c695a89778777fa8134979f
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 AccessibleBrowseBoxObjType eObjType)
36 : BrowseBoxAccessibleElement(rxParent,
37 rBrowseBox,
38 eObjType,
39 rBrowseBox.GetAccessibleObjectName( eObjType ,_nColumnRowId),
40 rBrowseBox.GetAccessibleObjectDescription( eObjType ,_nColumnRowId))
41 , m_nColumnRowId(_nColumnRowId)
44 /** Return a bitset of states of the current object.
46 sal_Int64 AccessibleBrowseBoxHeaderCell::implCreateStateSet()
48 SolarMethodGuard aGuard( getMutex() );
50 sal_Int64 nStateSet = 0;
52 if( isAlive() )
54 // SHOWING done with mxParent
55 if( implIsShowing() )
56 nStateSet |= AccessibleStateType::SHOWING;
58 mpBrowseBox->FillAccessibleStateSet( nStateSet, getType() );
59 nStateSet |= AccessibleStateType::VISIBLE;
60 nStateSet |= AccessibleStateType::FOCUSABLE;
61 nStateSet |= AccessibleStateType::TRANSIENT;
62 nStateSet |= AccessibleStateType::SELECTABLE;
64 bool bSelected = isRowBarCell() ? mpBrowseBox->IsRowSelected(m_nColumnRowId) : mpBrowseBox->IsColumnSelected(m_nColumnRowId);
65 if ( bSelected )
66 nStateSet |= AccessibleStateType::SELECTED;
68 else
69 nStateSet |= AccessibleStateType::DEFUNC;
71 return nStateSet;
74 /** @return
75 The count of visible children.
77 sal_Int64 SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleChildCount()
79 return 0;
83 /** @return
84 The XAccessible interface of the specified child.
86 Reference<XAccessible > SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleChild( sal_Int64 )
88 throw IndexOutOfBoundsException();
92 /** Grabs the focus to the column header. */
93 void SAL_CALL AccessibleBrowseBoxHeaderCell::grabFocus()
95 SolarMethodGuard aGuard(getMutex());
96 ensureIsAlive();
98 if ( isRowBarCell() )
99 mpBrowseBox->SelectRow(m_nColumnRowId);
100 else
101 mpBrowseBox->SelectColumn(static_cast<sal_uInt16>(m_nColumnRowId)); //!!!
104 /** @return
105 The name of this class.
107 OUString SAL_CALL AccessibleBrowseBoxHeaderCell::getImplementationName()
109 return u"com.sun.star.comp.svtools.AccessibleBrowseBoxHeaderCell"_ustr;
112 namespace
114 tools::Rectangle getRectangle(vcl::IAccessibleTableProvider* _pBrowseBox,sal_Int32 _nRowColIndex, bool _bOnScreen,bool _bRowBar)
116 sal_Int32 nRow = 0;
117 sal_uInt16 nCol = static_cast<sal_uInt16>(_nRowColIndex);
118 if ( _bRowBar )
120 nRow = _nRowColIndex + 1;
121 nCol = 0;
124 tools::Rectangle aRet(_pBrowseBox->GetFieldRectPixel( nRow , nCol, true, _bOnScreen));
125 return tools::Rectangle(aRet.TopLeft() - Point(0,aRet.GetHeight()),aRet.GetSize());
129 tools::Rectangle AccessibleBrowseBoxHeaderCell::implGetBoundingBox()
131 return getRectangle(mpBrowseBox,m_nColumnRowId,false,isRowBarCell());
135 AbsoluteScreenPixelRectangle AccessibleBrowseBoxHeaderCell::implGetBoundingBoxOnScreen()
137 return AbsoluteScreenPixelRectangle(getRectangle(mpBrowseBox,m_nColumnRowId,true,isRowBarCell()));
140 sal_Int64 SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleIndexInParent()
142 ::osl::MutexGuard aGuard( getMutex() );
143 ensureIsAlive();
144 sal_Int64 nIndex = m_nColumnRowId;
145 if ( mpBrowseBox->HasRowHeader() )
146 --nIndex;
147 return nIndex;
150 } // namespace accessibility
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */