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
;
24 import lib
.TestEnvironment
;
25 import lib
.TestParameters
;
26 import util
.DefaultDsc
;
27 import util
.DrawTools
;
28 import util
.InstCreator
;
29 import util
.SOfficeFactory
;
31 import com
.sun
.star
.beans
.XPropertySet
;
32 import com
.sun
.star
.drawing
.XShape
;
33 import com
.sun
.star
.lang
.XComponent
;
34 import com
.sun
.star
.lang
.XMultiServiceFactory
;
35 import com
.sun
.star
.style
.XStyle
;
36 import com
.sun
.star
.uno
.AnyConverter
;
37 import com
.sun
.star
.uno
.Type
;
38 import com
.sun
.star
.uno
.UnoRuntime
;
39 import com
.sun
.star
.uno
.XInterface
;
44 * @see com.sun.star.beans.XPropertySet
45 * @see com.sun.star.document.LinkTarget
46 * @see com.sun.star.document.XLinkTargetSupplier
47 * @see com.sun.star.drawing.ConnectorShapeDescriptor
48 * @see com.sun.star.drawing.LineShapeDescriptor
49 * @see com.sun.star.drawing.PolyPolygonDescriptor
50 * @see com.sun.star.drawing.RotationDescriptor
51 * @see com.sun.star.drawing.ShadowDescriptor
52 * @see com.sun.star.drawing.ShapeDescriptor
53 * @see com.sun.star.drawing.Text
54 * @see com.sun.star.drawing.XConnectorShape
55 * @see com.sun.star.drawing.XShape
56 * @see com.sun.star.drawing.XShapeDescriptor
57 * @see com.sun.star.lang.XComponent
58 * @see com.sun.star.style.CharacterProperties
59 * @see com.sun.star.style.ParagraphProperties
60 * @see com.sun.star.text.XSimpleText
61 * @see com.sun.star.text.XText
62 * @see com.sun.star.text.XTextRange
65 public class SvxShapeConnector
extends TestCase
{
67 static XComponent xDrawDoc
;
70 * in general this method creates a testdocument
72 * @param tParam class which contains additional test parameters
73 * @param log class to log the test state and result
81 protected void initialize( TestParameters tParam
, PrintWriter log
) throws Exception
{
82 log
.println( "creating a drawdoc" );
83 xDrawDoc
= DrawTools
.createDrawDoc(tParam
.getMSF());
87 * in general this method disposes the testenvironment and document
89 * @param tParam class which contains additional test parameters
90 * @param log class to log the test state and result
98 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
99 log
.println( " disposing xDrawDoc " );
100 util
.DesktopTools
.closeDoc(xDrawDoc
);
105 * * creating a TestEnvironment for the interfaces to be tested
107 * @param tParam class which contains additional test parameters
108 * @param log class to log the test state and result
110 * @return Status class
112 * @see TestParameters
116 protected TestEnvironment createTestEnvironment
117 (TestParameters tParam
, PrintWriter log
) {
119 XInterface oObj
= null;
120 XShape oShape
= null;
122 // creation of testobject here
123 // first we write what we are intend to do to log file
124 log
.println( "creating a test environment" );
126 XMultiServiceFactory oDocMSF
= UnoRuntime
.queryInterface(XMultiServiceFactory
.class,xDrawDoc
);
127 Object oInt
= oDocMSF
.createInstance
128 ( "com.sun.star.drawing.ConnectorShape" );
130 oShape
= UnoRuntime
.queryInterface( XShape
.class, oInt
);
131 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
);
133 catch (Exception e
) {
134 log
.println("Couldn't create instance");
135 e
.printStackTrace(log
);
138 // create testobject here
141 TestEnvironment tEnv
= new TestEnvironment( oObj
);
143 SOfficeFactory SOF
= SOfficeFactory
.getFactory( tParam
.getMSF());
144 oShape
= SOF
.createShape(xDrawDoc
,3000,4500,15000,1000,"Ellipse");
145 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
);
147 for (int i
=0;i
<10;i
++) {
148 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(
149 SOF
.createShape(xDrawDoc
,
150 3000,4500,7510+10*i
,5010+10*i
,"Rectangle"));
153 log
.println( "adding two style as ObjRelation for ShapeDescriptor" );
154 XPropertySet oShapeProps
= UnoRuntime
.queryInterface(XPropertySet
.class,oObj
);
155 XStyle aStyle
= null;
157 aStyle
= (XStyle
) AnyConverter
.toObject(
158 new Type(XStyle
.class),oShapeProps
.getPropertyValue("Style"));
159 } catch (Exception e
) {}
161 tEnv
.addObjRelation("Style1",aStyle
);
162 oShapeProps
= UnoRuntime
.queryInterface(XPropertySet
.class,oShape
);
164 aStyle
= (XStyle
) AnyConverter
.toObject(
165 new Type(XStyle
.class),oShapeProps
.getPropertyValue("Style"));
166 } catch (Exception e
) {}
168 tEnv
.addObjRelation("Style2",aStyle
);
170 DefaultDsc tDsc
= new DefaultDsc("com.sun.star.text.XTextContent",
171 "com.sun.star.text.TextField.URL");
172 log
.println( " adding InstCreator object" );
173 tEnv
.addObjRelation( "XTEXTINFO", new InstCreator( xDrawDoc
, tDsc
) );
174 tEnv
.addObjRelation("NoSetSize","SvxShapeConnector");
175 // adding relation for XConnectorShape
176 XShape oShape1
= SOF
.createShape(xDrawDoc
,1000,2000,1500,1000,"Line");
177 XShape oShape2
= SOF
.createShape(xDrawDoc
,1000,2000,4000,3000,"Line");
178 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape1
);
179 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape2
);
180 tEnv
.addObjRelation("XConnectorShape.Shapes",
181 new XShape
[] {oShape1
, oShape2
}) ;
182 System
.out
.println("IName: "+util
.utils
.getImplName(oObj
));
184 } // finish method getTestEnvironment
186 } // finish class SvxShapeConnector