lok: vcl: fix multiple floatwin removal case more robustly.
[LibreOffice.git] / accessibility / source / extended / AccessibleGridControlHeaderCell.cxx
blobd2d47cbcce276bd8814b6c96848676182a0840bb
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 .
20 #include <extended/AccessibleGridControlHeaderCell.hxx>
21 #include <vcl/accessibletable.hxx>
22 #include <extended/AccessibleGridControl.hxx>
24 namespace accessibility
26 using namespace ::com::sun::star::accessibility;
27 using namespace ::com::sun::star::lang;
28 using namespace ::com::sun::star::uno;
29 using namespace ::vcl;
30 using namespace ::vcl::table;
32 AccessibleGridControlHeaderCell::AccessibleGridControlHeaderCell(sal_Int32 _nColumnRowId,
33 const Reference< XAccessible >& rxParent,
34 IAccessibleTable& rTable,
35 AccessibleTableControlObjType eObjType)
36 : AccessibleGridControlCell( rxParent, rTable, _nColumnRowId, 0, eObjType)
37 , m_nColumnRowId(_nColumnRowId)
40 /** Creates a new AccessibleStateSetHelper and fills it with states of the
41 current object.
42 @return
43 A filled AccessibleStateSetHelper.
45 ::utl::AccessibleStateSetHelper* AccessibleGridControlHeaderCell::implCreateStateSetHelper()
47 ::utl::AccessibleStateSetHelper*
48 pStateSetHelper = new ::utl::AccessibleStateSetHelper;
50 if( isAlive() )
52 // SHOWING done with mxParent
53 if( implIsShowing() )
54 pStateSetHelper->AddState( AccessibleStateType::SHOWING );
56 pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
57 pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE );
58 pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
59 pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
61 if ( m_aTable.IsRowSelected(m_nColumnRowId) )
62 pStateSetHelper->AddState( AccessibleStateType::SELECTED );
64 else
65 pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
67 return pStateSetHelper;
70 /** @return
71 The count of visible children.
73 sal_Int32 SAL_CALL AccessibleGridControlHeaderCell::getAccessibleChildCount()
75 return 0;
79 /** @return
80 The XAccessible interface of the specified child.
82 Reference<XAccessible > SAL_CALL AccessibleGridControlHeaderCell::getAccessibleChild( sal_Int32 )
84 throw IndexOutOfBoundsException();
86 // XInterface -------------------------------------------------------------
88 /** Queries for a new interface. */
89 css::uno::Any SAL_CALL AccessibleGridControlHeaderCell::queryInterface( const css::uno::Type& rType )
91 Any aRet = AccessibleGridControlCell::queryInterface(rType);
92 return aRet;
95 /** Acquires the object (calls acquire() on base class). */
96 void SAL_CALL AccessibleGridControlHeaderCell::acquire() throw ()
98 AccessibleGridControlCell::acquire();
101 /** Releases the object (calls release() on base class). */
102 void SAL_CALL AccessibleGridControlHeaderCell::release() throw ()
104 AccessibleGridControlCell::release();
106 /** @return The XAccessibleContext interface of this object. */
107 Reference< css::accessibility::XAccessibleContext > SAL_CALL AccessibleGridControlHeaderCell::getAccessibleContext()
109 ensureIsAlive();
110 return this;
114 /** Grabs the focus to the column header. */
115 void SAL_CALL AccessibleGridControlHeaderCell::grabFocus()
119 /** @return
120 The name of this class.
122 OUString SAL_CALL AccessibleGridControlHeaderCell::getImplementationName()
124 return OUString( "com.sun.star.accessibility.AccessibleGridControlHeaderCell" );
127 tools::Rectangle AccessibleGridControlHeaderCell::implGetBoundingBox()
129 vcl::Window* pParent = m_aTable.GetAccessibleParentWindow();
130 tools::Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( pParent ) );
131 sal_Int32 nIndex = getAccessibleIndexInParent();
132 tools::Rectangle aCellRect;
133 if(m_eObjType == TCTYPE_COLUMNHEADERCELL)
134 aCellRect = m_aTable.calcHeaderCellRect(true, nIndex);
135 else
136 aCellRect = m_aTable.calcHeaderCellRect(false, nIndex);
137 return tools::Rectangle(Point(aGridRect.Left()+aCellRect.Left(),aGridRect.Top()+aCellRect.Top()), aCellRect.GetSize());
141 tools::Rectangle AccessibleGridControlHeaderCell::implGetBoundingBoxOnScreen()
143 tools::Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( nullptr ) );
144 sal_Int32 nIndex = getAccessibleIndexInParent();
145 tools::Rectangle aCellRect;
146 if(m_eObjType == TCTYPE_COLUMNHEADERCELL)
147 aCellRect = m_aTable.calcHeaderCellRect(true, nIndex);
148 else
149 aCellRect = m_aTable.calcHeaderCellRect(false, nIndex);
150 return tools::Rectangle(Point(aGridRect.Left()+aCellRect.Left(),aGridRect.Top()+aCellRect.Top()), aCellRect.GetSize());
153 sal_Int32 SAL_CALL AccessibleGridControlHeaderCell::getAccessibleIndexInParent()
155 SolarMutexGuard g;
157 ensureIsAlive();
158 sal_Int32 nIndex = m_nColumnRowId;
159 return nIndex;
162 } // namespace accessibility
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */