Branch libreoffice-5-0-4
[LibreOffice.git] / accessibility / source / standard / vclxaccessibletabpagewindow.cxx
blob3edb2b815864ca272c8904b032aa876b78694cdc
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;
33 // class VCLXAccessibleTabPageWindow
36 VCLXAccessibleTabPageWindow::VCLXAccessibleTabPageWindow( VCLXWindow* pVCLXWindow )
37 :VCLXAccessibleComponent( pVCLXWindow )
39 m_pTabPage = static_cast< TabPage* >( GetWindow().get() );
40 m_pTabControl = 0;
41 m_nPageId = 0;
42 if ( m_pTabPage )
44 vcl::Window* pParent = m_pTabPage->GetAccessibleParentWindow();
45 if ( pParent && pParent->GetType() == WINDOW_TABCONTROL )
47 m_pTabControl = static_cast< TabControl* >( pParent );
48 if ( m_pTabControl )
50 for ( sal_uInt16 i = 0, nCount = m_pTabControl->GetPageCount(); i < nCount; ++i )
52 sal_uInt16 nPageId = m_pTabControl->GetPageId( i );
53 if ( m_pTabControl->GetTabPage( nPageId ) == m_pTabPage.get() )
54 m_nPageId = nPageId;
63 VCLXAccessibleTabPageWindow::~VCLXAccessibleTabPageWindow()
68 // OCommonAccessibleComponent
71 awt::Rectangle VCLXAccessibleTabPageWindow::implGetBounds() throw (RuntimeException)
73 awt::Rectangle aBounds( 0, 0, 0, 0 );
75 if ( m_pTabControl )
77 Rectangle aPageRect = m_pTabControl->GetTabBounds( m_nPageId );
78 if ( m_pTabPage )
80 Rectangle aRect = Rectangle( m_pTabPage->GetPosPixel(), m_pTabPage->GetSizePixel() );
81 aRect.Move( -aPageRect.Left(), -aPageRect.Top() );
82 aBounds = AWTRectangle( aRect );
86 return aBounds;
90 // XComponent
93 void VCLXAccessibleTabPageWindow::disposing()
95 VCLXAccessibleComponent::disposing();
97 m_pTabControl = NULL;
98 m_pTabPage = NULL;
102 // XAccessibleContext
105 Reference< XAccessible > VCLXAccessibleTabPageWindow::getAccessibleParent( ) throw (RuntimeException, std::exception)
107 OExternalLockGuard aGuard( this );
109 Reference< XAccessible > xParent;
110 if ( m_pTabControl )
112 Reference< XAccessible > xAcc( m_pTabControl->GetAccessible() );
113 if ( xAcc.is() )
115 Reference< XAccessibleContext > xCont( xAcc->getAccessibleContext() );
116 if ( xCont.is() )
118 sal_uInt16 const nPagePos(m_pTabControl->GetPagePos(m_nPageId));
119 SAL_WARN_IF(TAB_PAGE_NOTFOUND == nPagePos, "accessibility",
120 "getAccessibleParent(): no tab page");
121 if (TAB_PAGE_NOTFOUND != nPagePos)
123 xParent = xCont->getAccessibleChild(nPagePos);
129 return xParent;
134 sal_Int32 VCLXAccessibleTabPageWindow::getAccessibleIndexInParent( ) throw (RuntimeException, std::exception)
136 OExternalLockGuard aGuard( this );
138 return 0;
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */