2012-06-21 11:53:00 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2003-01-27 17:20:08 +00:00
|
|
|
package mod._forms;
|
|
|
|
|
2012-06-27 15:09:57 +02:00
|
|
|
import ifc.form._XDatabaseParameterBroadcaster;
|
|
|
|
import ifc.sdb._XCompletedExecution;
|
|
|
|
|
2003-09-08 10:47:02 +00:00
|
|
|
import java.io.PrintWriter;
|
2012-06-27 15:09:57 +02:00
|
|
|
import java.util.ArrayList;
|
2003-09-08 10:47:02 +00:00
|
|
|
import lib.StatusException;
|
|
|
|
import lib.TestCase;
|
|
|
|
import lib.TestEnvironment;
|
|
|
|
import lib.TestParameters;
|
|
|
|
import util.DBTools;
|
|
|
|
import util.DrawTools;
|
|
|
|
import util.FormTools;
|
|
|
|
import util.WriterTools;
|
|
|
|
import util.utils;
|
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
import com.sun.star.awt.XControl;
|
|
|
|
import com.sun.star.awt.XControlModel;
|
|
|
|
import com.sun.star.beans.PropertyValue;
|
|
|
|
import com.sun.star.beans.XPropertySet;
|
|
|
|
import com.sun.star.container.XIndexAccess;
|
|
|
|
import com.sun.star.container.XNameContainer;
|
|
|
|
import com.sun.star.container.XNamed;
|
|
|
|
import com.sun.star.drawing.XControlShape;
|
|
|
|
import com.sun.star.drawing.XShapes;
|
2003-11-18 15:27:32 +00:00
|
|
|
import com.sun.star.form.DatabaseParameterEvent;
|
2003-01-27 17:20:08 +00:00
|
|
|
import com.sun.star.form.XForm;
|
|
|
|
import com.sun.star.form.XLoadable;
|
2003-11-18 15:27:32 +00:00
|
|
|
import com.sun.star.lang.EventObject;
|
|
|
|
import com.sun.star.sdb.CommandType;
|
|
|
|
import com.sun.star.sdb.ParametersRequest;
|
2003-01-27 17:20:08 +00:00
|
|
|
import com.sun.star.sdb.RowChangeEvent;
|
|
|
|
import com.sun.star.sdbc.SQLException;
|
|
|
|
import com.sun.star.sdbc.XConnection;
|
|
|
|
import com.sun.star.sdbc.XResultSet;
|
|
|
|
import com.sun.star.sdbc.XResultSetUpdate;
|
|
|
|
import com.sun.star.sdbc.XRow;
|
|
|
|
import com.sun.star.sdbc.XRowSet;
|
|
|
|
import com.sun.star.sdbc.XRowUpdate;
|
2003-11-18 15:27:32 +00:00
|
|
|
import com.sun.star.task.XInteractionRequest;
|
2003-01-27 17:20:08 +00:00
|
|
|
import com.sun.star.text.XTextDocument;
|
2003-09-08 10:47:02 +00:00
|
|
|
import com.sun.star.uno.AnyConverter;
|
|
|
|
import com.sun.star.uno.Type;
|
2003-01-27 17:20:08 +00:00
|
|
|
import com.sun.star.uno.UnoRuntime;
|
|
|
|
import com.sun.star.uno.XInterface;
|
2003-11-18 15:27:32 +00:00
|
|
|
import com.sun.star.util.Date;
|
|
|
|
import com.sun.star.util.DateTime;
|
|
|
|
import com.sun.star.util.Time;
|
2003-09-08 10:47:02 +00:00
|
|
|
import com.sun.star.util.XCloseable;
|
2003-01-27 17:20:08 +00:00
|
|
|
import com.sun.star.view.XControlAccess;
|
|
|
|
|
2003-02-04 07:51:36 +00:00
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
/**
|
|
|
|
* Test for object which is represented by service
|
|
|
|
* <code>com.sun.star.form.component.DatabaseForm</code>. <p>
|
|
|
|
*
|
|
|
|
* Object implements the following interfaces :
|
|
|
|
* <ul>
|
|
|
|
* <li> <code>com::sun::star::script::XEventAttacherManager</code></li>
|
|
|
|
* <li> <code>com::sun::star::container::XElementAccess</code></li>
|
|
|
|
* <li> <code>com::sun::star::sdbcx::ResultSet</code></li>
|
|
|
|
* <li> <code>com::sun::star::container::XChild</code></li>
|
|
|
|
* <li> <code>com::sun::star::sdbc::XResultSetUpdate</code></li>
|
|
|
|
* <li> <code>com::sun::star::sdb::XResultSetAccess</code></li>
|
|
|
|
* <li> <code>com::sun::star::form::FormComponent</code></li>
|
|
|
|
* <li> <code>com::sun::star::form::component::DataForm</code></li>
|
|
|
|
* <li> <code>com::sun::star::sdbc::XResultSetMetaDataSupplier</code></li>
|
|
|
|
* <li> <code>com::sun::star::container::XEnumerationAccess</code></li>
|
|
|
|
* <li> <code>com::sun::star::sdbcx::XDeleteRows</code></li>
|
|
|
|
* <li> <code>com::sun::star::sdb::RowSet</code></li>
|
|
|
|
* <li> <code>com::sun::star::lang::XComponent</code></li>
|
|
|
|
* <li> <code>com::sun::star::sdbc::XRowSet</code></li>
|
|
|
|
* <li> <code>com::sun::star::sdbc::XRowUpdate</code></li>
|
|
|
|
* <li> <code>com::sun::star::form::XLoadable</code></li>
|
|
|
|
* <li> <code>com::sun::star::container::XNamed</code></li>
|
|
|
|
* <li> <code>com::sun::star::container::XIndexReplace</code></li>
|
|
|
|
* <li> <code>com::sun::star::io::XPersistObject</code></li>
|
|
|
|
* <li> <code>com::sun::star::container::XNameReplace</code></li>
|
|
|
|
* <li> <code>com::sun::star::container::XIndexContainer</code></li>
|
|
|
|
* <li> <code>com::sun::star::container::XNameAccess</code></li>
|
|
|
|
* <li> <code>com::sun::star::sdbc::XParameters</code></li>
|
|
|
|
* <li> <code>com::sun::star::util::XCancellable</code></li>
|
|
|
|
* <li> <code>com::sun::star::form::XReset</code></li>
|
|
|
|
* <li> <code>com::sun::star::sdbc::XCloseable</code></li>
|
|
|
|
* <li> <code>com::sun::star::sdbcx::XColumnsSupplier</code></li>
|
|
|
|
* <li> <code>com::sun::star::sdb::XRowSetApproveBroadcaster</code></li>
|
|
|
|
* <li> <code>com::sun::star::sdbc::ResultSet</code></li>
|
|
|
|
* <li> <code>com::sun::star::sdbc::XResultSet</code></li>
|
|
|
|
* <li> <code>com::sun::star::sdbc::XRow</code></li>
|
|
|
|
* <li> <code>com::sun::star::sdbc::XColumnLocate</code></li>
|
|
|
|
* <li> <code>com::sun::star::awt::XTabControllerModel</code></li>
|
|
|
|
* <li> <code>com::sun::star::container::XIndexAccess</code></li>
|
|
|
|
* <li> <code>com::sun::star::form::XSubmit</code></li>
|
|
|
|
* <li> <code>com::sun::star::form::component::HTMLForm</code></li>
|
|
|
|
* <li> <code>com::sun::star::sdbcx::XRowLocate</code></li>
|
|
|
|
* <li> <code>com::sun::star::sdbc::XWarningsSupplier</code></li>
|
|
|
|
* <li> <code>com::sun::star::container::XNameContainer</code></li>
|
2007-06-04 12:34:15 +00:00
|
|
|
* <li> <code>com::sun::star::beans::XPropertyAccess</code></li>
|
|
|
|
* <li> <code>com::sun::star::beans::XPropertyContainer</code></li>
|
2003-01-27 17:20:08 +00:00
|
|
|
* <li> <code>com::sun::star::beans::XPropertySet</code></li>
|
|
|
|
* <li> <code>com::sun::star::sdbc::RowSet</code></li>
|
|
|
|
* </ul> <p>
|
|
|
|
*
|
|
|
|
* This object test <b> is NOT </b> designed to be run in several
|
2015-06-08 14:06:08 +02:00
|
|
|
* threads concurrently.
|
2003-01-27 17:20:08 +00:00
|
|
|
* The following parameters in ini-file used by this test:
|
|
|
|
* <ul>
|
|
|
|
* <li><code>test.db.url</code> - URL to MySQL database.
|
|
|
|
* For example: <code>mysql://mercury:3306/api_current</code></li>
|
|
|
|
* <li><code>test.db.user</code> - user for MySQL database</li>
|
|
|
|
* <li><code>test.db.password</code> - password for MySQL database</li>
|
|
|
|
* </ul><p>
|
|
|
|
*
|
|
|
|
* @see com.sun.star.script.XEventAttacherManager
|
|
|
|
* @see com.sun.star.container.XElementAccess
|
|
|
|
* @see com.sun.star.sdbcx.ResultSet
|
|
|
|
* @see com.sun.star.container.XChild
|
|
|
|
* @see com.sun.star.sdbc.XResultSetUpdate
|
|
|
|
* @see com.sun.star.sdb.XResultSetAccess
|
|
|
|
* @see com.sun.star.form.FormComponent
|
|
|
|
* @see com.sun.star.form.component.DataForm
|
|
|
|
* @see com.sun.star.sdbc.XResultSetMetaDataSupplier
|
|
|
|
* @see com.sun.star.container.XEnumerationAccess
|
|
|
|
* @see com.sun.star.sdbcx.XDeleteRows
|
|
|
|
* @see com.sun.star.sdb.RowSet
|
|
|
|
* @see com.sun.star.lang.XComponent
|
|
|
|
* @see com.sun.star.sdbc.XRowSet
|
|
|
|
* @see com.sun.star.sdbc.XRowUpdate
|
|
|
|
* @see com.sun.star.form.XLoadable
|
|
|
|
* @see com.sun.star.container.XNamed
|
|
|
|
* @see com.sun.star.container.XIndexReplace
|
|
|
|
* @see com.sun.star.io.XPersistObject
|
|
|
|
* @see com.sun.star.container.XNameReplace
|
|
|
|
* @see com.sun.star.container.XIndexContainer
|
|
|
|
* @see com.sun.star.container.XNameAccess
|
|
|
|
* @see com.sun.star.sdbc.XParameters
|
|
|
|
* @see com.sun.star.util.XCancellable
|
|
|
|
* @see com.sun.star.form.XReset
|
|
|
|
* @see com.sun.star.sdbc.XCloseable
|
|
|
|
* @see com.sun.star.sdbcx.XColumnsSupplier
|
|
|
|
* @see com.sun.star.sdb.XRowSetApproveBroadcaster
|
|
|
|
* @see com.sun.star.sdbc.ResultSet
|
|
|
|
* @see com.sun.star.sdbc.XResultSet
|
|
|
|
* @see com.sun.star.sdbc.XRow
|
|
|
|
* @see com.sun.star.sdbc.XColumnLocate
|
|
|
|
* @see com.sun.star.awt.XTabControllerModel
|
|
|
|
* @see com.sun.star.container.XIndexAccess
|
|
|
|
* @see com.sun.star.form.XSubmit
|
|
|
|
* @see com.sun.star.form.component.HTMLForm
|
|
|
|
* @see com.sun.star.sdbcx.XRowLocate
|
|
|
|
* @see com.sun.star.sdbc.XWarningsSupplier
|
|
|
|
* @see com.sun.star.container.XNameContainer
|
|
|
|
* @see com.sun.star.beans.XPropertySet
|
|
|
|
* @see com.sun.star.sdbc.RowSet
|
|
|
|
* @see ifc.script._XEventAttacherManager
|
|
|
|
* @see ifc.container._XElementAccess
|
|
|
|
* @see ifc.sdbcx._ResultSet
|
|
|
|
* @see ifc.container._XChild
|
|
|
|
* @see ifc.sdbc._XResultSetUpdate
|
|
|
|
* @see ifc.sdb._XResultSetAccess
|
|
|
|
* @see ifc.form._FormComponent
|
|
|
|
* @see ifc.form.component._DataForm
|
|
|
|
* @see ifc.sdbc._XResultSetMetaDataSupplier
|
|
|
|
* @see ifc.container._XEnumerationAccess
|
|
|
|
* @see ifc.sdbcx._XDeleteRows
|
|
|
|
* @see ifc.sdb._RowSet
|
|
|
|
* @see ifc.lang._XComponent
|
|
|
|
* @see ifc.sdbc._XRowSet
|
|
|
|
* @see ifc.sdbc._XRowUpdate
|
|
|
|
* @see ifc.form._XLoadable
|
|
|
|
* @see ifc.container._XNamed
|
|
|
|
* @see ifc.container._XIndexReplace
|
|
|
|
* @see ifc.io._XPersistObject
|
|
|
|
* @see ifc.container._XNameReplace
|
|
|
|
* @see ifc.container._XIndexContainer
|
|
|
|
* @see ifc.container._XNameAccess
|
|
|
|
* @see ifc.sdbc._XParameters
|
|
|
|
* @see ifc.util._XCancellable
|
|
|
|
* @see ifc.form._XReset
|
|
|
|
* @see ifc.sdbc._XCloseable
|
|
|
|
* @see ifc.sdbcx._XColumnsSupplier
|
|
|
|
* @see ifc.sdb._XRowSetApproveBroadcaster
|
|
|
|
* @see ifc.sdbc._ResultSet
|
|
|
|
* @see ifc.sdbc._XResultSet
|
|
|
|
* @see ifc.sdbc._XRow
|
|
|
|
* @see ifc.sdbc._XColumnLocate
|
|
|
|
* @see ifc.awt._XTabControllerModel
|
|
|
|
* @see ifc.container._XIndexAccess
|
|
|
|
* @see ifc.form._XSubmit
|
|
|
|
* @see ifc.form.component._HTMLForm
|
|
|
|
* @see ifc.sdbcx._XRowLocate
|
|
|
|
* @see ifc.sdbc._XWarningsSupplier
|
|
|
|
* @see ifc.container._XNameContainer
|
2007-06-04 12:34:15 +00:00
|
|
|
* @see ifc.beans._XPropertyAccess
|
|
|
|
* @see ifc.beans._XPropertyContainer
|
2003-01-27 17:20:08 +00:00
|
|
|
* @see ifc.beans._XPropertySet
|
|
|
|
* @see ifc.sdbc._RowSet
|
|
|
|
*/
|
|
|
|
public class ODatabaseForm extends TestCase {
|
2015-06-12 09:30:14 +02:00
|
|
|
protected static final String dbSourceName = "ODatabaseFormDataSource";
|
2003-09-08 10:47:02 +00:00
|
|
|
private static int uniqueSuffix = 0;
|
|
|
|
private static String origDB = null;
|
|
|
|
private static String tmpDir = null;
|
2003-02-04 07:51:36 +00:00
|
|
|
protected XTextDocument xTextDoc = null;
|
2003-09-08 10:47:02 +00:00
|
|
|
private DBTools dbTools = null;
|
2003-01-27 17:20:08 +00:00
|
|
|
String tableName = null;
|
|
|
|
DBTools.DataSourceInfo srcInf = null;
|
|
|
|
boolean isMySQLDB = false;
|
|
|
|
protected XConnection conn = null;
|
2005-02-24 16:42:37 +00:00
|
|
|
private Object dbSrc = null;
|
2003-01-27 17:20:08 +00:00
|
|
|
|
2014-08-06 08:55:09 +02:00
|
|
|
@Override
|
2015-06-09 15:24:08 +02:00
|
|
|
protected void initialize(TestParameters tParam, PrintWriter log) throws Exception {
|
2014-08-04 13:16:37 +02:00
|
|
|
tmpDir = utils.getOfficeTemp((tParam.getMSF()));
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
origDB = util.utils.getFullTestDocName("TestDB/testDB.dbf");
|
|
|
|
|
2014-08-06 08:38:10 +02:00
|
|
|
dbTools = new DBTools( tParam.getMSF() );
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
// creating DataSource and registering it in DatabaseContext
|
|
|
|
String dbURL = (String) tParam.get("test.db.url");
|
|
|
|
String dbUser = (String) tParam.get("test.db.user");
|
|
|
|
String dbPassword = (String) tParam.get("test.db.password");
|
|
|
|
|
|
|
|
log.println("Creating and registering DataSource ...");
|
|
|
|
srcInf = dbTools.newDataSourceInfo();
|
2003-09-08 10:47:02 +00:00
|
|
|
|
|
|
|
if ((dbURL != null) && (dbUser != null) && (dbPassword != null)) {
|
2003-01-27 17:20:08 +00:00
|
|
|
isMySQLDB = true;
|
|
|
|
log.println("dbURL = " + dbURL);
|
|
|
|
log.println("dbUSER = " + dbUser);
|
|
|
|
log.println("dbPASSWORD = " + dbPassword);
|
2003-09-08 10:47:02 +00:00
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
//DataSource for mysql db
|
|
|
|
try {
|
|
|
|
tableName = "soffice_test_table";
|
|
|
|
srcInf.URL = "jdbc:" + dbURL;
|
2014-08-12 14:00:54 +02:00
|
|
|
srcInf.IsPasswordRequired = Boolean.TRUE;
|
2003-01-27 17:20:08 +00:00
|
|
|
srcInf.Password = dbPassword;
|
|
|
|
srcInf.User = dbUser;
|
2003-09-08 10:47:02 +00:00
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
PropertyValue[] propInfo = new PropertyValue[1];
|
|
|
|
propInfo[0] = new PropertyValue();
|
|
|
|
propInfo[0].Name = "JavaDriverClass";
|
2003-11-18 15:27:32 +00:00
|
|
|
propInfo[0].Value = "util.dddriver.Driver";
|
2003-01-27 17:20:08 +00:00
|
|
|
srcInf.Info = propInfo;
|
2003-09-08 10:47:02 +00:00
|
|
|
|
2005-02-24 16:42:37 +00:00
|
|
|
dbSrc = srcInf.getDataSourceService();
|
2003-01-27 17:20:08 +00:00
|
|
|
dbTools.reRegisterDB(dbSourceName, dbSrc);
|
|
|
|
} catch (com.sun.star.uno.Exception e) {
|
2003-09-08 10:47:02 +00:00
|
|
|
log.println("Error while object test initialization :");
|
|
|
|
e.printStackTrace(log);
|
2003-01-27 17:20:08 +00:00
|
|
|
throw new StatusException("Error while object test" +
|
2003-09-08 10:47:02 +00:00
|
|
|
" initialization", e);
|
2003-01-27 17:20:08 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//DataSource for sdbc db
|
|
|
|
try {
|
2005-11-02 16:50:10 +00:00
|
|
|
String myDbUrl = "sdbc:dbase:" + DBTools.dirToUrl(tmpDir);
|
|
|
|
srcInf.URL = myDbUrl;
|
|
|
|
|
|
|
|
log.println("try to register '"+myDbUrl+"' as '"+dbSourceName+"'");
|
2003-09-08 10:47:02 +00:00
|
|
|
|
2005-02-24 16:42:37 +00:00
|
|
|
dbSrc = srcInf.getDataSourceService();
|
2003-09-08 10:47:02 +00:00
|
|
|
dbTools.reRegisterDB(dbSourceName, dbSrc);
|
2003-01-27 17:20:08 +00:00
|
|
|
} catch (com.sun.star.uno.Exception e) {
|
2003-09-08 10:47:02 +00:00
|
|
|
log.println("Error while object test initialization :");
|
|
|
|
e.printStackTrace(log);
|
|
|
|
throw new StatusException(
|
|
|
|
"Error while object test initialization", e);
|
2003-01-27 17:20:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-08 10:47:02 +00:00
|
|
|
String oldF = null;
|
|
|
|
String newF = null;
|
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
do {
|
2003-09-08 10:47:02 +00:00
|
|
|
tableName = "ODatabaseForm_tmp" + uniqueSuffix;
|
2003-01-27 17:20:08 +00:00
|
|
|
oldF = utils.getFullURL(origDB);
|
2014-08-04 13:16:37 +02:00
|
|
|
newF = utils.getOfficeTemp(tParam.getMSF()) + tableName +
|
2003-09-08 10:47:02 +00:00
|
|
|
".dbf";
|
2014-08-04 13:16:37 +02:00
|
|
|
} while (!utils.tryOverwriteFile((tParam.getMSF()), oldF, newF) &&
|
2003-09-08 10:47:02 +00:00
|
|
|
(uniqueSuffix++ < 50));
|
|
|
|
}
|
2003-01-27 17:20:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-06-09 10:13:12 +02:00
|
|
|
* creating a TestEnvironment for the interfaces to be tested
|
2003-01-27 17:20:08 +00:00
|
|
|
*/
|
2014-08-06 08:55:09 +02:00
|
|
|
@Override
|
2015-06-09 10:13:12 +02:00
|
|
|
protected TestEnvironment createTestEnvironment(TestParameters Param,
|
2015-06-09 08:52:12 +02:00
|
|
|
PrintWriter log) throws Exception {
|
2003-02-04 07:51:36 +00:00
|
|
|
if (xTextDoc != null) {
|
2003-09-08 10:47:02 +00:00
|
|
|
try {
|
2012-06-27 15:40:17 +02:00
|
|
|
XCloseable closer = UnoRuntime.queryInterface(
|
2003-09-08 10:47:02 +00:00
|
|
|
XCloseable.class, xTextDoc);
|
|
|
|
closer.close(true);
|
|
|
|
} catch (com.sun.star.util.CloseVetoException e) {
|
|
|
|
log.println("couldn't close document");
|
|
|
|
} catch (com.sun.star.lang.DisposedException e) {
|
|
|
|
log.println("couldn't close document");
|
|
|
|
}
|
|
|
|
|
|
|
|
log.println("Existing document disposed");
|
2003-02-04 07:51:36 +00:00
|
|
|
}
|
|
|
|
|
2003-09-08 10:47:02 +00:00
|
|
|
log.println("creating a text document");
|
2014-08-04 13:16:37 +02:00
|
|
|
xTextDoc = WriterTools.createTextDoc((Param.getMSF()));
|
2003-02-04 07:51:36 +00:00
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
//initialize test table
|
|
|
|
if (isMySQLDB) {
|
2015-06-09 08:52:12 +02:00
|
|
|
dbTools.initTestTableUsingJDBC(tableName, srcInf);
|
2003-01-27 17:20:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
XInterface oObj = null;
|
|
|
|
XShapes oShapes = null;
|
|
|
|
XInterface oInstance = null;
|
2003-09-08 10:47:02 +00:00
|
|
|
XConnection connection = null;
|
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
// creation of testobject here
|
|
|
|
// first we write what we are intend to do to log file
|
2003-09-08 10:47:02 +00:00
|
|
|
log.println("creating a test environment");
|
|
|
|
|
|
|
|
XNameContainer forms = FormTools.getForms(WriterTools.getDrawPage(
|
|
|
|
xTextDoc));
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
String[] formNames = forms.getElementNames();
|
2003-09-08 10:47:02 +00:00
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
for (int i = 0; i < formNames.length; i++) {
|
|
|
|
log.println("Removing form '" + formNames[i] + "' ...");
|
2003-09-08 10:47:02 +00:00
|
|
|
forms.removeByName(formNames[i]);
|
2003-01-27 17:20:08 +00:00
|
|
|
}
|
|
|
|
} catch (com.sun.star.lang.WrappedTargetException e) {
|
|
|
|
e.printStackTrace(log);
|
|
|
|
} catch (com.sun.star.container.NoSuchElementException e) {
|
|
|
|
e.printStackTrace(log);
|
|
|
|
}
|
|
|
|
|
|
|
|
String[] formNames = forms.getElementNames();
|
|
|
|
FormTools.insertForm(xTextDoc, forms, "MyForm");
|
|
|
|
formNames = forms.getElementNames();
|
|
|
|
|
2003-09-08 10:47:02 +00:00
|
|
|
XLoadable formLoader = null;
|
|
|
|
|
2015-06-09 08:52:12 +02:00
|
|
|
formLoader = FormTools.bindForm(xTextDoc, "MyForm", dbSourceName,
|
|
|
|
tableName);
|
2003-01-27 17:20:08 +00:00
|
|
|
|
2003-09-08 10:47:02 +00:00
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
// DEBUG
|
2003-09-08 10:47:02 +00:00
|
|
|
log.println("Forms before adding controls : ");
|
|
|
|
formNames = forms.getElementNames();
|
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
for (int i = 0; i < formNames.length; i++) {
|
|
|
|
log.println(" '" + formNames[i] + "'");
|
|
|
|
}
|
|
|
|
|
2003-09-08 10:47:02 +00:00
|
|
|
XControlShape shape1 = null;
|
|
|
|
XControlShape shape2 = null;
|
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
try {
|
2003-09-08 10:47:02 +00:00
|
|
|
|
|
|
|
log.println("Elements in the 'MyForm' :");
|
|
|
|
|
2012-06-27 15:40:17 +02:00
|
|
|
XIndexAccess formElements1 = UnoRuntime.queryInterface(
|
2003-09-08 10:47:02 +00:00
|
|
|
XIndexAccess.class,
|
|
|
|
forms.getByName("MyForm"));
|
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
for (int i = 0; i < formElements1.getCount(); i++) {
|
2012-06-27 15:40:17 +02:00
|
|
|
XNamed elemName = UnoRuntime.queryInterface(
|
2003-09-08 10:47:02 +00:00
|
|
|
XNamed.class,
|
|
|
|
formElements1.getByIndex(i));
|
2003-01-27 17:20:08 +00:00
|
|
|
log.println(" '" + elemName.getName() + "'");
|
|
|
|
}
|
|
|
|
|
2003-09-08 10:47:02 +00:00
|
|
|
|
|
|
|
// END DEBUG
|
2003-01-27 17:20:08 +00:00
|
|
|
//put something on the drawpage
|
2003-09-08 10:47:02 +00:00
|
|
|
log.println("inserting some ControlShapes");
|
2003-01-27 17:20:08 +00:00
|
|
|
oShapes = DrawTools.getShapes(WriterTools.getDrawPage(xTextDoc));
|
2003-09-08 10:47:02 +00:00
|
|
|
shape1 = FormTools.createControlShape(xTextDoc, 3000, 4500, 15000,
|
|
|
|
1000, "CommandButton");
|
|
|
|
shape2 = FormTools.createControlShape(xTextDoc, 5000, 3500, 7500,
|
|
|
|
5000, "TextField");
|
|
|
|
|
|
|
|
XControlShape shape3 = FormTools.createControlShape(xTextDoc, 2000,
|
|
|
|
1500, 1000,
|
|
|
|
1000,
|
|
|
|
"CheckBox");
|
2012-06-27 16:08:28 +02:00
|
|
|
oShapes.add(shape1);
|
|
|
|
oShapes.add(shape2);
|
2003-09-08 10:47:02 +00:00
|
|
|
oShapes.add(shape3);
|
2003-01-27 17:20:08 +00:00
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace(log);
|
|
|
|
}
|
|
|
|
|
2003-09-08 10:47:02 +00:00
|
|
|
log.println("Forms after adding controls : ");
|
|
|
|
formNames = forms.getElementNames();
|
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
for (int i = 0; i < formNames.length; i++) {
|
|
|
|
log.println(" '" + formNames[i] + "'");
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2003-09-08 10:47:02 +00:00
|
|
|
log.println("Elements in the 'MyForm' :");
|
|
|
|
|
2012-06-27 15:40:17 +02:00
|
|
|
XIndexAccess formElements1 = UnoRuntime.queryInterface(
|
2003-09-08 10:47:02 +00:00
|
|
|
XIndexAccess.class,
|
|
|
|
forms.getByName("MyForm"));
|
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
for (int i = 0; i < formElements1.getCount(); i++) {
|
2012-06-27 15:40:17 +02:00
|
|
|
XNamed elemName = UnoRuntime.queryInterface(
|
2003-09-08 10:47:02 +00:00
|
|
|
XNamed.class,
|
|
|
|
formElements1.getByIndex(i));
|
2003-01-27 17:20:08 +00:00
|
|
|
log.println(" '" + elemName.getName() + "'");
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace(log);
|
|
|
|
}
|
|
|
|
|
|
|
|
formLoader.load();
|
|
|
|
|
|
|
|
try {
|
2003-02-04 07:51:36 +00:00
|
|
|
oObj = (XForm) AnyConverter.toObject(new Type(XForm.class),
|
2003-09-08 10:47:02 +00:00
|
|
|
(FormTools.getForms(
|
|
|
|
WriterTools.getDrawPage(
|
|
|
|
xTextDoc)))
|
|
|
|
.getByName("MyForm"));
|
|
|
|
|
2012-06-27 16:08:28 +02:00
|
|
|
XPropertySet xSetProp = UnoRuntime.queryInterface(
|
2003-09-08 10:47:02 +00:00
|
|
|
XPropertySet.class, oObj);
|
|
|
|
connection = (XConnection) AnyConverter.toObject(
|
|
|
|
new Type(XConnection.class),
|
|
|
|
xSetProp.getPropertyValue("ActiveConnection"));
|
|
|
|
} catch (com.sun.star.uno.Exception e) {
|
2003-01-27 17:20:08 +00:00
|
|
|
log.println("Couldn't get Form");
|
|
|
|
e.printStackTrace(log);
|
|
|
|
}
|
|
|
|
|
2003-09-08 10:47:02 +00:00
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
// get a control
|
|
|
|
oInstance = FormTools.createControl(xTextDoc, "TextField");
|
|
|
|
|
2003-09-08 10:47:02 +00:00
|
|
|
log.println("creating a new environment for drawpage object");
|
|
|
|
|
|
|
|
TestEnvironment tEnv = new TestEnvironment(oObj);
|
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
// adding relation for closing connection while environment disposing.
|
|
|
|
this.conn = connection;
|
|
|
|
|
|
|
|
// adding relation for XSubmit
|
2003-09-08 10:47:02 +00:00
|
|
|
XControlModel the_Model = shape2.getControl();
|
2012-06-27 15:40:17 +02:00
|
|
|
XControlAccess the_access = UnoRuntime.queryInterface(
|
2003-09-08 10:47:02 +00:00
|
|
|
XControlAccess.class,
|
|
|
|
xTextDoc.getCurrentController());
|
|
|
|
XControl cntrl = null;
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
//now get the OEditControl
|
2015-06-09 08:52:12 +02:00
|
|
|
cntrl = the_access.getControl(the_Model);
|
|
|
|
log.println(cntrl.getClass().getName());
|
2003-01-27 17:20:08 +00:00
|
|
|
|
2012-06-27 15:40:17 +02:00
|
|
|
XResultSet the_set = UnoRuntime.queryInterface(
|
2003-09-08 10:47:02 +00:00
|
|
|
XResultSet.class, oObj);
|
2003-01-27 17:20:08 +00:00
|
|
|
|
2015-06-09 10:39:00 +02:00
|
|
|
the_set.first();
|
2003-01-27 17:20:08 +00:00
|
|
|
|
2003-09-08 10:47:02 +00:00
|
|
|
tEnv.addObjRelation("Model1", shape1.getControl());
|
|
|
|
tEnv.addObjRelation("Model2", shape2.getControl());
|
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
// adding an object for XNameReplace testing
|
2003-09-08 10:47:02 +00:00
|
|
|
log.println("adding oInstace as obj relation to environment");
|
2003-01-27 17:20:08 +00:00
|
|
|
tEnv.addObjRelation("INSTANCE", oInstance);
|
|
|
|
|
2003-09-08 10:47:02 +00:00
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
// INDEX : _XNameContainer
|
2003-09-08 10:47:02 +00:00
|
|
|
log.println("adding INDEX as obj relation to environment");
|
2003-01-27 17:20:08 +00:00
|
|
|
tEnv.addObjRelation("INDEX", "0");
|
|
|
|
|
2003-09-08 10:47:02 +00:00
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
// INDEX : _XNameReplace
|
2003-09-08 10:47:02 +00:00
|
|
|
log.println("adding NameReplaceIndex as obj relation to environment");
|
2003-01-27 17:20:08 +00:00
|
|
|
tEnv.addObjRelation("XNameReplaceINDEX", "2");
|
|
|
|
|
2003-09-08 10:47:02 +00:00
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
// INSTANCEn : _XNameContainer; _XNameReplace
|
2003-09-08 10:47:02 +00:00
|
|
|
log.println("adding INSTANCEn as obj relation to environment");
|
2003-01-27 17:20:08 +00:00
|
|
|
|
2003-09-08 10:47:02 +00:00
|
|
|
String tc = (String) Param.get("THRCNT");
|
2003-01-27 17:20:08 +00:00
|
|
|
int THRCNT = 1;
|
2003-09-08 10:47:02 +00:00
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
if (tc != null) {
|
|
|
|
THRCNT = Integer.parseInt(tc);
|
|
|
|
}
|
2003-09-08 10:47:02 +00:00
|
|
|
|
|
|
|
for (int n = 1; n < (2 * (THRCNT + 1)); n++) {
|
|
|
|
log.println("adding INSTANCE" + n +
|
|
|
|
" as obj relation to environment");
|
2003-01-27 17:20:08 +00:00
|
|
|
tEnv.addObjRelation("INSTANCE" + n,
|
2003-09-08 10:47:02 +00:00
|
|
|
FormTools.createControl(xTextDoc, "CheckBox"));
|
2003-01-27 17:20:08 +00:00
|
|
|
}
|
|
|
|
|
2003-09-08 10:47:02 +00:00
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
// adding relation for XNameContainer
|
|
|
|
tEnv.addObjRelation("XNameContainer.AllowDuplicateNames", new Object());
|
|
|
|
|
2003-09-08 10:47:02 +00:00
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
// adding relation for XPersistObject
|
2003-09-08 10:47:02 +00:00
|
|
|
tEnv.addObjRelation("OBJNAME", "stardiv.one.form.component.Form");
|
|
|
|
|
|
|
|
if (the_set != null) {
|
|
|
|
log.println("The Form has a not empty ResultSet");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Adding obj relation for XRowSetApproveBroadcaster test
|
2012-06-27 15:40:17 +02:00
|
|
|
final XResultSet xResSet = UnoRuntime.queryInterface(
|
2003-09-08 10:47:02 +00:00
|
|
|
XResultSet.class, oObj);
|
2012-06-27 15:40:17 +02:00
|
|
|
final XResultSetUpdate xResSetUpdate = UnoRuntime.queryInterface(
|
2003-09-08 10:47:02 +00:00
|
|
|
XResultSetUpdate.class,
|
|
|
|
oObj);
|
2012-06-27 15:40:17 +02:00
|
|
|
final XRowSet xRowSet = UnoRuntime.queryInterface(
|
2003-09-08 10:47:02 +00:00
|
|
|
XRowSet.class, oObj);
|
|
|
|
final PrintWriter logF = log;
|
|
|
|
tEnv.addObjRelation("XRowSetApproveBroadcaster.ApproveChecker",
|
|
|
|
new ifc.sdb._XRowSetApproveBroadcaster.RowSetApproveChecker() {
|
|
|
|
public void moveCursor() {
|
|
|
|
try {
|
|
|
|
xResSet.beforeFirst();
|
|
|
|
xResSet.afterLast();
|
|
|
|
} catch (com.sun.star.sdbc.SQLException e) {
|
|
|
|
logF.println("### _XRowSetApproveBroadcaster." + "RowSetApproveChecker.moveCursor() :");
|
|
|
|
e.printStackTrace(logF);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public RowChangeEvent changeRow() {
|
|
|
|
try {
|
|
|
|
xResSet.first();
|
|
|
|
|
2012-06-27 15:40:17 +02:00
|
|
|
XRowUpdate row = UnoRuntime.queryInterface(
|
2003-09-08 10:47:02 +00:00
|
|
|
XRowUpdate.class, xResSet);
|
|
|
|
row.updateString(1, "1");
|
|
|
|
xResSetUpdate.updateRow();
|
|
|
|
} catch (com.sun.star.sdbc.SQLException e) {
|
|
|
|
logF.println("### _XRowSetApproveBroadcaster." + "RowSetApproveChecker.changeRow() :");
|
|
|
|
e.printStackTrace(logF);
|
|
|
|
}
|
|
|
|
|
|
|
|
RowChangeEvent ev = new RowChangeEvent();
|
|
|
|
ev.Action = com.sun.star.sdb.RowChangeAction.UPDATE;
|
|
|
|
ev.Rows = 1;
|
|
|
|
|
|
|
|
return ev;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void changeRowSet() {
|
|
|
|
try {
|
|
|
|
xRowSet.execute();
|
|
|
|
} catch (com.sun.star.sdbc.SQLException e) {
|
|
|
|
logF.println("### _XRowSetApproveBroadcaster." + "RowSetApproveChecker.changeRowSet() :");
|
|
|
|
e.printStackTrace(logF);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
// Adding relation for XColumnLocate test
|
2003-09-08 10:47:02 +00:00
|
|
|
tEnv.addObjRelation("XColumnLocate.ColumnName", DBTools.TST_STRING_F);
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
// Adding relation for XParameters ifc test
|
2012-06-27 15:40:17 +02:00
|
|
|
ArrayList<Object> params = new ArrayList<Object>();
|
2003-09-08 10:47:02 +00:00
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
/***** statement parameter types and their initial
|
2003-11-18 15:27:32 +00:00
|
|
|
values must be added here as relation. */
|
2013-11-24 20:58:56 +01:00
|
|
|
params.add("SAU99") ;
|
2014-08-12 14:00:54 +02:00
|
|
|
params.add(Boolean.FALSE) ;
|
2014-08-12 15:13:30 +02:00
|
|
|
params.add(Byte.valueOf((byte) 123)) ;
|
2014-08-12 15:12:27 +02:00
|
|
|
params.add(Short.valueOf((short) 234)) ;
|
2014-08-12 15:09:06 +02:00
|
|
|
params.add(Integer.valueOf(12345)) ;
|
2014-08-12 15:10:41 +02:00
|
|
|
params.add(Long.valueOf(23456)) ;
|
2003-01-27 17:20:08 +00:00
|
|
|
params.add(new Float(1.234)) ;
|
|
|
|
params.add(new Double(2.345)) ;
|
|
|
|
params.add(new byte[] {1, 2, 3}) ;
|
2003-11-18 15:27:32 +00:00
|
|
|
Date d = new Date();
|
|
|
|
d.Day = 26; d.Month = 1; d.Year = 2001;
|
|
|
|
params.add(d) ;
|
|
|
|
Time t = new Time();
|
2013-03-17 08:36:26 +01:00
|
|
|
t.Hours = 1; t.NanoSeconds = 123456789; t.Minutes = 25; t.Seconds = 14;
|
2003-11-18 15:27:32 +00:00
|
|
|
params.add(t) ;
|
|
|
|
DateTime dt = new DateTime();
|
|
|
|
dt.Day = 26; dt.Month = 1; dt.Year = 2001; dt.Hours = 1;
|
2013-03-17 08:36:26 +01:00
|
|
|
dt.NanoSeconds = 123456789; dt.Minutes = 25; dt.Seconds = 14;
|
2003-11-18 15:27:32 +00:00
|
|
|
params.add(dt) ;
|
2003-09-08 10:47:02 +00:00
|
|
|
tEnv.addObjRelation("XParameters.ParamValues", params);
|
2003-01-27 17:20:08 +00:00
|
|
|
|
2003-11-18 15:27:32 +00:00
|
|
|
// Adding relation for XCompletedExecution
|
|
|
|
tEnv.addObjRelation("InteractionHandlerChecker", new InteractionHandlerImpl());
|
|
|
|
|
|
|
|
// Adding for XWarningSupplier
|
2014-08-12 14:00:54 +02:00
|
|
|
tEnv.addObjRelation("CheckWarningsSupplier", Boolean.valueOf(isMySQLDB));
|
2003-11-18 15:27:32 +00:00
|
|
|
|
|
|
|
// Adding relation for XDatabaseParameterBroadcaster
|
|
|
|
tEnv.addObjRelation("ParameterListenerChecker", new ODatabaseForm.ParameterListenerImpl());
|
2012-06-27 16:08:28 +02:00
|
|
|
XPropertySet xSetProp = UnoRuntime.queryInterface
|
2003-11-18 15:27:32 +00:00
|
|
|
(XPropertySet.class, oObj) ;
|
|
|
|
try {
|
|
|
|
xSetProp.setPropertyValue("DataSourceName", dbSourceName) ;
|
|
|
|
if(isMySQLDB) {
|
|
|
|
xSetProp.setPropertyValue("Command", "SELECT Column0 FROM soffice_test_table WHERE ( ( Column0 = :param1 ) )");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
xSetProp.setPropertyValue("Command", "SELECT \"_TEXT\" FROM \"ODatabaseForm_tmp0\" WHERE ( ( \"_TEXT\" = :param1 ) )");
|
|
|
|
}
|
|
|
|
|
|
|
|
xSetProp.setPropertyValue("CommandType",
|
2014-08-12 15:09:06 +02:00
|
|
|
Integer.valueOf(CommandType.COMMAND)) ;
|
2003-11-18 15:27:32 +00:00
|
|
|
}
|
|
|
|
catch(Exception e) {
|
|
|
|
}
|
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
// Adding relation for XResultSetUpdate
|
2012-06-27 15:40:17 +02:00
|
|
|
final XRowUpdate xRowUpdate = UnoRuntime.queryInterface(
|
2003-09-08 10:47:02 +00:00
|
|
|
XRowUpdate.class, oObj);
|
2012-06-27 15:40:17 +02:00
|
|
|
final XRow xRow = UnoRuntime.queryInterface(XRow.class, oObj);
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
tEnv.addObjRelation("XResultSetUpdate.UpdateTester",
|
2003-09-08 10:47:02 +00:00
|
|
|
new ifc.sdbc._XResultSetUpdate.UpdateTester() {
|
|
|
|
String lastUpdate = null;
|
2003-01-27 17:20:08 +00:00
|
|
|
|
2003-09-08 10:47:02 +00:00
|
|
|
public int rowCount() throws SQLException {
|
|
|
|
int prevPos = xResSet.getRow();
|
|
|
|
xResSet.last();
|
2003-01-27 17:20:08 +00:00
|
|
|
|
2003-09-08 10:47:02 +00:00
|
|
|
int count = xResSet.getRow();
|
|
|
|
xResSet.absolute(prevPos);
|
2003-01-27 17:20:08 +00:00
|
|
|
|
2003-09-08 10:47:02 +00:00
|
|
|
return count;
|
|
|
|
}
|
2003-01-27 17:20:08 +00:00
|
|
|
|
2003-09-08 10:47:02 +00:00
|
|
|
public void update() throws SQLException {
|
|
|
|
lastUpdate = xRow.getString(1);
|
|
|
|
lastUpdate += "_";
|
|
|
|
xRowUpdate.updateString(1, lastUpdate);
|
|
|
|
}
|
2003-01-27 17:20:08 +00:00
|
|
|
|
2003-09-08 10:47:02 +00:00
|
|
|
public boolean wasUpdated() throws SQLException {
|
|
|
|
String getStr = xRow.getString(1);
|
|
|
|
|
|
|
|
return lastUpdate.equals(getStr);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int currentRow() throws SQLException {
|
|
|
|
return xResSet.getRow();
|
|
|
|
}
|
|
|
|
});
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
// Adding relations for XRow as a Vector with all data
|
|
|
|
// of current row of RowSet.
|
|
|
|
|
2012-06-27 15:40:17 +02:00
|
|
|
ArrayList<Object> rowData = new ArrayList<Object>();
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < DBTools.TST_TABLE_VALUES[0].length; i++) {
|
|
|
|
rowData.add(DBTools.TST_TABLE_VALUES[0][i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
tEnv.addObjRelation("CurrentRowData", rowData);
|
|
|
|
|
|
|
|
// Adding relation for XRowUpdate
|
2012-06-27 15:40:17 +02:00
|
|
|
XRow row = UnoRuntime.queryInterface(XRow.class, oObj);
|
2003-01-27 17:20:08 +00:00
|
|
|
tEnv.addObjRelation("XRowUpdate.XRow", row);
|
|
|
|
|
2007-06-04 12:34:15 +00:00
|
|
|
|
|
|
|
tEnv.addObjRelation("XPropertyContainer.propertyNotRemovable", "Cycle");
|
|
|
|
|
|
|
|
PropertyValue propVal = new PropertyValue();
|
|
|
|
propVal.Name = "Name";
|
|
|
|
propVal.Value = "Text since XPropertyAccess";
|
|
|
|
|
|
|
|
tEnv.addObjRelation("XPropertyAccess.propertyToChange", propVal);
|
|
|
|
|
2003-01-27 17:20:08 +00:00
|
|
|
return tEnv;
|
|
|
|
} // finish method getTestEnvironment
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Closes connection of <code>RowSet</code> instance created.
|
|
|
|
*/
|
2014-08-06 08:55:09 +02:00
|
|
|
@Override
|
2003-09-08 10:47:02 +00:00
|
|
|
protected void cleanup(TestParameters Param, PrintWriter log) {
|
2005-02-24 16:42:37 +00:00
|
|
|
log.println("closing connection...");
|
2003-01-27 17:20:08 +00:00
|
|
|
try {
|
|
|
|
conn.close();
|
|
|
|
} catch (com.sun.star.uno.Exception e) {
|
|
|
|
log.println("Can't close the connection");
|
|
|
|
e.printStackTrace(log);
|
|
|
|
} catch (com.sun.star.lang.DisposedException e) {
|
|
|
|
log.println("Connection was already closed. It's OK.");
|
|
|
|
}
|
2003-09-08 10:47:02 +00:00
|
|
|
|
2005-02-24 16:42:37 +00:00
|
|
|
|
|
|
|
log.println("closing data source...");
|
|
|
|
try {
|
2012-06-27 15:40:17 +02:00
|
|
|
XCloseable closer = UnoRuntime.queryInterface(
|
2005-02-24 16:42:37 +00:00
|
|
|
XCloseable.class, dbSrc);
|
|
|
|
closer.close(true);
|
|
|
|
} catch (com.sun.star.util.CloseVetoException e) {
|
|
|
|
log.println("couldn't close data source");
|
|
|
|
} catch (com.sun.star.lang.DisposedException e) {
|
|
|
|
log.println("couldn't close data source");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
log.println("closing document...");
|
2003-01-27 17:20:08 +00:00
|
|
|
|
|
|
|
try {
|
2012-06-27 15:40:17 +02:00
|
|
|
XCloseable closer = UnoRuntime.queryInterface(
|
2003-09-08 10:47:02 +00:00
|
|
|
XCloseable.class, xTextDoc);
|
|
|
|
closer.close(true);
|
|
|
|
} catch (com.sun.star.util.CloseVetoException e) {
|
|
|
|
log.println("couldn't close document");
|
|
|
|
} catch (com.sun.star.lang.DisposedException e) {
|
|
|
|
log.println("couldn't close document");
|
|
|
|
}
|
|
|
|
|
2005-02-24 16:42:37 +00:00
|
|
|
log.println("revoking data source...");
|
2003-09-08 10:47:02 +00:00
|
|
|
try {
|
|
|
|
dbTools.revokeDB(dbSourceName);
|
2005-02-24 16:42:37 +00:00
|
|
|
} catch (com.sun.star.container.NoSuchElementException e){
|
2003-01-27 17:20:08 +00:00
|
|
|
} catch (com.sun.star.uno.Exception e) {
|
2003-09-08 10:47:02 +00:00
|
|
|
log.println("Error while object test cleaning up :");
|
|
|
|
e.printStackTrace(log);
|
|
|
|
throw new StatusException("Error while object test cleaning up", e);
|
2003-01-27 17:20:08 +00:00
|
|
|
}
|
|
|
|
}
|
2003-11-18 15:27:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation of interface _XDatabaseParameterBroadcaster.CheckParameterListener
|
|
|
|
* for the XDatabaseParameterBroadcaster test
|
|
|
|
* @see ifc.form._XDatabaseParameterBroadcaster
|
|
|
|
*/
|
2014-12-10 15:36:24 +02:00
|
|
|
private class ParameterListenerImpl implements _XDatabaseParameterBroadcaster.CheckParameterListener {
|
|
|
|
private boolean listenerWasCalled = false;
|
|
|
|
private PrintWriter log = new PrintWriter(System.out);
|
2003-11-18 15:27:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true, if the listener was called, false otherwise.
|
|
|
|
* @return True, if any other method of the listener was called.
|
|
|
|
*/
|
|
|
|
public boolean checkListener() {
|
|
|
|
return listenerWasCalled;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Take the DataBaseParameterEvent and fill it with a meaningful value.
|
|
|
|
* @param e The database parameter that will be filled with a value.
|
|
|
|
* @return True, if the value could be filled.
|
|
|
|
*/
|
|
|
|
public boolean approveParameter(DatabaseParameterEvent e) {
|
|
|
|
log.println("### ParameterListenerImpl: approve called.");
|
|
|
|
XIndexAccess params = e.Parameters;
|
|
|
|
int count = params.getCount();
|
|
|
|
try {
|
|
|
|
for(int i=0; i<count; i++) {
|
|
|
|
log.println("### _XDatabaseParameterBroadcaster.ParameterListenerImpl: Parameter "+i+": "+params.getByIndex(i));
|
2012-06-27 16:08:28 +02:00
|
|
|
XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class, params.getByIndex(i));
|
2003-11-18 15:27:32 +00:00
|
|
|
log.println("### _XDatabaseParameterBroadcaster.ParameterListenerImpl: Parameter Name: '"+xProp.getPropertyValue("Name") + "' is set to Value '1'");
|
2014-08-12 15:09:06 +02:00
|
|
|
xProp.setPropertyValue("Value", Integer.valueOf(1));
|
2003-11-18 15:27:32 +00:00
|
|
|
listenerWasCalled = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception eI) {
|
|
|
|
log.println("### _XDatabaseParameterBroadcaster.ParameterListenerImpl: Exception!");
|
|
|
|
eI.printStackTrace(log);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Dummy implemetnation. Do nothing, just log
|
|
|
|
* @param o Ignore.
|
|
|
|
*/
|
|
|
|
public void disposing(EventObject o) {
|
|
|
|
log.println("### _XDatabaseParameterBroadcaster.ParameterListenerImpl: disposing");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a log writer, so messages go to log instead of Standard.out
|
|
|
|
* @param log The log messages get printed to.
|
|
|
|
*/
|
|
|
|
public void setLog(PrintWriter log) {
|
|
|
|
this.log = log;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation of interface _XCompletedExecution.CheckInteractionHandler
|
|
|
|
* for the XCompletedExecution test
|
|
|
|
* @see ifc.sdb._XCompletedExecution
|
|
|
|
*/
|
2015-10-15 08:54:31 +02:00
|
|
|
private static class InteractionHandlerImpl implements _XCompletedExecution.CheckInteractionHandler {
|
2003-11-18 15:27:32 +00:00
|
|
|
private boolean handlerWasUsed = false;
|
|
|
|
private PrintWriter log = new PrintWriter(System.out);
|
|
|
|
|
|
|
|
public boolean checkInteractionHandler() {
|
|
|
|
return handlerWasUsed;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void handle(XInteractionRequest xInteractionRequest) {
|
|
|
|
log.println("### _XCompletedExecution.InteractionHandlerImpl: handle called.");
|
|
|
|
handlerWasUsed = true;
|
|
|
|
|
|
|
|
Object o = xInteractionRequest.getRequest();
|
|
|
|
ParametersRequest req = (ParametersRequest)o;
|
|
|
|
XIndexAccess params = req.Parameters;
|
|
|
|
int count = params.getCount();
|
|
|
|
try {
|
|
|
|
for(int i=0; i<count; i++) {
|
2012-06-27 16:22:54 +02:00
|
|
|
params.getByIndex(i);
|
2003-11-18 15:27:32 +00:00
|
|
|
log.println("### _XCompletedExecution.InteractionHandlerImpl: Parameter "+i+": "+params.getByIndex(i));
|
2012-06-27 16:08:28 +02:00
|
|
|
XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class, params.getByIndex(i));
|
2003-11-18 15:27:32 +00:00
|
|
|
log.println("### _XCompletedExecution.InteractionHandlerImpl: Parameter Name: '"+xProp.getPropertyValue("Name") + "' is set to Value '1'");
|
2014-08-12 15:09:06 +02:00
|
|
|
xProp.setPropertyValue("Value", Integer.valueOf(1));
|
2003-11-18 15:27:32 +00:00
|
|
|
handlerWasUsed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception eI) {
|
|
|
|
log.println("### _XCompletedExecution.InteractionHandlerImpl: Exception!");
|
|
|
|
eI.printStackTrace(log);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLog(PrintWriter log) {
|
|
|
|
this.log = log;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2003-09-08 10:47:02 +00:00
|
|
|
} // finish class ODatabaseForm
|