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 package complex.tdoc; 24 25 import com.sun.star.beans.XPropertyContainer; 26 import share.LogWriter; 27 28 /** 29 * 30 * @author sg128468 31 */ 32 public class _XPropertyContainer { 33 public XPropertyContainer oObj = null; 34 public LogWriter log = null; 35 _addProperty()36 public boolean _addProperty() { 37 boolean result = true; 38 // add illegal property 39 try { 40 oObj.addProperty("MyIllegalProperty", (short)0, null); 41 } 42 catch(com.sun.star.beans.PropertyExistException e) { 43 e.printStackTrace((java.io.PrintWriter)log); 44 result = false; 45 } 46 catch(com.sun.star.lang.IllegalArgumentException e) { 47 e.printStackTrace((java.io.PrintWriter)log); 48 log.println("'IllegalArgument' Unexpected but correct."); 49 } 50 catch(com.sun.star.beans.IllegalTypeException e) { 51 log.println("'IllegalType' Correctly thrown"); 52 } 53 // add valid property 54 try { 55 oObj.addProperty("MyLegalProperty", (short)0, "Just a value"); 56 } 57 catch(com.sun.star.beans.PropertyExistException e) { 58 e.printStackTrace((java.io.PrintWriter)log); 59 result = false; 60 } 61 catch(com.sun.star.lang.IllegalArgumentException e) { 62 e.printStackTrace((java.io.PrintWriter)log); 63 result = false; 64 } 65 catch(com.sun.star.beans.IllegalTypeException e) { 66 e.printStackTrace((java.io.PrintWriter)log); 67 result = false; 68 } 69 return result; 70 } 71 _removeProperty()72 public boolean _removeProperty() { 73 boolean result = true; 74 try { 75 oObj.removeProperty("MyIllegalProperty"); 76 } 77 catch(com.sun.star.beans.UnknownPropertyException e) { 78 log.println("'UnknownProperty' Correctly thrown"); 79 } 80 catch(com.sun.star.beans.NotRemoveableException e) { 81 e.printStackTrace((java.io.PrintWriter)log); 82 result = false; 83 } 84 try { 85 oObj.removeProperty("MyLegalProperty"); 86 } 87 catch(com.sun.star.beans.UnknownPropertyException e) { 88 e.printStackTrace((java.io.PrintWriter)log); 89 result = false; 90 } 91 catch(com.sun.star.beans.NotRemoveableException e) { 92 e.printStackTrace((java.io.PrintWriter)log); 93 result = false; 94 } 95 return result; 96 } 97 98 } 99