1c82f2877SAndrew Rist /**************************************************************
2*09e0ec10Smseidel  *
3c82f2877SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4c82f2877SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5c82f2877SAndrew Rist  * distributed with this work for additional information
6c82f2877SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7c82f2877SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8c82f2877SAndrew Rist  * "License"); you may not use this file except in compliance
9c82f2877SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*09e0ec10Smseidel  *
11c82f2877SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*09e0ec10Smseidel  *
13c82f2877SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14c82f2877SAndrew Rist  * software distributed under the License is distributed on an
15c82f2877SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16c82f2877SAndrew Rist  * KIND, either express or implied.  See the License for the
17c82f2877SAndrew Rist  * specific language governing permissions and limitations
18c82f2877SAndrew Rist  * under the License.
19*09e0ec10Smseidel  *
20c82f2877SAndrew Rist  *************************************************************/
21c82f2877SAndrew Rist 
22c82f2877SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_accessibility.hxx"
26cdf0e10cSrcweir #include <accessibility/standard/vclxaccessibletabpagewindow.hxx>
27cdf0e10cSrcweir #include <toolkit/helper/convert.hxx>
28cdf0e10cSrcweir #include <vcl/tabctrl.hxx>
29cdf0e10cSrcweir #include <vcl/tabpage.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir 
32cdf0e10cSrcweir using namespace ::com::sun::star;
33cdf0e10cSrcweir using namespace ::com::sun::star::uno;
34cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
35cdf0e10cSrcweir using namespace ::comphelper;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir 
38cdf0e10cSrcweir //	----------------------------------------------------
39cdf0e10cSrcweir //	class VCLXAccessibleTabPageWindow
40cdf0e10cSrcweir //	----------------------------------------------------
41cdf0e10cSrcweir 
VCLXAccessibleTabPageWindow(VCLXWindow * pVCLXWindow)42cdf0e10cSrcweir VCLXAccessibleTabPageWindow::VCLXAccessibleTabPageWindow( VCLXWindow* pVCLXWindow )
43cdf0e10cSrcweir 	:VCLXAccessibleComponent( pVCLXWindow )
44cdf0e10cSrcweir {
45*09e0ec10Smseidel 	m_pTabPage = static_cast< TabPage* >( GetWindow() );
46*09e0ec10Smseidel 	if ( m_pTabPage )
47*09e0ec10Smseidel 	{
48*09e0ec10Smseidel 		Window* pParent = m_pTabPage->GetAccessibleParentWindow();
49*09e0ec10Smseidel 		if ( pParent && pParent->GetType() == WINDOW_TABCONTROL )
50*09e0ec10Smseidel 		{
51*09e0ec10Smseidel 			m_pTabControl = static_cast< TabControl* >( pParent );
52*09e0ec10Smseidel 			if ( m_pTabControl )
53*09e0ec10Smseidel 			{
54*09e0ec10Smseidel 				for ( sal_uInt16 i = 0, nCount = m_pTabControl->GetPageCount(); i < nCount; ++i )
55*09e0ec10Smseidel 				{
56*09e0ec10Smseidel 					sal_uInt16 nPageId = m_pTabControl->GetPageId( i );
57*09e0ec10Smseidel 					if ( m_pTabControl->GetTabPage( nPageId ) == m_pTabPage )
58*09e0ec10Smseidel 						m_nPageId = nPageId;
59*09e0ec10Smseidel 				}
60*09e0ec10Smseidel 			}
61*09e0ec10Smseidel 		}
62*09e0ec10Smseidel 	}
63cdf0e10cSrcweir }
64cdf0e10cSrcweir 
65cdf0e10cSrcweir // -----------------------------------------------------------------------------
66cdf0e10cSrcweir 
~VCLXAccessibleTabPageWindow()67cdf0e10cSrcweir VCLXAccessibleTabPageWindow::~VCLXAccessibleTabPageWindow()
68cdf0e10cSrcweir {
69cdf0e10cSrcweir }
70cdf0e10cSrcweir 
71cdf0e10cSrcweir // -----------------------------------------------------------------------------
72*09e0ec10Smseidel // OCommonAccessibleComponent
73cdf0e10cSrcweir // -----------------------------------------------------------------------------
74cdf0e10cSrcweir 
implGetBounds()75cdf0e10cSrcweir awt::Rectangle VCLXAccessibleTabPageWindow::implGetBounds() throw (RuntimeException)
76cdf0e10cSrcweir {
77*09e0ec10Smseidel 	awt::Rectangle aBounds( 0, 0, 0, 0 );
78*09e0ec10Smseidel 
79*09e0ec10Smseidel 	if ( m_pTabControl )
80*09e0ec10Smseidel 	{
81*09e0ec10Smseidel 		Rectangle aPageRect = m_pTabControl->GetTabBounds( m_nPageId );
82*09e0ec10Smseidel 		if ( m_pTabPage )
83*09e0ec10Smseidel 		{
84*09e0ec10Smseidel 			Rectangle aRect = Rectangle( m_pTabPage->GetPosPixel(), m_pTabPage->GetSizePixel() );
85*09e0ec10Smseidel 			aRect.Move( -aPageRect.Left(), -aPageRect.Top() );
86*09e0ec10Smseidel 			aBounds = AWTRectangle( aRect );
87*09e0ec10Smseidel 		}
88*09e0ec10Smseidel 	}
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 	return aBounds;
91cdf0e10cSrcweir }
92cdf0e10cSrcweir 
93cdf0e10cSrcweir // -----------------------------------------------------------------------------
94cdf0e10cSrcweir // XComponent
95cdf0e10cSrcweir // -----------------------------------------------------------------------------
96cdf0e10cSrcweir 
disposing()97cdf0e10cSrcweir void VCLXAccessibleTabPageWindow::disposing()
98cdf0e10cSrcweir {
99cdf0e10cSrcweir 	VCLXAccessibleComponent::disposing();
100cdf0e10cSrcweir 
101*09e0ec10Smseidel 	m_pTabControl = NULL;
102*09e0ec10Smseidel 	m_pTabPage = NULL;
103cdf0e10cSrcweir }
104cdf0e10cSrcweir 
105cdf0e10cSrcweir // -----------------------------------------------------------------------------
106cdf0e10cSrcweir // XAccessibleContext
107cdf0e10cSrcweir // -----------------------------------------------------------------------------
108cdf0e10cSrcweir 
getAccessibleParent()109cdf0e10cSrcweir Reference< XAccessible > VCLXAccessibleTabPageWindow::getAccessibleParent(  ) throw (RuntimeException)
110cdf0e10cSrcweir {
111*09e0ec10Smseidel 	OExternalLockGuard aGuard( this );
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 	Reference< XAccessible > xParent;
114*09e0ec10Smseidel 	if ( m_pTabControl )
115*09e0ec10Smseidel 	{
116*09e0ec10Smseidel 		Reference< XAccessible > xAcc( m_pTabControl->GetAccessible() );
117*09e0ec10Smseidel 		if ( xAcc.is() )
118*09e0ec10Smseidel 		{
119*09e0ec10Smseidel 			Reference< XAccessibleContext > xCont( xAcc->getAccessibleContext() );
120*09e0ec10Smseidel 			if ( xCont.is() )
121*09e0ec10Smseidel 				xParent = xCont->getAccessibleChild( m_pTabControl->GetPagePos( m_nPageId ) );
122*09e0ec10Smseidel 		}
123*09e0ec10Smseidel 	}
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 	return xParent;
126cdf0e10cSrcweir }
127cdf0e10cSrcweir 
128cdf0e10cSrcweir // -----------------------------------------------------------------------------
129cdf0e10cSrcweir 
getAccessibleIndexInParent()130cdf0e10cSrcweir sal_Int32 VCLXAccessibleTabPageWindow::getAccessibleIndexInParent(  ) throw (RuntimeException)
131cdf0e10cSrcweir {
132cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
133cdf0e10cSrcweir 
134*09e0ec10Smseidel 	return 0;
135cdf0e10cSrcweir }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir // -----------------------------------------------------------------------------
138