merged tag ooo/DEV300_m102
[LibreOffice.git] / accessibility / source / extended / accessibletablistbox.cxx
blobaed68e55e48265659423aca5e1b9ccf629aaecd0
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_accessibility.hxx"
31 #ifndef ACCESSIBILITY_EXT_ACCESSIBLETABLISTBOX_HXX_
32 #include "accessibility/extended/accessibletablistbox.hxx"
33 #endif
34 #include "accessibility/extended/accessibletablistboxtable.hxx"
35 #include <svtools/svtabbx.hxx>
36 #include <comphelper/sequence.hxx>
38 //........................................................................
39 namespace accessibility
41 //........................................................................
43 // class TLBSolarGuard ---------------------------------------------------------
45 /** Aquire the solar mutex. */
46 class TLBSolarGuard : public ::vos::OGuard
48 public:
49 inline TLBSolarGuard() : ::vos::OGuard( Application::GetSolarMutex() ) {}
52 // class AccessibleTabListBox -----------------------------------------------------
54 using namespace ::com::sun::star::accessibility;
55 using namespace ::com::sun::star::uno;
56 using namespace ::com::sun::star::lang;
57 using namespace ::com::sun::star;
59 DBG_NAME(AccessibleTabListBox)
61 // -----------------------------------------------------------------------------
62 // Ctor() and Dtor()
63 // -----------------------------------------------------------------------------
64 AccessibleTabListBox::AccessibleTabListBox( const Reference< XAccessible >& rxParent, SvHeaderTabListBox& rBox )
65 :AccessibleBrowseBox( rxParent, NULL, rBox )
66 ,m_pTabListBox( &rBox )
69 DBG_CTOR( AccessibleTabListBox, NULL );
71 osl_incrementInterlockedCount( &m_refCount );
73 setCreator( this );
75 osl_decrementInterlockedCount( &m_refCount );
78 // -----------------------------------------------------------------------------
79 AccessibleTabListBox::~AccessibleTabListBox()
81 DBG_DTOR( AccessibleTabListBox, NULL );
83 if ( isAlive() )
85 // increment ref count to prevent double call of Dtor
86 osl_incrementInterlockedCount( &m_refCount );
87 dispose();
90 // -----------------------------------------------------------------------------
91 AccessibleBrowseBoxTable* AccessibleTabListBox::createAccessibleTable()
93 return new AccessibleTabListBoxTable( this, *m_pTabListBox );
96 // XInterface -----------------------------------------------------------------
97 IMPLEMENT_FORWARD_XINTERFACE2( AccessibleTabListBox, AccessibleBrowseBox, AccessibleTabListBox_Base )
99 // XTypeProvider --------------------------------------------------------------
100 IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleTabListBox, AccessibleBrowseBox, AccessibleTabListBox_Base )
102 // XAccessibleContext ---------------------------------------------------------
104 sal_Int32 SAL_CALL AccessibleTabListBox::getAccessibleChildCount()
105 throw ( uno::RuntimeException )
107 return 2; // header and table
110 // -----------------------------------------------------------------------------
111 Reference< XAccessibleContext > SAL_CALL AccessibleTabListBox::getAccessibleContext() throw ( RuntimeException )
113 return this;
116 // -----------------------------------------------------------------------------
117 Reference< XAccessible > SAL_CALL
118 AccessibleTabListBox::getAccessibleChild( sal_Int32 nChildIndex )
119 throw ( IndexOutOfBoundsException, RuntimeException )
121 TLBSolarGuard aSolarGuard;
122 ::osl::MutexGuard aGuard( getOslMutex() );
123 ensureIsAlive();
125 if ( nChildIndex < 0 || nChildIndex > 1 )
126 throw IndexOutOfBoundsException();
128 Reference< XAccessible > xRet;
129 if (nChildIndex == 0)
131 //! so far the actual implementation object only supports column headers
132 xRet = implGetFixedChild( ::svt::BBINDEX_COLUMNHEADERBAR );
134 else if (nChildIndex == 1)
135 xRet = implGetFixedChild( ::svt::BBINDEX_TABLE );
137 if ( !xRet.is() )
138 throw RuntimeException();
140 return xRet;
143 //........................................................................
144 }// namespace accessibility
145 //........................................................................