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