bump product version to 7.6.3.2-android
[LibreOffice.git] / accessibility / source / standard / vclxaccessibleheaderbar.cxx
blob23d2db4be3d836ed322ec6252783b6b139b717e9
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/vclxaccessibleheaderbar.hxx>
21 #include <standard/vclxaccessibleheaderbaritem.hxx>
23 #include <o3tl/safeint.hxx>
24 #include <vcl/headbar.hxx>
25 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
26 #include <com/sun/star/accessibility/AccessibleRole.hpp>
27 #include <vcl/svapp.hxx>
29 using namespace ::com::sun::star;
30 using namespace ::com::sun::star::uno;
31 using namespace ::com::sun::star::awt;
32 using namespace ::com::sun::star::lang;
33 using namespace ::com::sun::star::beans;
34 using namespace ::com::sun::star::accessibility;
35 using namespace ::comphelper;
37 VCLXAccessibleHeaderBar::VCLXAccessibleHeaderBar(VCLXWindow* pVCLWindow)
38 : VCLXAccessibleComponent(pVCLWindow)
40 m_pHeadBar = GetAs<HeaderBar>();
43 VCLXAccessibleHeaderBar::~VCLXAccessibleHeaderBar() {}
45 // XServiceInfo
47 OUString VCLXAccessibleHeaderBar::getImplementationName()
49 return "com.sun.star.comp.toolkit.AccessibleHeaderBar";
52 Sequence<OUString> VCLXAccessibleHeaderBar::getSupportedServiceNames()
54 return { "com.sun.star.awt.AccessibleHeaderBar" };
57 // =======XAccessibleContext=======
59 sal_Int64 SAL_CALL VCLXAccessibleHeaderBar::getAccessibleChildCount()
61 SolarMutexGuard g;
63 sal_Int64 nCount = 0;
64 if (m_pHeadBar)
65 nCount = m_pHeadBar->GetItemCount();
67 return nCount;
69 css::uno::Reference<css::accessibility::XAccessible>
70 SAL_CALL VCLXAccessibleHeaderBar::getAccessibleChild(sal_Int64 i)
72 SolarMutexGuard g;
74 if (i < 0 || i >= getAccessibleChildCount())
75 throw IndexOutOfBoundsException();
77 Reference<XAccessible> xChild;
78 // search for the child
79 if (o3tl::make_unsigned(i) >= m_aAccessibleChildren.size())
80 xChild = CreateChild(i);
81 else
83 xChild = m_aAccessibleChildren[i];
84 if (!xChild.is())
85 xChild = CreateChild(i);
87 return xChild;
90 sal_Int16 SAL_CALL VCLXAccessibleHeaderBar::getAccessibleRole()
92 return css::accessibility::AccessibleRole::LIST;
95 void SAL_CALL VCLXAccessibleHeaderBar::disposing()
97 SolarMutexGuard g;
99 ListItems().swap(m_aAccessibleChildren);
100 VCLXAccessibleComponent::disposing();
103 css::uno::Reference<css::accessibility::XAccessible>
104 VCLXAccessibleHeaderBar::CreateChild(sal_Int32 i)
106 Reference<XAccessible> xChild;
108 sal_uInt16 nPos = static_cast<sal_uInt16>(i);
109 if (nPos >= m_aAccessibleChildren.size())
111 m_aAccessibleChildren.resize(nPos + 1);
113 // insert into the container
114 xChild = new VCLXAccessibleHeaderBarItem(m_pHeadBar, i);
115 m_aAccessibleChildren[nPos] = xChild;
117 else
119 xChild = m_aAccessibleChildren[nPos];
120 // check if position is empty and can be used else we have to adjust all entries behind this
121 if (!xChild.is())
123 xChild = new VCLXAccessibleHeaderBarItem(m_pHeadBar, i);
124 m_aAccessibleChildren[nPos] = xChild;
127 return xChild;
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */