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/AccessibleBrowseBoxHeaderCell.hxx"
22 : #include <svtools/accessibletableprovider.hxx>
23 : #include "accessibility/extended/AccessibleBrowseBox.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 :
32 0 : AccessibleBrowseBoxHeaderCell::AccessibleBrowseBoxHeaderCell(sal_Int32 _nColumnRowId,
33 : const Reference< XAccessible >& rxParent,
34 : IAccessibleTableProvider& rBrowseBox,
35 : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& _xFocusWindow,
36 : AccessibleBrowseBoxObjType eObjType)
37 : : BrowseBoxAccessibleElement(rxParent,
38 : rBrowseBox,
39 : _xFocusWindow,
40 : eObjType,
41 0 : rBrowseBox.GetAccessibleObjectName( eObjType ,_nColumnRowId),
42 0 : rBrowseBox.GetAccessibleObjectDescription( eObjType ,_nColumnRowId))
43 0 : , m_nColumnRowId(_nColumnRowId)
44 : {
45 0 : }
46 : /** Creates a new AccessibleStateSetHelper and fills it with states of the
47 : current object.
48 : @return
49 : A filled AccessibleStateSetHelper.
50 : */
51 0 : ::utl::AccessibleStateSetHelper* AccessibleBrowseBoxHeaderCell::implCreateStateSetHelper()
52 : {
53 0 : ::osl::MutexGuard aGuard( getOslMutex() );
54 : ::utl::AccessibleStateSetHelper*
55 0 : pStateSetHelper = new ::utl::AccessibleStateSetHelper;
56 :
57 0 : if( isAlive() )
58 : {
59 : // SHOWING done with mxParent
60 0 : if( implIsShowing() )
61 0 : pStateSetHelper->AddState( AccessibleStateType::SHOWING );
62 :
63 0 : SolarMutexGuard aSolarGuard;
64 0 : pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
65 0 : pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE );
66 0 : pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
67 0 : pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
68 :
69 0 : sal_Bool bSelected = isRowBarCell() ? mpBrowseBox->IsRowSelected(m_nColumnRowId) : mpBrowseBox->IsColumnSelected(m_nColumnRowId);
70 0 : if ( bSelected )
71 0 : pStateSetHelper->AddState( AccessibleStateType::SELECTED );
72 : }
73 : else
74 0 : pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
75 :
76 0 : return pStateSetHelper;
77 : }
78 : // -----------------------------------------------------------------------------
79 : /** @return
80 : The count of visible children.
81 : */
82 0 : sal_Int32 SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleChildCount()
83 : throw ( RuntimeException )
84 : {
85 0 : return 0;
86 : }
87 : // -----------------------------------------------------------------------------
88 :
89 : /** @return
90 : The XAccessible interface of the specified child.
91 : */
92 0 : Reference<XAccessible > SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleChild( sal_Int32 )
93 : throw ( IndexOutOfBoundsException,RuntimeException )
94 : {
95 0 : throw IndexOutOfBoundsException();
96 : }
97 : // -----------------------------------------------------------------------------
98 :
99 : /** Grabs the focus to the column header. */
100 0 : void SAL_CALL AccessibleBrowseBoxHeaderCell::grabFocus()
101 : throw ( ::com::sun::star::uno::RuntimeException )
102 : {
103 0 : SolarMutexGuard aSolarGuard;
104 0 : ::osl::MutexGuard aGuard( getOslMutex() );
105 0 : ensureIsAlive();
106 0 : if ( isRowBarCell() )
107 0 : mpBrowseBox->SelectRow(m_nColumnRowId);
108 : else
109 0 : mpBrowseBox->SelectColumn(static_cast<sal_uInt16>(m_nColumnRowId)); //!!!
110 0 : }
111 : // -----------------------------------------------------------------------------
112 : /** @return
113 : The name of this class.
114 : */
115 0 : OUString SAL_CALL AccessibleBrowseBoxHeaderCell::getImplementationName()
116 : throw ( ::com::sun::star::uno::RuntimeException )
117 : {
118 0 : return OUString( "com.sun.star.comp.svtools.AccessibleBrowseBoxHeaderCell" );
119 : }
120 : // -----------------------------------------------------------------------------
121 : namespace
122 : {
123 0 : Rectangle getRectangle(IAccessibleTableProvider* _pBrowseBox,sal_Int32 _nRowColIndex, sal_Bool _bOnScreen,sal_Bool _bRowBar)
124 : {
125 0 : sal_Int32 nRow = 0;
126 0 : sal_uInt16 nCol = (sal_uInt16)_nRowColIndex;
127 0 : if ( _bRowBar )
128 : {
129 0 : nRow = _nRowColIndex + 1;
130 0 : nCol = 0;
131 : }
132 :
133 0 : Rectangle aRet(_pBrowseBox->GetFieldRectPixelAbs( nRow , nCol, sal_True, _bOnScreen));
134 0 : return Rectangle(aRet.TopLeft() - Point(0,aRet.GetHeight()),aRet.GetSize());
135 : }
136 : }
137 :
138 0 : Rectangle AccessibleBrowseBoxHeaderCell::implGetBoundingBox()
139 : {
140 0 : return getRectangle(mpBrowseBox,m_nColumnRowId,sal_False,isRowBarCell());
141 : }
142 : // -----------------------------------------------------------------------------
143 :
144 0 : Rectangle AccessibleBrowseBoxHeaderCell::implGetBoundingBoxOnScreen()
145 : {
146 0 : return getRectangle(mpBrowseBox,m_nColumnRowId,sal_True,isRowBarCell());
147 : }
148 : // -----------------------------------------------------------------------------
149 0 : sal_Int32 SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleIndexInParent()
150 : throw ( RuntimeException )
151 : {
152 0 : ::osl::MutexGuard aGuard( getOslMutex() );
153 0 : ensureIsAlive();
154 0 : sal_Int32 nIndex = m_nColumnRowId;
155 0 : if ( mpBrowseBox->HasRowHeader() )
156 0 : --nIndex;
157 0 : return nIndex;
158 : }
159 : // -----------------------------------------------------------------------------
160 : } // namespace accessibility
161 : // -----------------------------------------------------------------------------
162 :
163 :
164 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|