2004-10-04 20:06:09 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 09:47:39 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2004-10-04 20:06:09 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2004-10-04 20:06:09 +00:00
|
|
|
*
|
2008-04-11 09:47:39 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-10-04 20:06:09 +00:00
|
|
|
*
|
2008-04-11 09:47:39 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2004-10-04 20:06:09 +00:00
|
|
|
*
|
2008-04-11 09:47:39 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2004-10-04 20:06:09 +00:00
|
|
|
*
|
2008-04-11 09:47:39 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2004-10-04 20:06:09 +00:00
|
|
|
*
|
2008-04-11 09:47:39 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2004-10-04 20:06:09 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
#ifndef _COMPHELPER_STORAGEHELPER_HXX
|
|
|
|
#define _COMPHELPER_STORAGEHELPER_HXX
|
|
|
|
|
|
|
|
#include <com/sun/star/uno/Sequence.hxx>
|
|
|
|
#include <com/sun/star/uno/Reference.hxx>
|
|
|
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
|
|
|
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
|
|
|
|
#include <com/sun/star/embed/XStorage.hpp>
|
|
|
|
#include <com/sun/star/embed/ElementModes.hpp>
|
2010-11-04 17:56:39 +01:00
|
|
|
#include <com/sun/star/beans/NamedValue.hpp>
|
2004-10-04 20:06:09 +00:00
|
|
|
#include <com/sun/star/io/XInputStream.hpp>
|
|
|
|
#include <com/sun/star/io/XOutputStream.hpp>
|
|
|
|
#include <com/sun/star/io/XStream.hpp>
|
2005-02-16 15:02:06 +00:00
|
|
|
#include "comphelper/comphelperdllapi.h"
|
2004-10-04 20:06:09 +00:00
|
|
|
|
2006-10-13 10:40:22 +00:00
|
|
|
|
|
|
|
#define PACKAGE_STORAGE_FORMAT_STRING ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PackageFormat" ) )
|
|
|
|
#define ZIP_STORAGE_FORMAT_STRING ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ZipFormat" ) )
|
|
|
|
#define OFOPXML_STORAGE_FORMAT_STRING ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OFOPXMLFormat" ) )
|
|
|
|
|
2011-03-09 17:29:09 +01:00
|
|
|
#define PACKAGE_ENCRYPTIONDATA_SHA256UTF8 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PackageSHA256UTF8EncryptionKey" ) )
|
2010-11-04 17:56:39 +01:00
|
|
|
#define PACKAGE_ENCRYPTIONDATA_SHA1UTF8 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PackageSHA1UTF8EncryptionKey" ) )
|
|
|
|
#define PACKAGE_ENCRYPTIONDATA_SHA1MS1252 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PackageSHA1MS1252EncryptionKey" ) )
|
|
|
|
|
2004-10-04 20:06:09 +00:00
|
|
|
namespace comphelper {
|
|
|
|
|
2005-02-16 15:02:06 +00:00
|
|
|
class COMPHELPER_DLLPUBLIC OStorageHelper
|
2004-10-04 20:06:09 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory >
|
|
|
|
GetStorageFactory(
|
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xSF
|
|
|
|
= ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() )
|
|
|
|
throw ( ::com::sun::star::uno::Exception );
|
|
|
|
|
2008-07-01 15:28:24 +00:00
|
|
|
static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory >
|
|
|
|
GetFileSystemStorageFactory(
|
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xSF
|
|
|
|
= ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() )
|
|
|
|
throw ( ::com::sun::star::uno::Exception );
|
|
|
|
|
2004-10-04 20:06:09 +00:00
|
|
|
static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
|
|
|
|
GetTemporaryStorage(
|
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory
|
|
|
|
= ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() )
|
|
|
|
throw ( ::com::sun::star::uno::Exception );
|
|
|
|
|
2008-07-01 15:28:24 +00:00
|
|
|
/// this one will only return Storage
|
2004-10-04 20:06:09 +00:00
|
|
|
static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
|
|
|
|
GetStorageFromURL(
|
|
|
|
const ::rtl::OUString& aURL,
|
|
|
|
sal_Int32 nStorageMode,
|
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory
|
|
|
|
= ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() )
|
|
|
|
throw ( ::com::sun::star::uno::Exception );
|
|
|
|
|
2008-07-01 15:28:24 +00:00
|
|
|
/// this one will return either Storage or FileSystemStorage
|
|
|
|
static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
|
|
|
|
GetStorageFromURL2(
|
|
|
|
const ::rtl::OUString& aURL,
|
|
|
|
sal_Int32 nStorageMode,
|
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory
|
|
|
|
= ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() )
|
|
|
|
|
|
|
|
throw ( ::com::sun::star::uno::Exception );
|
|
|
|
|
2004-10-04 20:06:09 +00:00
|
|
|
static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
|
|
|
|
GetStorageFromInputStream(
|
|
|
|
const ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream >& xStream,
|
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory
|
|
|
|
= ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() )
|
|
|
|
throw ( ::com::sun::star::uno::Exception );
|
|
|
|
|
|
|
|
static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
|
|
|
|
GetStorageFromStream(
|
|
|
|
const ::com::sun::star::uno::Reference < ::com::sun::star::io::XStream >& xStream,
|
|
|
|
sal_Int32 nStorageMode = ::com::sun::star::embed::ElementModes::READWRITE,
|
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory
|
|
|
|
= ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() )
|
|
|
|
throw ( ::com::sun::star::uno::Exception );
|
|
|
|
|
|
|
|
static void CopyInputToOutput(
|
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInput,
|
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutput )
|
|
|
|
throw ( ::com::sun::star::uno::Exception );
|
|
|
|
|
|
|
|
static ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
|
|
|
|
GetInputStreamFromURL(
|
|
|
|
const ::rtl::OUString& aURL,
|
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory
|
|
|
|
= ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() )
|
|
|
|
throw ( ::com::sun::star::uno::Exception );
|
|
|
|
|
2010-11-04 17:56:39 +01:00
|
|
|
static void SetCommonStorageEncryptionData(
|
2004-10-04 20:06:09 +00:00
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
|
2010-11-04 17:56:39 +01:00
|
|
|
const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& aEncryptionData )
|
2004-10-04 20:06:09 +00:00
|
|
|
throw ( ::com::sun::star::uno::Exception );
|
|
|
|
|
2006-10-13 10:40:22 +00:00
|
|
|
// the following method supports only storages of OOo formats
|
2004-10-04 20:06:09 +00:00
|
|
|
static sal_Int32 GetXStorageFormat(
|
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage )
|
|
|
|
throw ( ::com::sun::star::uno::Exception );
|
2006-10-13 10:40:22 +00:00
|
|
|
|
|
|
|
// The followin methods are related to creation of a storage of specified format
|
|
|
|
static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
|
|
|
|
GetTemporaryStorageOfFormat(
|
|
|
|
const ::rtl::OUString& aFormat,
|
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory
|
|
|
|
= ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() )
|
|
|
|
throw ( ::com::sun::star::uno::Exception );
|
|
|
|
|
|
|
|
static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
|
|
|
|
GetStorageOfFormatFromURL(
|
|
|
|
const ::rtl::OUString& aFormat,
|
|
|
|
const ::rtl::OUString& aURL,
|
|
|
|
sal_Int32 nStorageMode,
|
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory
|
2010-04-08 10:20:00 +02:00
|
|
|
= ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >(),
|
|
|
|
sal_Bool bRepairStorage = sal_False )
|
2006-10-13 10:40:22 +00:00
|
|
|
throw ( ::com::sun::star::uno::Exception );
|
|
|
|
|
|
|
|
static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
|
|
|
|
GetStorageOfFormatFromInputStream(
|
|
|
|
const ::rtl::OUString& aFormat,
|
|
|
|
const ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream >& xStream,
|
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory
|
2010-04-08 10:20:00 +02:00
|
|
|
= ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >(),
|
|
|
|
sal_Bool bRepairStorage = sal_False )
|
2006-10-13 10:40:22 +00:00
|
|
|
throw ( ::com::sun::star::uno::Exception );
|
|
|
|
|
|
|
|
static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
|
|
|
|
GetStorageOfFormatFromStream(
|
|
|
|
const ::rtl::OUString& aFormat,
|
|
|
|
const ::com::sun::star::uno::Reference < ::com::sun::star::io::XStream >& xStream,
|
|
|
|
sal_Int32 nStorageMode = ::com::sun::star::embed::ElementModes::READWRITE,
|
|
|
|
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory
|
2010-04-08 10:20:00 +02:00
|
|
|
= ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >(),
|
|
|
|
sal_Bool bRepairStorage = sal_False )
|
2006-10-13 10:40:22 +00:00
|
|
|
throw ( ::com::sun::star::uno::Exception );
|
|
|
|
|
2010-11-04 17:56:39 +01:00
|
|
|
static ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >
|
|
|
|
CreatePackageEncryptionData( const ::rtl::OUString& aPassword );
|
|
|
|
|
2009-02-12 10:27:21 +00:00
|
|
|
static sal_Bool IsValidZipEntryFileName( const ::rtl::OUString& aName, sal_Bool bSlashAllowed );
|
|
|
|
static sal_Bool IsValidZipEntryFileName( const sal_Unicode *pChar, sal_Int32 nLength, sal_Bool bSlashAllowed );
|
2010-08-10 11:05:20 +02:00
|
|
|
|
|
|
|
static sal_Bool PathHasSegment( const ::rtl::OUString& aPath, const ::rtl::OUString& aSegment );
|
2004-10-04 20:06:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|