merged tag ooo/DEV300_m102
[LibreOffice.git] / accessibility / source / extended / AccessibleBrowseBoxHeaderCell.cxx
blob44d547f8fd5b327c299197abe3d4dabeb09ee49e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_accessibility.hxx"
31 #include "accessibility/extended/AccessibleBrowseBoxHeaderCell.hxx"
32 #include <svtools/accessibletableprovider.hxx>
33 #include "accessibility/extended/AccessibleBrowseBox.hxx"
35 namespace accessibility
37 using namespace ::com::sun::star::accessibility;
38 using namespace ::com::sun::star::lang;
39 using namespace ::com::sun::star::uno;
40 using namespace ::svt;
42 AccessibleBrowseBoxHeaderCell::AccessibleBrowseBoxHeaderCell(sal_Int32 _nColumnRowId,
43 const Reference< XAccessible >& rxParent,
44 IAccessibleTableProvider& rBrowseBox,
45 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& _xFocusWindow,
46 AccessibleBrowseBoxObjType eObjType)
47 : BrowseBoxAccessibleElement(rxParent,
48 rBrowseBox,
49 _xFocusWindow,
50 eObjType,
51 rBrowseBox.GetAccessibleObjectName( eObjType ,_nColumnRowId),
52 rBrowseBox.GetAccessibleObjectDescription( eObjType ,_nColumnRowId))
53 , m_nColumnRowId(_nColumnRowId)
56 /** Creates a new AccessibleStateSetHelper and fills it with states of the
57 current object.
58 @return
59 A filled AccessibleStateSetHelper.
61 ::utl::AccessibleStateSetHelper* AccessibleBrowseBoxHeaderCell::implCreateStateSetHelper()
63 ::osl::MutexGuard aGuard( getOslMutex() );
64 ::utl::AccessibleStateSetHelper*
65 pStateSetHelper = new ::utl::AccessibleStateSetHelper;
67 if( isAlive() )
69 // SHOWING done with mxParent
70 if( implIsShowing() )
71 pStateSetHelper->AddState( AccessibleStateType::SHOWING );
73 BBSolarGuard aSolarGuard;
74 pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
75 pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE );
76 pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
77 pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
79 sal_Bool bSelected = isRowBarCell() ? mpBrowseBox->IsRowSelected(m_nColumnRowId) : mpBrowseBox->IsColumnSelected(m_nColumnRowId);
80 if ( bSelected )
81 pStateSetHelper->AddState( AccessibleStateType::SELECTED );
83 else
84 pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
86 return pStateSetHelper;
88 // -----------------------------------------------------------------------------
89 /** @return
90 The count of visible children.
92 sal_Int32 SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleChildCount()
93 throw ( RuntimeException )
95 return 0;
97 // -----------------------------------------------------------------------------
99 /** @return
100 The XAccessible interface of the specified child.
102 Reference<XAccessible > SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleChild( sal_Int32 )
103 throw ( IndexOutOfBoundsException,RuntimeException )
105 throw IndexOutOfBoundsException();
107 // -----------------------------------------------------------------------------
109 /** Grabs the focus to the column header. */
110 void SAL_CALL AccessibleBrowseBoxHeaderCell::grabFocus()
111 throw ( ::com::sun::star::uno::RuntimeException )
113 BBSolarGuard aSolarGuard;
114 ::osl::MutexGuard aGuard( getOslMutex() );
115 ensureIsAlive();
116 if ( isRowBarCell() )
117 mpBrowseBox->SelectRow(m_nColumnRowId);
118 else
119 mpBrowseBox->SelectColumn(static_cast<sal_uInt16>(m_nColumnRowId)); //!!!
121 // -----------------------------------------------------------------------------
122 /** @return
123 The name of this class.
125 ::rtl::OUString SAL_CALL AccessibleBrowseBoxHeaderCell::getImplementationName()
126 throw ( ::com::sun::star::uno::RuntimeException )
128 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svtools.AccessibleBrowseBoxHeaderCell" ) );
130 // -----------------------------------------------------------------------------
131 namespace
133 Rectangle getRectangle(IAccessibleTableProvider* _pBrowseBox,sal_Int32 _nRowColIndex, sal_Bool _bOnScreen,sal_Bool _bRowBar)
135 sal_Int32 nRow = 0;
136 sal_uInt16 nCol = (sal_uInt16)_nRowColIndex;
137 if ( _bRowBar )
139 nRow = _nRowColIndex + 1;
140 nCol = 0;
143 Rectangle aRet(_pBrowseBox->GetFieldRectPixelAbs( nRow , nCol, sal_True, _bOnScreen));
144 return Rectangle(aRet.TopLeft() - Point(0,aRet.GetHeight()),aRet.GetSize());
148 Rectangle AccessibleBrowseBoxHeaderCell::implGetBoundingBox()
150 return getRectangle(mpBrowseBox,m_nColumnRowId,sal_False,isRowBarCell());
152 // -----------------------------------------------------------------------------
154 Rectangle AccessibleBrowseBoxHeaderCell::implGetBoundingBoxOnScreen()
156 return getRectangle(mpBrowseBox,m_nColumnRowId,sal_True,isRowBarCell());
158 // -----------------------------------------------------------------------------
159 sal_Int32 SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleIndexInParent()
160 throw ( RuntimeException )
162 ::osl::MutexGuard aGuard( getOslMutex() );
163 ensureIsAlive();
164 sal_Int32 nIndex = m_nColumnRowId;
165 if ( mpBrowseBox->HasRowHeader() )
166 --nIndex;
167 return nIndex;
169 // -----------------------------------------------------------------------------
170 } // namespace accessibility
171 // -----------------------------------------------------------------------------