2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 package ifc
.form
.binding
;
20 import com
.sun
.star
.form
.binding
.XBindableValue
;
21 import com
.sun
.star
.form
.binding
.XValueBinding
;
22 import com
.sun
.star
.uno
.Type
;
24 import java
.util
.ArrayList
;
26 import lib
.MultiMethodTest
;
29 public class _XBindableValue
extends MultiMethodTest
{
30 public XBindableValue oObj
;
31 protected XValueBinding xValueBinding
= null;
33 public void _getValueBinding() {
34 requiredMethod("setValueBinding");
37 xValueBinding
= oObj
.getValueBinding();
38 res
&= checkValueBinding(xValueBinding
);
39 tRes
.tested("getValueBinding()", res
);
42 public void _setValueBinding() {
46 oObj
.setValueBinding(new MyValueBinding());
47 rightOne
= (String
) oObj
.getValueBinding().getValue(null);
48 } catch (com
.sun
.star
.form
.binding
.IncompatibleTypesException e
) {
52 boolean res
= rightOne
.equals("MyValueBinding");
55 log
.println("Excepted: MyValueBinding");
56 log
.println("getting: " + rightOne
);
59 tRes
.tested("setValueBinding()", res
);
62 protected boolean checkValueBinding(XValueBinding xValueBinding
) {
64 Type
[] types
= xValueBinding
.getSupportedValueTypes();
65 log
.println("Checking: ");
67 for (int i
= 0; i
< types
.length
; i
++) {
68 log
.println("\t" + types
[i
].getTypeName());
70 boolean localRes
= xValueBinding
.supportsType(types
[i
]);
73 log
.println("\t\tsupportsType returns false -- FAILED");
75 log
.println("\t\tis supported -- OK");
84 class MyValueBinding
implements XValueBinding
{
85 private Type
[] TypeArray
;
86 private final ArrayList
<Type
> types
= new ArrayList
<Type
>();
88 public com
.sun
.star
.uno
.Type
[] getSupportedValueTypes() {
92 public Object
getValue(com
.sun
.star
.uno
.Type type
)
93 throws com
.sun
.star
.form
.binding
.IncompatibleTypesException
{
94 return "MyValueBinding";
97 public void setValue(Object obj
)
98 throws com
.sun
.star
.form
.binding
.IncompatibleTypesException
,
99 com
.sun
.star
.lang
.NoSupportException
{
102 public boolean supportsType(com
.sun
.star
.uno
.Type type
) {
104 TypeArray
= new Type
[types
.size()];
106 for (int i
= 0; i
< types
.size(); i
++) {
107 TypeArray
[i
] = (Type
) types
.toArray()[i
];