1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package ifc.xml;
25 import com.sun.star.container.XNameContainer;
26 import com.sun.star.uno.AnyConverter;
27 import com.sun.star.uno.Type;
28 import com.sun.star.xml.AttributeData;
29 
30 public class _UserDefinedAttributeSupplier extends lib.MultiPropertyTest {
31 
_UserDefinedAttributes()32     public void _UserDefinedAttributes() {
33         XNameContainer uda = null;
34         boolean res = false;
35         try {
36             uda = (XNameContainer) AnyConverter.toObject(
37                     new Type(XNameContainer.class),
38                         oObj.getPropertyValue("UserDefinedAttributes"));
39             AttributeData attr = new AttributeData();
40             attr.Namespace = "http://www.sun.com/staroffice/apitest/Chartprop";
41             attr.Type="CDATA";
42             attr.Value="true";
43             uda.insertByName("Chartprop:has-first-alien-attribute",attr);
44             String[] els = uda.getElementNames();
45             oObj.setPropertyValue("UserDefinedAttributes",uda);
46             uda = (XNameContainer) AnyConverter.toObject(
47                     new Type(XNameContainer.class),
48                         oObj.getPropertyValue("UserDefinedAttributes"));
49             els = uda.getElementNames();
50             Object obj = uda.getByName("Chartprop:has-first-alien-attribute");
51             res = true;
52         } catch (com.sun.star.beans.UnknownPropertyException upe) {
53             log.println("Don't know the Property 'UserDefinedAttributes'");
54         } catch (com.sun.star.lang.WrappedTargetException wte) {
55             log.println("WrappedTargetException while getting Property 'UserDefinedAttributes'");
56         } catch (com.sun.star.container.NoSuchElementException nee) {
57             log.println("added Element isn't part of the NameContainer");
58         } catch (com.sun.star.lang.IllegalArgumentException iae) {
59             log.println("IllegalArgumentException while getting Property 'UserDefinedAttributes'");
60         } catch (com.sun.star.beans.PropertyVetoException pve) {
61             log.println("PropertyVetoException while getting Property 'UserDefinedAttributes'");
62         } catch (com.sun.star.container.ElementExistException eee) {
63             log.println("ElementExistException while getting Property 'UserDefinedAttributes'");
64         }
65         tRes.tested("UserDefinedAttributes",res);
66     }
67 
68 }
69