1*c07c6c98SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*c07c6c98SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*c07c6c98SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*c07c6c98SAndrew Rist  * distributed with this work for additional information
6*c07c6c98SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*c07c6c98SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*c07c6c98SAndrew Rist  * "License"); you may not use this file except in compliance
9*c07c6c98SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*c07c6c98SAndrew Rist  *
11*c07c6c98SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*c07c6c98SAndrew Rist  *
13*c07c6c98SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*c07c6c98SAndrew Rist  * software distributed under the License is distributed on an
15*c07c6c98SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c07c6c98SAndrew Rist  * KIND, either express or implied.  See the License for the
17*c07c6c98SAndrew Rist  * specific language governing permissions and limitations
18*c07c6c98SAndrew Rist  * under the License.
19*c07c6c98SAndrew Rist  *
20*c07c6c98SAndrew Rist  *************************************************************/
21*c07c6c98SAndrew Rist 
22*c07c6c98SAndrew Rist 
23cdf0e10cSrcweir package complex.tdoc;
24cdf0e10cSrcweir 
25cdf0e10cSrcweir import com.sun.star.beans.XPropertyContainer;
26cdf0e10cSrcweir import share.LogWriter;
27cdf0e10cSrcweir 
28cdf0e10cSrcweir /**
29cdf0e10cSrcweir  *
30cdf0e10cSrcweir  * @author  sg128468
31cdf0e10cSrcweir  */
32cdf0e10cSrcweir public class _XPropertyContainer {
33cdf0e10cSrcweir     public XPropertyContainer oObj = null;
34cdf0e10cSrcweir     public LogWriter log = null;
35cdf0e10cSrcweir 
_addProperty()36cdf0e10cSrcweir     public boolean _addProperty() {
37cdf0e10cSrcweir         boolean result = true;
38cdf0e10cSrcweir         // add illegal property
39cdf0e10cSrcweir         try {
40cdf0e10cSrcweir             oObj.addProperty("MyIllegalProperty", (short)0, null);
41cdf0e10cSrcweir         }
42cdf0e10cSrcweir         catch(com.sun.star.beans.PropertyExistException e) {
43cdf0e10cSrcweir             e.printStackTrace((java.io.PrintWriter)log);
44cdf0e10cSrcweir             result = false;
45cdf0e10cSrcweir         }
46cdf0e10cSrcweir         catch(com.sun.star.lang.IllegalArgumentException e) {
47cdf0e10cSrcweir             e.printStackTrace((java.io.PrintWriter)log);
48cdf0e10cSrcweir             log.println("'IllegalArgument' Unexpected but correct.");
49cdf0e10cSrcweir         }
50cdf0e10cSrcweir         catch(com.sun.star.beans.IllegalTypeException e) {
51cdf0e10cSrcweir             log.println("'IllegalType' Correctly thrown");
52cdf0e10cSrcweir         }
53cdf0e10cSrcweir         // add valid property
54cdf0e10cSrcweir         try {
55cdf0e10cSrcweir             oObj.addProperty("MyLegalProperty", (short)0, "Just a value");
56cdf0e10cSrcweir         }
57cdf0e10cSrcweir         catch(com.sun.star.beans.PropertyExistException e) {
58cdf0e10cSrcweir             e.printStackTrace((java.io.PrintWriter)log);
59cdf0e10cSrcweir             result = false;
60cdf0e10cSrcweir         }
61cdf0e10cSrcweir         catch(com.sun.star.lang.IllegalArgumentException e) {
62cdf0e10cSrcweir             e.printStackTrace((java.io.PrintWriter)log);
63cdf0e10cSrcweir             result = false;
64cdf0e10cSrcweir         }
65cdf0e10cSrcweir         catch(com.sun.star.beans.IllegalTypeException e) {
66cdf0e10cSrcweir             e.printStackTrace((java.io.PrintWriter)log);
67cdf0e10cSrcweir             result = false;
68cdf0e10cSrcweir         }
69cdf0e10cSrcweir         return result;
70cdf0e10cSrcweir     }
71cdf0e10cSrcweir 
_removeProperty()72cdf0e10cSrcweir     public boolean _removeProperty() {
73cdf0e10cSrcweir         boolean result = true;
74cdf0e10cSrcweir         try {
75cdf0e10cSrcweir             oObj.removeProperty("MyIllegalProperty");
76cdf0e10cSrcweir         }
77cdf0e10cSrcweir         catch(com.sun.star.beans.UnknownPropertyException e) {
78cdf0e10cSrcweir             log.println("'UnknownProperty' Correctly thrown");
79cdf0e10cSrcweir         }
80cdf0e10cSrcweir         catch(com.sun.star.beans.NotRemoveableException e) {
81cdf0e10cSrcweir             e.printStackTrace((java.io.PrintWriter)log);
82cdf0e10cSrcweir             result = false;
83cdf0e10cSrcweir         }
84cdf0e10cSrcweir         try {
85cdf0e10cSrcweir             oObj.removeProperty("MyLegalProperty");
86cdf0e10cSrcweir         }
87cdf0e10cSrcweir         catch(com.sun.star.beans.UnknownPropertyException e) {
88cdf0e10cSrcweir             e.printStackTrace((java.io.PrintWriter)log);
89cdf0e10cSrcweir             result = false;
90cdf0e10cSrcweir         }
91cdf0e10cSrcweir         catch(com.sun.star.beans.NotRemoveableException e) {
92cdf0e10cSrcweir             e.printStackTrace((java.io.PrintWriter)log);
93cdf0e10cSrcweir             result = false;
94cdf0e10cSrcweir         }
95cdf0e10cSrcweir         return result;
96cdf0e10cSrcweir     }
97cdf0e10cSrcweir 
98cdf0e10cSrcweir }
99