LibreOffice Module dbaccess (master) 1
TableWindowAccess.cxx
Go to the documentation of this file.
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 <TableWindowAccess.hxx>
21#include <TableWindow.hxx>
23#include <JoinTableView.hxx>
24#include <com/sun/star/accessibility/AccessibleRole.hpp>
25#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
26#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
27#include <vcl/vclevent.hxx>
28
29namespace dbaui
30{
31 using namespace ::com::sun::star::accessibility;
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::beans;
34 using namespace ::com::sun::star::lang;
35 using namespace ::com::sun::star;
36
38 :ImplInheritanceHelper(_pTable->GetComponentInterface().is() ? _pTable->GetWindowPeer() : nullptr)
39 ,m_pTable(_pTable)
40 {
41 }
43 {
44 m_pTable = nullptr;
45 VCLXAccessibleComponent::disposing();
46 }
48 {
49 if ( rVclWindowEvent.GetId() == VclEventId::ObjectDying )
50 {
51 ::osl::MutexGuard aGuard( m_aMutex );
52 m_pTable = nullptr;
53 }
54
55 VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
56 }
58 {
59 return "org.openoffice.comp.dbu.TableWindowAccessibility";
60 }
62 {
63 return { "com.sun.star.accessibility.Accessible",
64 "com.sun.star.accessibility.AccessibleContext" };
65 }
66 // XAccessibleContext
68 {
69 ::osl::MutexGuard aGuard( m_aMutex );
70 sal_Int64 nCount = 0;
71 if(m_pTable)
72 {
73 ++nCount;
74 if(m_pTable->GetListBox())
75 ++nCount;
76 }
77 return nCount;
78 }
80 {
81 ::osl::MutexGuard aGuard( m_aMutex );
83 if (m_pTable && !m_pTable->isDisposed())
84 {
85 switch(i)
86 {
87 case 0:
88 {
89 VclPtr<OTableWindowTitle> xCtrl(m_pTable->GetTitleCtrl());
90 if (xCtrl)
91 aRet = xCtrl->GetAccessible();
92 break;
93 }
94 case 1:
95 {
96 VclPtr<OTableWindowListBox> xCtrl(m_pTable->GetListBox());
97 if (xCtrl)
98 aRet = xCtrl->GetAccessible();
99 break;
100 }
101 default:
102 throw IndexOutOfBoundsException();
103 }
104 }
105 return aRet;
106 }
108 {
109 ::osl::MutexGuard aGuard( m_aMutex );
110 sal_Int64 nIndex = -1;
111 if( m_pTable )
112 {
113 // search the position of our table window in the table window map
114 bool bFoundElem = false;
115 for (auto const& tabWin : m_pTable->getTableView()->GetTabWinMap())
116 {
117 if (tabWin.second == m_pTable)
118 {
119 bFoundElem = true;
120 break;
121 }
122 ++nIndex;
123 }
124 nIndex = bFoundElem? nIndex : -1;
125 }
126 return nIndex;
127 }
129 {
130 return AccessibleRole::PANEL; // ? or may be an AccessibleRole::WINDOW
131 }
133 {
134 ::osl::MutexGuard aGuard( m_aMutex );
135 return this;
136 }
137 // XAccessibleComponent
139 {
140 ::osl::MutexGuard aGuard( m_aMutex );
142 if(m_pTable && !m_pTable->isDisposed())
143 {
144 Point aPoint(_aPoint.X,_aPoint.Y);
145 tools::Rectangle aRect(m_pTable->GetDesktopRectPixel());
146 if( aRect.Contains(aPoint) )
147 aRet = this;
148 else if( m_pTable->GetListBox()->GetDesktopRectPixel().Contains(aPoint))
149 aRet = m_pTable->GetListBox()->GetAccessible();
150 }
151 return aRet;
152 }
154 {
156 Reference< XAccessible > xParent = getAccessibleParent();
157 if ( xParent.is() )
158 {
159 Reference< XAccessibleContext > xParentContext = xParent->getAccessibleContext();
160 if ( xParentContext.is() )
161 {
162 xReturn = xParentContext->getAccessibleChild(_nIndex);
163 }
164 }
165 return xReturn;
166 }
167
169 {
170 ::osl::MutexGuard aGuard( m_aMutex );
171 return m_pTable ? m_pTable->getTableView()->getConnectionCount(m_pTable) : sal_Int32(0);
172 }
173 AccessibleRelation SAL_CALL OTableWindowAccess::getRelation( sal_Int32 nIndex )
174 {
175 ::osl::MutexGuard aGuard( m_aMutex );
176 if( nIndex < 0 || nIndex >= getRelationCount() )
177 throw IndexOutOfBoundsException();
178
179 AccessibleRelation aRet;
180 if( m_pTable )
181 {
182 OJoinTableView* pView = m_pTable->getTableView();
183 auto aIter = pView->getTableConnections(m_pTable) + nIndex;
184 aRet.TargetSet = { getParentChild(aIter - pView->getTableConnections().begin()) };
185 aRet.RelationType = AccessibleRelationType::CONTROLLER_FOR;
186 }
187 return aRet;
188 }
189 sal_Bool SAL_CALL OTableWindowAccess::containsRelation( sal_Int16 aRelationType )
190 {
191 ::osl::MutexGuard aGuard( m_aMutex );
192 return AccessibleRelationType::CONTROLLER_FOR == aRelationType
193 && m_pTable && m_pTable->getTableView()->ExistsAConn(m_pTable);
194 }
195 AccessibleRelation SAL_CALL OTableWindowAccess::getRelationByType( sal_Int16 aRelationType )
196 {
197 ::osl::MutexGuard aGuard( m_aMutex );
198 if( AccessibleRelationType::CONTROLLER_FOR == aRelationType && m_pTable)
199 {
200 OJoinTableView* pView = m_pTable->getTableView();
201 const auto& rConnectionList = pView->getTableConnections();
202
203 auto aIter = pView->getTableConnections(m_pTable);
204 auto aEnd = rConnectionList.end();
205 std::vector< Reference<XInterface> > aRelations;
206 aRelations.reserve(5); // just guessing
207 // TODO JNA aIter comes from pView->getTableConnections(m_pTable)
208 // and aEnd comes from pView->getTableConnections().end()
209 for (; aIter != aEnd ; ++aIter )
210 {
211 uno::Reference<uno::XInterface> xInterface(
212 getParentChild(aIter - rConnectionList.begin()));
213 aRelations.push_back(xInterface);
214 }
215
216 Sequence< Reference<XInterface> > aSeq(aRelations.data(), aRelations.size());
217 return AccessibleRelation(AccessibleRelationType::CONTROLLER_FOR,aSeq);
218 }
219 return AccessibleRelation();
220 }
222 {
223 return getAccessibleName( );
224 }
226 {
227 ::osl::MutexGuard aGuard( m_aMutex );
228 OUString sAccessibleName;
229 if ( m_pTable )
230 sAccessibleName = m_pTable->getTitle();
231 return sAccessibleName;
232 }
234 {
235 return this;
236 }
237
238}
239
240/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
VclEventId GetId() const
const std::vector< VclPtr< OTableConnection > > & getTableConnections() const
gives a read only access to the connection vector
virtual void SAL_CALL disposing() override
this function is called upon disposing the component
OTableWindowAccess(OTableWindow *_pTable)
virtual OUString SAL_CALL getAccessibleName() override
virtual sal_Int64 SAL_CALL getAccessibleChildCount() override
css::uno::Reference< css::accessibility::XAccessible > getParentChild(sal_Int64 _nIndex)
virtual void ProcessWindowEvent(const VclWindowEvent &rVclWindowEvent) override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int64 i) override
virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() override
virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override
virtual sal_Int32 SAL_CALL getRelationCount() override
virtual css::accessibility::AccessibleRelation SAL_CALL getRelationByType(sal_Int16 aRelationType) override
virtual OUString SAL_CALL getImplementationName() override
virtual sal_Int16 SAL_CALL getAccessibleRole() override
virtual OUString SAL_CALL getTitledBorderText() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
VclPtr< OTableWindow > m_pTable
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override
virtual sal_Bool SAL_CALL containsRelation(sal_Int16 aRelationType) override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &aPoint) override
virtual css::accessibility::AccessibleRelation SAL_CALL getRelation(sal_Int32 nIndex) override
bool Contains(const Point &rPOINT) const
int nCount
std::mutex m_aMutex
sal_Int32 nIndex
Sequence< sal_Int8 > aSeq
int i
unsigned char sal_Bool