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
.DrawTools
;
28 import util
.SOfficeFactory
;
30 import com
.sun
.star
.beans
.XPropertySet
;
31 import com
.sun
.star
.document
.XLinkTargetSupplier
;
32 import com
.sun
.star
.drawing
.XDrawPage
;
33 import com
.sun
.star
.drawing
.XShape
;
34 import com
.sun
.star
.drawing
.XShapes
;
35 import com
.sun
.star
.lang
.XComponent
;
36 import com
.sun
.star
.lang
.XMultiServiceFactory
;
37 import com
.sun
.star
.uno
.UnoRuntime
;
38 import com
.sun
.star
.uno
.XInterface
;
41 * Test for object which is represented by service
42 * <code>com.sun.star.document.LinkTargets</code>. <p>
43 * Object implements the following interfaces :
45 * <li> <code>com::sun::star::container::XNameAccess</code></li>
46 * <li> <code>com::sun::star::container::XElementAccess</code></li>
48 * @see com.sun.star.document.LinkTargets
49 * @see com.sun.star.container.XNameAccess
50 * @see com.sun.star.container.XElementAccess
51 * @see ifc.container._XNameAccess
52 * @see ifc.container._XElementAccess
54 public class SdPageLinkTargets
extends TestCase
{
58 * Creates Drawing document.
60 protected void initialize(TestParameters Param
, PrintWriter log
) {
61 // get a soffice factory object
62 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
63 (XMultiServiceFactory
)Param
.getMSF());
66 log
.println( "creating a draw document" );
67 xDrawDoc
= SOF
.createDrawDoc(null);
68 } catch (com
.sun
.star
.uno
.Exception e
) {
69 // Some exception occurs.FAILED
70 e
.printStackTrace( log
);
71 throw new StatusException( "Couldn't create document", e
);
76 * Disposes Drawing document.
78 protected void cleanup( TestParameters Param
, PrintWriter log
) {
79 log
.println("disposing xDrawDoc");
80 util
.DesktopTools
.closeDoc(xDrawDoc
);
84 * Creating a Testenvironment for the interfaces to be tested.
85 * Retrieves the collection of draw pages and take one of them.
86 * Obtains the collection of possible links using the interface
87 * <code>XLinkTargetSupplier</code>. The obtained collection is
88 * the instance of the service <code>com.sun.star.document.LinkTargets</code>.
89 * Inserts some shapes into the document.
90 * @see com.sun.star.document.XLinkTargetSupplier
91 * @see com.sun.star.document.LinkTargets
93 public synchronized TestEnvironment
createTestEnvironment(
94 TestParameters Param
, PrintWriter log
) throws StatusException
{
96 // creation of testobject here
97 // first we write what we are intend to do to log file
98 log
.println( "creating a test environment" );
100 // create testobject here
101 XDrawPage the_page
= DrawTools
.getDrawPage(xDrawDoc
, 0);
102 XLinkTargetSupplier oLTS
= UnoRuntime
.queryInterface(XLinkTargetSupplier
.class, the_page
);
103 XInterface oObj
= oLTS
.getLinks();
105 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
106 (XMultiServiceFactory
)Param
.getMSF());
107 log
.println( "inserting some Shapes" );
108 XShapes oShapes
= UnoRuntime
.queryInterface(XShapes
.class,the_page
);
110 SOF
.createShape(xDrawDoc
, 15000, 13500, 5000, 5000, "OLE2");
113 XPropertySet shape_props
= UnoRuntime
.queryInterface(XPropertySet
.class,oShape
);
115 log
.println("Inserting a Chart");
119 setPropertyValue("CLSID","12DCAE26-281F-416F-a234-c3086127382e");
120 } catch (com
.sun
.star
.lang
.WrappedTargetException e
) {
121 e
.printStackTrace(log
);
122 throw new StatusException("WrappedTarget: couldn't change property CLSID", e
);
123 } catch (com
.sun
.star
.lang
.IllegalArgumentException e
) {
124 e
.printStackTrace(log
);
125 throw new StatusException("IllegalArgument: couldn't change property CLSID", e
);
126 } catch (com
.sun
.star
.beans
.PropertyVetoException e
) {
127 e
.printStackTrace(log
);
128 throw new StatusException("PropertyVeto: couldn't change property CLSID", e
);
129 } catch (com
.sun
.star
.beans
.UnknownPropertyException e
) {
130 e
.printStackTrace(log
);
131 throw new StatusException("UnknownProperty: couldn't change property CLSID", e
);
134 log
.println( "creating a new environment for LinkTargets object" );
135 TestEnvironment tEnv
= new TestEnvironment( oObj
);
138 } // finish method createTestEnvironment
140 } // finish class SdPageLinkTargets