Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : #include "accessibility/extended/AccessibleGridControlHeaderCell.hxx"
22 : #include <svtools/accessibletable.hxx>
23 : #include "accessibility/extended/AccessibleGridControl.hxx"
24 :
25 : namespace accessibility
26 : {
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;
32 :
33 0 : AccessibleGridControlHeaderCell::AccessibleGridControlHeaderCell(sal_Int32 _nColumnRowId,
34 : const Reference< XAccessible >& rxParent,
35 : IAccessibleTable& rTable,
36 : AccessibleTableControlObjType eObjType)
37 : : AccessibleGridControlCell( rxParent, rTable, _nColumnRowId, 0, eObjType)
38 0 : , m_nColumnRowId(_nColumnRowId)
39 : {
40 0 : }
41 : /** Creates a new AccessibleStateSetHelper and fills it with states of the
42 : current object.
43 : @return
44 : A filled AccessibleStateSetHelper.
45 : */
46 0 : ::utl::AccessibleStateSetHelper* AccessibleGridControlHeaderCell::implCreateStateSetHelper()
47 : {
48 0 : ::osl::MutexGuard aGuard( getOslMutex() );
49 : ::utl::AccessibleStateSetHelper*
50 0 : pStateSetHelper = new ::utl::AccessibleStateSetHelper;
51 :
52 0 : if( isAlive() )
53 : {
54 : // SHOWING done with mxParent
55 0 : if( implIsShowing() )
56 0 : pStateSetHelper->AddState( AccessibleStateType::SHOWING );
57 :
58 0 : SolarMutexGuard aSolarGuard;
59 0 : pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
60 0 : pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE );
61 0 : pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
62 0 : pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
63 :
64 0 : if ( m_aTable.IsRowSelected(m_nColumnRowId) )
65 0 : pStateSetHelper->AddState( AccessibleStateType::SELECTED );
66 : }
67 : else
68 0 : pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
69 :
70 0 : return pStateSetHelper;
71 : }
72 : // -----------------------------------------------------------------------------
73 : /** @return
74 : The count of visible children.
75 : */
76 0 : sal_Int32 SAL_CALL AccessibleGridControlHeaderCell::getAccessibleChildCount()
77 : throw ( RuntimeException )
78 : {
79 0 : return 0;
80 : }
81 : // -----------------------------------------------------------------------------
82 :
83 : /** @return
84 : The XAccessible interface of the specified child.
85 : */
86 0 : Reference<XAccessible > SAL_CALL AccessibleGridControlHeaderCell::getAccessibleChild( sal_Int32 )
87 : throw ( IndexOutOfBoundsException,RuntimeException )
88 : {
89 0 : throw IndexOutOfBoundsException();
90 : }
91 : // XInterface -------------------------------------------------------------
92 :
93 : /** Queries for a new interface. */
94 0 : ::com::sun::star::uno::Any SAL_CALL AccessibleGridControlHeaderCell::queryInterface(
95 : const ::com::sun::star::uno::Type& rType )
96 : throw ( ::com::sun::star::uno::RuntimeException )
97 : {
98 0 : Any aRet = AccessibleGridControlCell::queryInterface(rType);
99 0 : return aRet;
100 : }
101 :
102 : /** Aquires the object (calls acquire() on base class). */
103 0 : void SAL_CALL AccessibleGridControlHeaderCell::acquire() throw ()
104 : {
105 0 : AccessibleGridControlCell::acquire();
106 0 : }
107 :
108 : /** Releases the object (calls release() on base class). */
109 0 : void SAL_CALL AccessibleGridControlHeaderCell::release() throw ()
110 : {
111 0 : AccessibleGridControlCell::release();
112 0 : }
113 : /** @return The XAccessibleContext interface of this object. */
114 0 : Reference< com::sun::star::accessibility::XAccessibleContext > SAL_CALL AccessibleGridControlHeaderCell::getAccessibleContext() throw ( RuntimeException )
115 : {
116 0 : ensureIsAlive();
117 0 : return this;
118 : }
119 :
120 : // -----------------------------------------------------------------------------
121 :
122 : /** Grabs the focus to the column header. */
123 0 : void SAL_CALL AccessibleGridControlHeaderCell::grabFocus()
124 : throw ( ::com::sun::star::uno::RuntimeException )
125 : {
126 0 : }
127 : // -----------------------------------------------------------------------------
128 : /** @return
129 : The name of this class.
130 : */
131 0 : OUString SAL_CALL AccessibleGridControlHeaderCell::getImplementationName()
132 : throw ( ::com::sun::star::uno::RuntimeException )
133 : {
134 0 : return OUString( "com.sun.star.accessibility.AccessibleGridControlHeaderCell" );
135 : }
136 : // -----------------------------------------------------------------------------
137 0 : Rectangle AccessibleGridControlHeaderCell::implGetBoundingBox()
138 : {
139 0 : Window* pParent = m_aTable.GetAccessibleParentWindow();
140 0 : Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( pParent ) );
141 0 : sal_Int32 nIndex = getAccessibleIndexInParent();
142 0 : Rectangle aCellRect;
143 0 : if(m_eObjType == TCTYPE_COLUMNHEADERCELL)
144 0 : aCellRect = m_aTable.calcHeaderCellRect(true, nIndex);
145 : else
146 0 : aCellRect = m_aTable.calcHeaderCellRect(false, nIndex);
147 0 : return Rectangle(Point(aGridRect.Left()+aCellRect.Left(),aGridRect.Top()+aCellRect.Top()), aCellRect.GetSize());
148 : }
149 : // -----------------------------------------------------------------------------
150 :
151 0 : Rectangle AccessibleGridControlHeaderCell::implGetBoundingBoxOnScreen()
152 : {
153 0 : Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( NULL ) );
154 0 : sal_Int32 nIndex = getAccessibleIndexInParent();
155 0 : Rectangle aCellRect;
156 0 : if(m_eObjType == TCTYPE_COLUMNHEADERCELL)
157 0 : aCellRect = m_aTable.calcHeaderCellRect(true, nIndex);
158 : else
159 0 : aCellRect = m_aTable.calcHeaderCellRect(false, nIndex);
160 0 : return Rectangle(Point(aGridRect.Left()+aCellRect.Left(),aGridRect.Top()+aCellRect.Top()), aCellRect.GetSize());
161 : }
162 : // -----------------------------------------------------------------------------
163 0 : sal_Int32 SAL_CALL AccessibleGridControlHeaderCell::getAccessibleIndexInParent()
164 : throw ( RuntimeException )
165 : {
166 0 : ::osl::MutexGuard aGuard( getOslMutex() );
167 0 : ensureIsAlive();
168 0 : sal_Int32 nIndex = m_nColumnRowId;
169 0 : return nIndex;
170 : }
171 : // -----------------------------------------------------------------------------
172 : } // namespace accessibility
173 : // -----------------------------------------------------------------------------
174 :
175 :
176 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|