1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_accessibility.hxx"
26 
27 #ifndef ACCESSIBILITY_EXT_ACCESSIBLETABLISTBOX_HXX_
28 #include "accessibility/extended/accessibletablistbox.hxx"
29 #endif
30 #include "accessibility/extended/accessibletablistboxtable.hxx"
31 #include <svtools/svtabbx.hxx>
32 #include <comphelper/sequence.hxx>
33 
34 //........................................................................
35 namespace accessibility
36 {
37 //........................................................................
38 
39 	// class TLBSolarGuard ---------------------------------------------------------
40 
41 	/** Aquire the solar mutex. */
42 	class TLBSolarGuard : public ::vos::OGuard
43 	{
44 	public:
TLBSolarGuard()45     	inline TLBSolarGuard() : ::vos::OGuard( Application::GetSolarMutex() ) {}
46 	};
47 
48 	// class AccessibleTabListBox -----------------------------------------------------
49 
50 	using namespace ::com::sun::star::accessibility;
51 	using namespace ::com::sun::star::uno;
52 	using namespace ::com::sun::star::lang;
53 	using namespace ::com::sun::star;
54 
DBG_NAME(AccessibleTabListBox)55 	DBG_NAME(AccessibleTabListBox)
56 
57 	// -----------------------------------------------------------------------------
58 	// Ctor() and Dtor()
59 	// -----------------------------------------------------------------------------
60 	AccessibleTabListBox::AccessibleTabListBox( const Reference< XAccessible >& rxParent, SvHeaderTabListBox& rBox )
61         :AccessibleBrowseBox( rxParent, NULL, rBox )
62         ,m_pTabListBox( &rBox )
63 
64 	{
65 		DBG_CTOR( AccessibleTabListBox, NULL );
66 
67         osl_incrementInterlockedCount( &m_refCount );
68         {
69             setCreator( this );
70         }
71         osl_decrementInterlockedCount( &m_refCount );
72 	}
73 
74 	// -----------------------------------------------------------------------------
~AccessibleTabListBox()75 	AccessibleTabListBox::~AccessibleTabListBox()
76 	{
77 		DBG_DTOR( AccessibleTabListBox, NULL );
78 
79 		if ( isAlive() )
80 		{
81 			// increment ref count to prevent double call of Dtor
82         	osl_incrementInterlockedCount( &m_refCount );
83         	dispose();
84 		}
85 	}
86 	// -----------------------------------------------------------------------------
createAccessibleTable()87 	AccessibleBrowseBoxTable* AccessibleTabListBox::createAccessibleTable()
88 	{
89 		return new AccessibleTabListBoxTable( this, *m_pTabListBox );
90 	}
91 
92     // XInterface -----------------------------------------------------------------
IMPLEMENT_FORWARD_XINTERFACE2(AccessibleTabListBox,AccessibleBrowseBox,AccessibleTabListBox_Base)93     IMPLEMENT_FORWARD_XINTERFACE2( AccessibleTabListBox, AccessibleBrowseBox, AccessibleTabListBox_Base )
94 
95     // XTypeProvider --------------------------------------------------------------
96     IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleTabListBox, AccessibleBrowseBox, AccessibleTabListBox_Base )
97 
98     // XAccessibleContext ---------------------------------------------------------
99 
100 	sal_Int32 SAL_CALL AccessibleTabListBox::getAccessibleChildCount()
101 	    throw ( uno::RuntimeException )
102 	{
103 	    return 2; // header and table
104 	}
105 
106     // -----------------------------------------------------------------------------
getAccessibleContext()107     Reference< XAccessibleContext > SAL_CALL AccessibleTabListBox::getAccessibleContext() throw ( RuntimeException )
108     {
109         return this;
110     }
111 
112     // -----------------------------------------------------------------------------
113 	Reference< XAccessible > SAL_CALL
getAccessibleChild(sal_Int32 nChildIndex)114 	AccessibleTabListBox::getAccessibleChild( sal_Int32 nChildIndex )
115 	    throw ( IndexOutOfBoundsException, RuntimeException )
116 	{
117 	    TLBSolarGuard aSolarGuard;
118 	    ::osl::MutexGuard aGuard( getOslMutex() );
119 	    ensureIsAlive();
120 
121 		if ( nChildIndex < 0 || nChildIndex > 1 )
122 			throw IndexOutOfBoundsException();
123 
124         Reference< XAccessible > xRet;
125         if (nChildIndex == 0)
126         {
127             //! so far the actual implementation object only supports column headers
128             xRet = implGetFixedChild( ::svt::BBINDEX_COLUMNHEADERBAR );
129         }
130         else if (nChildIndex == 1)
131             xRet = implGetFixedChild( ::svt::BBINDEX_TABLE );
132 
133 	    if ( !xRet.is() )
134 	        throw RuntimeException();
135 
136 		return xRet;
137 	}
138 
139 //........................................................................
140 }// namespace accessibility
141 //........................................................................
142 
143