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
.DrawTools
;
27 import util
.SOfficeFactory
;
29 import com
.sun
.star
.beans
.XPropertySet
;
30 import com
.sun
.star
.document
.XLinkTargetSupplier
;
31 import com
.sun
.star
.drawing
.XDrawPage
;
32 import com
.sun
.star
.drawing
.XShape
;
33 import com
.sun
.star
.drawing
.XShapes
;
34 import com
.sun
.star
.lang
.XComponent
;
35 import com
.sun
.star
.uno
.UnoRuntime
;
36 import com
.sun
.star
.uno
.XInterface
;
39 * Test for object which is represented by service
40 * <code>com.sun.star.document.LinkTargets</code>. <p>
41 * Object implements the following interfaces :
43 * <li> <code>com::sun::star::container::XNameAccess</code></li>
44 * <li> <code>com::sun::star::container::XElementAccess</code></li>
46 * @see com.sun.star.document.LinkTargets
47 * @see com.sun.star.container.XNameAccess
48 * @see com.sun.star.container.XElementAccess
49 * @see ifc.container._XNameAccess
50 * @see ifc.container._XElementAccess
52 public class SdPageLinkTargets
extends TestCase
{
56 * Creates Drawing document.
59 protected void initialize(TestParameters Param
, PrintWriter log
) throws Exception
{
60 // get a soffice factory object
61 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
63 log
.println( "creating a draw document" );
64 xDrawDoc
= SOF
.createDrawDoc(null);
68 * Disposes Drawing document.
71 protected void cleanup( TestParameters Param
, PrintWriter log
) {
72 log
.println("disposing xDrawDoc");
73 util
.DesktopTools
.closeDoc(xDrawDoc
);
77 * Creating a TestEnvironment for the interfaces to be tested.
78 * Retrieves the collection of draw pages and take one of them.
79 * Obtains the collection of possible links using the interface
80 * <code>XLinkTargetSupplier</code>. The obtained collection is
81 * the instance of the service <code>com.sun.star.document.LinkTargets</code>.
82 * Inserts some shapes into the document.
83 * @see com.sun.star.document.XLinkTargetSupplier
84 * @see com.sun.star.document.LinkTargets
87 public TestEnvironment
createTestEnvironment(
88 TestParameters Param
, PrintWriter log
) throws Exception
{
90 // creation of testobject here
91 // first we write what we are intend to do to log file
92 log
.println( "creating a test environment" );
94 // create testobject here
95 XDrawPage the_page
= DrawTools
.getDrawPage(xDrawDoc
, 0);
96 XLinkTargetSupplier oLTS
= UnoRuntime
.queryInterface(XLinkTargetSupplier
.class, the_page
);
97 XInterface oObj
= oLTS
.getLinks();
99 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
101 log
.println( "inserting some Shapes" );
102 XShapes oShapes
= UnoRuntime
.queryInterface(XShapes
.class,the_page
);
104 SOF
.createShape(xDrawDoc
, 15000, 13500, 5000, 5000, "OLE2");
107 XPropertySet shape_props
= UnoRuntime
.queryInterface(XPropertySet
.class,oShape
);
109 log
.println("Inserting a Chart");
112 setPropertyValue("CLSID","12DCAE26-281F-416F-a234-c3086127382e");
114 log
.println( "creating a new environment for LinkTargets object" );
115 TestEnvironment tEnv
= new TestEnvironment( oObj
);
118 } // finish method createTestEnvironment
120 } // finish class SdPageLinkTargets