merge the formfield patch from ooo-build
[ooovba.git] / accessibility / source / standard / vclxaccessibletabpagewindow.cxx
blobca049e2aab68b476eae451f46c8d7eb4b7c0250f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: vclxaccessibletabpagewindow.cxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_accessibility.hxx"
33 #include <accessibility/standard/vclxaccessibletabpagewindow.hxx>
34 #include <toolkit/helper/convert.hxx>
35 #include <vcl/tabctrl.hxx>
36 #include <vcl/tabpage.hxx>
39 using namespace ::com::sun::star;
40 using namespace ::com::sun::star::uno;
41 using namespace ::com::sun::star::accessibility;
42 using namespace ::comphelper;
45 // ----------------------------------------------------
46 // class VCLXAccessibleTabPageWindow
47 // ----------------------------------------------------
49 VCLXAccessibleTabPageWindow::VCLXAccessibleTabPageWindow( VCLXWindow* pVCLXWindow )
50 :VCLXAccessibleComponent( pVCLXWindow )
52 m_pTabPage = static_cast< TabPage* >( GetWindow() );
53 if ( m_pTabPage )
55 Window* pParent = m_pTabPage->GetAccessibleParentWindow();
56 if ( pParent && pParent->GetType() == WINDOW_TABCONTROL )
58 m_pTabControl = static_cast< TabControl* >( pParent );
59 if ( m_pTabControl )
61 for ( sal_uInt16 i = 0, nCount = m_pTabControl->GetPageCount(); i < nCount; ++i )
63 sal_uInt16 nPageId = m_pTabControl->GetPageId( i );
64 if ( m_pTabControl->GetTabPage( nPageId ) == m_pTabPage )
65 m_nPageId = nPageId;
72 // -----------------------------------------------------------------------------
74 VCLXAccessibleTabPageWindow::~VCLXAccessibleTabPageWindow()
78 // -----------------------------------------------------------------------------
79 // OCommonAccessibleComponent
80 // -----------------------------------------------------------------------------
82 awt::Rectangle VCLXAccessibleTabPageWindow::implGetBounds() throw (RuntimeException)
84 awt::Rectangle aBounds( 0, 0, 0, 0 );
86 if ( m_pTabControl )
88 Rectangle aPageRect = m_pTabControl->GetTabBounds( m_nPageId );
89 if ( m_pTabPage )
91 Rectangle aRect = Rectangle( m_pTabPage->GetPosPixel(), m_pTabPage->GetSizePixel() );
92 aRect.Move( -aPageRect.Left(), -aPageRect.Top() );
93 aBounds = AWTRectangle( aRect );
97 return aBounds;
100 // -----------------------------------------------------------------------------
101 // XComponent
102 // -----------------------------------------------------------------------------
104 void VCLXAccessibleTabPageWindow::disposing()
106 VCLXAccessibleComponent::disposing();
108 m_pTabControl = NULL;
109 m_pTabPage = NULL;
112 // -----------------------------------------------------------------------------
113 // XAccessibleContext
114 // -----------------------------------------------------------------------------
116 Reference< XAccessible > VCLXAccessibleTabPageWindow::getAccessibleParent( ) throw (RuntimeException)
118 OExternalLockGuard aGuard( this );
120 Reference< XAccessible > xParent;
121 if ( m_pTabControl )
123 Reference< XAccessible > xAcc( m_pTabControl->GetAccessible() );
124 if ( xAcc.is() )
126 Reference< XAccessibleContext > xCont( xAcc->getAccessibleContext() );
127 if ( xCont.is() )
128 xParent = xCont->getAccessibleChild( m_pTabControl->GetPagePos( m_nPageId ) );
132 return xParent;
135 // -----------------------------------------------------------------------------
137 sal_Int32 VCLXAccessibleTabPageWindow::getAccessibleIndexInParent( ) throw (RuntimeException)
139 OExternalLockGuard aGuard( this );
141 return 0;
144 // -----------------------------------------------------------------------------