Tag: cws_dev300_odbmacros3 User: fs Date: 2008-08-02 11:49:15+0000 Modified: dba/dbaccess/qa/complex/dbaccess/DatabaseDocument.java
Log: GlobalEventBroadcaster is a XDocumentEventBroadcaster now File Changes: Directory: /dba/dbaccess/qa/complex/dbaccess/ ============================================= File [changed]: DatabaseDocument.java Url: http://dba.openoffice.org/source/browse/dba/dbaccess/qa/complex/dbaccess/DatabaseDocument.java?r1=1.1.2.5&r2=1.1.2.6 Delta lines: +27 -15 --------------------- --- DatabaseDocument.java 2008-07-30 20:54:19+0000 1.1.2.5 +++ DatabaseDocument.java 2008-08-02 11:49:13+0000 1.1.2.6 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: DatabaseDocument.java,v $ - * $Revision: 1.1.2.5 $ + * $Revision: 1.1.2.6 $ * * This file is part of OpenOffice.org. * @@ -42,6 +42,7 @@ import com.sun.star.beans.PropertyValue; import com.sun.star.beans.XPropertySet; import com.sun.star.container.XSet; +import com.sun.star.document.XDocumentEventBroadcaster; import com.sun.star.document.XDocumentEventListener; import com.sun.star.document.XEventBroadcaster; import com.sun.star.document.XEventsSupplier; @@ -79,7 +80,7 @@ import java.util.Iterator; import java.util.Vector; -public class DatabaseDocument extends CRMBasedTestCase implements com.sun.star.document.XEventListener +public class DatabaseDocument extends CRMBasedTestCase implements com.sun.star.document.XDocumentEventListener { private XComponent m_callbackFactory = null; private Vector m_documentEvents = new Vector(); @@ -192,9 +193,9 @@ globalFactory.insert( m_callbackFactory ); // register ourself as listener at the global event broadcaster - XEventBroadcaster broadcaster = (XEventBroadcaster)UnoRuntime.queryInterface( - XEventBroadcaster.class, getORB().createInstance( "com.sun.star.frame.GlobalEventBroadcaster" ) ); - broadcaster.addEventListener( this ); + XDocumentEventBroadcaster broadcaster = (XDocumentEventBroadcaster)UnoRuntime.queryInterface( + XDocumentEventBroadcaster.class, getORB().createInstance( "com.sun.star.frame.GlobalEventBroadcaster" ) ); + broadcaster.addDocumentEventListener( this ); } catch( Exception e ) { @@ -216,9 +217,9 @@ m_callbackFactory.dispose(); // revoke ourself as listener at the global event broadcaster - XEventBroadcaster broadcaster = (XEventBroadcaster) UnoRuntime.queryInterface( - XEventBroadcaster.class, getORB().createInstance( "com.sun.star.frame.GlobalEventBroadcaster" ) ); - broadcaster.removeEventListener( this ); + XDocumentEventBroadcaster broadcaster = (XDocumentEventBroadcaster) UnoRuntime.queryInterface( + XDocumentEventBroadcaster.class, getORB().createInstance( "com.sun.star.frame.GlobalEventBroadcaster" ) ); + broadcaster.removeDocumentEventListener( this ); } catch ( Exception e ) { @@ -344,7 +345,7 @@ dsProperties.setPropertyValue( "URL", "sdbc:embedded:hsqldb" ); String documentURL = createTempFileURL(); - storeDoc.storeAsURL( documentURL, new PropertyValue[] {} ); + storeDoc.storeAsURL( documentURL, new PropertyValue[0] ); // now that the document is stored, ... // ... its URL should be correct @@ -370,6 +371,8 @@ // .................................................................... // 2. XLoadable::load + databaseDoc = (XModel)UnoRuntime.queryInterface( XModel.class, + getORB().createInstance( "com.sun.star.sdb.OfficeDatabaseDocument" ) ); documentURL = impl_copyTempFile( documentURL ); // load the doc, and verify it's initialized then, and has the proper URL XLoadable loadDoc = (XLoadable)UnoRuntime.queryInterface( XLoadable.class, databaseDoc ); @@ -402,6 +405,14 @@ } // -------------------------------------------------------------------------------------------------------- + private PropertyValue[] impl_getDefaultLoadArgs() + { + return new PropertyValue[] { + new PropertyValue( "PickListEntry", 0, false, PropertyState.DIRECT_VALUE ) + }; + } + + // -------------------------------------------------------------------------------------------------------- public void testDocumentEvents() throws Exception, IOException { XModel databaseDoc = impl_createEmptyEmbeddedHSQLDocument(); @@ -456,7 +467,7 @@ context = "loadComponentFromURL"; impl_startObservingEvents( context ); databaseDoc = (XModel) UnoRuntime.queryInterface( XModel.class, - loader.loadComponentFromURL( newURL, "_blank", 0, new PropertyValue[0] ) ); + loader.loadComponentFromURL( newURL, "_blank", 0, impl_getDefaultLoadArgs() ) ); impl_stopObservingEvents( m_globalEvents, new String[] { "OnLoadFinished", "OnViewCreated", "OnFocus", "OnLoad" }, context ); @@ -473,7 +484,7 @@ context = "close (UI)"; impl_startObservingEvents( "prepare for '" + context + "'" ); databaseDoc = (XModel)UnoRuntime.queryInterface( XModel.class, - loader.loadComponentFromURL( newURL, "_blank", 0, new PropertyValue[0] ) ); + loader.loadComponentFromURL( newURL, "_blank", 0, impl_getDefaultLoadArgs() ) ); impl_waitForEvent( m_globalEvents, "OnLoad", 5000 ); // wait for all events to arrive - OnLoad should be the last one @@ -504,12 +515,12 @@ // for this, load a database document ... impl_startObservingEvents( "prepare for '" + context + "'" ); databaseDoc = (XModel)UnoRuntime.queryInterface( XModel.class, - loader.loadComponentFromURL( newURL, "_blank", 0, new PropertyValue[0] ) ); + loader.loadComponentFromURL( newURL, "_blank", 0, impl_getDefaultLoadArgs() ) ); impl_waitForEvent( m_globalEvents, "OnLoad", 5000 ); // ... and another document ... String otherURL = impl_copyTempFile( databaseDoc.getURL() ); XModel otherDoc = (XModel)UnoRuntime.queryInterface( XModel.class, - loader.loadComponentFromURL( otherURL, "_blank", 0, new PropertyValue[0] ) ); + loader.loadComponentFromURL( otherURL, "_blank", 0, impl_getDefaultLoadArgs() ) ); impl_raise( otherDoc ); // ... and switch between the two @@ -641,7 +652,7 @@ } // -------------------------------------------------------------------------------------------------------- - public void notifyEvent( com.sun.star.document.EventObject _Event ) + public void documentEventOccured( DocumentEvent _Event ) { if ( _Event.EventName.equals( "OnTitleChanged" ) ) // ignore. See onDocumentEvent for a justification @@ -656,8 +667,9 @@ log.println( " global event: " + _Event.EventName ); } + // -------------------------------------------------------------------------------------------------------- public void disposing( EventObject _Event ) { - throw new UnsupportedOperationException( "Not supported yet." ); + // not interested in } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
