1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include "AccRelation.h"
24 #include <vcl/svapp.hxx>
26 #include <com/sun/star/accessibility/XAccessible.hpp>
27 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
28 #include "MAccessible.h"
30 using namespace com::sun::star::accessibility
;
31 using namespace com::sun::star::uno
;
35 * @param relationType Variant to get relation type.
38 STDMETHODIMP
CAccRelation::get_relationType(BSTR
* relationType
)
44 if (relationType
== NULL
)
47 int type
= relation
.RelationType
;
48 SAFE_SYSFREESTRING(*relationType
);
50 *relationType
= getRelationTypeBSTR(type
);
56 // Gets what the type of localized relation is.
57 STDMETHODIMP
CAccRelation::get_localizedRelationType(BSTR
*)
70 * @param nTargets Variant to get targets length.
73 STDMETHODIMP
CAccRelation::get_nTargets(long * nTargets
)
82 Sequence
< Reference
< XInterface
> > xTargets
= relation
.TargetSet
;
83 *nTargets
= xTargets
.getLength();
91 * @param targetIndex target index.
92 * @param target Variant to get special target.
95 STDMETHODIMP
CAccRelation::get_target(long targetIndex
, IUnknown
* * target
)
104 Sequence
< Reference
< XInterface
> > xTargets
= relation
.TargetSet
;
105 int nCount
= xTargets
.getLength();
106 if( targetIndex
>= nCount
)
109 Reference
<XAccessible
> xRAcc(xTargets
[targetIndex
], UNO_QUERY
);
110 IAccessible
* pRet
= NULL
;
112 BOOL isGet
= CMAccessible::get_IAccessibleFromXAccessible(xRAcc
.get(), &pRet
);
115 *target
= /*(IAccessible2 *)*/(IUnknown
*)pRet
;
122 LEAVE_PROTECTED_BLOCK
126 * Get special targets.
127 * @param maxTargets Special targets count.
128 * @param target Variant to get special target.
129 * @param nTargets Variant to accept actual target length.
132 STDMETHODIMP
CAccRelation::get_targets(long, IUnknown
* * target
, long * nTargets
)
136 ENTER_PROTECTED_BLOCK
141 if (nTargets
== NULL
)
144 Sequence
< Reference
< XInterface
> > xTargets
= relation
.TargetSet
;
145 int nCount
= xTargets
.getLength();
147 *target
= (IUnknown
*)::CoTaskMemAlloc(nCount
*sizeof(IUnknown
));
149 // #CHECK Memory Allocation#
155 for(int i
=0; i
<nCount
; i
++)
157 IUnknown
* pAcc
= NULL
;
158 HRESULT hr
= get_target(i
,&pAcc
);
166 LEAVE_PROTECTED_BLOCK
171 * @param pXSubInterface AccessibleRelation pointer.
174 STDMETHODIMP
CAccRelation::put_XSubInterface(hyper pXSubInterface
)
176 // internal IUNOXWrapper - no mutex meeded
178 relation
= *reinterpret_cast<AccessibleRelation
*>(pXSubInterface
);
183 * Get relation type string by type.
184 * @param type Relation type.
185 * @return relation type string.
187 BSTR
CAccRelation::getRelationTypeBSTR(int type
)
189 static struct TYPE_BSTR_MAP
197 {IA2_RELATION_FLOWS_FROM
, 1},
198 {IA2_RELATION_FLOWS_TO
, 2},
199 {IA2_RELATION_CONTROLLED_BY
, 3},
200 {IA2_RELATION_CONTROLLER_FOR
, 4},
201 {IA2_RELATION_LABEL_FOR
, 5},
202 {IA2_RELATION_LABELED_BY
, 6},
203 {IA2_RELATION_MEMBER_OF
, 7},
204 {IA2_RELATION_SUBWINDOW_OF
, 8},
205 {IA2_RELATION_NODE_CHILD_OF
, 9},
206 {IA2_RELATION_DESCRIBED_BY
, 10},
209 return ::SysAllocString((type
>= 0 && type
<= 10) ? map
[type
].string
: _T(""));
212 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */