Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / accessibility / source / standard / vclxaccessibletabpagewindow.cxx
blob03aac5a9cd351bdb5d610527395c94e75a4a57f8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <accessibility/standard/vclxaccessibletabpagewindow.hxx>
21 #include <toolkit/helper/convert.hxx>
22 #include <vcl/tabctrl.hxx>
23 #include <vcl/tabpage.hxx>
26 using namespace ::com::sun::star;
27 using namespace ::com::sun::star::uno;
28 using namespace ::com::sun::star::accessibility;
29 using namespace ::comphelper;
32 // ----------------------------------------------------
33 // class VCLXAccessibleTabPageWindow
34 // ----------------------------------------------------
36 VCLXAccessibleTabPageWindow::VCLXAccessibleTabPageWindow( VCLXWindow* pVCLXWindow )
37 :VCLXAccessibleComponent( pVCLXWindow )
39 m_pTabPage = static_cast< TabPage* >( GetWindow() );
40 if ( m_pTabPage )
42 Window* pParent = m_pTabPage->GetAccessibleParentWindow();
43 if ( pParent && pParent->GetType() == WINDOW_TABCONTROL )
45 m_pTabControl = static_cast< TabControl* >( pParent );
46 if ( m_pTabControl )
48 for ( sal_uInt16 i = 0, nCount = m_pTabControl->GetPageCount(); i < nCount; ++i )
50 sal_uInt16 nPageId = m_pTabControl->GetPageId( i );
51 if ( m_pTabControl->GetTabPage( nPageId ) == m_pTabPage )
52 m_nPageId = nPageId;
59 // -----------------------------------------------------------------------------
61 VCLXAccessibleTabPageWindow::~VCLXAccessibleTabPageWindow()
65 // -----------------------------------------------------------------------------
66 // OCommonAccessibleComponent
67 // -----------------------------------------------------------------------------
69 awt::Rectangle VCLXAccessibleTabPageWindow::implGetBounds() throw (RuntimeException)
71 awt::Rectangle aBounds( 0, 0, 0, 0 );
73 if ( m_pTabControl )
75 Rectangle aPageRect = m_pTabControl->GetTabBounds( m_nPageId );
76 if ( m_pTabPage )
78 Rectangle aRect = Rectangle( m_pTabPage->GetPosPixel(), m_pTabPage->GetSizePixel() );
79 aRect.Move( -aPageRect.Left(), -aPageRect.Top() );
80 aBounds = AWTRectangle( aRect );
84 return aBounds;
87 // -----------------------------------------------------------------------------
88 // XComponent
89 // -----------------------------------------------------------------------------
91 void VCLXAccessibleTabPageWindow::disposing()
93 VCLXAccessibleComponent::disposing();
95 m_pTabControl = NULL;
96 m_pTabPage = NULL;
99 // -----------------------------------------------------------------------------
100 // XAccessibleContext
101 // -----------------------------------------------------------------------------
103 Reference< XAccessible > VCLXAccessibleTabPageWindow::getAccessibleParent( ) throw (RuntimeException)
105 OExternalLockGuard aGuard( this );
107 Reference< XAccessible > xParent;
108 if ( m_pTabControl )
110 Reference< XAccessible > xAcc( m_pTabControl->GetAccessible() );
111 if ( xAcc.is() )
113 Reference< XAccessibleContext > xCont( xAcc->getAccessibleContext() );
114 if ( xCont.is() )
115 xParent = xCont->getAccessibleChild( m_pTabControl->GetPagePos( m_nPageId ) );
119 return xParent;
122 // -----------------------------------------------------------------------------
124 sal_Int32 VCLXAccessibleTabPageWindow::getAccessibleIndexInParent( ) throw (RuntimeException)
126 OExternalLockGuard aGuard( this );
128 return 0;
131 // -----------------------------------------------------------------------------
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */