//create OLESimpleStorage based on it
Object pArgs[] = new Object[2];
pArgs[0] = (Object) xTempFile;
pArgs[1] = new Boolean( true );
Object oOLESimpleStorage = m_xMSF.createInstanceWithArguments ( "com.sun.star.embed.OLESimpleStorage", pArgs );
XOLESimpleStorage xOLESimpleStorage = (XOLESimpleStorage) UnoRuntime.queryInterface ( XOLESimpleStorage.class, oOLESimpleStorage );
m_aTestHelper.Message ( "OLESimpleStorage based on XStream created." );
//fill it with some streams
Object oStream[] = new Object[pStreamCnt];
byte pBytesIn[][][] = new byte [pStreamCnt][1][pBytesCnt];
byte pBytesOut[][] = new byte [pStreamCnt][pBytesCnt];
XTempFile xTempStream[] = new XTempFile[pStreamCnt];
Random oRandom = new Random ();
final String sSubStreamPrefix = "SubStream";
for ( int i = 0; i < pStreamCnt; i++ )
{
oRandom.nextBytes (pBytesOut[i]);
oStream[i] = m_xMSF.createInstance ( "com.sun.star.io.TempFile" );
xTempStream[i] = (XTempFile) UnoRuntime.queryInterface ( XTempFile.class, oStream[i] );
xTempStream[i].getOutputStream ().writeBytes (pBytesOut[i]);
xTempStream[i].seek (0);
m_aTestHelper.Message ( "Substream " + i + " initialized." );
if (xOLESimpleStorage.hasByName (sSubStreamPrefix + i))
{
xOLESimpleStorage.replaceByName ( sSubStreamPrefix + i, xTempStream[i] );
}
else
{
xOLESimpleStorage.insertByName ( sSubStreamPrefix + i, xTempStream[i] );
m_aTestHelper.Message ( "Substream " + i + " inserted." );
}
}
//commit the storage and close it
xOLESimpleStorage.commit ();
m_aTestHelper.Message ( "Storage commited." );
xOLESimpleStorage.dispose ();
for ( int i = 0; i < pStreamCnt; ++i )
{
xTempStream[i].setRemoveFile ( true );
xTempStream[i].getInputStream ().closeInput ();
xTempStream[i].getOutputStream ().closeOutput ();
}
m_aTestHelper.Message ( "Storage closed." );
//open the same stream with the constructor for inputstream
pArgs[0] = (Object)xTempFile.getInputStream ();
oOLESimpleStorage = m_xMSF.createInstanceWithArguments ( "com.sun.star.embed.OLESimpleStorage", pArgs );
xOLESimpleStorage = (XOLESimpleStorage)UnoRuntime.queryInterface ( XOLESimpleStorage.class, oOLESimpleStorage );
m_aTestHelper.Message ( "Storage reopened, based on XInputStream." );
//check that all the streams contain correct information
m_aTestHelper.Message ( "Checking data contained in all the substreams..." );
for ( int i = 0; i < pStreamCnt; ++i )
{
if ( xOLESimpleStorage.hasByName (sSubStreamPrefix + i) )
{
xTempStream[i] = (XTempFile)UnoRuntime.queryInterface (
XTempFile.class, xOLESimpleStorage.getByName (sSubStreamPrefix + i) );
xTempStream[i].seek (0);
xTempStream[i].getInputStream ().readBytes (pBytesIn[i], pBytesIn[i][0].length + 1 );
for ( int j = 0; j < pBytesCnt; ++j )
{
if ( pBytesIn[i][0][j] != pBytesOut[i][j] )