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