LibreOffice Module winaccessibility (master) 1
AccRelation.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 "stdafx.h"
21#include <UAccCOM.h>
22#include "AccRelation.h"
23
24#include <vcl/svapp.hxx>
25
26#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
27#include <com/sun/star/accessibility/XAccessible.hpp>
28#include <com/sun/star/accessibility/XAccessibleContext.hpp>
29#include "MAccessible.h"
30
31using namespace com::sun::star::accessibility;
32using namespace com::sun::star::uno;
33
39COM_DECLSPEC_NOTHROW STDMETHODIMP CAccRelation::get_relationType(BSTR * relationType)
40{
42
43 try {
44
45 if (relationType == nullptr)
46 return E_INVALIDARG;
47
48 int type = relation.RelationType;
49 SysFreeString(*relationType);
50
52 return S_OK;
53
54 } catch(...) { return E_FAIL; }
55}
56
57// Gets what the type of localized relation is.
58COM_DECLSPEC_NOTHROW STDMETHODIMP CAccRelation::get_localizedRelationType(BSTR *)
59{
60
61
62 try {
63
64 return S_OK;
65
66 } catch(...) { return E_FAIL; }
67}
68
74COM_DECLSPEC_NOTHROW STDMETHODIMP CAccRelation::get_nTargets(long * nTargets)
75{
77
78 try {
79
80 if (nTargets == nullptr)
81 return E_INVALIDARG;
82
83 Sequence< Reference< XInterface > > xTargets = relation.TargetSet;
84 *nTargets = xTargets.getLength();
85 return S_OK;
86
87 } catch(...) { return E_FAIL; }
88}
89
96COM_DECLSPEC_NOTHROW STDMETHODIMP CAccRelation::get_target(long targetIndex, IUnknown * * target)
97{
99
100 try {
101
102 if (target == nullptr)
103 return E_FAIL;
104
105 Sequence< Reference< XInterface > > xTargets = relation.TargetSet;
106 int nCount = xTargets.getLength();
107 if( targetIndex >= nCount )
108 return E_FAIL;
109
110 Reference<XAccessible> xRAcc(xTargets[targetIndex], UNO_QUERY);
111 IAccessible* pRet = nullptr;
112
113 bool isGet = CMAccessible::get_IAccessibleFromXAccessible(xRAcc.get(), &pRet);
114 if(isGet)
115 {
116 *target = /*(IAccessible2 *)*/pRet;
117 pRet->AddRef();
118 return S_OK;
119 }
120
121 return E_FAIL;
122
123 } catch(...) { return E_FAIL; }
124}
125
133COM_DECLSPEC_NOTHROW STDMETHODIMP CAccRelation::get_targets(long, IUnknown * * target, long * nTargets)
134{
136
137 try {
138
139 // #CHECK#
140 if(target == nullptr)
141 return E_INVALIDARG;
142 if (nTargets == nullptr)
143 return E_INVALIDARG;
144
145 Sequence< Reference< XInterface > > xTargets = relation.TargetSet;
146 int nCount = xTargets.getLength();
147
148 *target = static_cast<IUnknown*>(::CoTaskMemAlloc(nCount*sizeof(IUnknown)));
149
150 // #CHECK Memory Allocation#
151 if(*target == nullptr)
152 {
153 return E_FAIL;
154 }
155
156 for(int i=0; i<nCount ; i++)
157 {
158 IUnknown* pAcc = nullptr;
159 HRESULT hr = get_target(i,&pAcc);
160 if(SUCCEEDED(hr))
161 target[i] = pAcc;
162 }
163
164 *nTargets = nCount;
165 return S_OK;
166
167 } catch(...) { return E_FAIL; }
168}
169
175COM_DECLSPEC_NOTHROW STDMETHODIMP CAccRelation::put_XSubInterface(hyper pXSubInterface)
176{
177 // internal IUNOXWrapper - no mutex meeded
178
179 relation = *reinterpret_cast<AccessibleRelation*>(pXSubInterface);
180 return S_OK;
181}
182
189{
190 static LPCWSTR map[] =
191 {
192 L"INVALID", // AccessibleRelationType::INVALID
193 IA2_RELATION_FLOWS_FROM, // AccessibleRelationType::CONTENT_FLOWS_FROM
194 IA2_RELATION_FLOWS_TO, // AccessibleRelationType::CONTENT_FLOWS_TO
195 IA2_RELATION_CONTROLLED_BY, // AccessibleRelationType::CONTROLLED_BY
196 IA2_RELATION_CONTROLLER_FOR, // AccessibleRelationType::CONTROLLER_FOR
197 IA2_RELATION_LABEL_FOR, // AccessibleRelationType::LABEL_FOR
198 IA2_RELATION_LABELED_BY, // AccessibleRelationType::LABELED_BY
199 IA2_RELATION_MEMBER_OF, // AccessibleRelationType::MEMBER_OF
200 IA2_RELATION_SUBWINDOW_OF, // AccessibleRelationType::SUB_WINDOW_OF
201 IA2_RELATION_NODE_CHILD_OF, // AccessibleRelationType::NODE_CHILD_OF
202 IA2_RELATION_DESCRIBED_BY // AccessibleRelationType::DESCRIBED_BY
203 };
204
205 return ::SysAllocString( (type >= AccessibleRelationType::INVALID && type <= AccessibleRelationType::DESCRIBED_BY)
206 ? map[type] : L"");
207}
208
209/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
STDMETHOD() get_relationType(BSTR *relationType) override
Get relation type.
Definition: AccRelation.cxx:39
STDMETHOD() put_XSubInterface(hyper pXSubInterface) override
Put UNO interface.
STDMETHOD() get_targets(long maxTargets, IUnknown **target, long *nTargets) override
Get special targets.
css::accessibility::AccessibleRelation relation
Definition: AccRelation.h:88
STDMETHOD() get_target(long targetIndex, IUnknown **target) override
Get special target.
Definition: AccRelation.cxx:96
STDMETHOD() get_localizedRelationType(BSTR *relationType) override
Definition: AccRelation.cxx:58
static BSTR getRelationTypeBSTR(int type)
Get relation type string by type.
STDMETHOD() get_nTargets(long *nTargets) override
Get targets length.
Definition: AccRelation.cxx:74
static bool get_IAccessibleFromXAccessible(css::accessibility::XAccessible *pXAcc, IAccessible **ppIA)
int nCount
const WCHAR *const IA2_RELATION_CONTROLLED_BY
Some attribute of this object is affected by a target object.
const WCHAR *const IA2_RELATION_NODE_CHILD_OF
This object is a logical child of a target object.
const WCHAR *const IA2_RELATION_DESCRIBED_BY
This object is described by the target object.
const WCHAR *const IA2_RELATION_SUBWINDOW_OF
This object is a sub window of a target object.
const WCHAR *const IA2_RELATION_FLOWS_TO
Content flows from this object to a target object.
const WCHAR *const IA2_RELATION_LABELED_BY
This object is labelled by a target object.
const WCHAR *const IA2_RELATION_MEMBER_OF
This object is a member of a group of one or more objects.
const WCHAR *const IA2_RELATION_CONTROLLER_FOR
This object is interactive and controls some attribute of a target object.
const WCHAR *const IA2_RELATION_LABEL_FOR
This object is label for a target object.
const WCHAR *const IA2_RELATION_FLOWS_FROM
Content flows to this object from a target object.
long nTargets
Returns the number of targets for this relation.
IUnknown target([in] long targetIndex)
Returns one accessible relation target.
BSTR relationType
Returns the type of the relation.
int i
return hr
std::map< OUString, rtl::Reference< Entity > > map
ResultType type