CppunitTest_sc_tiledrendering2: move to tiledrendering folder
[LibreOffice.git] / accessibility / source / standard / vclxaccessibleheaderbar.cxx
blob2c8ad658b1ab0fb81c57fd4280e23cf1d5549a4d
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::lang;
32 using namespace ::com::sun::star::accessibility;
34 VCLXAccessibleHeaderBar::VCLXAccessibleHeaderBar(VCLXWindow* pVCLWindow)
35 : VCLXAccessibleComponent(pVCLWindow)
37 m_pHeadBar = GetAs<HeaderBar>();
40 VCLXAccessibleHeaderBar::~VCLXAccessibleHeaderBar() {}
42 // XServiceInfo
44 OUString VCLXAccessibleHeaderBar::getImplementationName()
46 return u"com.sun.star.comp.toolkit.AccessibleHeaderBar"_ustr;
49 Sequence<OUString> VCLXAccessibleHeaderBar::getSupportedServiceNames()
51 return { u"com.sun.star.awt.AccessibleHeaderBar"_ustr };
54 // =======XAccessibleContext=======
56 sal_Int64 SAL_CALL VCLXAccessibleHeaderBar::getAccessibleChildCount()
58 SolarMutexGuard g;
60 sal_Int64 nCount = 0;
61 if (m_pHeadBar)
62 nCount = m_pHeadBar->GetItemCount();
64 return nCount;
66 css::uno::Reference<css::accessibility::XAccessible>
67 SAL_CALL VCLXAccessibleHeaderBar::getAccessibleChild(sal_Int64 i)
69 SolarMutexGuard g;
71 if (i < 0 || i >= getAccessibleChildCount())
72 throw IndexOutOfBoundsException();
74 Reference<XAccessible> xChild;
75 // search for the child
76 if (o3tl::make_unsigned(i) >= m_aAccessibleChildren.size())
77 xChild = CreateChild(i);
78 else
80 xChild = m_aAccessibleChildren[i];
81 if (!xChild.is())
82 xChild = CreateChild(i);
84 return xChild;
87 sal_Int16 SAL_CALL VCLXAccessibleHeaderBar::getAccessibleRole()
89 return css::accessibility::AccessibleRole::LIST;
92 void SAL_CALL VCLXAccessibleHeaderBar::disposing()
94 SolarMutexGuard g;
96 ListItems().swap(m_aAccessibleChildren);
97 VCLXAccessibleComponent::disposing();
100 css::uno::Reference<css::accessibility::XAccessible>
101 VCLXAccessibleHeaderBar::CreateChild(sal_Int32 i)
103 Reference<XAccessible> xChild;
105 sal_uInt16 nPos = static_cast<sal_uInt16>(i);
106 if (nPos >= m_aAccessibleChildren.size())
108 m_aAccessibleChildren.resize(nPos + 1);
110 // insert into the container
111 xChild = new VCLXAccessibleHeaderBarItem(m_pHeadBar, i);
112 m_aAccessibleChildren[nPos] = xChild;
114 else
116 xChild = m_aAccessibleChildren[nPos];
117 // check if position is empty and can be used else we have to adjust all entries behind this
118 if (!xChild.is())
120 xChild = new VCLXAccessibleHeaderBarItem(m_pHeadBar, i);
121 m_aAccessibleChildren[nPos] = xChild;
124 return xChild;
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */