Impress Remote 1.0.5, tag sdremote-1.0.5
[LibreOffice.git] / accessibility / source / extended / AccessibleBrowseBoxHeaderCell.cxx
blob925aa5538930a89e937f0e2f7a5b8ee7259e9f41
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 pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
65 pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE );
66 pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
67 pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
69 sal_Bool bSelected = isRowBarCell() ? mpBrowseBox->IsRowSelected(m_nColumnRowId) : mpBrowseBox->IsColumnSelected(m_nColumnRowId);
70 if ( bSelected )
71 pStateSetHelper->AddState( AccessibleStateType::SELECTED );
73 else
74 pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
76 return pStateSetHelper;
78 // -----------------------------------------------------------------------------
79 /** @return
80 The count of visible children.
82 sal_Int32 SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleChildCount()
83 throw ( RuntimeException )
85 return 0;
87 // -----------------------------------------------------------------------------
89 /** @return
90 The XAccessible interface of the specified child.
92 Reference<XAccessible > SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleChild( sal_Int32 )
93 throw ( IndexOutOfBoundsException,RuntimeException )
95 throw IndexOutOfBoundsException();
97 // -----------------------------------------------------------------------------
99 /** Grabs the focus to the column header. */
100 void SAL_CALL AccessibleBrowseBoxHeaderCell::grabFocus()
101 throw ( ::com::sun::star::uno::RuntimeException )
103 SolarMutexGuard aSolarGuard;
104 ::osl::MutexGuard aGuard( getOslMutex() );
105 ensureIsAlive();
106 if ( isRowBarCell() )
107 mpBrowseBox->SelectRow(m_nColumnRowId);
108 else
109 mpBrowseBox->SelectColumn(static_cast<sal_uInt16>(m_nColumnRowId)); //!!!
111 // -----------------------------------------------------------------------------
112 /** @return
113 The name of this class.
115 OUString SAL_CALL AccessibleBrowseBoxHeaderCell::getImplementationName()
116 throw ( ::com::sun::star::uno::RuntimeException )
118 return OUString( "com.sun.star.comp.svtools.AccessibleBrowseBoxHeaderCell" );
120 // -----------------------------------------------------------------------------
121 namespace
123 Rectangle getRectangle(IAccessibleTableProvider* _pBrowseBox,sal_Int32 _nRowColIndex, sal_Bool _bOnScreen,sal_Bool _bRowBar)
125 sal_Int32 nRow = 0;
126 sal_uInt16 nCol = (sal_uInt16)_nRowColIndex;
127 if ( _bRowBar )
129 nRow = _nRowColIndex + 1;
130 nCol = 0;
133 Rectangle aRet(_pBrowseBox->GetFieldRectPixelAbs( nRow , nCol, sal_True, _bOnScreen));
134 return Rectangle(aRet.TopLeft() - Point(0,aRet.GetHeight()),aRet.GetSize());
138 Rectangle AccessibleBrowseBoxHeaderCell::implGetBoundingBox()
140 return getRectangle(mpBrowseBox,m_nColumnRowId,sal_False,isRowBarCell());
142 // -----------------------------------------------------------------------------
144 Rectangle AccessibleBrowseBoxHeaderCell::implGetBoundingBoxOnScreen()
146 return getRectangle(mpBrowseBox,m_nColumnRowId,sal_True,isRowBarCell());
148 // -----------------------------------------------------------------------------
149 sal_Int32 SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleIndexInParent()
150 throw ( RuntimeException )
152 ::osl::MutexGuard aGuard( getOslMutex() );
153 ensureIsAlive();
154 sal_Int32 nIndex = m_nColumnRowId;
155 if ( mpBrowseBox->HasRowHeader() )
156 --nIndex;
157 return nIndex;
159 // -----------------------------------------------------------------------------
160 } // namespace accessibility
161 // -----------------------------------------------------------------------------
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */