tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / accessibility / source / standard / vclxaccessibletabpagewindow.cxx
blob7bae454d322309efe4dcf30af098d1c03371e4ef
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 <standard/vclxaccessibletabpagewindow.hxx>
21 #include <comphelper/accessiblecontexthelper.hxx>
22 #include <vcl/tabctrl.hxx>
23 #include <vcl/tabpage.hxx>
24 #include <vcl/unohelp.hxx>
25 #include <sal/log.hxx>
27 using namespace ::com::sun::star;
28 using namespace ::com::sun::star::uno;
29 using namespace ::com::sun::star::accessibility;
30 using namespace ::comphelper;
35 VCLXAccessibleTabPageWindow::VCLXAccessibleTabPageWindow(vcl::Window* pWindow)
36 : VCLXAccessibleComponent(pWindow)
38 m_pTabPage = GetAs<TabPage>();
39 m_pTabControl = nullptr;
40 m_nPageId = 0;
41 if ( !m_pTabPage )
42 return;
44 vcl::Window* pParent = m_pTabPage->GetAccessibleParentWindow();
45 if ( !(pParent && pParent->GetType() == WindowType::TABCONTROL) )
46 return;
48 m_pTabControl = static_cast< TabControl* >( pParent );
49 if ( m_pTabControl )
51 for ( sal_uInt16 i = 0, nCount = m_pTabControl->GetPageCount(); i < nCount; ++i )
53 sal_uInt16 nPageId = m_pTabControl->GetPageId( i );
54 if ( m_pTabControl->GetTabPage( nPageId ) == m_pTabPage.get() )
55 m_nPageId = nPageId;
61 // OCommonAccessibleComponent
64 awt::Rectangle VCLXAccessibleTabPageWindow::implGetBounds()
66 awt::Rectangle aBounds( 0, 0, 0, 0 );
68 if ( m_pTabControl )
70 tools::Rectangle aPageRect = m_pTabControl->GetTabBounds( m_nPageId );
71 if ( m_pTabPage )
73 tools::Rectangle aRect( m_pTabPage->GetPosPixel(), m_pTabPage->GetSizePixel() );
74 aRect.Move( -aPageRect.Left(), -aPageRect.Top() );
75 aBounds = vcl::unohelper::ConvertToAWTRect(aRect);
79 return aBounds;
83 // XComponent
86 void VCLXAccessibleTabPageWindow::disposing()
88 VCLXAccessibleComponent::disposing();
90 m_pTabControl = nullptr;
91 m_pTabPage = nullptr;
95 // XAccessibleContext
98 Reference< XAccessible > VCLXAccessibleTabPageWindow::getAccessibleParent( )
100 OExternalLockGuard aGuard( this );
102 Reference< XAccessible > xParent;
103 if ( m_pTabControl )
105 Reference< XAccessible > xAcc( m_pTabControl->GetAccessible() );
106 if ( xAcc.is() )
108 Reference< XAccessibleContext > xCont( xAcc->getAccessibleContext() );
109 if ( xCont.is() )
111 sal_uInt16 const nPagePos(m_pTabControl->GetPagePos(m_nPageId));
112 SAL_WARN_IF(nPagePos == TAB_PAGE_NOTFOUND, "accessibility",
113 "getAccessibleParent(): no tab page");
114 if (nPagePos != TAB_PAGE_NOTFOUND)
116 xParent = xCont->getAccessibleChild(nPagePos);
122 return xParent;
126 sal_Int64 VCLXAccessibleTabPageWindow::getAccessibleIndexInParent( )
128 OExternalLockGuard aGuard( this );
130 return 0;
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */