"OnSave", "OnSaveDone", "OnModifyChanged"
}, context);
// XComponentLoader.loadComponentFromURL
newURL = copyToTempFile(databaseDoc.getURL());
final XComponentLoader loader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class,
getORB().createInstance("com.sun.star.frame.Desktop"));
context = "loadComponentFromURL";
impl_startObservingEvents(context);
databaseDoc = (XModel) UnoRuntime.queryInterface(XModel.class,
loader.loadComponentFromURL(newURL, _BLANK, 0, impl_getDefaultLoadArgs()));
impl_stopObservingEvents(m_globalEvents,
new String[]
{
"OnLoadFinished", "OnViewCreated", "OnFocus", "OnLoad"
}, context);
// closing a document by API
final XCloseable closeDoc = (XCloseable) UnoRuntime.queryInterface(XCloseable.class,
databaseDoc);
context = "close (API)";
impl_startObservingEvents(context);
closeDoc.close(true);
impl_stopObservingEvents(m_globalEvents,
new String[]
{
"OnPrepareUnload", "OnViewClosed", "OnUnload"
}, context);
// closing a document via UI
context = "close (UI)";
impl_startObservingEvents("prepare for '" + context + "'");
databaseDoc = (XModel) UnoRuntime.queryInterface(XModel.class,
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
final XDispatchProvider dispatchProvider = (XDispatchProvider) UnoRuntime.queryInterface(XDispatchProvider.class,
databaseDoc.getCurrentController().getFrame());
final URL url = impl_getURL(".uno:CloseDoc");
final XDispatch dispatcher = dispatchProvider.queryDispatch(url, "", 0);
impl_startObservingEvents(context);
dispatcher.dispatch(url, new PropertyValue[0]);
impl_stopObservingEvents(m_globalEvents,
new String[]
{
"OnPrepareViewClosing", "OnViewClosed", "OnPrepareUnload", "OnUnload"
}, context);
// creating a new document
databaseDoc = impl_createDocument();
final XLoadable loadDoc = (XLoadable) UnoRuntime.queryInterface(XLoadable.class,
databaseDoc);
context = "initNew";
impl_startObservingEvents(context);
loadDoc.initNew();
impl_stopObservingEvents(m_globalEvents, new String[]
{
"OnCreate"
}, context);
impl_startObservingEvents(context + " (cleanup)");
impl_closeDocument(databaseDoc);
impl_waitForEvent(m_globalEvents, "OnUnload", 5000);
// focus changes
context = "activation";
// for this, load a database document ...
impl_startObservingEvents("prepare for '" + context + "'");
databaseDoc = (XModel) UnoRuntime.queryInterface(XModel.class,
loader.loadComponentFromURL(newURL, _BLANK, 0, impl_getDefaultLoadArgs()));
final int previousOnLoadEventPos = impl_waitForEvent(m_globalEvents, "OnLoad", 5000);
// ... and another document ...
final String otherURL = copyToTempFile(databaseDoc.getURL());
final XModel otherDoc = (XModel) UnoRuntime.queryInterface(XModel.class,
loader.loadComponentFromURL(otherURL, _BLANK, 0, impl_getDefaultLoadArgs()));
impl_waitForEvent(m_globalEvents, "OnLoad", 5000, previousOnLoadEventPos + 1);
impl_raise(otherDoc);
// ... and switch between the two
impl_startObservingEvents(context);