1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 package complex.tdoc; 28 29 import com.sun.star.beans.XPropertyContainer; 30 import share.LogWriter; 31 32 /** 33 * 34 * @author sg128468 35 */ 36 public class _XPropertyContainer { 37 public XPropertyContainer oObj = null; 38 public LogWriter log = null; 39 40 public boolean _addProperty() { 41 boolean result = true; 42 // add illegal property 43 try { 44 oObj.addProperty("MyIllegalProperty", (short)0, null); 45 } 46 catch(com.sun.star.beans.PropertyExistException e) { 47 e.printStackTrace((java.io.PrintWriter)log); 48 result = false; 49 } 50 catch(com.sun.star.lang.IllegalArgumentException e) { 51 e.printStackTrace((java.io.PrintWriter)log); 52 log.println("'IllegalArgument' Unexpected but correct."); 53 } 54 catch(com.sun.star.beans.IllegalTypeException e) { 55 log.println("'IllegalType' Correctly thrown"); 56 } 57 // add valid property 58 try { 59 oObj.addProperty("MyLegalProperty", (short)0, "Just a value"); 60 } 61 catch(com.sun.star.beans.PropertyExistException e) { 62 e.printStackTrace((java.io.PrintWriter)log); 63 result = false; 64 } 65 catch(com.sun.star.lang.IllegalArgumentException e) { 66 e.printStackTrace((java.io.PrintWriter)log); 67 result = false; 68 } 69 catch(com.sun.star.beans.IllegalTypeException e) { 70 e.printStackTrace((java.io.PrintWriter)log); 71 result = false; 72 } 73 return result; 74 } 75 76 public boolean _removeProperty() { 77 boolean result = true; 78 try { 79 oObj.removeProperty("MyIllegalProperty"); 80 } 81 catch(com.sun.star.beans.UnknownPropertyException e) { 82 log.println("'UnknownProperty' Correctly thrown"); 83 } 84 catch(com.sun.star.beans.NotRemoveableException e) { 85 e.printStackTrace((java.io.PrintWriter)log); 86 result = false; 87 } 88 try { 89 oObj.removeProperty("MyLegalProperty"); 90 } 91 catch(com.sun.star.beans.UnknownPropertyException e) { 92 e.printStackTrace((java.io.PrintWriter)log); 93 result = false; 94 } 95 catch(com.sun.star.beans.NotRemoveableException e) { 96 e.printStackTrace((java.io.PrintWriter)log); 97 result = false; 98 } 99 return result; 100 } 101 102 } 103