xref: /AOO41X/main/qadevOOo/tests/java/mod/_forms/OScrollBarModel.java (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 package mod._forms;
29 
30 import com.sun.star.beans.PropertyValue;
31 import com.sun.star.drawing.XControlShape;
32 import com.sun.star.drawing.XShape;
33 import com.sun.star.lang.XMultiServiceFactory;
34 import com.sun.star.text.XTextDocument;
35 import com.sun.star.uno.UnoRuntime;
36 import com.sun.star.uno.XInterface;
37 import com.sun.star.util.XCloseable;
38 import java.io.PrintWriter;
39 import lib.TestCase;
40 import lib.TestEnvironment;
41 import lib.TestParameters;
42 import util.FormTools;
43 import util.WriterTools;
44 
45 public class OScrollBarModel extends TestCase {
46 
47     XTextDocument xTextDoc;
48 
49     /**
50     * Creates Writer document.
51     */
52     protected void initialize( TestParameters tParam, PrintWriter log ) {
53 
54         log.println( "creating a textdocument" );
55         xTextDoc = WriterTools.createTextDoc(((XMultiServiceFactory) tParam.getMSF()));
56     }
57 
58     /**
59     * Disposes the Writer document.
60     */
61     protected void cleanup(TestParameters tParam, PrintWriter log) {
62         log.println("    disposing xTextDoc ");
63 
64         try {
65             XCloseable closer = (XCloseable) UnoRuntime.queryInterface(
66                                         XCloseable.class, xTextDoc);
67             closer.close(true);
68         } catch (com.sun.star.util.CloseVetoException e) {
69             log.println("couldn't close document");
70         } catch (com.sun.star.lang.DisposedException e) {
71             log.println("couldn't close document");
72         }
73     }
74 
75     protected synchronized TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) {
76 
77         XInterface oObj = null;
78 
79         XControlShape aShape = FormTools.createControlShape(
80                                 xTextDoc,3000,4500,15000,10000,"ScrollBar");
81 
82         WriterTools.getDrawPage(xTextDoc).add((XShape) aShape);
83         oObj = aShape.getControl();
84         log.println( "creating a new environment for OScrollBarModel object" );
85         TestEnvironment tEnv = new TestEnvironment( oObj );
86 
87         System.out.println("Implementation Name: "+util.utils.getImplName(oObj));
88 
89         String objName = "ScrollBar";
90         tEnv.addObjRelation("OBJNAME", "com.sun.star.form.component." + objName);
91         PropertyValue prop = new PropertyValue();
92         prop.Name = "HelpText";
93         prop.Value = "new Help Text since XPropertyAccess";
94         tEnv.addObjRelation("XPropertyAccess.propertyToChange", prop);
95         tEnv.addObjRelation("XPropertyContainer.propertyNotRemovable", "HelpText");
96         return tEnv;
97     }
98 
99 }
100