1*0841af79SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*0841af79SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*0841af79SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*0841af79SAndrew Rist  * distributed with this work for additional information
6*0841af79SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*0841af79SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*0841af79SAndrew Rist  * "License"); you may not use this file except in compliance
9*0841af79SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*0841af79SAndrew Rist  *
11*0841af79SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*0841af79SAndrew Rist  *
13*0841af79SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*0841af79SAndrew Rist  * software distributed under the License is distributed on an
15*0841af79SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*0841af79SAndrew Rist  * KIND, either express or implied.  See the License for the
17*0841af79SAndrew Rist  * specific language governing permissions and limitations
18*0841af79SAndrew Rist  * under the License.
19*0841af79SAndrew Rist  *
20*0841af79SAndrew Rist  *************************************************************/
21*0841af79SAndrew Rist 
22*0841af79SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_accessibility.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include "accessibility/extended/AccessibleGridControlHeader.hxx"
29cdf0e10cSrcweir #include "accessibility/extended/AccessibleGridControlHeaderCell.hxx"
30cdf0e10cSrcweir #include "accessibility/extended/AccessibleGridControlTableCell.hxx"
31cdf0e10cSrcweir #include <svtools/accessibletable.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir 
34cdf0e10cSrcweir // ============================================================================
35cdf0e10cSrcweir 
36cdf0e10cSrcweir using ::rtl::OUString;
37cdf0e10cSrcweir 
38cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
39cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
40cdf0e10cSrcweir using ::com::sun::star::uno::Any;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir using namespace ::com::sun::star::uno;
43cdf0e10cSrcweir using namespace ::com::sun::star;
44cdf0e10cSrcweir using namespace ::com::sun::star::lang;
45cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
46cdf0e10cSrcweir using namespace ::svt;
47cdf0e10cSrcweir using namespace ::svt::table;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir // ============================================================================
50cdf0e10cSrcweir 
51cdf0e10cSrcweir namespace accessibility {
52cdf0e10cSrcweir 
53cdf0e10cSrcweir // ============================================================================
54cdf0e10cSrcweir 
DBG_NAME(AccessibleGridControlHeader)55cdf0e10cSrcweir DBG_NAME( AccessibleGridControlHeader )
56cdf0e10cSrcweir 
57cdf0e10cSrcweir AccessibleGridControlHeader::AccessibleGridControlHeader(
58cdf0e10cSrcweir         const Reference< XAccessible >& rxParent,
59cdf0e10cSrcweir         ::svt::table::IAccessibleTable&                      rTable,
60cdf0e10cSrcweir 		::svt::table::AccessibleTableControlObjType      eObjType):
61cdf0e10cSrcweir 		AccessibleGridControlTableBase( rxParent, rTable, eObjType )
62cdf0e10cSrcweir {
63cdf0e10cSrcweir     DBG_ASSERT( isRowBar() || isColumnBar(),
64cdf0e10cSrcweir         "accessibility/extended/AccessibleGridControlHeaderBar - invalid object type" );
65cdf0e10cSrcweir }
66cdf0e10cSrcweir 
~AccessibleGridControlHeader()67cdf0e10cSrcweir AccessibleGridControlHeader::~AccessibleGridControlHeader()
68cdf0e10cSrcweir {
69cdf0e10cSrcweir }
70cdf0e10cSrcweir 
71cdf0e10cSrcweir // XAccessibleContext ---------------------------------------------------------
72cdf0e10cSrcweir 
73cdf0e10cSrcweir Reference< XAccessible > SAL_CALL
getAccessibleChild(sal_Int32 nChildIndex)74cdf0e10cSrcweir AccessibleGridControlHeader::getAccessibleChild( sal_Int32 nChildIndex )
75cdf0e10cSrcweir     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
76cdf0e10cSrcweir {
77cdf0e10cSrcweir     TCSolarGuard aSolarGuard;
78cdf0e10cSrcweir     ::osl::MutexGuard aGuard( getOslMutex() );
79cdf0e10cSrcweir 
80cdf0e10cSrcweir     if (nChildIndex<0 || nChildIndex>=getAccessibleChildCount())
81cdf0e10cSrcweir 	throw IndexOutOfBoundsException();
82cdf0e10cSrcweir     ensureIsAlive();
83cdf0e10cSrcweir     Reference< XAccessible > xChild;
84cdf0e10cSrcweir     if(m_eObjType == svt::table::TCTYPE_COLUMNHEADERBAR)
85cdf0e10cSrcweir     {
86cdf0e10cSrcweir 	    AccessibleGridControlHeaderCell* pColHeaderCell = new AccessibleGridControlHeaderCell(nChildIndex, this, m_aTable, svt::table::TCTYPE_COLUMNHEADERCELL);
87cdf0e10cSrcweir 	    xChild = pColHeaderCell;
88cdf0e10cSrcweir     }
89cdf0e10cSrcweir     else if(m_eObjType == svt::table::TCTYPE_ROWHEADERBAR)
90cdf0e10cSrcweir     {
91cdf0e10cSrcweir 	    AccessibleGridControlHeaderCell* pRowHeaderCell = new AccessibleGridControlHeaderCell(nChildIndex, this, m_aTable, svt::table::TCTYPE_ROWHEADERCELL);
92cdf0e10cSrcweir 	    xChild = pRowHeaderCell;
93cdf0e10cSrcweir     }
94cdf0e10cSrcweir     return xChild;
95cdf0e10cSrcweir }
96cdf0e10cSrcweir 
getAccessibleIndexInParent()97cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleGridControlHeader::getAccessibleIndexInParent()
98cdf0e10cSrcweir     throw ( uno::RuntimeException )
99cdf0e10cSrcweir {
100cdf0e10cSrcweir      ensureIsAlive();
101cdf0e10cSrcweir      if(m_eObjType == svt::table::TCTYPE_ROWHEADERBAR && m_aTable.HasColHeader())
102cdf0e10cSrcweir 	     return 1;
103cdf0e10cSrcweir      else
104cdf0e10cSrcweir 	     return 0;
105cdf0e10cSrcweir }
106cdf0e10cSrcweir 
107cdf0e10cSrcweir // XAccessibleComponent -------------------------------------------------------
108cdf0e10cSrcweir 
109cdf0e10cSrcweir Reference< XAccessible > SAL_CALL
getAccessibleAtPoint(const awt::Point & rPoint)110cdf0e10cSrcweir AccessibleGridControlHeader::getAccessibleAtPoint( const awt::Point& rPoint )
111cdf0e10cSrcweir     throw ( uno::RuntimeException )
112cdf0e10cSrcweir {
113cdf0e10cSrcweir     TCSolarGuard aSolarGuard;
114cdf0e10cSrcweir     ::osl::MutexGuard aGuard( getOslMutex() );
115cdf0e10cSrcweir     ensureIsAlive();
116cdf0e10cSrcweir 
117cdf0e10cSrcweir     sal_Int32 nRow = 0;
118cdf0e10cSrcweir     sal_Int32 nColumnPos = 0;
119cdf0e10cSrcweir     sal_Bool bConverted = isRowBar() ?
120cdf0e10cSrcweir     m_aTable.ConvertPointToCellAddress( nRow, nColumnPos, VCLPoint( rPoint ) ) :
121cdf0e10cSrcweir     m_aTable.ConvertPointToCellAddress( nRow, nColumnPos, VCLPoint( rPoint ) );
122cdf0e10cSrcweir 
123cdf0e10cSrcweir     return bConverted ? implGetChild( nRow, nColumnPos ) : Reference< XAccessible >();
124cdf0e10cSrcweir }
125cdf0e10cSrcweir 
grabFocus()126cdf0e10cSrcweir void SAL_CALL AccessibleGridControlHeader::grabFocus()
127cdf0e10cSrcweir     throw ( uno::RuntimeException )
128cdf0e10cSrcweir {
129cdf0e10cSrcweir     ensureIsAlive();
130cdf0e10cSrcweir     // focus on header not supported
131cdf0e10cSrcweir }
132cdf0e10cSrcweir 
getAccessibleKeyBinding()133cdf0e10cSrcweir Any SAL_CALL AccessibleGridControlHeader::getAccessibleKeyBinding()
134cdf0e10cSrcweir     throw ( uno::RuntimeException )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir     ensureIsAlive();
137cdf0e10cSrcweir     return Any();   // no special key bindings for header
138cdf0e10cSrcweir }
139cdf0e10cSrcweir 
140cdf0e10cSrcweir // XAccessibleTable -----------------------------------------------------------
141cdf0e10cSrcweir 
getAccessibleRowDescription(sal_Int32 nRow)142cdf0e10cSrcweir OUString SAL_CALL AccessibleGridControlHeader::getAccessibleRowDescription( sal_Int32 nRow )
143cdf0e10cSrcweir     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
144cdf0e10cSrcweir {
145cdf0e10cSrcweir     TCSolarGuard aSolarGuard;
146cdf0e10cSrcweir     ::osl::MutexGuard aGuard( getOslMutex() );
147cdf0e10cSrcweir     ensureIsAlive();
148cdf0e10cSrcweir     ensureIsValidRow( nRow );
149cdf0e10cSrcweir     return OUString();  // no headers in headers
150cdf0e10cSrcweir }
151cdf0e10cSrcweir 
getAccessibleColumnDescription(sal_Int32 nColumn)152cdf0e10cSrcweir OUString SAL_CALL AccessibleGridControlHeader::getAccessibleColumnDescription( sal_Int32 nColumn )
153cdf0e10cSrcweir     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
154cdf0e10cSrcweir {
155cdf0e10cSrcweir     TCSolarGuard aSolarGuard;
156cdf0e10cSrcweir     ::osl::MutexGuard aGuard( getOslMutex() );
157cdf0e10cSrcweir     ensureIsAlive();
158cdf0e10cSrcweir     ensureIsValidColumn( nColumn );
159cdf0e10cSrcweir     return OUString();  // no headers in headers
160cdf0e10cSrcweir }
161cdf0e10cSrcweir 
getAccessibleRowHeaders()162cdf0e10cSrcweir Reference< XAccessibleTable > SAL_CALL AccessibleGridControlHeader::getAccessibleRowHeaders()
163cdf0e10cSrcweir     throw ( uno::RuntimeException )
164cdf0e10cSrcweir {
165cdf0e10cSrcweir     ensureIsAlive();
166cdf0e10cSrcweir     return NULL;        // no headers in headers
167cdf0e10cSrcweir }
168cdf0e10cSrcweir 
getAccessibleColumnHeaders()169cdf0e10cSrcweir Reference< XAccessibleTable > SAL_CALL AccessibleGridControlHeader::getAccessibleColumnHeaders()
170cdf0e10cSrcweir     throw ( uno::RuntimeException )
171cdf0e10cSrcweir {
172cdf0e10cSrcweir     ensureIsAlive();
173cdf0e10cSrcweir     return NULL;        // no headers in headers
174cdf0e10cSrcweir }
175cdf0e10cSrcweir //not selectable
getSelectedAccessibleRows()176cdf0e10cSrcweir Sequence< sal_Int32 > SAL_CALL AccessibleGridControlHeader::getSelectedAccessibleRows()
177cdf0e10cSrcweir     throw ( uno::RuntimeException )
178cdf0e10cSrcweir {
179cdf0e10cSrcweir     Sequence< sal_Int32 > aSelSeq(0);
180cdf0e10cSrcweir     return aSelSeq;
181cdf0e10cSrcweir }
182cdf0e10cSrcweir //columns aren't selectable
getSelectedAccessibleColumns()183cdf0e10cSrcweir Sequence< sal_Int32 > SAL_CALL AccessibleGridControlHeader::getSelectedAccessibleColumns()
184cdf0e10cSrcweir     throw ( uno::RuntimeException )
185cdf0e10cSrcweir {
186cdf0e10cSrcweir     Sequence< sal_Int32 > aSelSeq(0);
187cdf0e10cSrcweir     return aSelSeq;
188cdf0e10cSrcweir }
189cdf0e10cSrcweir //row headers not selectable
isAccessibleRowSelected(sal_Int32)190cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleRowSelected( sal_Int32 /*nRow*/ )
191cdf0e10cSrcweir     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
192cdf0e10cSrcweir {
193cdf0e10cSrcweir     return sal_False;
194cdf0e10cSrcweir }
195cdf0e10cSrcweir //columns aren't selectable
isAccessibleColumnSelected(sal_Int32 nColumn)196cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleColumnSelected( sal_Int32 nColumn )
197cdf0e10cSrcweir     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
198cdf0e10cSrcweir {
199cdf0e10cSrcweir     (void)nColumn;
200cdf0e10cSrcweir     return sal_False;
201cdf0e10cSrcweir }
202cdf0e10cSrcweir //not implemented
getAccessibleCellAt(sal_Int32,sal_Int32)203cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleGridControlHeader::getAccessibleCellAt(
204cdf0e10cSrcweir         sal_Int32 /*nRow*/, sal_Int32 /*nColumn*/ )
205cdf0e10cSrcweir     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
206cdf0e10cSrcweir {
207cdf0e10cSrcweir     return NULL;
208cdf0e10cSrcweir }
209cdf0e10cSrcweir // not selectable
isAccessibleSelected(sal_Int32,sal_Int32)210cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleSelected(
211cdf0e10cSrcweir         sal_Int32 /*nRow*/, sal_Int32 /*nColumn */)
212cdf0e10cSrcweir     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
213cdf0e10cSrcweir {
214cdf0e10cSrcweir     return sal_False;
215cdf0e10cSrcweir }
216cdf0e10cSrcweir 
217cdf0e10cSrcweir // XServiceInfo ---------------------------------------------------------------
218cdf0e10cSrcweir 
getImplementationName()219cdf0e10cSrcweir OUString SAL_CALL AccessibleGridControlHeader::getImplementationName()
220cdf0e10cSrcweir     throw ( uno::RuntimeException )
221cdf0e10cSrcweir {
222cdf0e10cSrcweir     return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleGridControlHeader" ) );
223cdf0e10cSrcweir }
224cdf0e10cSrcweir 
getImplementationId()225cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL AccessibleGridControlHeader::getImplementationId()
226cdf0e10cSrcweir     throw ( uno::RuntimeException )
227cdf0e10cSrcweir {
228cdf0e10cSrcweir     ::osl::MutexGuard aGuard( getOslGlobalMutex() );
229cdf0e10cSrcweir     static Sequence< sal_Int8 > aId;
230cdf0e10cSrcweir     implCreateUuid( aId );
231cdf0e10cSrcweir     return aId;
232cdf0e10cSrcweir }
233cdf0e10cSrcweir 
234cdf0e10cSrcweir // internal virtual methods ---------------------------------------------------
235cdf0e10cSrcweir 
implGetBoundingBox()236cdf0e10cSrcweir Rectangle AccessibleGridControlHeader::implGetBoundingBox()
237cdf0e10cSrcweir {
238cdf0e10cSrcweir     Window* pParent = m_aTable.GetAccessibleParentWindow();
239cdf0e10cSrcweir 	Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( pParent ) );
240cdf0e10cSrcweir 	Rectangle aHeaderRect (m_aTable.calcHeaderRect(isColumnBar()));
241cdf0e10cSrcweir 	if(isColumnBar())
242cdf0e10cSrcweir 		return Rectangle(aGridRect.TopLeft(), Size(aGridRect.getWidth(),aHeaderRect.getHeight()));
243cdf0e10cSrcweir 	else
244cdf0e10cSrcweir 		return Rectangle(aGridRect.TopLeft(), Size(aHeaderRect.getWidth(),aGridRect.getHeight()));
245cdf0e10cSrcweir 
246cdf0e10cSrcweir }
247cdf0e10cSrcweir 
implGetBoundingBoxOnScreen()248cdf0e10cSrcweir Rectangle AccessibleGridControlHeader::implGetBoundingBoxOnScreen()
249cdf0e10cSrcweir {
250cdf0e10cSrcweir     Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( NULL ) );
251cdf0e10cSrcweir 	Rectangle aHeaderRect (m_aTable.calcHeaderRect(isColumnBar()));
252cdf0e10cSrcweir 	if(isColumnBar())
253cdf0e10cSrcweir 		return Rectangle(aGridRect.TopLeft(), Size(aGridRect.getWidth(),aHeaderRect.getHeight()));
254cdf0e10cSrcweir 	else
255cdf0e10cSrcweir 		return Rectangle(aGridRect.TopLeft(), Size(aHeaderRect.getWidth(),aGridRect.getHeight()));
256cdf0e10cSrcweir }
257cdf0e10cSrcweir 
implGetRowCount() const258cdf0e10cSrcweir sal_Int32 AccessibleGridControlHeader::implGetRowCount() const
259cdf0e10cSrcweir {
260cdf0e10cSrcweir     return 1;
261cdf0e10cSrcweir }
262cdf0e10cSrcweir 
implGetColumnCount() const263cdf0e10cSrcweir sal_Int32 AccessibleGridControlHeader::implGetColumnCount() const
264cdf0e10cSrcweir {
265cdf0e10cSrcweir     return 1;
266cdf0e10cSrcweir }
267cdf0e10cSrcweir 
268cdf0e10cSrcweir // internal helper methods ----------------------------------------------------
269cdf0e10cSrcweir 
implGetChild(sal_Int32 nRow,sal_uInt32 nColumnPos)270cdf0e10cSrcweir Reference< XAccessible > AccessibleGridControlHeader::implGetChild(
271cdf0e10cSrcweir         sal_Int32 nRow, sal_uInt32 nColumnPos )
272cdf0e10cSrcweir {
273cdf0e10cSrcweir     Reference< XAccessible > xChild;
274cdf0e10cSrcweir     if(m_eObjType == svt::table::TCTYPE_COLUMNHEADERBAR)
275cdf0e10cSrcweir     {
276cdf0e10cSrcweir 	    AccessibleGridControlHeaderCell* pColHeaderCell = new AccessibleGridControlHeaderCell(nColumnPos, this, m_aTable, svt::table::TCTYPE_COLUMNHEADERCELL);
277cdf0e10cSrcweir 	    xChild = pColHeaderCell;
278cdf0e10cSrcweir     }
279cdf0e10cSrcweir     else if(m_eObjType == svt::table::TCTYPE_ROWHEADERBAR)
280cdf0e10cSrcweir     {
281cdf0e10cSrcweir 	    AccessibleGridControlHeaderCell* pRowHeaderCell = new AccessibleGridControlHeaderCell(nRow, this, m_aTable, svt::table::TCTYPE_ROWHEADERCELL);
282cdf0e10cSrcweir 	    xChild = pRowHeaderCell;
283cdf0e10cSrcweir     }
284cdf0e10cSrcweir     return xChild;
285cdf0e10cSrcweir }
286cdf0e10cSrcweir 
287cdf0e10cSrcweir // ============================================================================
288cdf0e10cSrcweir 
289cdf0e10cSrcweir } // namespace accessibility
290cdf0e10cSrcweir 
291cdf0e10cSrcweir // ============================================================================
292cdf0e10cSrcweir 
293