Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / accessibility / source / extended / AccessibleBrowseBoxHeaderCell.cxx
blob688f0283eae1d8c75a1558a3206868bdb73cf0a7
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 vcl::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 /** Creates a new AccessibleStateSetHelper and fills it with states of the
47 current object.
48 @return
49 A filled AccessibleStateSetHelper.
51 ::utl::AccessibleStateSetHelper* AccessibleBrowseBoxHeaderCell::implCreateStateSetHelper()
53 SolarMethodGuard aGuard( getMutex() );
55 ::utl::AccessibleStateSetHelper*
56 pStateSetHelper = new ::utl::AccessibleStateSetHelper;
58 if( isAlive() )
60 // SHOWING done with mxParent
61 if( implIsShowing() )
62 pStateSetHelper->AddState( AccessibleStateType::SHOWING );
64 mpBrowseBox->FillAccessibleStateSet( *pStateSetHelper, getType() );
65 pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
66 pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE );
67 pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
68 pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
70 bool bSelected = isRowBarCell() ? mpBrowseBox->IsRowSelected(m_nColumnRowId) : mpBrowseBox->IsColumnSelected(m_nColumnRowId);
71 if ( bSelected )
72 pStateSetHelper->AddState( AccessibleStateType::SELECTED );
74 else
75 pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
77 return pStateSetHelper;
80 /** @return
81 The count of visible children.
83 sal_Int32 SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleChildCount()
85 return 0;
89 /** @return
90 The XAccessible interface of the specified child.
92 Reference<XAccessible > SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleChild( sal_Int32 )
94 throw IndexOutOfBoundsException();
98 /** Grabs the focus to the column header. */
99 void SAL_CALL AccessibleBrowseBoxHeaderCell::grabFocus()
101 SolarMethodGuard aGuard(getMutex());
102 ensureIsAlive();
104 if ( isRowBarCell() )
105 mpBrowseBox->SelectRow(m_nColumnRowId);
106 else
107 mpBrowseBox->SelectColumn(static_cast<sal_uInt16>(m_nColumnRowId)); //!!!
110 /** @return
111 The name of this class.
113 OUString SAL_CALL AccessibleBrowseBoxHeaderCell::getImplementationName()
115 return "com.sun.star.comp.svtools.AccessibleBrowseBoxHeaderCell";
118 namespace
120 tools::Rectangle getRectangle(vcl::IAccessibleTableProvider* _pBrowseBox,sal_Int32 _nRowColIndex, bool _bOnScreen,bool _bRowBar)
122 sal_Int32 nRow = 0;
123 sal_uInt16 nCol = static_cast<sal_uInt16>(_nRowColIndex);
124 if ( _bRowBar )
126 nRow = _nRowColIndex + 1;
127 nCol = 0;
130 tools::Rectangle aRet(_pBrowseBox->GetFieldRectPixelAbs( nRow , nCol, true, _bOnScreen));
131 return tools::Rectangle(aRet.TopLeft() - Point(0,aRet.GetHeight()),aRet.GetSize());
135 tools::Rectangle AccessibleBrowseBoxHeaderCell::implGetBoundingBox()
137 return getRectangle(mpBrowseBox,m_nColumnRowId,false,isRowBarCell());
141 tools::Rectangle AccessibleBrowseBoxHeaderCell::implGetBoundingBoxOnScreen()
143 return getRectangle(mpBrowseBox,m_nColumnRowId,true,isRowBarCell());
146 sal_Int32 SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleIndexInParent()
148 ::osl::MutexGuard aGuard( getMutex() );
149 ensureIsAlive();
150 sal_Int32 nIndex = m_nColumnRowId;
151 if ( mpBrowseBox->HasRowHeader() )
152 --nIndex;
153 return nIndex;
156 } // namespace accessibility
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */