1*c7cc89feSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*c7cc89feSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*c7cc89feSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*c7cc89feSAndrew Rist  * distributed with this work for additional information
6*c7cc89feSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*c7cc89feSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*c7cc89feSAndrew Rist  * "License"); you may not use this file except in compliance
9*c7cc89feSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*c7cc89feSAndrew Rist  *
11*c7cc89feSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*c7cc89feSAndrew Rist  *
13*c7cc89feSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*c7cc89feSAndrew Rist  * software distributed under the License is distributed on an
15*c7cc89feSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c7cc89feSAndrew Rist  * KIND, either express or implied.  See the License for the
17*c7cc89feSAndrew Rist  * specific language governing permissions and limitations
18*c7cc89feSAndrew Rist  * under the License.
19*c7cc89feSAndrew Rist  *
20*c7cc89feSAndrew Rist  *************************************************************/
21*c7cc89feSAndrew Rist 
22*c7cc89feSAndrew Rist 
23cdf0e10cSrcweir package complex.persistent_window_states;
24cdf0e10cSrcweir 
25cdf0e10cSrcweir import com.sun.star.uno.Any;
26cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory;
27cdf0e10cSrcweir import com.sun.star.frame.XFramesSupplier;
28cdf0e10cSrcweir import com.sun.star.frame.XFrames;
29cdf0e10cSrcweir import com.sun.star.container.XIndexAccess;
30cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
31cdf0e10cSrcweir import com.sun.star.uno.AnyConverter;
32cdf0e10cSrcweir import com.sun.star.frame.XComponentLoader;
33cdf0e10cSrcweir import com.sun.star.awt.Rectangle;
34cdf0e10cSrcweir import com.sun.star.util.XCloseable;
35cdf0e10cSrcweir import helper.ConfigurationRead;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir 
38cdf0e10cSrcweir 
39cdf0e10cSrcweir // import org.junit.After;
40cdf0e10cSrcweir import org.junit.AfterClass;
41cdf0e10cSrcweir // import org.junit.Before;
42cdf0e10cSrcweir import org.junit.BeforeClass;
43cdf0e10cSrcweir import org.junit.Test;
44cdf0e10cSrcweir import org.openoffice.test.OfficeConnection;
45cdf0e10cSrcweir import static org.junit.Assert.*;
46cdf0e10cSrcweir 
47cdf0e10cSrcweir /**
48cdf0e10cSrcweir  * Parameters:
49cdf0e10cSrcweir  * <ul>
50cdf0e10cSrcweir  *   <li>NoOffice=yes - StarOffice is not started initially.</li>
51cdf0e10cSrcweir  * </ul>
52cdf0e10cSrcweir  */
53cdf0e10cSrcweir public class PersistentWindowTest
54cdf0e10cSrcweir {
55cdf0e10cSrcweir 
56cdf0e10cSrcweir     // private XMultiServiceFactory xMSF;
57cdf0e10cSrcweir //    private OfficeProvider oProvider;
58cdf0e10cSrcweir     private int iOfficeCloseTime = 0;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir     /**
61cdf0e10cSrcweir      * A frunction to tell the framework, which test functions are available.
62cdf0e10cSrcweir      * Right now, it's only 'checkPersistentWindowState'.
63cdf0e10cSrcweir      * @return All test methods.
64cdf0e10cSrcweir      */
65cdf0e10cSrcweir //    public String[] getTestMethodNames()
66cdf0e10cSrcweir //    {
67cdf0e10cSrcweir //        return new String[]
68cdf0e10cSrcweir //                {
69cdf0e10cSrcweir //                    "checkPersistentWindowState"
70cdf0e10cSrcweir //                };
71cdf0e10cSrcweir //    }
72cdf0e10cSrcweir 
73cdf0e10cSrcweir    /**
74cdf0e10cSrcweir      * The test parameters
75cdf0e10cSrcweir      */
76cdf0e10cSrcweir   //  private static TestParameters param = null;
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     /**
79cdf0e10cSrcweir      * Test if all available document types change the
80cdf0e10cSrcweir      * persistent Window Attributes
81cdf0e10cSrcweir      *
82cdf0e10cSrcweir      * The test follows basically these steps:
83cdf0e10cSrcweir      * - Create a configuration reader and a componentloader
84cdf0e10cSrcweir      * - Look for all document types in the configuration
85cdf0e10cSrcweir      * - Do for every doc type
86cdf0e10cSrcweir      *   - start office
87cdf0e10cSrcweir      *   - read configuration attibute settings
88cdf0e10cSrcweir      *   - create a new document
89cdf0e10cSrcweir      *   - resize the document and close it
90cdf0e10cSrcweir      *   - close office
91cdf0e10cSrcweir      *   - start office
92cdf0e10cSrcweir      *   - read configuration attribute settings
93cdf0e10cSrcweir      *   - create another new document
94cdf0e10cSrcweir      *   - compare old settings with new ones: should be different
95cdf0e10cSrcweir      *   - compare the document size with the resized document: should be equal
96cdf0e10cSrcweir      *   - close office
97cdf0e10cSrcweir      * - Test finished
98cdf0e10cSrcweir      */
checkPersistentWindowState()99cdf0e10cSrcweir     @Test public void checkPersistentWindowState()
100cdf0e10cSrcweir     {
101cdf0e10cSrcweir         // final XMultiServiceFactory xMsf = getMSF();
102cdf0e10cSrcweir 
103cdf0e10cSrcweir         // some Tests need the qadevOOo TestParameters, it is like a Hashmap for Properties.
104cdf0e10cSrcweir //        param = new TestParameters();
105cdf0e10cSrcweir //        param.put("ServiceFactory", xMsf); // some qadevOOo functions need the ServiceFactory
106cdf0e10cSrcweir 
107cdf0e10cSrcweir         try
108cdf0e10cSrcweir         {
109cdf0e10cSrcweir 
110cdf0e10cSrcweir             // At first we are already connected
111cdf0e10cSrcweir             // if (!connect())
112cdf0e10cSrcweir             // {
113cdf0e10cSrcweir             //     return;
114cdf0e10cSrcweir             // }
115cdf0e10cSrcweir 
116cdf0e10cSrcweir             // fetch the multi service factory for setup
117cdf0e10cSrcweir             // XMultiServiceFactory xCP = getMSF();
118cdf0e10cSrcweir 
119cdf0e10cSrcweir             // create the configuration reader
120cdf0e10cSrcweir             // ConfigurationRead cfgRead = new ConfigurationRead(xCP);
121cdf0e10cSrcweir 
122cdf0e10cSrcweir             // just test the wrong ones, not all.
123cdf0e10cSrcweir             String[] els = new String[]
124cdf0e10cSrcweir             {
125cdf0e10cSrcweir                 "Office/Factories/com.sun.star.drawing.DrawingDocument",
126cdf0e10cSrcweir                 "Office/Factories/com.sun.star.formula.FormulaProperties",
127cdf0e10cSrcweir                 //"Office/Factories/com.sun.star.presentation.PresentationDocument",
128cdf0e10cSrcweir                 "Office/Factories/com.sun.star.sheet.SpreadsheetDocument",
129cdf0e10cSrcweir                 "Office/Factories/com.sun.star.text.GlobalDocument",
130cdf0e10cSrcweir                 "Office/Factories/com.sun.star.text.TextDocument",
131cdf0e10cSrcweir                 "Office/Factories/com.sun.star.text.WebDocument",
132cdf0e10cSrcweir             };
133cdf0e10cSrcweir             // uncomment the following line for all doc types
134cdf0e10cSrcweir             // String [] els = cfgRead.getSubNodeNames("Office/Factories");
135cdf0e10cSrcweir 
136cdf0e10cSrcweir             System.out.println("Found " + els.length + " document types to test.\n");
137cdf0e10cSrcweir             disconnect();
138cdf0e10cSrcweir 
139cdf0e10cSrcweir             // for all types
140cdf0e10cSrcweir             for (int i = 0; i < els.length; i++)
141cdf0e10cSrcweir             {
142cdf0e10cSrcweir                 System.out.println("\tStart test for document type " + i + ": " + els[i]);
143cdf0e10cSrcweir                 // exclude chart documents: cannot be created this way.
144cdf0e10cSrcweir                 if (els[i].indexOf("ChartDocument") != -1)
145cdf0e10cSrcweir                 {
146cdf0e10cSrcweir                     System.out.println("Skipping chart document: cannot be create like this.");
147cdf0e10cSrcweir                     continue;
148cdf0e10cSrcweir                 }
149cdf0e10cSrcweir 
150cdf0e10cSrcweir                 // start an office
151cdf0e10cSrcweir                 connect();
152cdf0e10cSrcweir 
153cdf0e10cSrcweir                 // get configuration
154cdf0e10cSrcweir                 String[] settings = getConfigurationAndLoader(getMSF(), els[i]);
155cdf0e10cSrcweir                 if (settings == null)
156cdf0e10cSrcweir                 {
157cdf0e10cSrcweir                     System.out.println("Skipping document type " + els[i]);
158cdf0e10cSrcweir                     disconnect();
159cdf0e10cSrcweir                     continue;
160cdf0e10cSrcweir                 }
161cdf0e10cSrcweir                 String cfg = settings[1];
162cdf0e10cSrcweir 
163cdf0e10cSrcweir                 // load a document
164cdf0e10cSrcweir                 DocumentHandle handle = loadDocument(getMSF(), settings[0]);
165cdf0e10cSrcweir 
166cdf0e10cSrcweir                 // first size
167cdf0e10cSrcweir                 Rectangle rect1 = handle.getDocumentPosSize();
168cdf0e10cSrcweir 
169cdf0e10cSrcweir                 // resize
170cdf0e10cSrcweir                 handle.resizeDocument();
171cdf0e10cSrcweir                 // after resize
172cdf0e10cSrcweir                 Rectangle rect2 = handle.getDocumentPosSize();
173cdf0e10cSrcweir 
174cdf0e10cSrcweir                 // disposeManager and start a new office
175cdf0e10cSrcweir                 disconnect();
176cdf0e10cSrcweir 
177cdf0e10cSrcweir                 connect();
178cdf0e10cSrcweir 
179cdf0e10cSrcweir                 // get configuration
180cdf0e10cSrcweir                 settings = getConfigurationAndLoader(getMSF(), els[i]);
181cdf0e10cSrcweir 
182cdf0e10cSrcweir                 String newCfg = settings[1];
183cdf0e10cSrcweir 
184cdf0e10cSrcweir                 // load a document
185cdf0e10cSrcweir                 handle = loadDocument(getMSF(), settings[0]);
186cdf0e10cSrcweir 
187cdf0e10cSrcweir                 Rectangle newRect = handle.getDocumentPosSize();
188cdf0e10cSrcweir 
189cdf0e10cSrcweir                 // print the settings and window sizes
190cdf0e10cSrcweir                 System.out.println("----------------------------");
191cdf0e10cSrcweir                 System.out.println("Initial Config String      : " + cfg);
192cdf0e10cSrcweir                 System.out.println("Config String after restart: " + newCfg);
193cdf0e10cSrcweir 
194cdf0e10cSrcweir                 System.out.println("----------------------------");
195cdf0e10cSrcweir                 System.out.println("Initial window       (X,Y,Width,Height): "
196cdf0e10cSrcweir                         + rect1.X + ";" + rect1.Y + ";" + rect1.Width + ";" + rect1.Height);
197cdf0e10cSrcweir                 System.out.println("Window after resize  (X,Y,Width,Height): "
198cdf0e10cSrcweir                         + rect2.X + ";" + rect2.Y + ";" + rect2.Width + ";" + rect2.Height);
199cdf0e10cSrcweir                 System.out.println("Window after restart (X,Y,Width,Height): "
200cdf0e10cSrcweir                         + newRect.X + ";" + newRect.Y + ";" + newRect.Width + ";"
201cdf0e10cSrcweir                         + newRect.Height);
202cdf0e10cSrcweir 
203cdf0e10cSrcweir                 // compare to see if resize worked
204cdf0e10cSrcweir                 System.out.println("----------------------------");
205cdf0e10cSrcweir                 if (els[i].indexOf("SpreadsheetDocument") == -1 &&
206cdf0e10cSrcweir                     els[i].indexOf("DrawingDocument") == -1)
207cdf0e10cSrcweir                 {
208cdf0e10cSrcweir                     // leave out Spreadsheet- and DrawingDocumnt
209cdf0e10cSrcweir                     assertTrue("Resize values for " + els[i] + " are equal.", !compareRectangles(rect1, rect2));
210cdf0e10cSrcweir                 }
211cdf0e10cSrcweir                 // compare settings and sizes
212cdf0e10cSrcweir                 assertTrue("Config settings for " + els[i] + " were not changed.", !cfg.equals(newCfg));
213cdf0e10cSrcweir                 assertTrue("Resized and restarted window for " + els[i] + " are not equal.", compareRectangles(rect2, newRect));
214cdf0e10cSrcweir                 System.out.println("----------------------------");
215cdf0e10cSrcweir 
216cdf0e10cSrcweir                 // disposeManager
217cdf0e10cSrcweir                 disconnect();
218cdf0e10cSrcweir 
219cdf0e10cSrcweir                 System.out.println("\tFinish test for document type " + i + ": " + els[i]);
220cdf0e10cSrcweir 
221cdf0e10cSrcweir             }
222cdf0e10cSrcweir         }
223cdf0e10cSrcweir         catch (Exception e)
224cdf0e10cSrcweir         {
225cdf0e10cSrcweir             e.printStackTrace();
226cdf0e10cSrcweir         }
227cdf0e10cSrcweir     }
228cdf0e10cSrcweir 
229cdf0e10cSrcweir     /**
230cdf0e10cSrcweir      * Get the configuration settings and the document loader
231cdf0e10cSrcweir      * @param  xMSF A MultiServiceFactory from an office
232cdf0e10cSrcweir      * @param cfgString A configuration string
233cdf0e10cSrcweir      * @return Settings and Loader
234cdf0e10cSrcweir      */
getConfigurationAndLoader(XMultiServiceFactory xMSF, String cfgString)235cdf0e10cSrcweir     private static String[] getConfigurationAndLoader(XMultiServiceFactory xMSF,
236cdf0e10cSrcweir             String cfgString)
237cdf0e10cSrcweir     {
238cdf0e10cSrcweir         String[] conf = new String[2];
239cdf0e10cSrcweir 
240cdf0e10cSrcweir         try
241cdf0e10cSrcweir         {
242cdf0e10cSrcweir             Object o = xMSF.createInstance(
243cdf0e10cSrcweir                     "com.sun.star.configuration.ConfigurationProvider");
244cdf0e10cSrcweir 
245cdf0e10cSrcweir             // fetch the multi service factory for setup
246cdf0e10cSrcweir             XMultiServiceFactory xCP = UnoRuntime.queryInterface(XMultiServiceFactory.class, o);
247cdf0e10cSrcweir 
248cdf0e10cSrcweir             // create the configuration reader
249cdf0e10cSrcweir             ConfigurationRead cfgRead = new ConfigurationRead(xCP);
250cdf0e10cSrcweir 
251cdf0e10cSrcweir             // get the document loader
252cdf0e10cSrcweir             String loader = getStringFromObject(
253cdf0e10cSrcweir                     cfgRead.getByHierarchicalName(cfgString + "/ooSetupFactoryEmptyDocumentURL"));
254cdf0e10cSrcweir 
255cdf0e10cSrcweir             if (loader == null)
256cdf0e10cSrcweir             {
257cdf0e10cSrcweir                 return null;
258cdf0e10cSrcweir             }
259cdf0e10cSrcweir             System.out.println("\tLoader: " + loader);
260cdf0e10cSrcweir 
261cdf0e10cSrcweir             // read attributes
262cdf0e10cSrcweir             String hierchName = cfgString + "/ooSetupFactoryWindowAttributes";
263cdf0e10cSrcweir             String setupSettings = getStringFromObject(cfgRead.getByHierarchicalName(hierchName));
264cdf0e10cSrcweir             // remove slots: just plain document types have to start
265cdf0e10cSrcweir             if (loader.indexOf("?slot") != -1)
266cdf0e10cSrcweir             {
267cdf0e10cSrcweir                 loader = loader.substring(0, loader.indexOf("?slot"));
268cdf0e10cSrcweir                 System.out.println("Loader: " + loader);
269cdf0e10cSrcweir             }
270cdf0e10cSrcweir 
271cdf0e10cSrcweir             conf[0] = loader;
272cdf0e10cSrcweir             conf[1] = setupSettings;
273cdf0e10cSrcweir         }
274cdf0e10cSrcweir         catch (com.sun.star.uno.Exception e)
275cdf0e10cSrcweir         {
276cdf0e10cSrcweir         }
277cdf0e10cSrcweir         return conf;
278cdf0e10cSrcweir     }
279cdf0e10cSrcweir 
280cdf0e10cSrcweir     /**
281cdf0e10cSrcweir      * Load a document
282cdf0e10cSrcweir      * @param xMSF A MultiServiceFactory from an office
283cdf0e10cSrcweir      * @param docLoader A documet loader
284cdf0e10cSrcweir      * @return A handle to the document
285cdf0e10cSrcweir      */
loadDocument(XMultiServiceFactory xMSF, String docLoader)286cdf0e10cSrcweir     private DocumentHandle loadDocument(XMultiServiceFactory xMSF,
287cdf0e10cSrcweir             String docLoader)
288cdf0e10cSrcweir     {
289cdf0e10cSrcweir         DocumentHandle docHandle = null;
290cdf0e10cSrcweir         try
291cdf0e10cSrcweir         {
292cdf0e10cSrcweir             // create component loaader
293cdf0e10cSrcweir             XComponentLoader xCompLoader = UnoRuntime.queryInterface(XComponentLoader.class, xMSF.createInstance("com.sun.star.frame.Desktop"));
294cdf0e10cSrcweir             XFramesSupplier xFrameSupp = UnoRuntime.queryInterface(XFramesSupplier.class, xCompLoader);
295cdf0e10cSrcweir             // close all existing frames
296cdf0e10cSrcweir             XFrames xFrames = xFrameSupp.getFrames();
297cdf0e10cSrcweir             XIndexAccess xAcc = UnoRuntime.queryInterface(XIndexAccess.class, xFrames);
298cdf0e10cSrcweir             for (int i = 0; i < xAcc.getCount(); i++)
299cdf0e10cSrcweir             {
300cdf0e10cSrcweir                 XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xAcc.getByIndex(i));
301cdf0e10cSrcweir                 try
302cdf0e10cSrcweir                 {
303cdf0e10cSrcweir                     if (xClose != null)
304cdf0e10cSrcweir                     {
305cdf0e10cSrcweir                         xClose.close(false);
306cdf0e10cSrcweir                     }
307cdf0e10cSrcweir                     else
308cdf0e10cSrcweir                     {
309cdf0e10cSrcweir                         fail("Could not query frame for XCloseable!");
310cdf0e10cSrcweir                     }
311cdf0e10cSrcweir                 }
312cdf0e10cSrcweir                 catch (com.sun.star.uno.Exception e)
313cdf0e10cSrcweir                 {
314cdf0e10cSrcweir                     e.printStackTrace();
315cdf0e10cSrcweir                     fail("Could not query frame for XCloseable!");
316cdf0e10cSrcweir                 }
317cdf0e10cSrcweir             }
318cdf0e10cSrcweir             docHandle = new DocumentHandle(xCompLoader);
319cdf0e10cSrcweir             docHandle.loadDocument(docLoader, false);
320cdf0e10cSrcweir         }
321cdf0e10cSrcweir         catch (com.sun.star.uno.Exception e)
322cdf0e10cSrcweir         {
323cdf0e10cSrcweir             e.printStackTrace();
324cdf0e10cSrcweir         }
325cdf0e10cSrcweir         catch (java.lang.Exception e)
326cdf0e10cSrcweir         {
327cdf0e10cSrcweir             e.printStackTrace();
328cdf0e10cSrcweir         }
329cdf0e10cSrcweir         return docHandle;
330cdf0e10cSrcweir     }
331cdf0e10cSrcweir 
connect()332cdf0e10cSrcweir     private boolean connect()
333cdf0e10cSrcweir     {
334cdf0e10cSrcweir         try
335cdf0e10cSrcweir         {
336cdf0e10cSrcweir             connection.setUp();
337cdf0e10cSrcweir         }
338cdf0e10cSrcweir         catch (java.lang.InterruptedException e)
339cdf0e10cSrcweir         {
340cdf0e10cSrcweir             fail("can't connect.");
341cdf0e10cSrcweir         }
342cdf0e10cSrcweir         catch (Exception e)
343cdf0e10cSrcweir         {
344cdf0e10cSrcweir             fail("can't connect.");
345cdf0e10cSrcweir         }
346cdf0e10cSrcweir         return true;
347cdf0e10cSrcweir     }
348cdf0e10cSrcweir 
disconnect()349cdf0e10cSrcweir     private boolean disconnect()
350cdf0e10cSrcweir     {
351cdf0e10cSrcweir         try
352cdf0e10cSrcweir         {
353cdf0e10cSrcweir             connection.tearDown();
354cdf0e10cSrcweir         }
355cdf0e10cSrcweir         catch (java.lang.InterruptedException e)
356cdf0e10cSrcweir         {
357cdf0e10cSrcweir             fail("can't disconnect.");
358cdf0e10cSrcweir         }
359cdf0e10cSrcweir         catch (Exception e)
360cdf0e10cSrcweir         {
361cdf0e10cSrcweir             fail("can't disconnect.");
362cdf0e10cSrcweir         }
363cdf0e10cSrcweir         return true;
364cdf0e10cSrcweir     }
365cdf0e10cSrcweir 
getStringFromObject(Object oName)366cdf0e10cSrcweir     private static String getStringFromObject(Object oName)
367cdf0e10cSrcweir     {
368cdf0e10cSrcweir         if (oName instanceof String)
369cdf0e10cSrcweir         {
370cdf0e10cSrcweir             return (String) oName;
371cdf0e10cSrcweir         }
372cdf0e10cSrcweir         String value = null;
373cdf0e10cSrcweir         if (oName instanceof Any)
374cdf0e10cSrcweir         {
375cdf0e10cSrcweir             try
376cdf0e10cSrcweir             {
377cdf0e10cSrcweir                 value = AnyConverter.toString(oName);
378cdf0e10cSrcweir                 if (value == null)
379cdf0e10cSrcweir                 {
380cdf0e10cSrcweir                     System.out.println("Got a void css.uno.Any as loading string.");
381cdf0e10cSrcweir                 }
382cdf0e10cSrcweir             }
383cdf0e10cSrcweir             catch (Exception e)
384cdf0e10cSrcweir             {
385cdf0e10cSrcweir                 System.out.println("This document type cannot be opened directly.");
386cdf0e10cSrcweir             }
387cdf0e10cSrcweir         }
388cdf0e10cSrcweir         return value;
389cdf0e10cSrcweir     }
390cdf0e10cSrcweir 
391cdf0e10cSrcweir     /**
392cdf0e10cSrcweir      * Compare two rectangles. Return true, if both are equal, false
393cdf0e10cSrcweir      * otherwise.
394cdf0e10cSrcweir      * @param rect1 First Rectangle.
395cdf0e10cSrcweir      * @param rect2 Second Rectangle.
396cdf0e10cSrcweir      * @return True, if the rectangles are equal.
397cdf0e10cSrcweir      */
compareRectangles(Rectangle rect1, Rectangle rect2)398cdf0e10cSrcweir     private boolean compareRectangles(Rectangle rect1, Rectangle rect2)
399cdf0e10cSrcweir     {
400cdf0e10cSrcweir         boolean result = true;
401cdf0e10cSrcweir         result &= (rect1.X == rect2.X);
402cdf0e10cSrcweir         result &= (rect1.Y == rect2.Y);
403cdf0e10cSrcweir         result &= (rect1.Width == rect2.Width);
404cdf0e10cSrcweir         result &= (rect1.Height == rect2.Height);
405cdf0e10cSrcweir         return result;
406cdf0e10cSrcweir     }
407cdf0e10cSrcweir 
408cdf0e10cSrcweir 
409cdf0e10cSrcweir 
getMSF()410cdf0e10cSrcweir         private XMultiServiceFactory getMSF()
411cdf0e10cSrcweir     {
412cdf0e10cSrcweir         final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
413cdf0e10cSrcweir         return xMSF1;
414cdf0e10cSrcweir     }
415cdf0e10cSrcweir 
416cdf0e10cSrcweir     // setup and close connections
setUpConnection()417cdf0e10cSrcweir     @BeforeClass public static void setUpConnection() throws Exception {
418cdf0e10cSrcweir         System.out.println("setUpConnection()");
419cdf0e10cSrcweir         connection.setUp();
420cdf0e10cSrcweir     }
421cdf0e10cSrcweir 
tearDownConnection()422cdf0e10cSrcweir     @AfterClass public static void tearDownConnection()
423cdf0e10cSrcweir         throws InterruptedException, com.sun.star.uno.Exception
424cdf0e10cSrcweir     {
425cdf0e10cSrcweir         System.out.println("tearDownConnection()");
426cdf0e10cSrcweir         connection.tearDown();
427cdf0e10cSrcweir     }
428cdf0e10cSrcweir 
429cdf0e10cSrcweir     private static final OfficeConnection connection = new OfficeConnection();
430cdf0e10cSrcweir 
431cdf0e10cSrcweir }
432