1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_accessibility.hxx"
30 
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>
37 
38 //........................................................................
39 namespace accessibility
40 {
41 //........................................................................
42 
43 	// class TLBSolarGuard ---------------------------------------------------------
44 
45 	/** Aquire the solar mutex. */
46 	class TLBSolarGuard : public ::vos::OGuard
47 	{
48 	public:
49     	inline TLBSolarGuard() : ::vos::OGuard( Application::GetSolarMutex() ) {}
50 	};
51 
52 	// class AccessibleTabListBox -----------------------------------------------------
53 
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;
58 
59 	DBG_NAME(AccessibleTabListBox)
60 
61 	// -----------------------------------------------------------------------------
62 	// Ctor() and Dtor()
63 	// -----------------------------------------------------------------------------
64 	AccessibleTabListBox::AccessibleTabListBox( const Reference< XAccessible >& rxParent, SvHeaderTabListBox& rBox )
65         :AccessibleBrowseBox( rxParent, NULL, rBox )
66         ,m_pTabListBox( &rBox )
67 
68 	{
69 		DBG_CTOR( AccessibleTabListBox, NULL );
70 
71         osl_incrementInterlockedCount( &m_refCount );
72         {
73             setCreator( this );
74         }
75         osl_decrementInterlockedCount( &m_refCount );
76 	}
77 
78 	// -----------------------------------------------------------------------------
79 	AccessibleTabListBox::~AccessibleTabListBox()
80 	{
81 		DBG_DTOR( AccessibleTabListBox, NULL );
82 
83 		if ( isAlive() )
84 		{
85 			// increment ref count to prevent double call of Dtor
86         	osl_incrementInterlockedCount( &m_refCount );
87         	dispose();
88 		}
89 	}
90 	// -----------------------------------------------------------------------------
91 	AccessibleBrowseBoxTable* AccessibleTabListBox::createAccessibleTable()
92 	{
93 		return new AccessibleTabListBoxTable( this, *m_pTabListBox );
94 	}
95 
96     // XInterface -----------------------------------------------------------------
97     IMPLEMENT_FORWARD_XINTERFACE2( AccessibleTabListBox, AccessibleBrowseBox, AccessibleTabListBox_Base )
98 
99     // XTypeProvider --------------------------------------------------------------
100     IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleTabListBox, AccessibleBrowseBox, AccessibleTabListBox_Base )
101 
102     // XAccessibleContext ---------------------------------------------------------
103 
104 	sal_Int32 SAL_CALL AccessibleTabListBox::getAccessibleChildCount()
105 	    throw ( uno::RuntimeException )
106 	{
107 	    return 2; // header and table
108 	}
109 
110     // -----------------------------------------------------------------------------
111     Reference< XAccessibleContext > SAL_CALL AccessibleTabListBox::getAccessibleContext() throw ( RuntimeException )
112     {
113         return this;
114     }
115 
116     // -----------------------------------------------------------------------------
117 	Reference< XAccessible > SAL_CALL
118 	AccessibleTabListBox::getAccessibleChild( sal_Int32 nChildIndex )
119 	    throw ( IndexOutOfBoundsException, RuntimeException )
120 	{
121 	    TLBSolarGuard aSolarGuard;
122 	    ::osl::MutexGuard aGuard( getOslMutex() );
123 	    ensureIsAlive();
124 
125 		if ( nChildIndex < 0 || nChildIndex > 1 )
126 			throw IndexOutOfBoundsException();
127 
128         Reference< XAccessible > xRet;
129         if (nChildIndex == 0)
130         {
131             //! so far the actual implementation object only supports column headers
132             xRet = implGetFixedChild( ::svt::BBINDEX_COLUMNHEADERBAR );
133         }
134         else if (nChildIndex == 1)
135             xRet = implGetFixedChild( ::svt::BBINDEX_TABLE );
136 
137 	    if ( !xRet.is() )
138 	        throw RuntimeException();
139 
140 		return xRet;
141 	}
142 
143 //........................................................................
144 }// namespace accessibility
145 //........................................................................
146 
147