15900e8ecSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
35900e8ecSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
45900e8ecSAndrew Rist * or more contributor license agreements. See the NOTICE file
55900e8ecSAndrew Rist * distributed with this work for additional information
65900e8ecSAndrew Rist * regarding copyright ownership. The ASF licenses this file
75900e8ecSAndrew Rist * to you under the Apache License, Version 2.0 (the
85900e8ecSAndrew Rist * "License"); you may not use this file except in compliance
95900e8ecSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
115900e8ecSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
135900e8ecSAndrew Rist * Unless required by applicable law or agreed to in writing,
145900e8ecSAndrew Rist * software distributed under the License is distributed on an
155900e8ecSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165900e8ecSAndrew Rist * KIND, either express or implied. See the License for the
175900e8ecSAndrew Rist * specific language governing permissions and limitations
185900e8ecSAndrew Rist * under the License.
19cdf0e10cSrcweir *
205900e8ecSAndrew Rist *************************************************************/
215900e8ecSAndrew Rist
225900e8ecSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svtools.hxx"
26cdf0e10cSrcweir #include <svtools/brwbox.hxx>
27cdf0e10cSrcweir #include <svtools/AccessibleBrowseBoxObjType.hxx>
28cdf0e10cSrcweir #include <tools/debug.hxx>
29cdf0e10cSrcweir #include <tools/multisel.hxx>
30cdf0e10cSrcweir #include "datwin.hxx"
31cdf0e10cSrcweir #include "brwimpl.hxx"
32cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
33cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp>
34cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
35cdf0e10cSrcweir
36cdf0e10cSrcweir // Accessibility ==============================================================
37cdf0e10cSrcweir
38cdf0e10cSrcweir using ::rtl::OUString;
39cdf0e10cSrcweir using namespace ::com::sun::star::uno;
40cdf0e10cSrcweir using ::com::sun::star::accessibility::XAccessible;
41cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
42cdf0e10cSrcweir
43cdf0e10cSrcweir // ============================================================================
44cdf0e10cSrcweir namespace svt
45cdf0e10cSrcweir {
46cdf0e10cSrcweir using namespace ::com::sun::star::lang;
47cdf0e10cSrcweir using namespace utl;
48cdf0e10cSrcweir
getHeaderCell(BrowseBoxImpl::THeaderCellMap & _raHeaderCells,sal_Int32 _nPos,AccessibleBrowseBoxObjType _eType,const Reference<XAccessible> & _rParent,BrowseBox & _rBrowseBox,IAccessibleFactory & rFactory)49cdf0e10cSrcweir Reference< XAccessible > getHeaderCell( BrowseBoxImpl::THeaderCellMap& _raHeaderCells,
50cdf0e10cSrcweir sal_Int32 _nPos,
51cdf0e10cSrcweir AccessibleBrowseBoxObjType _eType,
52cdf0e10cSrcweir const Reference< XAccessible >& _rParent,
53cdf0e10cSrcweir BrowseBox& _rBrowseBox,
54cdf0e10cSrcweir IAccessibleFactory& rFactory
55cdf0e10cSrcweir )
56cdf0e10cSrcweir {
57cdf0e10cSrcweir Reference< XAccessible > xRet;
58cdf0e10cSrcweir BrowseBoxImpl::THeaderCellMap::iterator aFind = _raHeaderCells.find( _nPos );
59cdf0e10cSrcweir if ( aFind == _raHeaderCells.end() )
60cdf0e10cSrcweir {
61cdf0e10cSrcweir Reference< XAccessible > xAccessible = rFactory.createAccessibleBrowseBoxHeaderCell(
62cdf0e10cSrcweir _nPos,
63cdf0e10cSrcweir _rParent,
64cdf0e10cSrcweir _rBrowseBox,
65cdf0e10cSrcweir NULL,
66cdf0e10cSrcweir _eType
67cdf0e10cSrcweir );
68cdf0e10cSrcweir aFind = _raHeaderCells.insert( BrowseBoxImpl::THeaderCellMap::value_type( _nPos, xAccessible ) ).first;
69cdf0e10cSrcweir }
70cdf0e10cSrcweir if ( aFind != _raHeaderCells.end() )
71cdf0e10cSrcweir xRet = aFind->second;
72cdf0e10cSrcweir return xRet;
73cdf0e10cSrcweir }
74cdf0e10cSrcweir
75cdf0e10cSrcweir // ============================================================================
76cdf0e10cSrcweir // ----------------------------------------------------------------------------
getAccessibleHeaderBar(AccessibleBrowseBoxObjType _eObjType)77cdf0e10cSrcweir Reference< XAccessible > BrowseBoxImpl::getAccessibleHeaderBar( AccessibleBrowseBoxObjType _eObjType )
78cdf0e10cSrcweir {
79cdf0e10cSrcweir if ( m_pAccessible && m_pAccessible->isAlive() )
80cdf0e10cSrcweir return m_pAccessible->getHeaderBar( _eObjType );
81cdf0e10cSrcweir return NULL;
82cdf0e10cSrcweir }
83cdf0e10cSrcweir
84cdf0e10cSrcweir // ----------------------------------------------------------------------------
getAccessibleTable()85cdf0e10cSrcweir Reference< XAccessible > BrowseBoxImpl::getAccessibleTable( )
86cdf0e10cSrcweir {
87cdf0e10cSrcweir if ( m_pAccessible && m_pAccessible->isAlive() )
88cdf0e10cSrcweir return m_pAccessible->getTable( );
89cdf0e10cSrcweir return NULL;
90cdf0e10cSrcweir }
91cdf0e10cSrcweir }
92cdf0e10cSrcweir
93cdf0e10cSrcweir // ============================================================================
94cdf0e10cSrcweir
CreateAccessible()95cdf0e10cSrcweir Reference< XAccessible > BrowseBox::CreateAccessible()
96cdf0e10cSrcweir {
97cdf0e10cSrcweir Window* pParent = GetAccessibleParentWindow();
98cdf0e10cSrcweir DBG_ASSERT( pParent, "BrowseBox::CreateAccessible - parent not found" );
99cdf0e10cSrcweir
100cdf0e10cSrcweir if( pParent && !m_pImpl->m_pAccessible)
101cdf0e10cSrcweir {
102cdf0e10cSrcweir Reference< XAccessible > xAccParent = pParent->GetAccessible();
103cdf0e10cSrcweir if( xAccParent.is() )
104cdf0e10cSrcweir {
105cdf0e10cSrcweir m_pImpl->m_pAccessible = getAccessibleFactory().createAccessibleBrowseBox(
106cdf0e10cSrcweir xAccParent, *this
107cdf0e10cSrcweir );
108cdf0e10cSrcweir }
109cdf0e10cSrcweir }
110cdf0e10cSrcweir
111cdf0e10cSrcweir Reference< XAccessible > xAccessible;
112cdf0e10cSrcweir if ( m_pImpl->m_pAccessible )
113cdf0e10cSrcweir xAccessible = m_pImpl->m_pAccessible->getMyself();
114cdf0e10cSrcweir
115cdf0e10cSrcweir return xAccessible;
116cdf0e10cSrcweir }
117cdf0e10cSrcweir // -----------------------------------------------------------------------------
118cdf0e10cSrcweir
119cdf0e10cSrcweir // Children -------------------------------------------------------------------
120cdf0e10cSrcweir
CreateAccessibleCell(sal_Int32 _nRow,sal_uInt16 _nColumnPos)121cdf0e10cSrcweir Reference< XAccessible > BrowseBox::CreateAccessibleCell( sal_Int32 _nRow, sal_uInt16 _nColumnPos )
122cdf0e10cSrcweir {
123cdf0e10cSrcweir // BBINDEX_TABLE must be the table
124cdf0e10cSrcweir OSL_ENSURE(m_pImpl->m_pAccessible,"Invalid call: Accessible is null");
125cdf0e10cSrcweir
126cdf0e10cSrcweir return m_pImpl->m_aFactoryAccess.getFactory().createAccessibleBrowseBoxTableCell(
127cdf0e10cSrcweir m_pImpl->getAccessibleTable(),
128cdf0e10cSrcweir *this,
129cdf0e10cSrcweir NULL,
130cdf0e10cSrcweir _nRow,
131cdf0e10cSrcweir _nColumnPos,
132cdf0e10cSrcweir OFFSET_DEFAULT
133cdf0e10cSrcweir );
134cdf0e10cSrcweir }
135cdf0e10cSrcweir // -----------------------------------------------------------------------------
136cdf0e10cSrcweir
CreateAccessibleRowHeader(sal_Int32 _nRow)137cdf0e10cSrcweir Reference< XAccessible > BrowseBox::CreateAccessibleRowHeader( sal_Int32 _nRow )
138cdf0e10cSrcweir {
139cdf0e10cSrcweir return svt::getHeaderCell(
140cdf0e10cSrcweir m_pImpl->m_aRowHeaderCellMap,
141cdf0e10cSrcweir _nRow,
142cdf0e10cSrcweir svt::BBTYPE_ROWHEADERCELL,
143cdf0e10cSrcweir m_pImpl->getAccessibleHeaderBar(svt::BBTYPE_ROWHEADERBAR),
144cdf0e10cSrcweir *this,
145cdf0e10cSrcweir m_pImpl->m_aFactoryAccess.getFactory()
146cdf0e10cSrcweir );
147cdf0e10cSrcweir }
148cdf0e10cSrcweir // -----------------------------------------------------------------------------
149cdf0e10cSrcweir
CreateAccessibleColumnHeader(sal_uInt16 _nColumnPos)150cdf0e10cSrcweir Reference< XAccessible > BrowseBox::CreateAccessibleColumnHeader( sal_uInt16 _nColumnPos )
151cdf0e10cSrcweir {
152cdf0e10cSrcweir return svt::getHeaderCell(
153cdf0e10cSrcweir m_pImpl->m_aColHeaderCellMap,
154cdf0e10cSrcweir _nColumnPos,
155cdf0e10cSrcweir svt::BBTYPE_COLUMNHEADERCELL,
156cdf0e10cSrcweir m_pImpl->getAccessibleHeaderBar(svt::BBTYPE_COLUMNHEADERBAR),
157cdf0e10cSrcweir *this,
158cdf0e10cSrcweir m_pImpl->m_aFactoryAccess.getFactory()
159cdf0e10cSrcweir );
160cdf0e10cSrcweir }
161cdf0e10cSrcweir // -----------------------------------------------------------------------------
162cdf0e10cSrcweir
GetAccessibleControlCount() const163cdf0e10cSrcweir sal_Int32 BrowseBox::GetAccessibleControlCount() const
164cdf0e10cSrcweir {
165cdf0e10cSrcweir return 0;
166cdf0e10cSrcweir }
167cdf0e10cSrcweir // -----------------------------------------------------------------------------
168cdf0e10cSrcweir
CreateAccessibleControl(sal_Int32)169cdf0e10cSrcweir Reference< XAccessible > BrowseBox::CreateAccessibleControl( sal_Int32 )
170cdf0e10cSrcweir {
171cdf0e10cSrcweir DBG_ASSERT( sal_False, "BrowseBox::CreateAccessibleControl: to be overwritten!" );
172cdf0e10cSrcweir return NULL;
173cdf0e10cSrcweir }
174cdf0e10cSrcweir // -----------------------------------------------------------------------------
175cdf0e10cSrcweir
176cdf0e10cSrcweir // Conversions ----------------------------------------------------------------
177cdf0e10cSrcweir
ConvertPointToCellAddress(sal_Int32 & rnRow,sal_uInt16 & rnColumnPos,const Point & rPoint)178cdf0e10cSrcweir sal_Bool BrowseBox::ConvertPointToCellAddress(
179cdf0e10cSrcweir sal_Int32& rnRow, sal_uInt16& rnColumnPos, const Point& rPoint )
180cdf0e10cSrcweir {
181cdf0e10cSrcweir //! TODO has to be checked
182cdf0e10cSrcweir rnRow = GetRowAtYPosPixel(rPoint.Y());
183cdf0e10cSrcweir rnColumnPos = GetColumnAtXPosPixel(rPoint.X());
184cdf0e10cSrcweir return rnRow != BROWSER_INVALIDID && rnColumnPos != BROWSER_INVALIDID;
185cdf0e10cSrcweir }
186cdf0e10cSrcweir // -----------------------------------------------------------------------------
187cdf0e10cSrcweir
ConvertPointToRowHeader(sal_Int32 & rnRow,const Point & rPoint)188cdf0e10cSrcweir sal_Bool BrowseBox::ConvertPointToRowHeader( sal_Int32& rnRow, const Point& rPoint )
189cdf0e10cSrcweir {
190cdf0e10cSrcweir rnRow = GetRowAtYPosPixel(rPoint.Y());
191cdf0e10cSrcweir // sal_uInt16 nColumnId = GetColumnAtXPosPixel(rPoint.X());
192cdf0e10cSrcweir return rnRow != BROWSER_INVALIDID;// && nColumnId == 0;
193cdf0e10cSrcweir }
194cdf0e10cSrcweir // -----------------------------------------------------------------------------
195cdf0e10cSrcweir
ConvertPointToColumnHeader(sal_uInt16 & _rnColumnPos,const Point & _rPoint)196cdf0e10cSrcweir sal_Bool BrowseBox::ConvertPointToColumnHeader( sal_uInt16& _rnColumnPos, const Point& _rPoint )
197cdf0e10cSrcweir {
198cdf0e10cSrcweir _rnColumnPos = GetColumnAtXPosPixel(_rPoint.X());
199cdf0e10cSrcweir return _rnColumnPos != BROWSER_INVALIDID;
200cdf0e10cSrcweir }
201cdf0e10cSrcweir // -----------------------------------------------------------------------------
202cdf0e10cSrcweir
ConvertPointToControlIndex(sal_Int32 & _rnIndex,const Point & _rPoint)203cdf0e10cSrcweir sal_Bool BrowseBox::ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint )
204cdf0e10cSrcweir {
205cdf0e10cSrcweir //! TODO has to be checked
206cdf0e10cSrcweir sal_Int32 nRow = 0;
207cdf0e10cSrcweir sal_uInt16 nColumn = 0;
208cdf0e10cSrcweir sal_Bool bRet = ConvertPointToCellAddress(nRow,nColumn,_rPoint);
209cdf0e10cSrcweir if ( bRet )
210cdf0e10cSrcweir _rnIndex = nRow * ColCount() + nColumn;
211cdf0e10cSrcweir
212cdf0e10cSrcweir return bRet;
213cdf0e10cSrcweir }
214cdf0e10cSrcweir // -----------------------------------------------------------------------------
215cdf0e10cSrcweir
216cdf0e10cSrcweir // Object data and state ------------------------------------------------------
217cdf0e10cSrcweir
GetAccessibleObjectName(::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition) const218*2bfcd321SSteve Yin OUString BrowseBox::GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition) const
219cdf0e10cSrcweir {
220cdf0e10cSrcweir OUString aRetText;
221cdf0e10cSrcweir switch( eObjType )
222cdf0e10cSrcweir {
223cdf0e10cSrcweir case ::svt::BBTYPE_BROWSEBOX:
224cdf0e10cSrcweir aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "BrowseBox" ) );
225cdf0e10cSrcweir break;
226cdf0e10cSrcweir case ::svt::BBTYPE_TABLE:
227cdf0e10cSrcweir aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "Table" ) );
228cdf0e10cSrcweir break;
229cdf0e10cSrcweir case ::svt::BBTYPE_ROWHEADERBAR:
230cdf0e10cSrcweir aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "RowHeaderBar" ) );
231cdf0e10cSrcweir break;
232cdf0e10cSrcweir case ::svt::BBTYPE_COLUMNHEADERBAR:
233cdf0e10cSrcweir aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "ColumnHeaderBar" ) );
234cdf0e10cSrcweir break;
235cdf0e10cSrcweir case ::svt::BBTYPE_TABLECELL:
236*2bfcd321SSteve Yin if( ColCount() !=0 && GetRowCount()!=0)
237*2bfcd321SSteve Yin {
238*2bfcd321SSteve Yin
239*2bfcd321SSteve Yin sal_Int32 columnId = _nPosition % ColCount() +1;
240*2bfcd321SSteve Yin aRetText = OUString( GetColumnDescription( sal_Int16( columnId ) ) );
241*2bfcd321SSteve Yin sal_Int32 rowId = _nPosition / GetRowCount() + 1;
242*2bfcd321SSteve Yin aRetText += OUString::valueOf(rowId);
243*2bfcd321SSteve Yin }
244*2bfcd321SSteve Yin else
245cdf0e10cSrcweir aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "TableCell" ) );
246cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
247cdf0e10cSrcweir aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( " [" ) );
248cdf0e10cSrcweir aRetText += OUString::valueOf(sal_Int32(GetCurRow()));
249cdf0e10cSrcweir aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( "," ) );
250cdf0e10cSrcweir aRetText += OUString::valueOf(sal_Int32(GetCurColumnId()));
251cdf0e10cSrcweir aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( "]" ) );
252cdf0e10cSrcweir #endif
253cdf0e10cSrcweir break;
254cdf0e10cSrcweir case ::svt::BBTYPE_ROWHEADERCELL:
255*2bfcd321SSteve Yin {
256*2bfcd321SSteve Yin sal_Int32 rowId = _nPosition + 1;
257*2bfcd321SSteve Yin aRetText = OUString::valueOf( rowId );
258*2bfcd321SSteve Yin }
259cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
260cdf0e10cSrcweir aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( " [" ) );
261cdf0e10cSrcweir aRetText += OUString::valueOf(sal_Int32(GetCurRow()));
262cdf0e10cSrcweir aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( "," ) );
263cdf0e10cSrcweir aRetText += OUString::valueOf(sal_Int32(GetCurColumnId()));
264cdf0e10cSrcweir aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( "]" ) );
265cdf0e10cSrcweir #endif
266cdf0e10cSrcweir break;
267cdf0e10cSrcweir case ::svt::BBTYPE_COLUMNHEADERCELL:
268*2bfcd321SSteve Yin aRetText = OUString( GetColumnDescription( sal_Int16( _nPosition ) ) );
269cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
270cdf0e10cSrcweir aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( " [" ) );
271cdf0e10cSrcweir aRetText += OUString::valueOf(sal_Int32(GetCurRow()));
272cdf0e10cSrcweir aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( "," ) );
273cdf0e10cSrcweir aRetText += OUString::valueOf(sal_Int32(GetCurColumnId()));
274cdf0e10cSrcweir aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( "]" ) );
275cdf0e10cSrcweir #endif
276cdf0e10cSrcweir break;
277cdf0e10cSrcweir default:
278cdf0e10cSrcweir OSL_ENSURE(0,"BrowseBox::GetAccessibleName: invalid enum!");
279cdf0e10cSrcweir }
280cdf0e10cSrcweir return aRetText;
281cdf0e10cSrcweir }
282cdf0e10cSrcweir // -----------------------------------------------------------------------------
283cdf0e10cSrcweir
GetAccessibleObjectDescription(::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32) const284cdf0e10cSrcweir OUString BrowseBox::GetAccessibleObjectDescription( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 ) const
285cdf0e10cSrcweir {
286cdf0e10cSrcweir OUString aRetText;
287cdf0e10cSrcweir switch( eObjType )
288cdf0e10cSrcweir {
289cdf0e10cSrcweir case ::svt::BBTYPE_BROWSEBOX:
290cdf0e10cSrcweir aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "BrowseBox description" ) );
291cdf0e10cSrcweir break;
292cdf0e10cSrcweir case ::svt::BBTYPE_TABLE:
293cdf0e10cSrcweir // aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "TABLE description" ) );
294cdf0e10cSrcweir break;
295cdf0e10cSrcweir case ::svt::BBTYPE_ROWHEADERBAR:
296cdf0e10cSrcweir // aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "ROWHEADERBAR description" ) );
297cdf0e10cSrcweir break;
298cdf0e10cSrcweir case ::svt::BBTYPE_COLUMNHEADERBAR:
299cdf0e10cSrcweir // aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "COLUMNHEADERBAR description" ) );
300cdf0e10cSrcweir break;
301cdf0e10cSrcweir case ::svt::BBTYPE_TABLECELL:
302cdf0e10cSrcweir // aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "TABLECELL description" ) );
303cdf0e10cSrcweir break;
304cdf0e10cSrcweir case ::svt::BBTYPE_ROWHEADERCELL:
305cdf0e10cSrcweir // aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "ROWHEADERCELL description" ) );
306cdf0e10cSrcweir break;
307cdf0e10cSrcweir case ::svt::BBTYPE_COLUMNHEADERCELL:
308cdf0e10cSrcweir // aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "COLUMNHEADERCELL description" ) );
309cdf0e10cSrcweir break;
310cdf0e10cSrcweir case ::svt::BBTYPE_CHECKBOXCELL:
311cdf0e10cSrcweir break;
312cdf0e10cSrcweir }
313cdf0e10cSrcweir return aRetText;
314cdf0e10cSrcweir }
315cdf0e10cSrcweir // -----------------------------------------------------------------------------
316cdf0e10cSrcweir
GetRowDescription(sal_Int32) const317cdf0e10cSrcweir OUString BrowseBox::GetRowDescription( sal_Int32 ) const
318cdf0e10cSrcweir {
319cdf0e10cSrcweir return OUString();
320cdf0e10cSrcweir }
321cdf0e10cSrcweir // -----------------------------------------------------------------------------
322cdf0e10cSrcweir
GetColumnDescription(sal_uInt16 _nColumn) const323cdf0e10cSrcweir OUString BrowseBox::GetColumnDescription( sal_uInt16 _nColumn ) const
324cdf0e10cSrcweir {
325cdf0e10cSrcweir return OUString( GetColumnTitle( GetColumnId( _nColumn ) ) );
326cdf0e10cSrcweir }
327cdf0e10cSrcweir
328cdf0e10cSrcweir // -----------------------------------------------------------------------------
329cdf0e10cSrcweir
FillAccessibleStateSet(::utl::AccessibleStateSetHelper & rStateSet,::svt::AccessibleBrowseBoxObjType eObjType) const330cdf0e10cSrcweir void BrowseBox::FillAccessibleStateSet(
331cdf0e10cSrcweir ::utl::AccessibleStateSetHelper& rStateSet,
332cdf0e10cSrcweir ::svt::AccessibleBrowseBoxObjType eObjType ) const
333cdf0e10cSrcweir {
334cdf0e10cSrcweir switch( eObjType )
335cdf0e10cSrcweir {
336cdf0e10cSrcweir case ::svt::BBTYPE_BROWSEBOX:
337cdf0e10cSrcweir case ::svt::BBTYPE_TABLE:
338cdf0e10cSrcweir
339cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::FOCUSABLE );
340cdf0e10cSrcweir if ( HasFocus() )
341cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::FOCUSED );
342cdf0e10cSrcweir if ( IsActive() )
343cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::ACTIVE );
344cdf0e10cSrcweir if ( GetUpdateMode() )
345cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::EDITABLE );
346cdf0e10cSrcweir if ( IsEnabled() )
347cdf0e10cSrcweir {
348cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::ENABLED );
349cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::SENSITIVE );
350cdf0e10cSrcweir }
351cdf0e10cSrcweir if ( IsReallyVisible() )
352cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::VISIBLE );
353cdf0e10cSrcweir if ( eObjType == ::svt::BBTYPE_TABLE )
354cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS );
355cdf0e10cSrcweir
356cdf0e10cSrcweir break;
357cdf0e10cSrcweir case ::svt::BBTYPE_ROWHEADERBAR:
358cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::FOCUSABLE );
359cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::VISIBLE );
360cdf0e10cSrcweir if ( GetSelectRowCount() )
361cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::FOCUSED );
362cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS );
363cdf0e10cSrcweir break;
364cdf0e10cSrcweir case ::svt::BBTYPE_COLUMNHEADERBAR:
365cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::FOCUSABLE );
366cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::VISIBLE );
367cdf0e10cSrcweir if ( GetSelectColumnCount() )
368cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::FOCUSED );
369cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS );
370cdf0e10cSrcweir break;
371cdf0e10cSrcweir case ::svt::BBTYPE_TABLECELL:
372cdf0e10cSrcweir {
373cdf0e10cSrcweir sal_Int32 nRow = GetCurRow();
374cdf0e10cSrcweir sal_uInt16 nColumn = GetCurColumnId();
375cdf0e10cSrcweir if ( IsFieldVisible(nRow,nColumn) )
376cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::VISIBLE );
377cdf0e10cSrcweir if ( !IsFrozen( nColumn ) )
378cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::FOCUSABLE );
379cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::TRANSIENT );
380cdf0e10cSrcweir }
381cdf0e10cSrcweir break;
382cdf0e10cSrcweir case ::svt::BBTYPE_ROWHEADERCELL:
383cdf0e10cSrcweir case ::svt::BBTYPE_COLUMNHEADERCELL:
384cdf0e10cSrcweir case ::svt::BBTYPE_CHECKBOXCELL:
385cdf0e10cSrcweir OSL_ENSURE(0,"Illegal call here!");
386cdf0e10cSrcweir break;
387cdf0e10cSrcweir }
388cdf0e10cSrcweir }
389cdf0e10cSrcweir // -----------------------------------------------------------------------
FillAccessibleStateSetForCell(::utl::AccessibleStateSetHelper & _rStateSet,sal_Int32 _nRow,sal_uInt16 _nColumnPos) const390cdf0e10cSrcweir void BrowseBox::FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper& _rStateSet,
391cdf0e10cSrcweir sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const
392cdf0e10cSrcweir {
393cdf0e10cSrcweir //! TODO check if the state is valid for table cells
394cdf0e10cSrcweir if ( IsCellVisible( _nRow, _nColumnPos ) )
395cdf0e10cSrcweir _rStateSet.AddState( AccessibleStateType::VISIBLE );
396cdf0e10cSrcweir if ( GetCurrRow() == _nRow && GetCurrColumn() == _nColumnPos )
397cdf0e10cSrcweir _rStateSet.AddState( AccessibleStateType::FOCUSED );
398cdf0e10cSrcweir else // only transient when column is not focused
399cdf0e10cSrcweir _rStateSet.AddState( AccessibleStateType::TRANSIENT );
400cdf0e10cSrcweir }
401cdf0e10cSrcweir // -----------------------------------------------------------------------------
402cdf0e10cSrcweir
GrabTableFocus()403cdf0e10cSrcweir void BrowseBox::GrabTableFocus()
404cdf0e10cSrcweir {
405cdf0e10cSrcweir GrabFocus();
406cdf0e10cSrcweir }
407cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetCellText(long,sal_uInt16) const408cdf0e10cSrcweir String BrowseBox::GetCellText(long, sal_uInt16 ) const
409cdf0e10cSrcweir {
410cdf0e10cSrcweir DBG_ASSERT(0,"This method has to be implemented by the derived classes! BUG!!");
411cdf0e10cSrcweir return String();
412cdf0e10cSrcweir }
413cdf0e10cSrcweir
414cdf0e10cSrcweir // -----------------------------------------------------------------------------
commitHeaderBarEvent(sal_Int16 nEventId,const Any & rNewValue,const Any & rOldValue,sal_Bool _bColumnHeaderBar)415cdf0e10cSrcweir void BrowseBox::commitHeaderBarEvent(sal_Int16 nEventId,
416cdf0e10cSrcweir const Any& rNewValue, const Any& rOldValue, sal_Bool _bColumnHeaderBar )
417cdf0e10cSrcweir {
418cdf0e10cSrcweir if ( isAccessibleAlive() )
419cdf0e10cSrcweir m_pImpl->m_pAccessible->commitHeaderBarEvent( nEventId,
420cdf0e10cSrcweir rNewValue, rOldValue, _bColumnHeaderBar );
421cdf0e10cSrcweir }
422cdf0e10cSrcweir
423cdf0e10cSrcweir // -----------------------------------------------------------------------------
commitTableEvent(sal_Int16 _nEventId,const Any & _rNewValue,const Any & _rOldValue)424cdf0e10cSrcweir void BrowseBox::commitTableEvent( sal_Int16 _nEventId, const Any& _rNewValue, const Any& _rOldValue )
425cdf0e10cSrcweir {
426cdf0e10cSrcweir if ( isAccessibleAlive() )
427cdf0e10cSrcweir m_pImpl->m_pAccessible->commitTableEvent( _nEventId, _rNewValue, _rOldValue );
428cdf0e10cSrcweir }
429cdf0e10cSrcweir // -----------------------------------------------------------------------------
commitBrowseBoxEvent(sal_Int16 _nEventId,const Any & _rNewValue,const Any & _rOldValue)430cdf0e10cSrcweir void BrowseBox::commitBrowseBoxEvent( sal_Int16 _nEventId, const Any& _rNewValue, const Any& _rOldValue )
431cdf0e10cSrcweir {
432cdf0e10cSrcweir if ( isAccessibleAlive() )
433cdf0e10cSrcweir m_pImpl->m_pAccessible->commitEvent( _nEventId, _rNewValue, _rOldValue);
434cdf0e10cSrcweir }
435cdf0e10cSrcweir
436cdf0e10cSrcweir // -----------------------------------------------------------------------------
getAccessibleFactory()437cdf0e10cSrcweir ::svt::IAccessibleFactory& BrowseBox::getAccessibleFactory()
438cdf0e10cSrcweir {
439cdf0e10cSrcweir return m_pImpl->m_aFactoryAccess.getFactory();
440cdf0e10cSrcweir }
441cdf0e10cSrcweir
442cdf0e10cSrcweir // -----------------------------------------------------------------------------
isAccessibleAlive() const443cdf0e10cSrcweir sal_Bool BrowseBox::isAccessibleAlive( ) const
444cdf0e10cSrcweir {
445cdf0e10cSrcweir return ( NULL != m_pImpl->m_pAccessible ) && m_pImpl->m_pAccessible->isAlive();
446cdf0e10cSrcweir }
447cdf0e10cSrcweir // -----------------------------------------------------------------------------
448cdf0e10cSrcweir // IAccessibleTableProvider
449cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetCurrRow() const450cdf0e10cSrcweir sal_Int32 BrowseBox::GetCurrRow() const
451cdf0e10cSrcweir {
452cdf0e10cSrcweir return GetCurRow();
453cdf0e10cSrcweir }
454cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetCurrColumn() const455cdf0e10cSrcweir sal_uInt16 BrowseBox::GetCurrColumn() const
456cdf0e10cSrcweir {
457cdf0e10cSrcweir return GetColumnPos( GetCurColumnId() );
458cdf0e10cSrcweir }
459cdf0e10cSrcweir // -----------------------------------------------------------------------------
HasRowHeader() const460cdf0e10cSrcweir sal_Bool BrowseBox::HasRowHeader() const
461cdf0e10cSrcweir {
462cdf0e10cSrcweir return ( GetColumnId( 0 ) == 0 ); // HandleColumn == RowHeader
463cdf0e10cSrcweir }
464cdf0e10cSrcweir // -----------------------------------------------------------------------------
IsCellFocusable() const465cdf0e10cSrcweir sal_Bool BrowseBox::IsCellFocusable() const
466cdf0e10cSrcweir {
467cdf0e10cSrcweir return sal_True;
468cdf0e10cSrcweir }
469cdf0e10cSrcweir // -----------------------------------------------------------------------------
GoToCell(sal_Int32 _nRow,sal_uInt16 _nColumn)470cdf0e10cSrcweir sal_Bool BrowseBox::GoToCell( sal_Int32 _nRow, sal_uInt16 _nColumn )
471cdf0e10cSrcweir {
472cdf0e10cSrcweir return GoToRowColumnId( _nRow, GetColumnId( _nColumn ) );
473cdf0e10cSrcweir }
474cdf0e10cSrcweir // -----------------------------------------------------------------------------
SelectColumn(sal_uInt16 _nColumn,sal_Bool _bSelect)475cdf0e10cSrcweir void BrowseBox::SelectColumn( sal_uInt16 _nColumn, sal_Bool _bSelect )
476cdf0e10cSrcweir {
477cdf0e10cSrcweir SelectColumnPos( _nColumn, _bSelect );
478cdf0e10cSrcweir }
479cdf0e10cSrcweir // -----------------------------------------------------------------------------
IsColumnSelected(long _nColumn) const480cdf0e10cSrcweir sal_Bool BrowseBox::IsColumnSelected( long _nColumn ) const
481cdf0e10cSrcweir {
482cdf0e10cSrcweir return ( pColSel && (0 <= _nColumn) && (_nColumn <= 0xFFF) ) ?
483cdf0e10cSrcweir pColSel->IsSelected( static_cast< sal_uInt16 >( _nColumn ) ) :
484cdf0e10cSrcweir sal_False;
485cdf0e10cSrcweir }
486cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetSelectedRowCount() const487cdf0e10cSrcweir sal_Int32 BrowseBox::GetSelectedRowCount() const
488cdf0e10cSrcweir {
489cdf0e10cSrcweir return GetSelectRowCount();
490cdf0e10cSrcweir }
491cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetSelectedColumnCount() const492cdf0e10cSrcweir sal_Int32 BrowseBox::GetSelectedColumnCount() const
493cdf0e10cSrcweir {
494cdf0e10cSrcweir const MultiSelection* pColumnSel = GetColumnSelection();
495cdf0e10cSrcweir return pColumnSel ? pColumnSel->GetSelectCount() : 0;
496cdf0e10cSrcweir }
497cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetAllSelectedRows(::com::sun::star::uno::Sequence<sal_Int32> & _rRows) const498cdf0e10cSrcweir void BrowseBox::GetAllSelectedRows( ::com::sun::star::uno::Sequence< sal_Int32 >& _rRows ) const
499cdf0e10cSrcweir {
500cdf0e10cSrcweir sal_Int32 nCount = GetSelectRowCount();
501cdf0e10cSrcweir if( nCount )
502cdf0e10cSrcweir {
503cdf0e10cSrcweir _rRows.realloc( nCount );
504cdf0e10cSrcweir _rRows[ 0 ] = const_cast< BrowseBox* >( this )->FirstSelectedRow();
505cdf0e10cSrcweir for( sal_Int32 nIndex = 1; nIndex < nCount; ++nIndex )
506cdf0e10cSrcweir _rRows[ nIndex ] = const_cast< BrowseBox* >( this )->NextSelectedRow();
507cdf0e10cSrcweir DBG_ASSERT( const_cast< BrowseBox* >( this )->NextSelectedRow() == BROWSER_ENDOFSELECTION,
508cdf0e10cSrcweir "BrowseBox::GetAllSelectedRows - too many selected rows found" );
509cdf0e10cSrcweir }
510cdf0e10cSrcweir }
511cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetAllSelectedColumns(::com::sun::star::uno::Sequence<sal_Int32> & _rColumns) const512cdf0e10cSrcweir void BrowseBox::GetAllSelectedColumns( ::com::sun::star::uno::Sequence< sal_Int32 >& _rColumns ) const
513cdf0e10cSrcweir {
514cdf0e10cSrcweir const MultiSelection* pColumnSel = GetColumnSelection();
515cdf0e10cSrcweir sal_Int32 nCount = GetSelectedColumnCount();
516cdf0e10cSrcweir if( pColumnSel && nCount )
517cdf0e10cSrcweir {
518cdf0e10cSrcweir _rColumns.realloc( nCount );
519cdf0e10cSrcweir
520cdf0e10cSrcweir sal_Int32 nIndex = 0;
521cdf0e10cSrcweir sal_uInt32 nRangeCount = pColumnSel->GetRangeCount();
522cdf0e10cSrcweir for( sal_uInt32 nRange = 0; nRange < nRangeCount; ++nRange )
523cdf0e10cSrcweir {
524cdf0e10cSrcweir const Range& rRange = pColumnSel->GetRange( nRange );
525cdf0e10cSrcweir // loop has to include aRange.Max()
526cdf0e10cSrcweir for( sal_Int32 nCol = rRange.Min(); nCol <= rRange.Max(); ++nCol )
527cdf0e10cSrcweir {
528cdf0e10cSrcweir DBG_ASSERT( nIndex < nCount,
529cdf0e10cSrcweir "GetAllSelectedColumns - range overflow" );
530cdf0e10cSrcweir _rColumns[ nIndex ] = nCol;
531cdf0e10cSrcweir ++nIndex;
532cdf0e10cSrcweir }
533cdf0e10cSrcweir }
534cdf0e10cSrcweir }
535cdf0e10cSrcweir }
536cdf0e10cSrcweir // -----------------------------------------------------------------------------
IsCellVisible(sal_Int32 _nRow,sal_uInt16 _nColumnPos) const537cdf0e10cSrcweir sal_Bool BrowseBox::IsCellVisible( sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const
538cdf0e10cSrcweir {
539cdf0e10cSrcweir return IsFieldVisible( _nRow, GetColumnId( _nColumnPos ) );
540cdf0e10cSrcweir }
541cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetAccessibleCellText(long _nRow,sal_uInt16 _nColPos) const542cdf0e10cSrcweir String BrowseBox::GetAccessibleCellText(long _nRow, sal_uInt16 _nColPos) const
543cdf0e10cSrcweir {
544cdf0e10cSrcweir return GetCellText( _nRow, GetColumnId( _nColPos ) );
545cdf0e10cSrcweir }
546cdf0e10cSrcweir
547cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetGlyphBoundRects(const Point & rOrigin,const String & rStr,int nIndex,int nLen,int nBase,MetricVector & rVector)548cdf0e10cSrcweir sal_Bool BrowseBox::GetGlyphBoundRects( const Point& rOrigin, const String& rStr, int nIndex, int nLen, int nBase, MetricVector& rVector )
549cdf0e10cSrcweir {
550cdf0e10cSrcweir return Control::GetGlyphBoundRects( rOrigin, rStr, nIndex, nLen, nBase, rVector );
551cdf0e10cSrcweir }
552cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetWindowExtentsRelative(Window * pRelativeWindow) const553cdf0e10cSrcweir Rectangle BrowseBox::GetWindowExtentsRelative( Window *pRelativeWindow ) const
554cdf0e10cSrcweir {
555cdf0e10cSrcweir return Control::GetWindowExtentsRelative( pRelativeWindow );
556cdf0e10cSrcweir }
557cdf0e10cSrcweir // -----------------------------------------------------------------------------
GrabFocus()558cdf0e10cSrcweir void BrowseBox::GrabFocus()
559cdf0e10cSrcweir {
560cdf0e10cSrcweir Control::GrabFocus();
561cdf0e10cSrcweir }
562cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetAccessible(sal_Bool bCreate)563cdf0e10cSrcweir Reference< XAccessible > BrowseBox::GetAccessible( sal_Bool bCreate )
564cdf0e10cSrcweir {
565cdf0e10cSrcweir return Control::GetAccessible( bCreate );
566cdf0e10cSrcweir }
567cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetAccessibleParentWindow() const568cdf0e10cSrcweir Window* BrowseBox::GetAccessibleParentWindow() const
569cdf0e10cSrcweir {
570cdf0e10cSrcweir return Control::GetAccessibleParentWindow();
571cdf0e10cSrcweir }
572cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetWindowInstance()573cdf0e10cSrcweir Window* BrowseBox::GetWindowInstance()
574cdf0e10cSrcweir {
575cdf0e10cSrcweir return this;
576cdf0e10cSrcweir }
577