summaryrefslogtreecommitdiff
path: root/forms
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@sun.com>2009-11-05 14:33:55 +0100
committerFrank Schoenheit [fs] <frank.schoenheit@sun.com>2009-11-05 14:33:55 +0100
commita7b054e6309a841df1c67696258af8ad19cebdea (patch)
tree383811d31673b47585924856a8f26ef7545e01bd /forms
parent6ad1eebbe252c983a3f915912cd119e36af0bfed (diff)
new test case catching issue #i105235# (note that the fix for this issue is not yet in here, so until we rebase to a milestone where CWS dba32h resp. dba32j are integrated, the test will fail)
Diffstat (limited to 'forms')
-rw-r--r--forms/qa/integration/forms/FormLayer.java20
-rw-r--r--forms/qa/integration/forms/MasterDetailForms.java334
-rw-r--r--forms/qa/org/openoffice/complex/forms/tools/ResultSet.java264
-rw-r--r--forms/source/component/DatabaseForm.cxx26
4 files changed, 550 insertions, 94 deletions
diff --git a/forms/qa/integration/forms/FormLayer.java b/forms/qa/integration/forms/FormLayer.java
index d67e28bcf412..21767b254ae0 100644
--- a/forms/qa/integration/forms/FormLayer.java
+++ b/forms/qa/integration/forms/FormLayer.java
@@ -42,6 +42,7 @@ import com.sun.star.drawing.XControlShape;
import com.sun.star.drawing.XShapes;
import com.sun.star.awt.Size;
import com.sun.star.awt.Point;
+import com.sun.star.awt.VisualEffect;
import com.sun.star.awt.XControlModel;
import com.sun.star.text.TextContentAnchorType;
import com.sun.star.drawing.XDrawPage;
@@ -95,7 +96,7 @@ public class FormLayer
the property access to the control's model
*/
public XPropertySet createControlAndShape( String sFormComponentService, int nXPos,
- int nYPos, int nWidth, int nHeight, XIndexContainer xParentForm ) throws java.lang.Exception
+ int nYPos, int nWidth, int nHeight, Object _parentForm ) throws java.lang.Exception
{
// let the document create a shape
XMultiServiceFactory xDocAsFactory = (XMultiServiceFactory)UnoRuntime.queryInterface(
@@ -118,9 +119,14 @@ public class FormLayer
m_document.getOrb().createInstance( sQualifiedComponentName ) );
// insert the model into the form component hierarchy, if the caller gave us a location
- if ( null != xParentForm )
+ if ( null != _parentForm )
{
- xParentForm.insertByIndex( xParentForm.getCount(), xModel );
+ XIndexContainer parentForm = null;
+ if ( _parentForm instanceof XIndexContainer )
+ parentForm = (XIndexContainer)_parentForm;
+ else
+ parentForm = (XIndexContainer)UnoRuntime.queryInterface( XIndexContainer.class, _parentForm );
+ parentForm.insertByIndex( parentForm.getCount(), xModel );
}
// knitt them
@@ -231,6 +237,12 @@ public class FormLayer
// insert the text field control
XPropertySet xFieldModel = createControlAndShape( sControlType, nXPos + 26, nYPos, 40, nHeight );
xFieldModel.setPropertyValue( "DataField", sFieldName );
+ if ( xFieldModel.getPropertySetInfo().hasPropertyByName( "Border" ) )
+ {
+ xFieldModel.setPropertyValue( "Border", new Short( VisualEffect.FLAT ) );
+ if ( xFieldModel.getPropertySetInfo().hasPropertyByName( "BorderColor" ) )
+ xFieldModel.setPropertyValue( "BorderColor", new Integer( 0x00C0C0C0 ) );
+ }
// knit it to it's label component
xFieldModel.setPropertyValue( "LabelControl", xLabelModel );
@@ -256,7 +268,7 @@ public class FormLayer
public XPropertySet insertControlLine( String sControlType, String sFieldName, String sControlNamePostfix, int nYPos )
throws java.lang.Exception
{
- return insertControlLine( sControlType, sFieldName, sControlNamePostfix, 2, nYPos, 6 );
+ return insertControlLine( sControlType, sFieldName, sControlNamePostfix, 10, nYPos, 6 );
}
/* ------------------------------------------------------------------ */
diff --git a/forms/qa/integration/forms/MasterDetailForms.java b/forms/qa/integration/forms/MasterDetailForms.java
index 2b83a11dd223..ffebe93ee559 100644
--- a/forms/qa/integration/forms/MasterDetailForms.java
+++ b/forms/qa/integration/forms/MasterDetailForms.java
@@ -30,67 +30,77 @@
package integration.forms;
+import com.sun.star.beans.NamedValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XIndexContainer;
import java.lang.reflect.Method;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.lang.XMultiServiceFactory;
-import com.sun.star.beans.*;
import com.sun.star.container.XNameContainer;
+import com.sun.star.embed.XComponentSupplier;
+import com.sun.star.form.XGridColumnFactory;
+import com.sun.star.form.XGridFieldDataSupplier;
import com.sun.star.form.XLoadable;
-import com.sun.star.sdbc.*;
-
-import connectivity.tools.*;
+import com.sun.star.lang.XComponent;
+import com.sun.star.sdb.CommandType;
+import com.sun.star.sdb.XFormDocumentsSupplier;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.sdbc.XColumnLocate;
+import com.sun.star.ucb.Command;
+import com.sun.star.ucb.OpenMode;
+import com.sun.star.ucb.XCommandProcessor;
+import com.sun.star.uno.Type;
+import com.sun.star.util.XModifiable;
+import connectivity.tools.CRMDatabase;
+import connectivity.tools.HsqlColumnDescriptor;
+import connectivity.tools.HsqlDatabase;
+import connectivity.tools.HsqlTableDescriptor;
+import org.openoffice.complex.forms.tools.ResultSet;
public class MasterDetailForms extends complexlib.ComplexTestCase implements com.sun.star.form.XLoadListener
{
private XMultiServiceFactory m_orb;
- private HsqlDatabase m_databaseDocument;
private XPropertySet m_masterForm;
private XPropertySet m_detailForm;
- private XResultSet m_masterSet;
- private XResultSet m_detailSet;
- private XRow m_masterRow;
- private XRow m_detailRow;
+ private ResultSet m_masterResult;
+ private ResultSet m_detailResult;
- private Object m_waitForLoad;
- private boolean m_loaded;
+ final private Object m_waitForLoad = new Object();
+ private boolean m_loaded = false;
- /** Creates a new instance of ValueBinding */
+ /** Creates a new instance of MasterDetailForms */
public MasterDetailForms()
{
- m_loaded = false;
- m_waitForLoad = new Object();
}
/* ------------------------------------------------------------------ */
public String[] getTestMethodNames()
{
return new String[] {
- "checkMultipleKeys"
+ "checkMultipleKeys",
+ "checkDetailFormDefaults"
};
}
/* ------------------------------------------------------------------ */
- public String getTestObjectName()
+ public void before()
{
- return "Form Control Spreadsheet Cell Binding Test";
+ m_orb = (XMultiServiceFactory)param.getMSF();
}
/* ------------------------------------------------------------------ */
- public void before() throws java.lang.Exception
+ public String getTestObjectName()
{
- m_orb = (XMultiServiceFactory)param.getMSF();
- m_databaseDocument = new HsqlDatabase( m_orb );
- createTableStructure();
- createForms();
+ return "Form Control Spreadsheet Cell Binding Test";
}
/* ------------------------------------------------------------------ */
/** creates the table structure needed for the test
*/
- private void createTableStructure() throws SQLException
+ private void impl_createTableStructure( final HsqlDatabase _databaseDocument ) throws SQLException
{
HsqlColumnDescriptor[] masterColumns = {
new HsqlColumnDescriptor( "ID1", "INTEGER", HsqlColumnDescriptor.PRIMARY ),
@@ -103,94 +113,257 @@ public class MasterDetailForms extends complexlib.ComplexTestCase implements com
new HsqlColumnDescriptor( "FK_ID2", "INTEGER", HsqlColumnDescriptor.REQUIRED, "master", "ID2" ),
new HsqlColumnDescriptor( "name", "VARCHAR(50)" ),
};
- m_databaseDocument.createTable( new HsqlTableDescriptor( "master", masterColumns ) );
- m_databaseDocument.createTable( new HsqlTableDescriptor( "detail", detailColumns ) );
+ _databaseDocument.createTable( new HsqlTableDescriptor( "master", masterColumns ) );
+ _databaseDocument.createTable( new HsqlTableDescriptor( "detail", detailColumns ) );
- m_databaseDocument.executeSQL( "INSERT INTO \"master\" VALUES ( 1, 1, 'First Record' )" );
- m_databaseDocument.executeSQL( "INSERT INTO \"master\" VALUES ( 1, 2, 'Second Record' )" );
- m_databaseDocument.executeSQL( "INSERT INTO \"detail\" VALUES ( 1, 1, 1, 'record 1.1 (1)')");
- m_databaseDocument.executeSQL( "INSERT INTO \"detail\" VALUES ( 2, 1, 1, 'record 1.1 (2)')");
- m_databaseDocument.executeSQL( "INSERT INTO \"detail\" VALUES ( 3, 1, 2, 'record 1.2 (1)')");
+ _databaseDocument.executeSQL( "INSERT INTO \"master\" VALUES ( 1, 1, 'First Record' )" );
+ _databaseDocument.executeSQL( "INSERT INTO \"master\" VALUES ( 1, 2, 'Second Record' )" );
+ _databaseDocument.executeSQL( "INSERT INTO \"detail\" VALUES ( 1, 1, 1, 'record 1.1 (1)')");
+ _databaseDocument.executeSQL( "INSERT INTO \"detail\" VALUES ( 2, 1, 1, 'record 1.1 (2)')");
+ _databaseDocument.executeSQL( "INSERT INTO \"detail\" VALUES ( 3, 1, 2, 'record 1.2 (1)')");
- m_databaseDocument.getDataSource().refreshTables( m_databaseDocument.defaultConnection() );
+ _databaseDocument.getDataSource().refreshTables( _databaseDocument.defaultConnection() );
}
/* ------------------------------------------------------------------ */
- public void createForms() throws com.sun.star.uno.Exception
+ private void impl_createForms( final HsqlDatabase _databaseDocument ) throws com.sun.star.uno.Exception
{
m_masterForm = dbfTools.queryPropertySet( m_orb.createInstance( "com.sun.star.form.component.DataForm" ) );
- m_masterRow = (XRow)UnoRuntime.queryInterface( XRow.class, m_masterForm );
- m_masterSet = (XResultSet)UnoRuntime.queryInterface( XResultSet.class, m_masterForm );
- m_masterForm.setPropertyValue( "ActiveConnection", m_databaseDocument.defaultConnection() );
+ m_masterForm.setPropertyValue( "ActiveConnection", _databaseDocument.defaultConnection() );
m_masterForm.setPropertyValue( "CommandType", new Integer( com.sun.star.sdb.CommandType.TABLE ) );
m_masterForm.setPropertyValue( "Command", "master" );
+ m_masterResult = new ResultSet( m_masterForm );
+
m_detailForm = dbfTools.queryPropertySet( m_orb.createInstance( "com.sun.star.form.component.DataForm" ) );
- m_detailRow = (XRow)UnoRuntime.queryInterface( XRow.class, m_detailForm );
- m_detailSet = (XResultSet)UnoRuntime.queryInterface( XResultSet.class, m_detailForm );
- m_detailForm.setPropertyValue( "ActiveConnection", m_databaseDocument.defaultConnection() );
+ m_detailForm.setPropertyValue( "ActiveConnection", _databaseDocument.defaultConnection() );
m_detailForm.setPropertyValue( "CommandType", new Integer( com.sun.star.sdb.CommandType.TABLE ) );
m_detailForm.setPropertyValue( "Command", "detail" );
+ m_detailResult = new ResultSet( m_detailForm );
+
XNameContainer masterContainer = (XNameContainer)UnoRuntime.queryInterface( XNameContainer.class,
m_masterForm );
masterContainer.insertByName( "slave", m_detailForm );
}
/* ------------------------------------------------------------------ */
- public void after() throws com.sun.star.uno.Exception, java.lang.Exception
- {
- m_databaseDocument.closeAndDelete();
- dbfTools.disposeComponent( m_masterForm );
- dbfTools.disposeComponent( m_detailForm );
- }
-
- /* ------------------------------------------------------------------ */
/** checks if master-detail relationships including multiple keys work
*/
public void checkMultipleKeys() throws com.sun.star.uno.Exception, java.lang.Exception
{
- m_detailForm.setPropertyValue( "MasterFields", new String[] { "ID1", "ID2" } );
- m_detailForm.setPropertyValue( "DetailFields", new String[] { "FK_ID1", "FK_ID2" } );
+ HsqlDatabase databaseDocument = null;
+ try
+ {
+ databaseDocument = new HsqlDatabase( m_orb );
+ impl_createTableStructure( databaseDocument );
+ impl_createForms( databaseDocument );
+
+ m_detailForm.setPropertyValue( "MasterFields", new String[] { "ID1", "ID2" } );
+ m_detailForm.setPropertyValue( "DetailFields", new String[] { "FK_ID1", "FK_ID2" } );
- XLoadable loadMaster = (XLoadable)UnoRuntime.queryInterface( XLoadable.class, m_masterForm );
- XLoadable loadDetail = (XLoadable)UnoRuntime.queryInterface( XLoadable.class, m_detailForm );
- loadDetail.addLoadListener( this );
+ XLoadable loadMaster = (XLoadable)UnoRuntime.queryInterface( XLoadable.class, m_masterForm );
+ XLoadable loadDetail = (XLoadable)UnoRuntime.queryInterface( XLoadable.class, m_detailForm );
+ loadDetail.addLoadListener( this );
- // wait until the detail form is loaded
- operateMasterAndWaitForDetailForm( loadMaster.getClass().getMethod( "load", new Class[] {} ), loadMaster, new Object[] { } );
+ // wait until the detail form is loaded
+ operateMasterAndWaitForDetailForm( loadMaster.getClass().getMethod( "load", new Class[] {} ), loadMaster, new Object[] { } );
- // okay, now the master form should be on the first record
- assure( "wrong form state after loading (ID1)", m_masterRow.getInt(1) == 1 );
- assure( "wrong form state after loading (ID2)", m_masterRow.getInt(2) == 1 );
- assure( "wrong form state after loading (value)", m_masterRow.getString(3).equals( "First Record" ) );
+ // okay, now the master form should be on the first record
+ assure( "wrong form state after loading (ID1)", m_masterResult.getInt(1) == 1 );
+ assure( "wrong form state after loading (ID2)", m_masterResult.getInt(2) == 1 );
+ assure( "wrong form state after loading (value)", m_masterResult.getString(3).equals( "First Record" ) );
- // the "XResultSet.next" method
- Method methodNext = m_masterSet.getClass().getMethod( "next" , new Class[] {} );
+ // the "XResultSet.next" method
+ Method methodNext = m_masterResult.getClass().getMethod( "next" , new Class[] {} );
+
+ // the values in the linked fields should be identical
+ int expectedDetailRowCounts[] = { 2, 1 };
+ do
+ {
+ verifyColumnValueIdentity( "ID1", "FK_ID1" );
+ verifyColumnValueIdentity( "ID2", "FK_ID2" );
+
+ m_detailResult.last();
+ int masterPos = m_masterResult.getRow();
+ assure( "wrong number of records in detail form, for master form at pos " + masterPos,
+ ((Integer)m_detailForm.getPropertyValue( "RowCount" )).intValue() == expectedDetailRowCounts[ masterPos - 1 ] );
+
+ operateMasterAndWaitForDetailForm( methodNext, m_masterResult, new Object[] {} );
+ }
+ while ( !m_masterResult.isAfterLast() );
+ assure( "wrong number of records in master form", 2 == ((Integer)m_masterForm.getPropertyValue( "RowCount" )).intValue() );
+ }
+ finally
+ {
+ if ( databaseDocument != null )
+ databaseDocument.closeAndDelete();
+ impl_cleanUpStep();
+ }
+ }
+
+ /* ------------------------------------------------------------------ */
+ private final void impl_cleanUpStep()
+ {
+ if ( m_masterForm != null )
+ dbfTools.disposeComponent( m_masterForm );
+ if ( m_detailForm != null )
+ dbfTools.disposeComponent( m_detailForm );
+ m_masterForm = m_detailForm = null;
+ }
- // the values in the linked fields should be identical
- int expectedDetailRowCounts[] = { 2, 1 };
- do
+ /* ------------------------------------------------------------------ */
+ /** checks whether default values in detail forms work as expected.
+ *
+ * Effectively, this test case verifies the issues #i106574# and #i105235# did not creep back in.
+ */
+ public void checkDetailFormDefaults() throws Exception
+ {
+ CRMDatabase database = null;
+ XCommandProcessor subComponentCommands = null;
+ try
+ {
+ // create our standard CRM database document
+ database = new CRMDatabase( m_orb, true );
+
+ // create a form document therein
+ XFormDocumentsSupplier formDocSupp = (XFormDocumentsSupplier)UnoRuntime.queryInterface(
+ XFormDocumentsSupplier.class, database.getDatabase().getModel() );
+ XMultiServiceFactory formFactory = (XMultiServiceFactory)UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, formDocSupp.getFormDocuments() );
+ NamedValue[] loadArgs = new NamedValue[] {
+ new NamedValue( "ActiveConnection", database.getConnection() ),
+ new NamedValue( "MediaType", "application/vnd.oasis.opendocument.text" )
+ };
+
+ subComponentCommands = (XCommandProcessor)UnoRuntime.queryInterface(
+ XCommandProcessor.class,
+ formFactory.createInstanceWithArguments( "com.sun.star.sdb.DocumentDefinition", loadArgs ) );
+ Command command = new Command();
+ command.Name = "openDesign";
+ command.Argument = new Short( OpenMode.DOCUMENT );
+
+ DocumentHelper subDocument = new DocumentHelper( m_orb,
+ (XComponent)UnoRuntime.queryInterface( XComponent.class,
+ subComponentCommands.execute( command, subComponentCommands.createCommandIdentifier(), null )
+ )
+ );
+ FormLayer formLayer = new FormLayer( subDocument );
+ XPropertySet controlModel = formLayer.insertControlLine( "DatabaseNumericField", "ID", "", 10 );
+ formLayer.insertControlLine( "DatabaseTextField", "Name", "", 20 );
+ formLayer.insertControlLine( "DatabaseTextField", "Description", "", 30 );
+
+ m_masterForm = (XPropertySet)dbfTools.getParent( controlModel, XPropertySet.class );
+ m_masterForm.setPropertyValue( "Command", "categories" );
+ m_masterForm.setPropertyValue( "CommandType", new Integer( CommandType.TABLE ) );
+
+ // create a detail form
+ m_detailForm = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, subDocument.createSubForm( m_masterForm, "products" ) );
+ m_detailForm.setPropertyValue( "Command", "SELECT \"ID\", \"Name\", \"CategoryID\" FROM \"products\"" );
+ m_detailForm.setPropertyValue( "CommandType", new Integer( CommandType.COMMAND ) );
+ m_detailForm.setPropertyValue( "MasterFields", new String[] { "ID" } );
+ m_detailForm.setPropertyValue( "DetailFields", new String[] { "CategoryID" } );
+
+ // create a grid control in the detail form, with some columns
+ XPropertySet gridControlModel = formLayer.createControlAndShape( "GridControl", 20, 40, 130, 50, m_detailForm );
+ gridControlModel.setPropertyValue( "Name", "product list" );
+ XIndexContainer gridColumns = (XIndexContainer)UnoRuntime.queryInterface(
+ XIndexContainer.class, gridControlModel );
+ impl_createGridColumn( gridColumns, "TextField", "ID" );
+ XPropertySet nameColumn = impl_createGridColumn( gridColumns, "TextField", "Name" );
+ nameColumn.setPropertyValue( "Width", new Integer( 600 ) ); // 6 cm
+ nameColumn.setPropertyValue( "DefaultText", "default text" );
+
+ // go live
+ m_masterResult = new ResultSet( m_masterForm );
+ m_detailResult = new ResultSet( m_detailForm );
+
+ XLoadable loadDetail = (XLoadable)UnoRuntime.queryInterface( XLoadable.class, m_detailForm );
+ loadDetail.addLoadListener( this );
+
+ subDocument.getCurrentView().toggleFormDesignMode();
+ impl_waitForLoadedEvent();
+
+ // now that we set up this, do the actual tests
+ // First, http://www.openoffice.org/issues/show_bug.cgi?id=105235 described the problem
+ // that default values in the sub form didn't work when the master form was navigated to a row
+ // for which no detail records were present, and the default of the column/control is the same
+ // as the last known value.
+
+ // so, take the current value of the "Name" column, and set it as default value ...
+ String defaultValue = m_detailResult.getString( 2 );
+ nameColumn.setPropertyValue( "DefaultText", defaultValue );
+ // ... then move to the second main form row ...
+ m_masterResult.absolute( 2 );
+ impl_waitForLoadedEvent();
+ // ... which should result in an empty sub form ...
+ assure( "test precondition not met: The second master form record is expected to have no detail records, " +
+ "else the test becomes meaningless", impl_isNewRecord( m_detailForm ) );
+ // ... and in the "Name" column having the proper text
+ String actualValue = (String)nameColumn.getPropertyValue( "Text" );
+ assureEquals( "#i105235#: default value in sub form not working (not propagated to column model)", defaultValue, actualValue );
+ // However, checking the column model's value alone is not enough - we need to ensure it is properly
+ // propagated to the control.
+ XGridFieldDataSupplier gridData = (XGridFieldDataSupplier)subDocument.getCurrentView().getControl(
+ gridControlModel, XGridFieldDataSupplier.class );
+ actualValue = (String)(gridData.queryFieldData( 0, Type.STRING )[1]);
+ assureEquals( "#i105235#: default value in sub form not working (not propagated to column)", defaultValue, actualValue );
+ }
+ finally
{
- verifyColumnValueIdentity( "ID1", "FK_ID1" );
- verifyColumnValueIdentity( "ID2", "FK_ID2" );
+ if ( subComponentCommands != null )
+ {
+ XComponentSupplier componentSupplier = (XComponentSupplier)UnoRuntime.queryInterface( XComponentSupplier.class,
+ subComponentCommands );
+ XModifiable modifySubComponent = (XModifiable)UnoRuntime.queryInterface( XModifiable.class,
+ componentSupplier.getComponent() );
+ modifySubComponent.setModified( false );
+ Command command = new Command();
+ command.Name = "close";
+ subComponentCommands.execute( command, subComponentCommands.createCommandIdentifier(), null );
+ }
- m_detailSet.last();
- int masterPos = m_masterSet.getRow();
- assure( "wrong number of records in detail form, for master form at pos " + masterPos,
- ((Integer)m_detailForm.getPropertyValue( "RowCount" )).intValue() == expectedDetailRowCounts[ masterPos - 1 ] );
+ if ( database != null )
+ database.saveAndClose();
- operateMasterAndWaitForDetailForm( methodNext, m_masterSet, new Object[] {} );
+ impl_cleanUpStep();
}
- while ( !m_masterSet.isAfterLast() );
- assure( "wrong number of records in master form", 2 == ((Integer)m_masterForm.getPropertyValue( "RowCount" )).intValue() );
}
+ /* ------------------------------------------------------------------ */
+ private boolean impl_isNewRecord( final XPropertySet _rowSet )
+ {
+ boolean isNew = false;
+ try
+ {
+ isNew = ((Boolean)_rowSet.getPropertyValue( "IsNew" )).booleanValue();
+ }
+ catch ( Exception ex )
+ {
+ failed( "obtaining the IsNew property failed" );
+ }
+ return isNew;
+ }
+
+ /* ------------------------------------------------------------------ */
+ private XPropertySet impl_createGridColumn( final XIndexContainer _gridModel, final String _columnType, final String _boundField ) throws Exception
+ {
+ final XGridColumnFactory columnFactory = (XGridColumnFactory)UnoRuntime.queryInterface(
+ XGridColumnFactory.class, _gridModel );
+ XPropertySet column = columnFactory.createColumn( _columnType );
+ column.setPropertyValue( "DataField", _boundField );
+ column.setPropertyValue( "Name", _boundField );
+ column.setPropertyValue( "Label", _boundField );
+ _gridModel.insertByIndex( _gridModel.getCount(), column );
+ return column;
+ }
+
+ /* ------------------------------------------------------------------ */
/** executes an operation on the master, and waits until the detail form has been (re)loaded aferwards
*/
private void operateMasterAndWaitForDetailForm( Method _masterMethod, Object _masterInterface, Object[] _methodParameters ) throws SQLException
{
- m_loaded = false;
Object result;
try
{
@@ -205,28 +378,35 @@ public class MasterDetailForms extends complexlib.ComplexTestCase implements com
if ( !((Boolean)result).booleanValue() )
return;
+ impl_waitForLoadedEvent();
+ }
+
+ private void impl_waitForLoadedEvent()
+ {
synchronized( m_waitForLoad )
{
- if ( !m_loaded )
+ while ( !m_loaded )
{
try { m_waitForLoad.wait(); }
catch( java.lang.InterruptedException e ) { }
}
+ // reset the flag for the next time
+ m_loaded = false;
}
}
/** assures that the (integer) values in the given columns of our master and detail forms are identical
*/
- public void verifyColumnValueIdentity( String masterColName, String detailColName ) throws SQLException
+ private void verifyColumnValueIdentity( final String masterColName, final String detailColName ) throws SQLException
{
XColumnLocate locateMasterCols = (XColumnLocate)UnoRuntime.queryInterface( XColumnLocate.class, m_masterForm );
XColumnLocate locateDetailCols = (XColumnLocate)UnoRuntime.queryInterface( XColumnLocate.class, m_detailForm );
- int masterValue = m_masterRow.getInt( locateMasterCols.findColumn( masterColName ) );
- int detailValue = m_detailRow.getInt( locateDetailCols.findColumn( detailColName ) );
+ int masterValue = m_masterResult.getInt( locateMasterCols.findColumn( masterColName ) );
+ int detailValue = m_detailResult.getInt( locateDetailCols.findColumn( detailColName ) );
assure( "values in linked column pair " + detailColName + "->" + masterColName + " (" +
- detailValue + "->" + masterValue + ") do not match (master position: " + m_masterSet.getRow() + ")!",
+ detailValue + "->" + masterValue + ") do not match (master position: " + m_masterResult.getRow() + ")!",
masterValue == detailValue );
}
diff --git a/forms/qa/org/openoffice/complex/forms/tools/ResultSet.java b/forms/qa/org/openoffice/complex/forms/tools/ResultSet.java
new file mode 100644
index 000000000000..7763afe6b262
--- /dev/null
+++ b/forms/qa/org/openoffice/complex/forms/tools/ResultSet.java
@@ -0,0 +1,264 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.openoffice.complex.forms.tools;
+
+import com.sun.star.container.XNameAccess;
+import com.sun.star.io.XInputStream;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.sdbc.XArray;
+import com.sun.star.sdbc.XBlob;
+import com.sun.star.sdbc.XClob;
+import com.sun.star.sdbc.XRef;
+import com.sun.star.sdbc.XResultSet;
+import com.sun.star.sdbc.XRow;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.Date;
+import com.sun.star.util.DateTime;
+import com.sun.star.util.Time;
+
+/**
+ *
+ * @author frank.schoenheit@sun.com
+ */
+public class ResultSet implements XResultSet, XRow
+{
+ private final XResultSet m_resultSet;
+ private final XRow m_row;
+
+ public ResultSet( final Object _resultSet )
+ {
+ m_resultSet = (XResultSet)UnoRuntime.queryInterface( XResultSet.class, _resultSet );
+ m_row = (XRow)UnoRuntime.queryInterface( XRow.class, _resultSet );
+ }
+
+ public
+ boolean next() throws SQLException
+ {
+ return m_resultSet.next();
+ }
+
+ public
+ boolean isBeforeFirst() throws SQLException
+ {
+ return m_resultSet.isBeforeFirst();
+ }
+
+ public
+ boolean isAfterLast() throws SQLException
+ {
+ return m_resultSet.isAfterLast();
+ }
+
+ public
+ boolean isFirst() throws SQLException
+ {
+ return m_resultSet.isFirst();
+ }
+
+ public
+ boolean isLast() throws SQLException
+ {
+ return m_resultSet.isLast();
+ }
+
+ public
+ void beforeFirst() throws SQLException
+ {
+ m_resultSet.beforeFirst();
+ }
+
+ public
+ void afterLast() throws SQLException
+ {
+ m_resultSet.afterLast();
+ }
+
+ public
+ boolean first() throws SQLException
+ {
+ return m_resultSet.first();
+ }
+
+ public
+ boolean last() throws SQLException
+ {
+ return m_resultSet.last();
+ }
+
+ public
+ int getRow() throws SQLException
+ {
+ return m_resultSet.getRow();
+ }
+
+ public
+ boolean absolute( int _row ) throws SQLException
+ {
+ return m_resultSet.absolute( _row );
+ }
+
+ public
+ boolean relative( int _offset ) throws SQLException
+ {
+ return m_resultSet.relative( _offset );
+ }
+
+ public
+ boolean previous() throws SQLException
+ {
+ return m_resultSet.previous();
+ }
+
+ public
+ void refreshRow() throws SQLException
+ {
+ m_resultSet.refreshRow();
+ }
+
+ public
+ boolean rowUpdated() throws SQLException
+ {
+ return m_resultSet.rowUpdated();
+ }
+
+ public
+ boolean rowInserted() throws SQLException
+ {
+ return m_resultSet.rowInserted();
+ }
+
+ public
+ boolean rowDeleted() throws SQLException
+ {
+ return m_resultSet.rowDeleted();
+ }
+
+ public
+ Object getStatement() throws SQLException
+ {
+ return m_resultSet.getStatement();
+ }
+
+ public
+ boolean wasNull() throws SQLException
+ {
+ return m_row.wasNull();
+ }
+
+ public
+ String getString( int _colIndex ) throws SQLException
+ {
+ return m_row.getString( _colIndex );
+ }
+
+ public
+ boolean getBoolean( int _colIndex ) throws SQLException
+ {
+ return m_row.getBoolean( _colIndex );
+ }
+
+ public
+ byte getByte( int _colIndex ) throws SQLException
+ {
+ return m_row.getByte( _colIndex );
+ }
+
+ public
+ short getShort( int _colIndex ) throws SQLException
+ {
+ return m_row.getShort( _colIndex );
+ }
+
+ public
+ int getInt( int _colIndex ) throws SQLException
+ {
+ return m_row.getInt( _colIndex );
+ }
+
+ public
+ long getLong( int _colIndex ) throws SQLException
+ {
+ return m_row.getLong( _colIndex );
+ }
+
+ public
+ float getFloat( int _colIndex ) throws SQLException
+ {
+ return m_row.getFloat( _colIndex );
+ }
+
+ public
+ double getDouble( int _colIndex ) throws SQLException
+ {
+ return m_row.getDouble( _colIndex );
+ }
+
+ public
+ byte[] getBytes( int _colIndex ) throws SQLException
+ {
+ return m_row.getBytes( _colIndex );
+ }
+
+ public
+ Date getDate( int _colIndex ) throws SQLException
+ {
+ return m_row.getDate( _colIndex );
+ }
+
+ public
+ Time getTime( int _colIndex ) throws SQLException
+ {
+ return m_row.getTime( _colIndex );
+ }
+
+ public
+ DateTime getTimestamp( int _colIndex ) throws SQLException
+ {
+ return m_row.getTimestamp( _colIndex );
+ }
+
+ public
+ XInputStream getBinaryStream( int _colIndex ) throws SQLException
+ {
+ return m_row.getBinaryStream( _colIndex );
+ }
+
+ public
+ XInputStream getCharacterStream( int _colIndex ) throws SQLException
+ {
+ return m_row.getCharacterStream( _colIndex );
+ }
+
+ public
+ Object getObject( int _colIndex, XNameAccess _typeMap ) throws SQLException
+ {
+ return m_row.getObject( _colIndex, _typeMap );
+ }
+
+ public
+ XRef getRef( int _colIndex ) throws SQLException
+ {
+ return m_row.getRef( _colIndex );
+ }
+
+ public
+ XBlob getBlob( int _colIndex ) throws SQLException
+ {
+ return m_row.getBlob( _colIndex );
+ }
+
+ public
+ XClob getClob( int _colIndex ) throws SQLException
+ {
+ return m_row.getClob( _colIndex );
+ }
+
+ public
+ XArray getArray( int _colIndex ) throws SQLException
+ {
+ return m_row.getArray( _colIndex );
+ }
+}
diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx
index 38899ba81235..b95b48b9b214 100644
--- a/forms/source/component/DatabaseForm.cxx
+++ b/forms/source/component/DatabaseForm.cxx
@@ -96,7 +96,6 @@
#include <ctype.h>
#include <hash_map>
-//#include <stdio.h>
// compatiblity: DatabaseCursorType is dead, but for compatiblity reasons we still have to write it ...
namespace com {
@@ -2630,16 +2629,15 @@ void ODatabaseForm::impl_createLoadTimer()
//------------------------------------------------------------------------------
void SAL_CALL ODatabaseForm::loaded(const EventObject& /*aEvent*/) throw( RuntimeException )
{
- // now start the rowset listening to recover cursor events
- load_impl(sal_True);
{
- ::osl::MutexGuard aGuard(m_aMutex);
- Reference<XRowSet> xParentRowSet(m_xParent, UNO_QUERY);
- if (xParentRowSet.is())
- xParentRowSet->addRowSetListener(this);
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Reference< XRowSet > xParentRowSet( m_xParent, UNO_QUERY_THROW );
+ xParentRowSet->addRowSetListener( this );
impl_createLoadTimer();
}
+
+ load_impl( sal_True );
}
//------------------------------------------------------------------------------
@@ -2647,12 +2645,14 @@ void SAL_CALL ODatabaseForm::unloading(const EventObject& /*aEvent*/) throw( Run
{
{
// now stop the rowset listening if we are a subform
- ::osl::MutexGuard aGuard(m_aMutex);
- DELETEZ(m_pLoadTimer);
+ ::osl::MutexGuard aGuard( m_aMutex );
- Reference<XRowSet> xParentRowSet(m_xParent, UNO_QUERY);
- if (xParentRowSet.is())
- xParentRowSet->removeRowSetListener(this);
+ if ( m_pLoadTimer && m_pLoadTimer->IsActive() )
+ m_pLoadTimer->Stop();
+ DELETEZ( m_pLoadTimer );
+
+ Reference< XRowSet > xParentRowSet( m_xParent, UNO_QUERY_THROW );
+ xParentRowSet->removeRowSetListener( this );
}
unload();
@@ -2880,7 +2880,7 @@ sal_Bool ODatabaseForm::implEnsureConnection()
}
catch( Exception )
{
- DBG_ERROR( "ODatabaseForm::implEnsureConnection: caught an exception which I cannot handle!" );
+ DBG_UNHANDLED_EXCEPTION();
}
return sal_False;