1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
,
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
49 A filled AccessibleStateSetHelper.
51 ::utl::AccessibleStateSetHelper
* AccessibleBrowseBoxHeaderCell::implCreateStateSetHelper()
53 ::osl::MutexGuard
aGuard( getOslMutex() );
54 ::utl::AccessibleStateSetHelper
*
55 pStateSetHelper
= new ::utl::AccessibleStateSetHelper
;
59 // SHOWING done with mxParent
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
);
72 pStateSetHelper
->AddState( AccessibleStateType::SELECTED
);
75 pStateSetHelper
->AddState( AccessibleStateType::DEFUNC
);
77 return pStateSetHelper
;
81 The count of visible children.
83 sal_Int32 SAL_CALL
AccessibleBrowseBoxHeaderCell::getAccessibleChildCount()
84 throw ( RuntimeException
, std::exception
)
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() );
107 if ( isRowBarCell() )
108 mpBrowseBox
->SelectRow(m_nColumnRowId
);
110 mpBrowseBox
->SelectColumn(static_cast<sal_uInt16
>(m_nColumnRowId
)); //!!!
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" );
124 Rectangle
getRectangle(IAccessibleTableProvider
* _pBrowseBox
,sal_Int32 _nRowColIndex
, bool _bOnScreen
,bool _bRowBar
)
127 sal_uInt16 nCol
= (sal_uInt16
)_nRowColIndex
;
130 nRow
= _nRowColIndex
+ 1;
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() );
155 sal_Int32 nIndex
= m_nColumnRowId
;
156 if ( mpBrowseBox
->HasRowHeader() )
161 } // namespace accessibility
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */