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
81 protected void initialize( TestParameters tParam
, PrintWriter log
) {
84 log
.println( "creating a drawdoc" );
85 xDrawDoc
= DrawTools
.createDrawDoc((XMultiServiceFactory
)tParam
.getMSF());
86 } catch ( Exception e
) {
87 // Some exception occurs.FAILED
88 e
.printStackTrace( log
);
89 throw new StatusException( "Couldn't create document", e
);
94 * in general this method disposes the testenvironment and document
96 * @param tParam class which contains additional test parameters
97 * @param log class to log the test state and result
100 * @see TestParameters
104 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
105 log
.println( " disposing xDrawDoc " );
106 util
.DesktopTools
.closeDoc(xDrawDoc
);
111 * * creating a Testenvironment for the interfaces to be tested
113 * @param tParam class which contains additional test parameters
114 * @param log class to log the test state and result
116 * @return Status class
118 * @see TestParameters
121 protected TestEnvironment createTestEnvironment
122 (TestParameters tParam
, PrintWriter log
) {
124 XInterface oObj
= null;
125 XShape oShape
= null;
127 // creation of testobject here
128 // first we write what we are intend to do to log file
129 log
.println( "creating a test environment" );
131 XMultiServiceFactory oDocMSF
= UnoRuntime
.queryInterface(XMultiServiceFactory
.class,xDrawDoc
);
132 Object oInt
= oDocMSF
.createInstance
133 ( "com.sun.star.drawing.ConnectorShape" );
135 oShape
= UnoRuntime
.queryInterface( XShape
.class, oInt
);
136 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
);
138 catch (Exception e
) {
139 log
.println("Couldn't create insance");
140 e
.printStackTrace(log
);
143 // create testobject here
146 TestEnvironment tEnv
= new TestEnvironment( oObj
);
148 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF());
149 oShape
= SOF
.createShape(xDrawDoc
,3000,4500,15000,1000,"Ellipse");
150 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape
);
152 for (int i
=0;i
<10;i
++) {
153 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(
154 SOF
.createShape(xDrawDoc
,
155 3000,4500,7510+10*i
,5010+10*i
,"Rectangle"));
158 log
.println( "adding two style as ObjRelation for ShapeDescriptor" );
159 XPropertySet oShapeProps
= UnoRuntime
.queryInterface(XPropertySet
.class,oObj
);
160 XStyle aStyle
= null;
162 aStyle
= (XStyle
) AnyConverter
.toObject(
163 new Type(XStyle
.class),oShapeProps
.getPropertyValue("Style"));
164 } catch (Exception e
) {}
166 tEnv
.addObjRelation("Style1",aStyle
);
167 oShapeProps
= UnoRuntime
.queryInterface(XPropertySet
.class,oShape
);
169 aStyle
= (XStyle
) AnyConverter
.toObject(
170 new Type(XStyle
.class),oShapeProps
.getPropertyValue("Style"));
171 } catch (Exception e
) {}
173 tEnv
.addObjRelation("Style2",aStyle
);
175 DefaultDsc tDsc
= new DefaultDsc("com.sun.star.text.XTextContent",
176 "com.sun.star.text.TextField.URL");
177 log
.println( " adding InstCreator object" );
178 tEnv
.addObjRelation( "XTEXTINFO", new InstCreator( xDrawDoc
, tDsc
) );
179 tEnv
.addObjRelation("NoSetSize","SvxShapeConnector");
180 // adding relation for XConnectorShape
181 XShape oShape1
= SOF
.createShape(xDrawDoc
,1000,2000,1500,1000,"Line");
182 XShape oShape2
= SOF
.createShape(xDrawDoc
,1000,2000,4000,3000,"Line");
183 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape1
);
184 DrawTools
.getShapes(DrawTools
.getDrawPage(xDrawDoc
,0)).add(oShape2
);
185 tEnv
.addObjRelation("XConnectorShape.Shapes",
186 new XShape
[] {oShape1
, oShape2
}) ;
187 System
.out
.println("IName: "+util
.utils
.getImplName(oObj
));
189 } // finish method getTestEnvironment
191 } // finish class SvxShapeConnector