1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: _UserDefinedAttributeSupplier.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 import com
.sun
.star
.container
.XNameContainer
;
33 import com
.sun
.star
.uno
.AnyConverter
;
34 import com
.sun
.star
.uno
.Type
;
35 import com
.sun
.star
.xml
.AttributeData
;
37 public class _UserDefinedAttributeSupplier
extends lib
.MultiPropertyTest
{
39 public void _UserDefinedAttributes() {
40 XNameContainer uda
= null;
43 uda
= (XNameContainer
) AnyConverter
.toObject(
44 new Type(XNameContainer
.class),
45 oObj
.getPropertyValue("UserDefinedAttributes"));
46 AttributeData attr
= new AttributeData();
47 attr
.Namespace
= "http://www.sun.com/staroffice/apitest/Chartprop";
50 uda
.insertByName("Chartprop:has-first-alien-attribute",attr
);
51 String
[] els
= uda
.getElementNames();
52 oObj
.setPropertyValue("UserDefinedAttributes",uda
);
53 uda
= (XNameContainer
) AnyConverter
.toObject(
54 new Type(XNameContainer
.class),
55 oObj
.getPropertyValue("UserDefinedAttributes"));
56 els
= uda
.getElementNames();
57 Object obj
= uda
.getByName("Chartprop:has-first-alien-attribute");
59 } catch (com
.sun
.star
.beans
.UnknownPropertyException upe
) {
60 log
.println("Don't know the Property 'UserDefinedAttributes'");
61 } catch (com
.sun
.star
.lang
.WrappedTargetException wte
) {
62 log
.println("WrappedTargetException while getting Property 'UserDefinedAttributes'");
63 } catch (com
.sun
.star
.container
.NoSuchElementException nee
) {
64 log
.println("added Element isn't part of the NameContainer");
65 } catch (com
.sun
.star
.lang
.IllegalArgumentException iae
) {
66 log
.println("IllegalArgumentException while getting Property 'UserDefinedAttributes'");
67 } catch (com
.sun
.star
.beans
.PropertyVetoException pve
) {
68 log
.println("PropertyVetoException while getting Property 'UserDefinedAttributes'");
69 } catch (com
.sun
.star
.container
.ElementExistException eee
) {
70 log
.println("ElementExistException while getting Property 'UserDefinedAttributes'");
72 tRes
.tested("UserDefinedAttributes",res
);