Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/vcl/source/accessibility/vclxaccessibletabpagewindow.cxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
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/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
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 .
18
 */
19
20
#include <accessibility/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>
26
27
using namespace ::com::sun::star;
28
using namespace ::com::sun::star::uno;
29
using namespace ::com::sun::star::accessibility;
30
using namespace ::comphelper;
31
32
33
34
35
VCLXAccessibleTabPageWindow::VCLXAccessibleTabPageWindow(vcl::Window* pWindow)
36
0
    : VCLXAccessibleComponent(pWindow)
37
0
{
38
0
    m_pTabPage = GetAs<TabPage>();
39
0
    m_pTabControl = nullptr;
40
0
    m_nPageId = 0;
41
0
    if ( !m_pTabPage )
42
0
        return;
43
44
0
    vcl::Window* pParent = m_pTabPage->GetAccessibleParentWindow();
45
0
    if ( !(pParent && pParent->GetType() == WindowType::TABCONTROL) )
46
0
        return;
47
48
0
    m_pTabControl = static_cast< TabControl* >( pParent );
49
0
    if ( m_pTabControl )
50
0
    {
51
0
        for ( sal_uInt16 i = 0, nCount = m_pTabControl->GetPageCount(); i < nCount; ++i )
52
0
        {
53
0
            sal_uInt16 nPageId = m_pTabControl->GetPageId( i );
54
0
            if ( m_pTabControl->GetTabPage( nPageId ) == m_pTabPage.get() )
55
0
                m_nPageId = nPageId;
56
0
        }
57
0
    }
58
0
}
59
60
// OAccessible
61
62
awt::Rectangle VCLXAccessibleTabPageWindow::implGetBounds()
63
0
{
64
0
    awt::Rectangle aBounds( 0, 0, 0, 0 );
65
66
0
    if ( m_pTabControl )
67
0
    {
68
0
        tools::Rectangle aPageRect = m_pTabControl->GetTabBounds( m_nPageId );
69
0
        if ( m_pTabPage )
70
0
        {
71
0
            tools::Rectangle aRect( m_pTabPage->GetPosPixel(), m_pTabPage->GetSizePixel() );
72
0
            aRect.Move( -aPageRect.Left(), -aPageRect.Top() );
73
0
            aBounds = vcl::unohelper::ConvertToAWTRect(aRect);
74
0
        }
75
0
    }
76
77
0
    return aBounds;
78
0
}
79
80
81
// XComponent
82
83
84
void VCLXAccessibleTabPageWindow::disposing()
85
0
{
86
0
    VCLXAccessibleComponent::disposing();
87
88
0
    m_pTabControl = nullptr;
89
0
    m_pTabPage = nullptr;
90
0
}
91
92
93
// XAccessibleContext
94
95
96
Reference< XAccessible > VCLXAccessibleTabPageWindow::getAccessibleParent(  )
97
0
{
98
0
    OExternalLockGuard aGuard( this );
99
100
0
    Reference< XAccessible > xParent;
101
0
    if ( m_pTabControl )
102
0
    {
103
0
        rtl::Reference<comphelper::OAccessible> pAcc = m_pTabControl->GetAccessible();
104
0
        if (pAcc.is())
105
0
        {
106
0
            sal_uInt16 const nPagePos(m_pTabControl->GetPagePos(m_nPageId));
107
0
            SAL_WARN_IF(nPagePos == TAB_PAGE_NOTFOUND, "accessibility",
108
0
                        "getAccessibleParent(): no tab page");
109
0
            if (nPagePos != TAB_PAGE_NOTFOUND)
110
0
            {
111
0
                xParent = pAcc->getAccessibleChild(nPagePos);
112
0
            }
113
0
        }
114
0
    }
115
116
0
    return xParent;
117
0
}
118
119
120
sal_Int64 VCLXAccessibleTabPageWindow::getAccessibleIndexInParent(  )
121
0
{
122
0
    OExternalLockGuard aGuard( this );
123
124
0
    return 0;
125
0
}
126
127
128
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */