1ef39d40dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3ef39d40dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4ef39d40dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5ef39d40dSAndrew Rist  * distributed with this work for additional information
6ef39d40dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7ef39d40dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8ef39d40dSAndrew Rist  * "License"); you may not use this file except in compliance
9ef39d40dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10ef39d40dSAndrew Rist  *
11ef39d40dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12ef39d40dSAndrew Rist  *
13ef39d40dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14ef39d40dSAndrew Rist  * software distributed under the License is distributed on an
15ef39d40dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16ef39d40dSAndrew Rist  * KIND, either express or implied.  See the License for the
17ef39d40dSAndrew Rist  * specific language governing permissions and limitations
18ef39d40dSAndrew Rist  * under the License.
19ef39d40dSAndrew Rist  *
20ef39d40dSAndrew Rist  *************************************************************/
21ef39d40dSAndrew Rist 
22ef39d40dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir package ifc.frame;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir import lib.MultiMethodTest;
27cdf0e10cSrcweir 
28cdf0e10cSrcweir import com.sun.star.beans.PropertyState;
29cdf0e10cSrcweir import com.sun.star.beans.PropertyValue;
30cdf0e10cSrcweir import com.sun.star.frame.XComponentLoader;
31cdf0e10cSrcweir import com.sun.star.lang.XComponent;
32cdf0e10cSrcweir 
33cdf0e10cSrcweir 
34cdf0e10cSrcweir /**
35cdf0e10cSrcweir * Testing <code>com.sun.star.frame.XComponentLoader</code>
36cdf0e10cSrcweir * interface methods:
37cdf0e10cSrcweir * <ul>
38cdf0e10cSrcweir *  <li><code> loadComponentFromURL() </code></li>
39cdf0e10cSrcweir * </ul><p>
40cdf0e10cSrcweir * Test is <b> NOT </b> multithread compilant. <p>
41cdf0e10cSrcweir * @see com.sun.star.frame.XComponentLoader
42cdf0e10cSrcweir */
43cdf0e10cSrcweir public class _XComponentLoader extends MultiMethodTest {
44cdf0e10cSrcweir     public XComponentLoader oObj = null; // oObj filled by MultiMethodTest
45cdf0e10cSrcweir 
46cdf0e10cSrcweir     /**
47cdf0e10cSrcweir     * Method which tests the objects ability to load a
48cdf0e10cSrcweir     * component from URL. All available components are loaded by turns. <p>
49cdf0e10cSrcweir     * Has <b> OK </b> status if the method successfully returns
50cdf0e10cSrcweir     * and no exceptions were thrown. <p>
51cdf0e10cSrcweir     * @see XComponent
52cdf0e10cSrcweir     */
_loadComponentFromURL()53cdf0e10cSrcweir     public void _loadComponentFromURL() {
54cdf0e10cSrcweir         boolean result = true;
55cdf0e10cSrcweir 
56cdf0e10cSrcweir         log.println("testing loadComponentFromURL() ... ");
57cdf0e10cSrcweir         try {
58cdf0e10cSrcweir             PropertyValue [] szEmptyArgs = new PropertyValue [0];
59cdf0e10cSrcweir             String frameName = "_blank";
60cdf0e10cSrcweir             XComponent oDoc = null;
61cdf0e10cSrcweir 
62cdf0e10cSrcweir             log.println("load writer doc that contains links");
63cdf0e10cSrcweir             PropertyValue [] szArgs = new PropertyValue [1];
64cdf0e10cSrcweir             PropertyValue Arg = new PropertyValue();
65cdf0e10cSrcweir             Arg.Name = "UpdateDocMode";
66cdf0e10cSrcweir             Arg.Value = new Short(com.sun.star.document.UpdateDocMode.NO_UPDATE);
67cdf0e10cSrcweir             szArgs[0]=Arg;
68cdf0e10cSrcweir             String url = util.utils.getFullTestURL("Writer_link.sxw");
69cdf0e10cSrcweir             log.println("try to load '" + url + "'");
70cdf0e10cSrcweir             oDoc = oObj.loadComponentFromURL(
71cdf0e10cSrcweir                             url, frameName, 0, szArgs);
72cdf0e10cSrcweir 
73cdf0e10cSrcweir             try {
74cdf0e10cSrcweir                 Thread.sleep(500);
75cdf0e10cSrcweir             }
76cdf0e10cSrcweir             catch (InterruptedException ex) {
77cdf0e10cSrcweir             }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir             oDoc.dispose();
80cdf0e10cSrcweir 
81cdf0e10cSrcweir             url = util.utils.getFullTestURL("Calc_Link.sxc");
82cdf0e10cSrcweir             log.println("try to load '" + url + "'");
83cdf0e10cSrcweir             oDoc = oObj.loadComponentFromURL(
84cdf0e10cSrcweir                             url, frameName, 0, szArgs);
85cdf0e10cSrcweir 
86cdf0e10cSrcweir             try {
87cdf0e10cSrcweir                 Thread.sleep(500);
88cdf0e10cSrcweir             }
89cdf0e10cSrcweir             catch (InterruptedException ex) {
90cdf0e10cSrcweir             }
91cdf0e10cSrcweir 
92cdf0e10cSrcweir             oDoc.dispose();
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 
96cdf0e10cSrcweir             log.println("load a blank impress doc");
97cdf0e10cSrcweir             Arg.Name = "OpenFlags";
98cdf0e10cSrcweir             Arg.Value = "S";
99cdf0e10cSrcweir             Arg.Handle = -1;
100cdf0e10cSrcweir             Arg.State = PropertyState.DEFAULT_VALUE;
101cdf0e10cSrcweir             szArgs[0]=Arg;
102cdf0e10cSrcweir             oDoc = oObj.loadComponentFromURL(
103cdf0e10cSrcweir                             "private:factory/simpress", frameName, 0, szArgs );
104cdf0e10cSrcweir 
105cdf0e10cSrcweir             log.println("disposing impress doc");
106cdf0e10cSrcweir             oDoc.dispose();
107cdf0e10cSrcweir 
108cdf0e10cSrcweir             log.println("load a blank writer doc");
109cdf0e10cSrcweir             oDoc = oObj.loadComponentFromURL(
110cdf0e10cSrcweir                         "private:factory/swriter", frameName, 0, szEmptyArgs );
111cdf0e10cSrcweir 
112cdf0e10cSrcweir             log.println("disposing writer doc");
113cdf0e10cSrcweir             oDoc.dispose();
114cdf0e10cSrcweir 
115cdf0e10cSrcweir             log.println("load a blank calc doc");
116cdf0e10cSrcweir             oDoc = oObj.loadComponentFromURL(
117cdf0e10cSrcweir                         "private:factory/scalc", frameName, 0, szEmptyArgs );
118cdf0e10cSrcweir 
119cdf0e10cSrcweir             log.println("disposing calc doc");
120cdf0e10cSrcweir             oDoc.dispose();
121cdf0e10cSrcweir 
122cdf0e10cSrcweir             log.println("load a blank draw doc");
123cdf0e10cSrcweir             oDoc = oObj.loadComponentFromURL(
124cdf0e10cSrcweir                         "private:factory/sdraw", frameName, 0, szEmptyArgs );
125cdf0e10cSrcweir 
126cdf0e10cSrcweir             log.println("disposing draw doc");
127cdf0e10cSrcweir             oDoc.dispose();
128cdf0e10cSrcweir 
129cdf0e10cSrcweir             log.println("load a blank math doc");
130cdf0e10cSrcweir             oDoc = oObj.loadComponentFromURL(
131cdf0e10cSrcweir                         "private:factory/smath", frameName, 0, szEmptyArgs );
132cdf0e10cSrcweir 
133cdf0e10cSrcweir             log.println("disposing math doc");
134cdf0e10cSrcweir             oDoc.dispose();
135cdf0e10cSrcweir 
136cdf0e10cSrcweir         }
137cdf0e10cSrcweir         catch (com.sun.star.lang.IllegalArgumentException e) {
138*bb6af6bcSPedro Giffuni             log.println("Exception occurred while loading");
139cdf0e10cSrcweir             e.printStackTrace(log);
140cdf0e10cSrcweir             result=false;
141cdf0e10cSrcweir         }
142cdf0e10cSrcweir         catch (com.sun.star.io.IOException e) {
143*bb6af6bcSPedro Giffuni             log.println("Exception occurred while loading");
144cdf0e10cSrcweir             e.printStackTrace(log);
145cdf0e10cSrcweir             result=false;
146cdf0e10cSrcweir         }
147cdf0e10cSrcweir 
148cdf0e10cSrcweir         tRes.tested("loadComponentFromURL()", result);
149cdf0e10cSrcweir         return;
150cdf0e10cSrcweir     }
151cdf0e10cSrcweir 
152cdf0e10cSrcweir }
153cdf0e10cSrcweir 
154