LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / accessibility / source / extended / AccessibleGridControlHeaderCell.cxx
blob72333d3405c52a5b4db648d16d184a8032a4df32
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 <com/sun/star/accessibility/AccessibleStateType.hpp>
21 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
22 #include <extended/AccessibleGridControlHeaderCell.hxx>
23 #include <vcl/accessibletable.hxx>
24 #include <vcl/svapp.hxx>
26 namespace accessibility
28 using namespace ::com::sun::star::accessibility;
29 using namespace ::com::sun::star::lang;
30 using namespace ::com::sun::star::uno;
31 using namespace ::vcl;
32 using namespace ::vcl::table;
34 AccessibleGridControlHeaderCell::AccessibleGridControlHeaderCell(sal_Int32 _nColumnRowId,
35 const Reference< XAccessible >& rxParent,
36 IAccessibleTable& rTable,
37 AccessibleTableControlObjType eObjType)
38 : AccessibleGridControlCell( rxParent, rTable, _nColumnRowId, 0, eObjType)
39 , m_nColumnRowId(_nColumnRowId)
42 /** Creates a new AccessibleStateSetHelper and fills it with states of the
43 current object.
44 @return
45 A filled AccessibleStateSetHelper.
47 rtl::Reference<::utl::AccessibleStateSetHelper> AccessibleGridControlHeaderCell::implCreateStateSetHelper()
49 rtl::Reference<::utl::AccessibleStateSetHelper>
50 pStateSetHelper = new ::utl::AccessibleStateSetHelper;
52 if( isAlive() )
54 // SHOWING done with mxParent
55 if( implIsShowing() )
56 pStateSetHelper->AddState( AccessibleStateType::SHOWING );
58 pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
59 pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE );
60 pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
61 pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
63 if ( m_aTable.IsRowSelected(m_nColumnRowId) )
64 pStateSetHelper->AddState( AccessibleStateType::SELECTED );
66 else
67 pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
69 return pStateSetHelper;
72 /** @return
73 The count of visible children.
75 sal_Int32 SAL_CALL AccessibleGridControlHeaderCell::getAccessibleChildCount()
77 return 0;
81 /** @return
82 The XAccessible interface of the specified child.
84 Reference<XAccessible > SAL_CALL AccessibleGridControlHeaderCell::getAccessibleChild( sal_Int32 )
86 throw IndexOutOfBoundsException();
88 // XInterface -------------------------------------------------------------
90 /** Queries for a new interface. */
91 css::uno::Any SAL_CALL AccessibleGridControlHeaderCell::queryInterface( const css::uno::Type& rType )
93 Any aRet = AccessibleGridControlCell::queryInterface(rType);
94 return aRet;
97 /** Acquires the object (calls acquire() on base class). */
98 void SAL_CALL AccessibleGridControlHeaderCell::acquire() noexcept
100 AccessibleGridControlCell::acquire();
103 /** Releases the object (calls release() on base class). */
104 void SAL_CALL AccessibleGridControlHeaderCell::release() noexcept
106 AccessibleGridControlCell::release();
108 /** @return The XAccessibleContext interface of this object. */
109 Reference< css::accessibility::XAccessibleContext > SAL_CALL AccessibleGridControlHeaderCell::getAccessibleContext()
111 ensureIsAlive();
112 return this;
116 /** Grabs the focus to the column header. */
117 void SAL_CALL AccessibleGridControlHeaderCell::grabFocus()
121 /** @return
122 The name of this class.
124 OUString SAL_CALL AccessibleGridControlHeaderCell::getImplementationName()
126 return "com.sun.star.accessibility.AccessibleGridControlHeaderCell";
129 tools::Rectangle AccessibleGridControlHeaderCell::implGetBoundingBox()
131 vcl::Window* pParent = m_aTable.GetAccessibleParentWindow();
132 tools::Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( pParent ) );
133 sal_Int32 nIndex = getAccessibleIndexInParent();
134 tools::Rectangle aCellRect;
135 if(m_eObjType == TCTYPE_COLUMNHEADERCELL)
136 aCellRect = m_aTable.calcHeaderCellRect(true, nIndex);
137 else
138 aCellRect = m_aTable.calcHeaderCellRect(false, nIndex);
139 return tools::Rectangle(Point(aGridRect.Left()+aCellRect.Left(),aGridRect.Top()+aCellRect.Top()), aCellRect.GetSize());
143 tools::Rectangle AccessibleGridControlHeaderCell::implGetBoundingBoxOnScreen()
145 tools::Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( nullptr ) );
146 sal_Int32 nIndex = getAccessibleIndexInParent();
147 tools::Rectangle aCellRect;
148 if(m_eObjType == TCTYPE_COLUMNHEADERCELL)
149 aCellRect = m_aTable.calcHeaderCellRect(true, nIndex);
150 else
151 aCellRect = m_aTable.calcHeaderCellRect(false, nIndex);
152 return tools::Rectangle(Point(aGridRect.Left()+aCellRect.Left(),aGridRect.Top()+aCellRect.Top()), aCellRect.GetSize());
155 sal_Int32 SAL_CALL AccessibleGridControlHeaderCell::getAccessibleIndexInParent()
157 SolarMutexGuard g;
159 ensureIsAlive();
160 sal_Int32 nIndex = m_nColumnRowId;
161 return nIndex;
164 } // namespace accessibility
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */