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 OScrollBarModel extends TestCase {
42 
43     XTextDocument xTextDoc;
44 
45     /**
46     * Creates 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 
createTestEnvironment(TestParameters Param, PrintWriter log)71     protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
72 
73         XInterface oObj = null;
74 
75         XControlShape aShape = FormTools.createControlShape(
76                                 xTextDoc,3000,4500,15000,10000,"ScrollBar");
77 
78         WriterTools.getDrawPage(xTextDoc).add((XShape) aShape);
79         oObj = aShape.getControl();
80         log.println( "creating a new environment for OScrollBarModel object" );
81         TestEnvironment tEnv = new TestEnvironment( oObj );
82 
83         System.out.println("Implementation Name: "+util.utils.getImplName(oObj));
84 
85         String objName = "ScrollBar";
86         tEnv.addObjRelation("OBJNAME", "com.sun.star.form.component." + objName);
87         PropertyValue prop = new PropertyValue();
88         prop.Name = "HelpText";
89         prop.Value = "new Help Text since XPropertyAccess";
90         tEnv.addObjRelation("XPropertyAccess.propertyToChange", prop);
91         tEnv.addObjRelation("XPropertyContainer.propertyNotRemovable", "HelpText");
92         return tEnv;
93     }
94 
95 }
96