1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AccessibleBrowseBoxHeaderCell.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_accessibility.hxx"
34 #include "accessibility/extended/AccessibleBrowseBoxHeaderCell.hxx"
35 #include <svtools/accessibletableprovider.hxx>
36 #include "accessibility/extended/AccessibleBrowseBox.hxx"
38 namespace accessibility
40 using namespace ::com::sun::star::accessibility
;
41 using namespace ::com::sun::star::lang
;
42 using namespace ::com::sun::star::uno
;
43 using namespace ::svt
;
45 AccessibleBrowseBoxHeaderCell::AccessibleBrowseBoxHeaderCell(sal_Int32 _nColumnRowId
,
46 const Reference
< XAccessible
>& rxParent
,
47 IAccessibleTableProvider
& rBrowseBox
,
48 const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
>& _xFocusWindow
,
49 AccessibleBrowseBoxObjType eObjType
)
50 : BrowseBoxAccessibleElement(rxParent
,
54 rBrowseBox
.GetAccessibleObjectName( eObjType
,_nColumnRowId
),
55 rBrowseBox
.GetAccessibleObjectDescription( eObjType
,_nColumnRowId
))
56 , m_nColumnRowId(_nColumnRowId
)
59 /** Creates a new AccessibleStateSetHelper and fills it with states of the
62 A filled AccessibleStateSetHelper.
64 ::utl::AccessibleStateSetHelper
* AccessibleBrowseBoxHeaderCell::implCreateStateSetHelper()
66 ::osl::MutexGuard
aGuard( getOslMutex() );
67 ::utl::AccessibleStateSetHelper
*
68 pStateSetHelper
= new ::utl::AccessibleStateSetHelper
;
72 // SHOWING done with mxParent
74 pStateSetHelper
->AddState( AccessibleStateType::SHOWING
);
76 BBSolarGuard aSolarGuard
;
77 pStateSetHelper
->AddState( AccessibleStateType::VISIBLE
);
78 pStateSetHelper
->AddState( AccessibleStateType::FOCUSABLE
);
79 pStateSetHelper
->AddState( AccessibleStateType::TRANSIENT
);
80 pStateSetHelper
->AddState( AccessibleStateType::SELECTABLE
);
82 sal_Bool bSelected
= isRowBarCell() ? mpBrowseBox
->IsRowSelected(m_nColumnRowId
) : mpBrowseBox
->IsColumnSelected(m_nColumnRowId
);
84 pStateSetHelper
->AddState( AccessibleStateType::SELECTED
);
87 pStateSetHelper
->AddState( AccessibleStateType::DEFUNC
);
89 return pStateSetHelper
;
91 // -----------------------------------------------------------------------------
93 The count of visible children.
95 sal_Int32 SAL_CALL
AccessibleBrowseBoxHeaderCell::getAccessibleChildCount()
96 throw ( RuntimeException
)
100 // -----------------------------------------------------------------------------
103 The XAccessible interface of the specified child.
105 Reference
<XAccessible
> SAL_CALL
AccessibleBrowseBoxHeaderCell::getAccessibleChild( sal_Int32
)
106 throw ( IndexOutOfBoundsException
,RuntimeException
)
108 throw IndexOutOfBoundsException();
110 // -----------------------------------------------------------------------------
112 /** Grabs the focus to the column header. */
113 void SAL_CALL
AccessibleBrowseBoxHeaderCell::grabFocus()
114 throw ( ::com::sun::star::uno::RuntimeException
)
116 BBSolarGuard aSolarGuard
;
117 ::osl::MutexGuard
aGuard( getOslMutex() );
119 if ( isRowBarCell() )
120 mpBrowseBox
->SelectRow(m_nColumnRowId
);
122 mpBrowseBox
->SelectColumn(static_cast<sal_uInt16
>(m_nColumnRowId
)); //!!!
124 // -----------------------------------------------------------------------------
126 The name of this class.
128 ::rtl::OUString SAL_CALL
AccessibleBrowseBoxHeaderCell::getImplementationName()
129 throw ( ::com::sun::star::uno::RuntimeException
)
131 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svtools.AccessibleBrowseBoxHeaderCell" ) );
133 // -----------------------------------------------------------------------------
136 Rectangle
getRectangle(IAccessibleTableProvider
* _pBrowseBox
,sal_Int32 _nRowColIndex
, BOOL _bOnScreen
,BOOL _bRowBar
)
139 sal_uInt16 nCol
= (sal_uInt16
)_nRowColIndex
;
142 nRow
= _nRowColIndex
+ 1;
146 Rectangle
aRet(_pBrowseBox
->GetFieldRectPixelAbs( nRow
, nCol
, TRUE
, _bOnScreen
));
147 return Rectangle(aRet
.TopLeft() - Point(0,aRet
.GetHeight()),aRet
.GetSize());
151 Rectangle
AccessibleBrowseBoxHeaderCell::implGetBoundingBox()
153 return getRectangle(mpBrowseBox
,m_nColumnRowId
,FALSE
,isRowBarCell());
155 // -----------------------------------------------------------------------------
157 Rectangle
AccessibleBrowseBoxHeaderCell::implGetBoundingBoxOnScreen()
159 return getRectangle(mpBrowseBox
,m_nColumnRowId
,TRUE
,isRowBarCell());
161 // -----------------------------------------------------------------------------
162 sal_Int32 SAL_CALL
AccessibleBrowseBoxHeaderCell::getAccessibleIndexInParent()
163 throw ( RuntimeException
)
165 ::osl::MutexGuard
aGuard( getOslMutex() );
167 sal_Int32 nIndex
= m_nColumnRowId
;
168 if ( mpBrowseBox
->HasRowHeader() )
172 // -----------------------------------------------------------------------------
173 } // namespace accessibility
174 // -----------------------------------------------------------------------------