Branch libreoffice-5-0-4
[LibreOffice.git] / accessibility / source / extended / AccessibleBrowseBoxHeaderCell.cxx
blob04a09c28f8e5bb6c32470550f4b736ffe78445c6
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 "accessibility/extended/AccessibleBrowseBoxHeaderCell.hxx"
22 #include <svtools/accessibletableprovider.hxx>
23 #include "accessibility/extended/AccessibleBrowseBox.hxx"
25 namespace accessibility
27 using namespace ::com::sun::star::accessibility;
28 using namespace ::com::sun::star::lang;
29 using namespace ::com::sun::star::uno;
30 using namespace ::svt;
32 AccessibleBrowseBoxHeaderCell::AccessibleBrowseBoxHeaderCell(sal_Int32 _nColumnRowId,
33 const Reference< XAccessible >& rxParent,
34 IAccessibleTableProvider& rBrowseBox,
35 const ::com::sun::star::uno::Reference< ::com::sun::star::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 /** 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 ::osl::MutexGuard aGuard( getOslMutex() );
54 ::utl::AccessibleStateSetHelper*
55 pStateSetHelper = new ::utl::AccessibleStateSetHelper;
57 if( isAlive() )
59 // SHOWING done with mxParent
60 if( implIsShowing() )
61 pStateSetHelper->AddState( AccessibleStateType::SHOWING );
63 SolarMutexGuard aSolarGuard;
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()
84 throw ( RuntimeException, std::exception )
86 return 0;
90 /** @return
91 The XAccessible interface of the specified child.
93 Reference<XAccessible > SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleChild( sal_Int32 )
94 throw ( IndexOutOfBoundsException,RuntimeException, std::exception )
96 throw IndexOutOfBoundsException();
100 /** Grabs the focus to the column header. */
101 void SAL_CALL AccessibleBrowseBoxHeaderCell::grabFocus()
102 throw ( ::com::sun::star::uno::RuntimeException, std::exception )
104 SolarMutexGuard aSolarGuard;
105 ::osl::MutexGuard aGuard( getOslMutex() );
106 ensureIsAlive();
107 if ( isRowBarCell() )
108 mpBrowseBox->SelectRow(m_nColumnRowId);
109 else
110 mpBrowseBox->SelectColumn(static_cast<sal_uInt16>(m_nColumnRowId)); //!!!
113 /** @return
114 The name of this class.
116 OUString SAL_CALL AccessibleBrowseBoxHeaderCell::getImplementationName()
117 throw ( ::com::sun::star::uno::RuntimeException, std::exception )
119 return OUString( "com.sun.star.comp.svtools.AccessibleBrowseBoxHeaderCell" );
122 namespace
124 Rectangle getRectangle(IAccessibleTableProvider* _pBrowseBox,sal_Int32 _nRowColIndex, bool _bOnScreen,bool _bRowBar)
126 sal_Int32 nRow = 0;
127 sal_uInt16 nCol = (sal_uInt16)_nRowColIndex;
128 if ( _bRowBar )
130 nRow = _nRowColIndex + 1;
131 nCol = 0;
134 Rectangle aRet(_pBrowseBox->GetFieldRectPixelAbs( nRow , nCol, true, _bOnScreen));
135 return Rectangle(aRet.TopLeft() - Point(0,aRet.GetHeight()),aRet.GetSize());
139 Rectangle AccessibleBrowseBoxHeaderCell::implGetBoundingBox()
141 return getRectangle(mpBrowseBox,m_nColumnRowId,false,isRowBarCell());
145 Rectangle AccessibleBrowseBoxHeaderCell::implGetBoundingBoxOnScreen()
147 return getRectangle(mpBrowseBox,m_nColumnRowId,true,isRowBarCell());
150 sal_Int32 SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleIndexInParent()
151 throw ( RuntimeException, std::exception )
153 ::osl::MutexGuard aGuard( getOslMutex() );
154 ensureIsAlive();
155 sal_Int32 nIndex = m_nColumnRowId;
156 if ( mpBrowseBox->HasRowHeader() )
157 --nIndex;
158 return nIndex;
161 } // namespace accessibility
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */