Kaydet (Commit) f0e5122f authored tarafından Oliver Bolte's avatar Oliver Bolte

INTEGRATION: CWS qadev16 (1.4.2); FILE MERGED

2004/02/13 16:54:36 sw 1.4.2.1: #23458#
üst 1d0193c0
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: GraphicExporter.java,v $ * $RCSfile: GraphicExporter.java,v $
* *
* $Revision: 1.4 $ * $Revision: 1.5 $
* *
* last change:$Date: 2004-01-05 19:45:36 $ * last change:$Date: 2004-03-19 14:37:22 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -58,28 +58,29 @@ ...@@ -58,28 +58,29 @@
* *
* *
************************************************************************/ ************************************************************************/
package mod._svx; package mod._svx;
import com.sun.star.beans.XPropertySet;
import com.sun.star.document.XExporter;
import com.sun.star.drawing.XShape;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.ucb.XSimpleFileAccess;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XInterface;
import com.sun.star.util.URL;
import java.io.PrintWriter; import java.io.PrintWriter;
import lib.StatusException; import lib.StatusException;
import lib.TestCase; import lib.TestCase;
import lib.TestEnvironment; import lib.TestEnvironment;
import lib.TestParameters; import lib.TestParameters;
import util.DrawTools; import util.DrawTools;
import util.SOfficeFactory; import util.SOfficeFactory;
import util.XMLTools; import util.XMLTools;
import com.sun.star.beans.XPropertySet;
import com.sun.star.document.XExporter;
import com.sun.star.drawing.XShape;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.ucb.XSimpleFileAccess;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XInterface;
import com.sun.star.util.URL;
/** /**
* Test for object which is represented by service * Test for object which is represented by service
...@@ -109,23 +110,22 @@ import com.sun.star.util.URL; ...@@ -109,23 +110,22 @@ import com.sun.star.util.URL;
* @see ifc.document._XExporter * @see ifc.document._XExporter
*/ */
public class GraphicExporter extends TestCase { public class GraphicExporter extends TestCase {
XComponent xDrawDoc; XComponent xDrawDoc;
/** /**
* Creates a new draw document. * Creates a new draw document.
*/ */
protected void initialize( TestParameters tParam, PrintWriter log ) { protected void initialize(TestParameters tParam, PrintWriter log) {
log.println("creating a drawdoc");
log.println( "creating a drawdoc" ); xDrawDoc = DrawTools.createDrawDoc(
xDrawDoc = DrawTools.createDrawDoc((XMultiServiceFactory)tParam.getMSF()); (XMultiServiceFactory) tParam.getMSF());
} }
/** /**
* Disposes the draw document created before * Disposes the draw document created before
*/ */
protected void cleanup( TestParameters tParam, PrintWriter log ) { protected void cleanup(TestParameters tParam, PrintWriter log) {
log.println( " disposing xDrawDoc " ); log.println(" disposing xDrawDoc ");
util.DesktopTools.closeDoc(xDrawDoc); util.DesktopTools.closeDoc(xDrawDoc);
} }
...@@ -158,101 +158,114 @@ public class GraphicExporter extends TestCase { ...@@ -158,101 +158,114 @@ public class GraphicExporter extends TestCase {
* </li> * </li>
* </ul> * </ul>
*/ */
protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log) { protected TestEnvironment createTestEnvironment(TestParameters tParam,
PrintWriter log) {
XInterface oObj = null; XInterface oObj = null;
XShape oShape = null; XShape oShape = null;
Object go=null; Object go = null;
// creation of testobject here // creation of testobject here
// first we write what we are intend to do to log file // first we write what we are intend to do to log file
log.println( "creating a test environment" ); log.println("creating a test environment");
try { try {
go = ((XMultiServiceFactory)tParam.getMSF()).createInstance go = ((XMultiServiceFactory) tParam.getMSF()).createInstance(
("com.sun.star.drawing.GraphicExportFilter"); "com.sun.star.drawing.GraphicExportFilter");
} catch (com.sun.star.uno.Exception e) { } catch (com.sun.star.uno.Exception e) {
log.println("Couldn't create instance"); log.println("Couldn't create instance");
e.printStackTrace(log); e.printStackTrace(log);
} }
// create testobject here // create testobject here
SOfficeFactory SOF = SOfficeFactory.getFactory( (XMultiServiceFactory)tParam.getMSF()); SOfficeFactory SOF = SOfficeFactory.getFactory(
oShape = SOF.createShape(xDrawDoc,5000,5000,1500,1000,"GraphicObject"); (XMultiServiceFactory) tParam.getMSF());
DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc,0)).add(oShape); oShape = SOF.createShape(xDrawDoc, 5000, 5000, 1500, 1000,
XPropertySet oShapeProps = (XPropertySet) "GraphicObject");
UnoRuntime.queryInterface(XPropertySet.class,oShape); DrawTools.getShapes(DrawTools.getDrawPage(xDrawDoc, 0)).add(oShape);
XPropertySet oShapeProps = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, oShape);
XComponent xComp = null; XComponent xComp = null;
try { try {
oShapeProps.setPropertyValue( oShapeProps.setPropertyValue("GraphicURL",
"GraphicURL",util.utils.getFullTestURL("space-metal.jpg")); util.utils.getFullTestURL(
xComp = (XComponent) UnoRuntime.queryInterface "space-metal.jpg"));
(XComponent.class,oShape); xComp = (XComponent) UnoRuntime.queryInterface(XComponent.class,
XExporter xEx = (XExporter) UnoRuntime.queryInterface oShape);
(XExporter.class,(XInterface) go);
XExporter xEx = (XExporter) UnoRuntime.queryInterface(
XExporter.class, (XInterface) go);
xEx.setSourceDocument(xComp); xEx.setSourceDocument(xComp);
} catch (com.sun.star.lang.WrappedTargetException e) { } catch (com.sun.star.lang.WrappedTargetException e) {
e.printStackTrace(log) ; e.printStackTrace(log);
throw new StatusException("Error while preparing component", e) ; throw new StatusException("Error while preparing component", e);
} catch (com.sun.star.lang.IllegalArgumentException e) { } catch (com.sun.star.lang.IllegalArgumentException e) {
e.printStackTrace(log) ; e.printStackTrace(log);
throw new StatusException("Error while preparing component", e) ; throw new StatusException("Error while preparing component", e);
} catch (com.sun.star.beans.PropertyVetoException e) { } catch (com.sun.star.beans.PropertyVetoException e) {
e.printStackTrace(log) ; e.printStackTrace(log);
throw new StatusException("Error while preparing component", e) ; throw new StatusException("Error while preparing component", e);
} catch (com.sun.star.beans.UnknownPropertyException e) { } catch (com.sun.star.beans.UnknownPropertyException e) {
e.printStackTrace(log) ; e.printStackTrace(log);
throw new StatusException("Error while preparing component", e) ; throw new StatusException("Error while preparing component", e);
} }
final URL aURL = new URL() ; final URL aURL = new URL();
aURL.Complete = util.utils.getOfficeTemp((XMultiServiceFactory)tParam.getMSF())+"picture.jpg"; aURL.Complete = util.utils.getOfficeTemp(
(XMultiServiceFactory) tParam.getMSF()) +
"picture.jpg";
final XSimpleFileAccess fAcc;
final XSimpleFileAccess fAcc ;
try { try {
Object oFAcc = ((XMultiServiceFactory)tParam.getMSF()).createInstance Object oFAcc = ((XMultiServiceFactory) tParam.getMSF()).createInstance(
("com.sun.star.ucb.SimpleFileAccess") ; "com.sun.star.ucb.SimpleFileAccess");
fAcc = (XSimpleFileAccess) UnoRuntime.queryInterface fAcc = (XSimpleFileAccess) UnoRuntime.queryInterface(
(XSimpleFileAccess.class, oFAcc) ; XSimpleFileAccess.class, oFAcc);
if (fAcc.exists(aURL.Complete)) { if (fAcc.exists(aURL.Complete)) {
fAcc.kill(aURL.Complete); fAcc.kill(aURL.Complete);
} }
} catch (com.sun.star.uno.Exception e) { } catch (com.sun.star.uno.Exception e) {
log.println("Error accessing file system :"); log.println("Error accessing file system :");
e.printStackTrace(log); e.printStackTrace(log);
throw new StatusException("Error accessing file system.", e) ; throw new StatusException("Error accessing file system.", e);
} }
oObj = (XInterface) go; oObj = (XInterface) go;
log.println("ImplName "+ util.utils.getImplName(oObj)); log.println("ImplName " + util.utils.getImplName(oObj));
TestEnvironment tEnv = new TestEnvironment( oObj ); TestEnvironment tEnv = new TestEnvironment(oObj);
tEnv.addObjRelation("MediaDescriptor", XMLTools.createMediaDescriptor( tEnv.addObjRelation("MediaDescriptor",
new String[] {"FilterName","URL", "MediaType"}, XMLTools.createMediaDescriptor(
new Object[] {"JPG",aURL, "image/jpeg"})); new String[] {
tEnv.addObjRelation("SourceDocument",xComp); "FilterName", "URL", "MediaType"
}, new Object[] { "JPG", aURL, "image/jpeg" }));
tEnv.addObjRelation("SourceDocument", xComp);
log.println("adding ObjRelation for XFilter"); log.println("adding ObjRelation for XFilter");
log.println("This Component doesn't really support the cancel method"); log.println("This Component doesn't really support the cancel method");
log.println("See #101725"); log.println("See #101725");
tEnv.addObjRelation("CANCEL", new Boolean(false)); tEnv.addObjRelation("NoFilter.cancel()", new Boolean(true));
final String hideMode = (String) tParam.get("soapi.test.hidewindows");
final String hideMode = (String) tParam.get("soapi.test.hidewindows") ;
tEnv.addObjRelation("XFilter.Checker", tEnv.addObjRelation("XFilter.Checker",
new ifc.document._XFilter.FilterChecker() { new ifc.document._XFilter.FilterChecker() {
public boolean checkFilter() { public boolean checkFilter() {
try { try {
if (hideMode != null && hideMode.equals("true")) if ((hideMode != null) && hideMode.equals("true")) {
return true ; return true;
return fAcc.exists(aURL.Complete) ; }
return fAcc.exists(aURL.Complete);
} catch (com.sun.star.uno.Exception e) { } catch (com.sun.star.uno.Exception e) {
return false ; return false;
} }
} }
}) ; });
return tEnv; return tEnv;
} // finish method getTestEnvironment } // finish method getTestEnvironment
} // finish class GraphicExporter } // finish class GraphicExporter
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment