1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/AccessibleGridControlHeaderCell.hxx"
22 #include <svtools/accessibletable.hxx>
23 #include "accessibility/extended/AccessibleGridControl.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
;
31 using namespace ::svt::table
;
33 AccessibleGridControlHeaderCell::AccessibleGridControlHeaderCell(sal_Int32 _nColumnRowId
,
34 const Reference
< XAccessible
>& rxParent
,
35 IAccessibleTable
& rTable
,
36 AccessibleTableControlObjType eObjType
)
37 : AccessibleGridControlCell( rxParent
, rTable
, _nColumnRowId
, 0, eObjType
)
38 , m_nColumnRowId(_nColumnRowId
)
41 /** Creates a new AccessibleStateSetHelper and fills it with states of the
44 A filled AccessibleStateSetHelper.
46 ::utl::AccessibleStateSetHelper
* AccessibleGridControlHeaderCell::implCreateStateSetHelper()
48 ::utl::AccessibleStateSetHelper
*
49 pStateSetHelper
= new ::utl::AccessibleStateSetHelper
;
53 // SHOWING done with mxParent
55 pStateSetHelper
->AddState( AccessibleStateType::SHOWING
);
57 pStateSetHelper
->AddState( AccessibleStateType::VISIBLE
);
58 pStateSetHelper
->AddState( AccessibleStateType::FOCUSABLE
);
59 pStateSetHelper
->AddState( AccessibleStateType::TRANSIENT
);
60 pStateSetHelper
->AddState( AccessibleStateType::SELECTABLE
);
62 if ( m_aTable
.IsRowSelected(m_nColumnRowId
) )
63 pStateSetHelper
->AddState( AccessibleStateType::SELECTED
);
66 pStateSetHelper
->AddState( AccessibleStateType::DEFUNC
);
68 return pStateSetHelper
;
72 The count of visible children.
74 sal_Int32 SAL_CALL
AccessibleGridControlHeaderCell::getAccessibleChildCount()
75 throw ( RuntimeException
, std::exception
)
82 The XAccessible interface of the specified child.
84 Reference
<XAccessible
> SAL_CALL
AccessibleGridControlHeaderCell::getAccessibleChild( sal_Int32
)
85 throw ( IndexOutOfBoundsException
,RuntimeException
, std::exception
)
87 throw IndexOutOfBoundsException();
89 // XInterface -------------------------------------------------------------
91 /** Queries for a new interface. */
92 ::com::sun::star::uno::Any SAL_CALL
AccessibleGridControlHeaderCell::queryInterface(
93 const ::com::sun::star::uno::Type
& rType
)
94 throw ( ::com::sun::star::uno::RuntimeException
, std::exception
)
96 Any aRet
= AccessibleGridControlCell::queryInterface(rType
);
100 /** Aquires the object (calls acquire() on base class). */
101 void SAL_CALL
AccessibleGridControlHeaderCell::acquire() throw ()
103 AccessibleGridControlCell::acquire();
106 /** Releases the object (calls release() on base class). */
107 void SAL_CALL
AccessibleGridControlHeaderCell::release() throw ()
109 AccessibleGridControlCell::release();
111 /** @return The XAccessibleContext interface of this object. */
112 Reference
< com::sun::star::accessibility::XAccessibleContext
> SAL_CALL
AccessibleGridControlHeaderCell::getAccessibleContext() throw ( RuntimeException
, std::exception
)
120 /** Grabs the focus to the column header. */
121 void SAL_CALL
AccessibleGridControlHeaderCell::grabFocus()
122 throw ( ::com::sun::star::uno::RuntimeException
, std::exception
)
127 The name of this class.
129 OUString SAL_CALL
AccessibleGridControlHeaderCell::getImplementationName()
130 throw ( ::com::sun::star::uno::RuntimeException
, std::exception
)
132 return OUString( "com.sun.star.accessibility.AccessibleGridControlHeaderCell" );
135 Rectangle
AccessibleGridControlHeaderCell::implGetBoundingBox()
137 vcl::Window
* pParent
= m_aTable
.GetAccessibleParentWindow();
138 Rectangle
aGridRect( m_aTable
.GetWindowExtentsRelative( pParent
) );
139 sal_Int32 nIndex
= getAccessibleIndexInParent();
141 if(m_eObjType
== TCTYPE_COLUMNHEADERCELL
)
142 aCellRect
= m_aTable
.calcHeaderCellRect(true, nIndex
);
144 aCellRect
= m_aTable
.calcHeaderCellRect(false, nIndex
);
145 return Rectangle(Point(aGridRect
.Left()+aCellRect
.Left(),aGridRect
.Top()+aCellRect
.Top()), aCellRect
.GetSize());
149 Rectangle
AccessibleGridControlHeaderCell::implGetBoundingBoxOnScreen()
151 Rectangle
aGridRect( m_aTable
.GetWindowExtentsRelative( NULL
) );
152 sal_Int32 nIndex
= getAccessibleIndexInParent();
154 if(m_eObjType
== TCTYPE_COLUMNHEADERCELL
)
155 aCellRect
= m_aTable
.calcHeaderCellRect(true, nIndex
);
157 aCellRect
= m_aTable
.calcHeaderCellRect(false, nIndex
);
158 return Rectangle(Point(aGridRect
.Left()+aCellRect
.Left(),aGridRect
.Top()+aCellRect
.Top()), aCellRect
.GetSize());
161 sal_Int32 SAL_CALL
AccessibleGridControlHeaderCell::getAccessibleIndexInParent()
162 throw ( RuntimeException
, std::exception
)
167 sal_Int32 nIndex
= m_nColumnRowId
;
171 } // namespace accessibility
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */