Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <svtools/editbrowsebox.hxx>
30 : : #include <com/sun/star/accessibility/XAccessible.hpp>
31 : : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
32 : : #include "editbrowseboximpl.hxx"
33 : : #include <comphelper/types.hxx>
34 : : #include <toolkit/helper/vclunohelper.hxx>
35 : : #include "svtaccessiblefactory.hxx"
36 : :
37 : : namespace svt
38 : : {
39 : : using namespace com::sun::star::accessibility;
40 : : using namespace com::sun::star::uno;
41 : : using namespace ::com::sun::star::accessibility::AccessibleEventId;
42 : :
43 : : // -----------------------------------------------------------------------------
44 : 0 : Reference< XAccessible > EditBrowseBox::CreateAccessibleCheckBoxCell(long _nRow, sal_uInt16 _nColumnPos,const TriState& eState,sal_Bool _bEnabled)
45 : : {
46 [ # # ]: 0 : Reference< XAccessible > xAccessible( GetAccessible() );
47 : 0 : Reference< XAccessibleContext > xAccContext;
48 [ # # ]: 0 : if ( xAccessible.is() )
49 [ # # ][ # # ]: 0 : xAccContext = xAccessible->getAccessibleContext();
[ # # ]
50 : :
51 : 0 : Reference< XAccessible > xReturn;
52 [ # # ]: 0 : if ( xAccContext.is() )
53 : : {
54 [ # # ]: 0 : xReturn = getAccessibleFactory().createAccessibleCheckBoxCell(
55 [ # # ]: 0 : xAccContext->getAccessibleChild( ::svt::BBINDEX_TABLE ),
56 : : *this,
57 : : NULL,
58 : : _nRow,
59 : : _nColumnPos,
60 : : eState,
61 : : _bEnabled,
62 : : sal_True
63 [ # # ][ # # ]: 0 : );
[ # # ][ # # ]
64 : : }
65 : 0 : return xReturn;
66 : : }
67 : : // -----------------------------------------------------------------------------
68 : 0 : Reference< XAccessible > EditBrowseBox::CreateAccessibleCell( sal_Int32 _nRow, sal_uInt16 _nColumnPos )
69 : : {
70 : 0 : return BrowseBox::CreateAccessibleCell( _nRow, _nColumnPos );
71 : : }
72 : : // -----------------------------------------------------------------------------
73 : 0 : sal_Int32 EditBrowseBox::GetAccessibleControlCount() const
74 : : {
75 [ # # ]: 0 : return IsEditing() ? 1 : 0;
76 : : }
77 : : // -----------------------------------------------------------------------------
78 : 0 : void EditBrowseBox::implCreateActiveAccessible( )
79 : : {
80 : : DBG_ASSERT( IsEditing(), "EditBrowseBox::implCreateActiveAccessible: not to be called if we're not editing currently!" );
81 : : DBG_ASSERT( !m_aImpl->m_xActiveCell.is(), "EditBrowseBox::implCreateActiveAccessible: not to be called if the old one is still alive!" );
82 : :
83 [ # # ][ # # ]: 0 : if ( !m_aImpl->m_xActiveCell.is() && IsEditing() )
[ # # ]
84 : : {
85 [ # # ]: 0 : Reference< XAccessible > xCont = aController->GetWindow().GetAccessible();
86 [ # # ]: 0 : Reference< XAccessible > xMy = GetAccessible();
87 [ # # ][ # # ]: 0 : if ( xMy.is() && xCont.is() )
[ # # ]
88 : : {
89 [ # # ]: 0 : m_aImpl->m_xActiveCell = getAccessibleFactory().createEditBrowseBoxTableCellAccess(
90 : : xMy, // parent accessible
91 : : xCont, // control accessible
92 : 0 : VCLUnoHelper::GetInterface( &aController->GetWindow() ), // focus window (for notifications)
93 : : *this, // the browse box
94 : : GetCurRow(),
95 [ # # ]: 0 : GetColumnPos( GetCurColumnId() )
96 [ # # ]: 0 : );
[ # # # # ]
97 : :
98 [ # # ][ # # ]: 0 : commitBrowseBoxEvent( CHILD, makeAny( m_aImpl->m_xActiveCell ), Any() );
99 : 0 : }
100 : : }
101 : 0 : }
102 : :
103 : : // -----------------------------------------------------------------------------
104 : 0 : Reference< XAccessible > EditBrowseBox::CreateAccessibleControl( sal_Int32
105 : : #ifdef DBG_UTIL
106 : : _nIndex
107 : : #endif
108 : : )
109 : : {
110 : : DBG_ASSERT( 0 == _nIndex, "EditBrowseBox::CreateAccessibleControl: invalid index!" );
111 : :
112 [ # # ]: 0 : if ( isAccessibleAlive() )
113 : : {
114 [ # # ]: 0 : if ( !m_aImpl->m_xActiveCell.is() )
115 : 0 : implCreateActiveAccessible();
116 : : }
117 : :
118 : 0 : return m_aImpl->m_xActiveCell;
119 : : }
120 : : // -----------------------------------------------------------------------------
121 : 0 : Reference<XAccessible > EditBrowseBox::CreateAccessibleRowHeader( sal_Int32 _nRow )
122 : : {
123 : 0 : return BrowseBox::CreateAccessibleRowHeader( _nRow );
124 : : }
125 : : // -----------------------------------------------------------------------------
126 : 0 : void EditBrowseBoxImpl::clearActiveCell()
127 : : {
128 : : try
129 : : {
130 [ # # ]: 0 : ::comphelper::disposeComponent(m_xActiveCell);
131 : : }
132 : 0 : catch(const Exception&)
133 : : {
134 : : OSL_FAIL( "EditBrowseBoxImpl::clearActiveCell: caught an exception while disposing the AccessibleCell!" );
135 : : }
136 : :
137 : 0 : m_xActiveCell = NULL;
138 [ # # ]: 0 : }
139 : : // -----------------------------------------------------------------------------
140 : 0 : void EditBrowseBox::GrabTableFocus()
141 : : {
142 [ # # ]: 0 : if ( aController.Is() )
143 : 0 : aController->GetWindow().GrabFocus();
144 : 0 : }
145 : : //------------------------------------------------------------------------------
146 : 0 : void EditBrowseBox::DetermineFocus( const sal_uInt16 _nGetFocusFlags )
147 : : {
148 : 0 : sal_Bool bFocus = sal_False;
149 [ # # ][ # # ]: 0 : for (Window* pWindow = Application::GetFocusWindow();
[ # # ]
150 : : pWindow && !bFocus;
151 : : pWindow = pWindow->GetParent())
152 : 0 : bFocus = pWindow == this;
153 : :
154 [ # # ]: 0 : if (bFocus != bHasFocus)
155 : : {
156 : 0 : bHasFocus = bFocus;
157 : :
158 [ # # ]: 0 : if ( GetBrowserFlags( ) & EBBF_SMART_TAB_TRAVEL )
159 : : {
160 [ # # ][ # # ]: 0 : if ( bHasFocus // we got the focus
161 : : && ( _nGetFocusFlags & GETFOCUS_TAB ) // using the TAB key
162 : : )
163 : : {
164 : 0 : long nRows = GetRowCount();
165 : 0 : sal_uInt16 nCols = ColCount();
166 : :
167 [ # # ][ # # ]: 0 : if ( ( nRows > 0 ) && ( nCols > 0 ) )
168 : : {
169 [ # # ]: 0 : if ( _nGetFocusFlags & GETFOCUS_FORWARD )
170 : : {
171 [ # # ]: 0 : if ( GetColumnId( 0 ) != HandleColumnId )
172 : : {
173 : 0 : GoToRowColumnId( 0, GetColumnId( 0 ) );
174 : : }
175 : : else
176 : : { // the first column is the handle column -> not focussable
177 [ # # ]: 0 : if ( nCols > 1 )
178 : 0 : GoToRowColumnId( 0, GetColumnId( 1 ) );
179 : : }
180 : : }
181 [ # # ]: 0 : else if ( _nGetFocusFlags & GETFOCUS_BACKWARD )
182 : : {
183 : 0 : GoToRowColumnId( nRows - 1, GetColumnId( nCols -1 ) );
184 : : }
185 : : }
186 : : }
187 : : }
188 : : }
189 : 0 : }
190 : : // -----------------------------------------------------------------------------
191 : 0 : Rectangle EditBrowseBox::GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 _nIndex)
192 : : {
193 : 0 : Rectangle aRect;
194 [ # # ]: 0 : if ( SeekRow(_nRow) )
195 : : {
196 : : CellController* pController = GetController(
197 : 0 : _nRow, GetColumnId( sal::static_int_cast< sal_uInt16 >(_nColumnPos) ) );
198 [ # # ]: 0 : if ( pController )
199 : 0 : aRect = pController->GetWindow().GetCharacterBounds(_nIndex);
200 : : }
201 : 0 : return aRect;
202 : : }
203 : : // -----------------------------------------------------------------------------
204 : 0 : sal_Int32 EditBrowseBox::GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint)
205 : : {
206 : 0 : sal_Int32 nRet = -1;
207 [ # # ]: 0 : if ( SeekRow(_nRow) )
208 : : {
209 : : CellController* pController = GetController(
210 : 0 : _nRow, GetColumnId( sal::static_int_cast< sal_uInt16 >(_nColumnPos) ) );
211 [ # # ]: 0 : if ( pController )
212 : 0 : nRet = pController->GetWindow().GetIndexForPoint(_rPoint);
213 : : }
214 : 0 : return nRet;
215 : : }
216 : : // -----------------------------------------------------------------------------
217 : : // -----------------------------------------------------------------------------
218 : : } // namespace svt
219 : : // -----------------------------------------------------------------------------
220 : :
221 : :
222 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|