assure( "A newly created doc should not have the test case marker", !impl_hasMarker( databaseDoc.getArgs() ) );
// obtain the DataSource associated with the document. Keeping this alive
// ensures that the "impl data" of the document is kept alive, too, so when closing
// and re-opening it, this "impl data" must be re-used.
XDocumentDataSource dataSource = (XDocumentDataSource)UnoRuntime.queryInterface( XDocumentDataSource.class,
((XOfficeDatabaseDocument)UnoRuntime.queryInterface(
XOfficeDatabaseDocument.class, databaseDoc )).getDataSource() );
// close and reload the doc
impl_closeDocument(databaseDoc);
databaseDoc = impl_loadDocument( documentURL, impl_getMarkerLoadArgs() );
// since we just put the marker into the load-call, it should be present at the doc
assure( "The test case marker got lost.", impl_hasMarker( databaseDoc.getArgs() ) );
// The basic library should have survived
final XEmbeddedScripts embeddedScripts = (XEmbeddedScripts) UnoRuntime.queryInterface(XEmbeddedScripts.class,
databaseDoc);
final XStorageBasedLibraryContainer basicLibs = embeddedScripts.getBasicLibraries();
assure( "Baisc lib did not survive reloading a closed document", basicLibs.hasByName( "Lib" ) );
final XNameContainer lib = (XNameContainer)UnoRuntime.queryInterface(
XNameContainer.class, basicLibs.getByName( "Lib" ) );
assure( "Basic module did not survive reloading a closed document", lib.hasByName( "Module" ) );
// now closing the doc, and obtaining it from the data source, should preserve the marker we put into the load
// args
impl_closeDocument( databaseDoc );
databaseDoc = (XModel)UnoRuntime.queryInterface( XModel.class, dataSource.getDatabaseDocument() );
assure( "The test case marker did not survive re-retrieval of the doc from the data source.",
impl_hasMarker( databaseDoc.getArgs() ) );
// on the other hand, closing and regurlarly re-loading the doc *without* the marker should indeed
// lose it