/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * 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 .
*/
uno::Reference< uno::XInterface > SAL_CALL OStorageFactory::createInstanceWithArguments( const uno::Sequence< uno::Any >& aArguments )
{ // The request for storage can be done with up to three arguments
// The first argument specifies a source for the storage // it can be URL, XStream, XInputStream. // The second value is a mode the storage should be open in. // And the third value is a media descriptor.
// first try to retrieve storage open mode if any // by default the storage will be open in readonly mode
sal_Int32 nStorageMode = embed::ElementModes::READ; if ( nArgNum >= 2 )
{ if( !( aArguments[1] >>= nStorageMode ) )
{
OSL_FAIL( "Wrong second argument!" ); throw lang::IllegalArgumentException(); // TODO:
} // it's always possible to read written storage in this implementation
nStorageMode |= embed::ElementModes::READ;
}
// create storage based on source if ( xInputStream.is() )
{ // if xInputStream is set the storage should be open from it if ( nStorageMode & embed::ElementModes::WRITE ) throw uno::Exception(u"storagemode==write"_ustr, nullptr); // TODO: access denied
uno::Reference< io::XSeekable > xSeekable( xInputStream, uno::UNO_QUERY ); if ( !xSeekable.is() )
{ // TODO: wrap stream to let it be seekable
OSL_FAIL( "Nonseekable streams are not supported for now!" );
}
if ( !CheckPackageSignature_Impl( xInputStream, xSeekable ) ) throw io::IOException(u"package signature check failed, probably not a package file"_ustr, nullptr); // TODO: this is not a package file
uno::Reference< io::XSeekable > xSeekable( xStream, uno::UNO_QUERY ); if ( !xSeekable.is() )
{ // TODO: wrap stream to let it be seekable
OSL_FAIL( "Nonseekable streams are not supported for now!" );
}
if ( !CheckPackageSignature_Impl( xStream->getInputStream(), xSeekable ) ) throw io::IOException(); // TODO: this is not a package file
return cppu::getXWeak( new OStorage(xStream, nStorageMode, aPropsToSet, m_xContext, nStorageType));
}
throw uno::Exception(u"no input stream or regular stream"_ustr, nullptr); // general error during creation
}
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.