String sTempFileURL = m_aTestHelper.CreateTempFile( m_xMSF ); if ( sTempFileURL == null || sTempFileURL == "" )
{
m_aTestHelper.Error( "No valid temporary file was created!" ); returnfalse;
}
// create temporary storage based on a previously created temporary file
Object pArgs[] = new Object[2];
pArgs[0] = (Object) sTempFileURL;
pArgs[1] = Integer.valueOf( ElementModes.WRITE );
// open a new substream hierarchically, set "MediaType" and "Compressed" properties to it, write some bytes // and commit if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aSubStream1Path, "MediaType1", true, pBytes1, true ) ) returnfalse; if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aBigSubStream1Path, "MediaType1", true, pBigBytes, true ) ) returnfalse;
byte pBytes2[] = { 2, 2, 2, 2, 2 };
// open a new substream hierarchically, set "MediaType" and "Compressed" properties to it, write some bytes // and commit if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aSubStream2Path, "MediaType2", false, pBytes2, true ) ) returnfalse; if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aBigSubStream2Path, "MediaType2", false, pBigBytes, true ) ) returnfalse;
// open a new substream hierarchically, set "MediaType" and "Compressed" properties to it, write some bytes // and don't commit if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aSubStream3Path, "MediaType2", false, pBytes2, false ) ) returnfalse; if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aBigSubStream3Path, "MediaType2", false, pBigBytes, false ) ) returnfalse;
// set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempFileStorage, "MediaType3", true,
ElementModes.WRITE ) ) returnfalse;
// commit the root storage so the contents must be stored now if ( !m_aTestHelper.commitStorage( xTempFileStorage ) ) returnfalse;
// dispose used storages to free resources if ( !m_aTestHelper.disposeStorage( xTempFileStorage ) ) returnfalse;
// now reopen the storage, // check all the written and copied information // and change it
// the temporary file must not be locked any more after storage disposing
oTempFileStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
xTempFileStorage = (XStorage)UnoRuntime.queryInterface( XStorage.class, oTempFileStorage ); if ( xTempFileStorage == null )
{
m_aTestHelper.Error( "Can't create storage based on temporary file!" ); returnfalse;
}
if ( !m_aTestHelper.checkStorageProperties( xTempFileStorage, "MediaType3", true, ElementModes.WRITE ) ) returnfalse;
if ( !m_aTestHelper.cantOpenStreamH( xTempFileStorage, aSubStream3Path, ElementModes.READ ) ) returnfalse;
if ( !m_aTestHelper.cantOpenStreamH( xTempFileStorage, aBigSubStream3Path, ElementModes.READ ) ) returnfalse;
// open existing substream hierarchically, set "MediaType" and "Compressed" properties to it, write some bytes // and commit if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aSubStream1Path, "MediaType3", true, pBytes2, true ) ) returnfalse; if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aBigSubStream1Path, "MediaType3", true, pBigBytes, true ) ) returnfalse;
// open existing substream hierarchically, set "MediaType" and "Compressed" properties to it, write some bytes // and don't commit if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aSubStream2Path, "MediaType3", true, pBytes1, false ) ) returnfalse; if ( !m_aTestHelper.WriteBytesToStreamH( xTempFileStorage, aBigSubStream2Path, "MediaType3", true, pBigBytes, false ) ) returnfalse;
// commit the root storage so the contents must be stored now if ( !m_aTestHelper.commitStorage( xTempFileStorage ) ) returnfalse;
// dispose used storages to free resources if ( !m_aTestHelper.disposeStorage( xTempFileStorage ) ) returnfalse;
// now reopen the storage, // check all the written information
// the temporary file must not be locked any more after storage disposing
pArgs[1] = Integer.valueOf( ElementModes.READ );
Object oResultStorage = m_xStorageFactory.createInstanceWithArguments( pArgs );
XStorage xResultStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oResultStorage ); if ( xResultStorage == null )
{
m_aTestHelper.Error( "Can't reopen storage based on temporary file!" ); returnfalse;
}
if ( !m_aTestHelper.checkStorageProperties( xResultStorage, "MediaType3", true, ElementModes.READ ) ) returnfalse;
// the following stream was not committed last time, so the last change must be lost if ( !m_aTestHelper.checkStreamH( xResultStorage, aBigSubStream2Path, "MediaType2", false, pBigBytes ) ) returnfalse;
// dispose used storages to free resources if ( !m_aTestHelper.disposeStorage( xResultStorage ) ) returnfalse;
returntrue;
} catch( Exception e )
{
m_aTestHelper.Error( "Exception: " + e ); returnfalse;
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-09-28)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.