xref: /AOO41X/main/qadevOOo/runner/util/ShapeDsc.java (revision ef39d40d3f5e66cf3f035b3e93783012b340500d)
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 util;
25 
26 import com.sun.star.lang.XMultiServiceFactory;
27 import com.sun.star.uno.XInterface;
28 import com.sun.star.uno.UnoRuntime;
29 import com.sun.star.drawing.*;
30 import com.sun.star.awt.*;
31 /**
32  * the class TableDsc
33  */
34 public class ShapeDsc extends InstDescr {
35 
36     private int x = 0;
37     private int y = 0;
38     private int height = 0;
39     private int width = 0;
40     private String name = null;
41     final String ifcName = "com.sun.star.drawing.XShape";
42     String service = "com.sun.star.drawing.RectangleShape";
43 
ShapeDsc( int nheight, int nwidth, int nx, int ny, String kind )44     public ShapeDsc( int nheight, int nwidth, int nx, int ny, String kind ) {
45         x=nx;
46                 y=ny;
47                 height=nheight;
48                 width=nwidth;
49         service="com.sun.star.drawing."+kind+"Shape";
50         initShape();
51     }
getName()52     public String getName() {
53         return name;
54     }
55 
getIfcName()56     public String getIfcName() {
57         return ifcName;
58     }
getService()59     public String getService() {
60         return service;
61     }
62 
initShape()63     private void initShape() {
64         try {
65             ifcClass = Class.forName( ifcName );
66         }
67         catch( ClassNotFoundException cnfE ) {
68         }
69     }
createInstance( XMultiServiceFactory docMSF )70     public XInterface createInstance( XMultiServiceFactory docMSF ) {
71 
72 
73         Object SrvObj = null;
74         try {
75             SrvObj = docMSF.createInstance( service );
76         }
77         catch( com.sun.star.uno.Exception cssuE ){
78         }
79 
80         XShape Sh = (XShape)UnoRuntime.queryInterface(ifcClass, SrvObj );
81                 Size size = new Size();
82                 Point position = new Point();
83                 size.Height = height;
84         size.Width = width;
85         position.X = x;
86         position.Y = y;
87                 try {
88              Sh.setSize(size);
89              Sh.setPosition(position);
90                 }
91                 catch ( com.sun.star.beans.PropertyVetoException e) {
92                 }
93 
94         return Sh;
95 
96     }
97 }