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 .
20 import com
.sun
.star
.beans
.XPropertySet
;
21 import com
.sun
.star
.drawing
.XShape
;
22 import com
.sun
.star
.frame
.XController
;
23 import com
.sun
.star
.frame
.XModel
;
24 import com
.sun
.star
.lang
.XComponent
;
25 import com
.sun
.star
.uno
.UnoRuntime
;
26 import com
.sun
.star
.view
.XSelectionSupplier
;
27 import ifc
.view
._XPrintJobBroadcaster
;
30 import java
.io
.PrintWriter
;
33 import lib
.TestEnvironment
;
34 import lib
.TestParameters
;
36 import util
.DrawTools
;
37 import util
.SOfficeFactory
;
42 * Test for object which is represented by service
43 * <code>com.sun.star.presentation.PresentationDocument</code>. <p>
44 * Object implements the following interfaces :
46 * <li> <code>com::sun::star::lang::XMultiServiceFactory</code></li>
47 * <li> <code>com::sun::star::drawing::XMasterPagesSupplier</code></li>
48 * <li> <code>com::sun::star::presentation::XCustomPresentationSupplier</code></li>
49 * <li> <code>com::sun::star::document::XLinkTargetSupplier</code></li>
50 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
51 * <li> <code>com::sun::star::drawing::XLayerSupplier</code></li>
52 * <li> <code>com::sun::star::presentation::XPresentationSupplier</code></li>
53 * <li> <code>com::sun::star::style::XStyleFamiliesSupplier</code></li>
54 * <li> <code>com::sun::star::drawing::DrawingDocument</code></li>
55 * <li> <code>com::sun::star::drawing::XDrawPageDuplicator</code></li>
56 * <li> <code>com::sun::star::drawing::XDrawPagesSupplier</code></li>
58 * @see com.sun.star.presentation.PresentationDocument
59 * @see com.sun.star.lang.XMultiServiceFactory
60 * @see com.sun.star.drawing.XMasterPagesSupplier
61 * @see com.sun.star.presentation.XCustomPresentationSupplier
62 * @see com.sun.star.document.XLinkTargetSupplier
63 * @see com.sun.star.beans.XPropertySet
64 * @see com.sun.star.drawing.XLayerSupplier
65 * @see com.sun.star.presentation.XPresentationSupplier
66 * @see com.sun.star.style.XStyleFamiliesSupplier
67 * @see com.sun.star.drawing.DrawingDocument
68 * @see com.sun.star.drawing.XDrawPageDuplicator
69 * @see com.sun.star.drawing.XDrawPagesSupplier
70 * @see ifc.lang._XMultiServiceFactory
71 * @see ifc.drawing._XMasterPagesSupplier
72 * @see ifc.presentation._XCustomPresentationSupplier
73 * @see ifc.document._XLinkTargetSupplier
74 * @see ifc.beans._XPropertySet
75 * @see ifc.drawing._XLayerSupplier
76 * @see ifc.presentation._XPresentationSupplier
77 * @see ifc.style._XStyleFamiliesSupplier
78 * @see ifc.drawing._DrawingDocument
79 * @see ifc.drawing._XDrawPageDuplicator
80 * @see ifc.drawing._XDrawPagesSupplier
82 public class SdXImpressDocument
extends TestCase
{
83 XComponent xImpressDoc
;
84 XComponent xImpressDoc2
;
87 * Called while disposing a <code>TestEnvironment</code>.
88 * Disposes Impress document.
89 * @param Param test parameters
90 * @param log writer to log information while testing
93 protected void cleanup(TestParameters Param
, PrintWriter log
) {
94 log
.println("disposing xImpressDoc");
95 util
.DesktopTools
.closeDoc(xImpressDoc
);
96 util
.DesktopTools
.closeDoc(xImpressDoc2
);
100 * Creating a TestEnvironment for the interfaces to be tested.
101 * Creates new impress document that is the instance of the service
102 * <code>com.sun.star.presentation.PresentationDocument</code>.
103 * @see com.sun.star.presentation.PresentationDocument
106 public TestEnvironment
createTestEnvironment(TestParameters Param
,
109 log
.println("creating a test environment");
111 // get a soffice factory object
112 SOfficeFactory SOF
= SOfficeFactory
.getFactory(
115 log
.println("creating two impress documents");
116 xImpressDoc2
= SOF
.createImpressDoc(null);
117 xImpressDoc
= SOF
.createImpressDoc(null);
119 XModel xModel1
= UnoRuntime
.queryInterface(XModel
.class,
121 XModel xModel2
= UnoRuntime
.queryInterface(XModel
.class,
124 XController cont1
= xModel1
.getCurrentController();
125 XController cont2
= xModel2
.getCurrentController();
127 cont1
.getFrame().setName("cont1");
128 cont2
.getFrame().setName("cont2");
130 XSelectionSupplier sel
= UnoRuntime
.queryInterface(
131 XSelectionSupplier
.class, cont1
);
133 XShape aShape
= SOF
.createShape(xImpressDoc
, 5000, 3500, 7500, 5000,
137 XPropertySet xShapeProps
= UnoRuntime
.queryInterface(XPropertySet
.class, aShape
);
139 xShapeProps
.setPropertyValue("FillStyle", com
.sun
.star
.drawing
.FillStyle
.SOLID
);
140 xShapeProps
.setPropertyValue("FillTransparence", Integer
.valueOf(50));
142 DrawTools
.getDrawPage(xImpressDoc
, 0).add(aShape
);
144 log
.println("creating a new environment for drawpage object");
146 TestEnvironment tEnv
= new TestEnvironment(xImpressDoc
);
148 log
.println("adding Controller as ObjRelation for XModel");
149 tEnv
.addObjRelation("CONT2", cont2
);
151 log
.println("Adding SelectionSupplier and Shape to select for XModel");
152 tEnv
.addObjRelation("SELSUPP", sel
);
153 tEnv
.addObjRelation("TOSELECT", aShape
);
155 // create object relation for XPrintJobBroadcaster
156 String fileName
= utils
.getOfficeTempDirSys(Param
.getMSF())+"printfile.prt" ;
157 File f
= new File(fileName
);
159 boolean bDeleteOk
= f
.delete();
161 System
.out
.println("delete failed");
164 _XPrintJobBroadcaster
.MyPrintJobListener listener
= new _XPrintJobBroadcaster
.MyPrintJobListener(xImpressDoc
, fileName
);
165 tEnv
.addObjRelation("XPrintJobBroadcaster.XPrintJobListener", listener
);
168 } // finish method getTestEnvironment
170 } // finish class SdDrawPage