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.document;
25 
26 
27 import lib.MultiMethodTest;
28 import lib.Status;
29 import lib.StatusException;
30 
31 import com.sun.star.document.XExporter;
32 import com.sun.star.lang.XComponent;
33 
34 /**
35 * Testing <code>com.sun.star.document.XExporter</code>
36 * interface methods :
37 * <ul>
38 *  <li><code> setSourceDocument()</code></li>
39 * </ul> <p>
40 * This test needs the following object relations :
41 * <ul>
42 *  <li> <code>'SourceDocument'</code> (of type <code>XComponent</code>):
43 *   the source document to be passed to the method. </li>
44 * <ul> <p>
45 * Test is <b> NOT </b> multithread compilant. <p>
46 * @see com.sun.star.document.XExporter
47 */
48 public class _XExporter extends MultiMethodTest {
49 
50     public XExporter oObj = null;
51     public XComponent source = null ;
52 
53     /**
54     * Retrieves object relations.
55     * @throws StatusException If one of relations not found.
56     */
before()57     public void before() {
58         source = (XComponent) tEnv.getObjRelation("SourceDocument") ;
59 
60         if (source == null) throw new StatusException(Status.failed
61             ("Relation not found")) ;
62     }
63 
64     /**
65     * Just calls the method. <p>
66     * Has <b> OK </b> status if no runtime exceptions occured.
67         * Usually this interface is supported both with <code>XFilter</code>
68         * where source document setting is checked.
69     */
_setSourceDocument()70     public void _setSourceDocument() {
71         boolean result = true ;
72 
73         try {
74             oObj.setSourceDocument(source);
75         }
76         catch (com.sun.star.lang.IllegalArgumentException ex) {
77             log.println("Exception while checking :");
78             ex.printStackTrace(log);
79             result = false;
80         }
81 
82         tRes.tested("setSourceDocument()", result) ;
83     }
84 }
85 
86 
87