2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 import java
.io
.PrintWriter
;
23 import lib
.StatusException
;
25 import lib
.TestEnvironment
;
26 import lib
.TestParameters
;
27 import util
.DefaultDsc
;
28 import util
.DrawTools
;
29 import util
.InstCreator
;
30 import util
.SOfficeFactory
;
32 import com
.sun
.star
.beans
.XPropertySet
;
33 import com
.sun
.star
.drawing
.XShape
;
34 import com
.sun
.star
.lang
.XComponent
;
35 import com
.sun
.star
.lang
.XMultiServiceFactory
;
36 import com
.sun
.star
.style
.XStyle
;
37 import com
.sun
.star
.uno
.AnyConverter
;
38 import com
.sun
.star
.uno
.Type
;
39 import com
.sun
.star
.uno
.UnoRuntime
;
40 import com
.sun
.star
.uno
.XInterface
;
45 * @see com.sun.star.beans.XPropertySet
46 * @see com.sun.star.document.LinkTarget
47 * @see com.sun.star.document.XLinkTargetSupplier
48 * @see com.sun.star.drawing.ConnectorShapeDescriptor
49 * @see com.sun.star.drawing.LineShapeDescriptor
50 * @see com.sun.star.drawing.PolyPolygonDescriptor
51 * @see com.sun.star.drawing.RotationDescriptor
52 * @see com.sun.star.drawing.ShadowDescriptor
53 * @see com.sun.star.drawing.ShapeDescriptor
54 * @see com.sun.star.drawing.Text
55 * @see com.sun.star.drawing.XConnectorShape
56 * @see com.sun.star.drawing.XShape
57 * @see com.sun.star.drawing.XShapeDescriptor
58 * @see com.sun.star.lang.XComponent
59 * @see com.sun.star.style.CharacterProperties
60 * @see com.sun.star.style.ParagraphProperties
61 * @see com.sun.star.text.XSimpleText
62 * @see com.sun.star.text.XText
63 * @see com.sun.star.text.XTextRange
66 public class SvxShapeConnector
extends TestCase
{
68 static XComponent xDrawDoc
;
71 * in general this method creates a testdocument
73 * @param tParam class which contains additional test parameters
74 * @param log class to log the test state and result
82 protected void initialize( TestParameters tParam
, PrintWriter log
) {
85 log
.println( "creating a drawdoc" );
86 xDrawDoc
= DrawTools
.createDrawDoc(tParam
.getMSF());
87 } catch ( Exception e
) {
88 // Some exception occurs.FAILED
89 e
.printStackTrace( log
);
90 throw new StatusException( "Couldn't create document", e
);
95 * in general this method disposes the testenvironment and document
97 * @param tParam class which contains additional test parameters
98 * @param log class to log the test state and result
101 * @see TestParameters
106 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
107 log
.println( " disposing xDrawDoc " );
108 util
.DesktopTools
.closeDoc(xDrawDoc
);
113 * * creating a Testenvironment for the interfaces to be tested
115 * @param tParam class which contains additional test parameters
116 * @param log class to log the test state and result
118 * @return Status class
120 * @see TestParameters
124 protected TestEnvironment createTestEnvironment
125 (TestParameters tParam
, PrintWriter log
) {
127 XInterface oObj
= null;
128 XShape oShape
= null;
130 // creation of testobject here
131 // first we write what we are intend to do to log file
132 log
.println( "creating a test environment" );
134 XMultiServiceFactory oDocMSF
= UnoRuntime
.queryInterface(XMultiServiceFactory
.class,xDrawDoc
);
135 Object oInt
= oDocMSF
.createInstance
136 ( "com.sun.star.drawing.ConnectorShape" );
138 oShape
= UnoRuntime
.queryInterface( XShape
.class, oInt
);
139 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
);
141 catch (Exception e
) {
142 log
.println("Couldn't create insance");
143 e
.printStackTrace(log
);
146 // create testobject here
149 TestEnvironment tEnv
= new TestEnvironment( oObj
);
151 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF());
152 oShape
= SOF
.createShape(xDrawDoc
,3000,4500,15000,1000,"Ellipse");
153 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
);
155 for (int i
=0;i
<10;i
++) {
156 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(
157 SOF
.createShape(xDrawDoc
,
158 3000,4500,7510+10*i
,5010+10*i
,"Rectangle"));
161 log
.println( "adding two style as ObjRelation for ShapeDescriptor" );
162 XPropertySet oShapeProps
= UnoRuntime
.queryInterface(XPropertySet
.class,oObj
);
163 XStyle aStyle
= null;
165 aStyle
= (XStyle
) AnyConverter
.toObject(
166 new Type(XStyle
.class),oShapeProps
.getPropertyValue("Style"));
167 } catch (Exception e
) {}
169 tEnv
.addObjRelation("Style1",aStyle
);
170 oShapeProps
= UnoRuntime
.queryInterface(XPropertySet
.class,oShape
);
172 aStyle
= (XStyle
) AnyConverter
.toObject(
173 new Type(XStyle
.class),oShapeProps
.getPropertyValue("Style"));
174 } catch (Exception e
) {}
176 tEnv
.addObjRelation("Style2",aStyle
);
178 DefaultDsc tDsc
= new DefaultDsc("com.sun.star.text.XTextContent",
179 "com.sun.star.text.TextField.URL");
180 log
.println( " adding InstCreator object" );
181 tEnv
.addObjRelation( "XTEXTINFO", new InstCreator( xDrawDoc
, tDsc
) );
182 tEnv
.addObjRelation("NoSetSize","SvxShapeConnector");
183 // adding relation for XConnectorShape
184 XShape oShape1
= SOF
.createShape(xDrawDoc
,1000,2000,1500,1000,"Line");
185 XShape oShape2
= SOF
.createShape(xDrawDoc
,1000,2000,4000,3000,"Line");
186 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape1
);
187 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape2
);
188 tEnv
.addObjRelation("XConnectorShape.Shapes",
189 new XShape
[] {oShape1
, oShape2
}) ;
190 System
.out
.println("IName: "+util
.utils
.getImplName(oObj
));
192 } // finish method getTestEnvironment
194 } // finish class SvxShapeConnector