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 mod._forms;
25 
26 import com.sun.star.beans.PropertyValue;
27 import com.sun.star.drawing.XControlShape;
28 import com.sun.star.drawing.XShape;
29 import com.sun.star.lang.XMultiServiceFactory;
30 import com.sun.star.text.XTextDocument;
31 import com.sun.star.uno.UnoRuntime;
32 import com.sun.star.uno.XInterface;
33 import com.sun.star.util.XCloseable;
34 import java.io.PrintWriter;
35 import lib.TestCase;
36 import lib.TestEnvironment;
37 import lib.TestParameters;
38 import util.FormTools;
39 import util.WriterTools;
40 
41 public class OSpinButtonModel extends TestCase {
42 
43     XTextDocument xTextDoc;
44 
45     /**
46      * Creates a Writer document.
47      */
initialize( TestParameters tParam, PrintWriter log )48     protected void initialize( TestParameters tParam, PrintWriter log ) {
49 
50         log.println( "creating a textdocument" );
51         xTextDoc = WriterTools.createTextDoc(((XMultiServiceFactory) tParam.getMSF()));
52     }
53 
54     /**
55      * Disposes the Writer document.
56      */
cleanup(TestParameters tParam, PrintWriter log)57     protected void cleanup(TestParameters tParam, PrintWriter log) {
58         log.println("    disposing xTextDoc ");
59 
60         try {
61             XCloseable closer = (XCloseable) UnoRuntime.queryInterface(
62                 XCloseable.class, xTextDoc);
63             closer.close(true);
64         } catch (com.sun.star.util.CloseVetoException e) {
65             log.println("couldn't close document");
66         } catch (com.sun.star.lang.DisposedException e) {
67             log.println("couldn't close document");
68         }
69     }
70 
71 
72     /**
73      * Creating a Testenvironment for the interfaces to be tested.
74      * Adds spin button into text and retrieves it's control model.
75      */
createTestEnvironment(TestParameters Param, PrintWriter log)76     protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
77 
78         XInterface oObj = null;
79 
80         XControlShape aShape = FormTools.createControlShape(
81             xTextDoc,3000,4500,15000,10000,"SpinButton");
82 
83         WriterTools.getDrawPage(xTextDoc).add((XShape) aShape);
84         oObj = aShape.getControl();
85         log.println( "creating a new environment for OButtonModel object" );
86         TestEnvironment tEnv = new TestEnvironment( oObj );
87         tEnv.addObjRelation("OBJNAME", "com.sun.star.form.component.SpinButton");
88         PropertyValue prop = new PropertyValue();
89         prop.Name = "HelpText";
90         prop.Value = "new Help Text since XPropertyAccess";
91         tEnv.addObjRelation("XPropertyAccess.propertyToChange", prop);
92         tEnv.addObjRelation("XPropertyContainer.propertyNotRemovable", "HelpText");
93 
94         System.out.println("Implementation name: "+util.utils.getImplName(oObj));
95         return tEnv;
96     } // finish method getTestEnvironment
97 
98 }
99