Line data Source code
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 : #include <vclxaccessibleheaderbar.hxx>
20 : #include <vclxaccessibleheaderbaritem.hxx>
21 :
22 : #include <toolkit/awt/vclxwindows.hxx>
23 : #include <svtools/headbar.hxx>
24 : #include <unotools/accessiblestatesethelper.hxx>
25 : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
26 : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
27 : #include <cppuhelper/typeprovider.hxx>
28 : #include <comphelper/sequence.hxx>
29 : #include <com/sun/star/accessibility/AccessibleRole.hpp>
30 : #include <vcl/svapp.hxx>
31 :
32 : using namespace ::com::sun::star;
33 : using namespace ::com::sun::star::uno;
34 : using namespace ::com::sun::star::awt;
35 : using namespace ::com::sun::star::lang;
36 : using namespace ::com::sun::star::beans;
37 : using namespace ::com::sun::star::accessibility;
38 : using namespace ::comphelper;
39 :
40 0 : VCLXHeaderBar::VCLXHeaderBar(vcl::Window* pHeaderBar)
41 : {
42 0 : SetWindow(pHeaderBar);
43 0 : }
44 :
45 0 : VCLXHeaderBar::~VCLXHeaderBar()
46 : {
47 0 : }
48 :
49 0 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXHeaderBar::CreateAccessibleContext()
50 : {
51 0 : return new VCLXAccessibleHeaderBar(this);
52 : }
53 :
54 :
55 0 : VCLXAccessibleHeaderBar::VCLXAccessibleHeaderBar( VCLXWindow* pVCLWindow )
56 : :VCLXAccessibleComponent( pVCLWindow )
57 0 : ,m_pHeadBar(NULL)
58 : {
59 0 : m_pHeadBar = GetAs< HeaderBar >();
60 0 : }
61 :
62 :
63 0 : VCLXAccessibleHeaderBar::~VCLXAccessibleHeaderBar()
64 : {
65 0 : }
66 :
67 :
68 :
69 0 : void VCLXAccessibleHeaderBar::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
70 : {
71 0 : VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
72 0 : }
73 :
74 :
75 :
76 0 : void VCLXAccessibleHeaderBar::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
77 : {
78 0 : VCLXAccessibleComponent::FillAccessibleStateSet( rStateSet );
79 0 : }
80 :
81 :
82 : // XServiceInfo
83 :
84 :
85 0 : ::rtl::OUString VCLXAccessibleHeaderBar::getImplementationName() throw (RuntimeException, std::exception)
86 : {
87 0 : return OUString( "com.sun.star.comp.toolkit.AccessibleHeaderBar" );
88 : }
89 :
90 :
91 :
92 0 : Sequence< ::rtl::OUString > VCLXAccessibleHeaderBar::getSupportedServiceNames() throw (RuntimeException, std::exception)
93 : {
94 0 : Sequence< ::rtl::OUString > aNames(1);
95 0 : aNames[0] = "com.sun.star.awt.AccessibleHeaderBar";
96 0 : return aNames;
97 : }
98 :
99 : // =======XAccessibleContext=======
100 :
101 0 : sal_Int32 SAL_CALL VCLXAccessibleHeaderBar::getAccessibleChildCount( )
102 : throw (::com::sun::star::uno::RuntimeException, std::exception)
103 : {
104 0 : SolarMutexGuard g;
105 :
106 0 : sal_Int32 nCount = 0;
107 0 : if ( m_pHeadBar )
108 0 : nCount = m_pHeadBar->GetItemCount();
109 :
110 0 : return nCount;
111 : }
112 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
113 0 : VCLXAccessibleHeaderBar::getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception)
114 : {
115 0 : SolarMutexGuard g;
116 :
117 0 : if ( i < 0 || i >= getAccessibleChildCount() )
118 0 : throw IndexOutOfBoundsException();
119 :
120 0 : Reference< XAccessible > xChild;
121 : // search for the child
122 0 : if ( static_cast<sal_uInt16>(i) >= m_aAccessibleChildren.size() )
123 0 : xChild = CreateChild (i);
124 : else
125 : {
126 0 : xChild = m_aAccessibleChildren[i];
127 0 : if ( !xChild.is() )
128 0 : xChild = CreateChild (i);
129 : }
130 0 : return xChild;
131 : }
132 :
133 0 : sal_Int16 SAL_CALL VCLXAccessibleHeaderBar::getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
134 : {
135 0 : return com::sun::star::accessibility::AccessibleRole::LIST;
136 : }
137 :
138 0 : void SAL_CALL VCLXAccessibleHeaderBar::disposing()
139 : {
140 0 : SolarMutexGuard g;
141 :
142 0 : ListItems().swap(m_aAccessibleChildren);
143 0 : VCLXAccessibleComponent::disposing();
144 0 : }
145 :
146 0 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > VCLXAccessibleHeaderBar::CreateChild (sal_Int32 i)
147 : {
148 0 : Reference<XAccessible> xChild;
149 :
150 0 : sal_uInt16 nPos = static_cast<sal_uInt16>(i);
151 0 : if ( nPos >= m_aAccessibleChildren.size() )
152 : {
153 0 : m_aAccessibleChildren.resize(nPos + 1);
154 :
155 : // insert into the container
156 0 : xChild = new VCLXAccessibleHeaderBarItem(m_pHeadBar, i);
157 0 : m_aAccessibleChildren[nPos] = xChild;
158 : }
159 : else
160 : {
161 0 : xChild = m_aAccessibleChildren[nPos];
162 : // check if position is empty and can be used else we have to adjust all entries behind this
163 0 : if ( !xChild.is() )
164 : {
165 0 : xChild = new VCLXAccessibleHeaderBarItem(m_pHeadBar, i);
166 0 : m_aAccessibleChildren[nPos] = xChild;
167 : }
168 : }
169 0 : return xChild;
170 : }
171 :
172 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|