/* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempStorage, "MediaType1", true,
ElementModes.WRITE ) ) returnfalse;
// open a new substorage
XStorage xTempSubStorage = m_aTestHelper.openSubStorage( xTempStorage, "SubStorage1",
ElementModes.WRITE ); if ( xTempSubStorage == null )
{
m_aTestHelper.Error( "Can't create substorage!" ); returnfalse;
}
// set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempSubStorage, "MediaType2", false,
ElementModes.WRITE ) ) returnfalse;
// open a new substorage
XStorage xTempSubSubStorage = m_aTestHelper.openSubStorage( xTempSubStorage, "SubStorage2",
ElementModes.WRITE ); if ( xTempSubStorage == null )
{
m_aTestHelper.Error( "Can't create substorage!" ); returnfalse;
}
// set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempSubSubStorage, "MediaType3", false,
ElementModes.WRITE ) ) returnfalse;
// open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubSubStorage, "SubStream1", "MediaType4", true, pBytes ) ) returnfalse;
// open a new substorage
XStorage xTempSubStorage1 = m_aTestHelper.openSubStorage( xTempStorage, "SubStorage3",
ElementModes.WRITE ); if ( xTempSubStorage1 == null )
{
m_aTestHelper.Error( "Can't create substorage!" ); returnfalse;
}
// set "MediaType" property for storages and check that "IsRoot" and "OpenMode" properties are set correctly if ( !m_aTestHelper.setStorageTypeAndCheckProps( xTempSubStorage1, "MediaType5", false,
ElementModes.WRITE ) ) returnfalse;
// open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes if ( !m_aTestHelper.WriteBytesToSubstream( xTempSubStorage1, "SubStream2", "MediaType4", false, pBytes ) ) returnfalse;
// commit substorages first if ( !m_aTestHelper.commitStorage( xTempSubSubStorage ) ) returnfalse;
if ( !m_aTestHelper.commitStorage( xTempSubStorage ) ) returnfalse;
if ( !m_aTestHelper.commitStorage( xTempSubStorage1 ) ) returnfalse;
// commit the root storage so the contents must be stored now if ( !m_aTestHelper.commitStorage( xTempStorage ) ) returnfalse;
// dispose used storage to free resources if ( !m_aTestHelper.disposeStorage( xTempStorage ) ) returnfalse;
// now change the contents of the second substorage // without changing of the contents of the first substorage
// open a new substream, set "MediaType" and "Compressed" properties to it and write some bytes if ( !m_aTestHelper.WriteBytesToSubstream( xStep2TempSubStorage1, "SubStream2", "MediaType4", false, pBytes ) ) returnfalse;
if ( !m_aTestHelper.commitStorage( xStep2TempSubStorage1 ) ) returnfalse;
// commit the root storage so the contents must be stored now if ( !m_aTestHelper.commitStorage( xStep2TempStorage ) ) returnfalse;
// dispose used storage to free resources if ( !m_aTestHelper.disposeStorage( xStep2TempStorage ) ) returnfalse;
// now check all the written information // and the raw stream contents
// close the output part of the temporary stream // the output part must present since we already wrote to the stream if ( !m_aTestHelper.closeOutput( xTempFileStream ) ) returnfalse;
// open input stream // since no mode is provided the result storage must be opened readonly
Object pOneArg[] = new Object[1];
pOneArg[0] = (Object) xTempInStream;
Object oResultStorage = m_xStorageFactory.createInstanceWithArguments( pOneArg );
XStorage xResultStorage = (XStorage) UnoRuntime.queryInterface( XStorage.class, oResultStorage ); if ( xResultStorage == null )
{
m_aTestHelper.Error( "Can't open storage based on input stream!" ); returnfalse;
}
if ( !m_aTestHelper.checkStorageProperties( xResultStorage, "MediaType1", true, ElementModes.READ ) ) returnfalse;
// open existing substorage
XStorage xResultSubStorage = m_aTestHelper.openSubStorage( xResultStorage, "SubStorage1",
ElementModes.READ ); if ( xResultSubStorage == null )
{
m_aTestHelper.Error( "Can't open existing substorage!" ); returnfalse;
}
if ( !m_aTestHelper.checkStorageProperties( xResultSubStorage, "MediaType2", false, ElementModes.READ ) ) returnfalse;
// open existing substorage
XStorage xResultSubSubStorage = m_aTestHelper.openSubStorage( xResultSubStorage, "SubStorage2",
ElementModes.READ ); if ( xResultSubSubStorage == null )
{
m_aTestHelper.Error( "Can't open existing substorage!" ); returnfalse;
}
if ( !m_aTestHelper.checkStorageProperties( xResultSubSubStorage, "MediaType3", false, ElementModes.READ ) ) returnfalse;
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.