summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorMikhail Voytenko <mav@openoffice.org>2010-03-23 13:00:11 +0100
committerMikhail Voytenko <mav@openoffice.org>2010-03-23 13:00:11 +0100
commit682a87732c864ee15ca2c6be10d2aa655936c93d (patch)
tree3492a17701b4fa884652c549204970bb0b19267a /package
parent94bf193db97db0d4ccf6491f8886fdca44e4b252 (diff)
fwk138: #i87496# publish services, interfaces and etc.
Diffstat (limited to 'package')
-rw-r--r--package/source/xstor/ocompinstream.cxx23
-rw-r--r--package/source/xstor/owriteablestream.cxx111
-rw-r--r--package/source/xstor/xfactory.cxx36
-rw-r--r--package/source/xstor/xstorage.cxx153
-rw-r--r--package/source/xstor/xstorage.hxx7
-rw-r--r--package/source/zippackage/ZipPackage.cxx29
6 files changed, 194 insertions, 165 deletions
diff --git a/package/source/xstor/ocompinstream.cxx b/package/source/xstor/ocompinstream.cxx
index 45bf7c01eb2f..789c7a3faa4a 100644
--- a/package/source/xstor/ocompinstream.cxx
+++ b/package/source/xstor/ocompinstream.cxx
@@ -29,6 +29,7 @@
#include "precompiled_package.hxx"
#include "ocompinstream.hxx"
+#include <com/sun/star/embed/StorageFormats.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
#include <osl/diagnose.h>
@@ -107,7 +108,7 @@ uno::Any SAL_CALL OInputCompStream::queryInterface( const uno::Type& rType )
if ( aReturn.hasValue() == sal_True )
return aReturn ;
- if ( m_nStorageType == OFOPXML_STORAGE )
+ if ( m_nStorageType == embed::StorageFormats::OFOPXML )
{
aReturn <<= ::cppu::queryInterface
( rType
@@ -356,7 +357,7 @@ sal_Bool SAL_CALL OInputCompStream::hasByID( const ::rtl::OUString& sID )
throw lang::DisposedException();
}
- if ( m_nStorageType != OFOPXML_STORAGE )
+ if ( m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
try
@@ -384,7 +385,7 @@ sal_Bool SAL_CALL OInputCompStream::hasByID( const ::rtl::OUString& sID )
throw lang::DisposedException();
}
- if ( m_nStorageType != OFOPXML_STORAGE )
+ if ( m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
uno::Sequence< beans::StringPair > aSeq = getRelationshipByID( sID );
@@ -409,7 +410,7 @@ sal_Bool SAL_CALL OInputCompStream::hasByID( const ::rtl::OUString& sID )
throw lang::DisposedException();
}
- if ( m_nStorageType != OFOPXML_STORAGE )
+ if ( m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
uno::Sequence< beans::StringPair > aSeq = getRelationshipByID( sID );
@@ -434,7 +435,7 @@ uno::Sequence< beans::StringPair > SAL_CALL OInputCompStream::getRelationshipByI
throw lang::DisposedException();
}
- if ( m_nStorageType != OFOPXML_STORAGE )
+ if ( m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
// TODO/LATER: in future the unification of the ID could be checked
@@ -464,7 +465,7 @@ uno::Sequence< uno::Sequence< beans::StringPair > > SAL_CALL OInputCompStream::g
throw lang::DisposedException();
}
- if ( m_nStorageType != OFOPXML_STORAGE )
+ if ( m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
uno::Sequence< uno::Sequence< beans::StringPair > > aResult;
@@ -499,7 +500,7 @@ uno::Sequence< uno::Sequence< beans::StringPair > > SAL_CALL OInputCompStream::g
throw lang::DisposedException();
}
- if ( m_nStorageType != OFOPXML_STORAGE )
+ if ( m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
// TODO/LATER: in future the information could be taken directly from m_pImpl when possible
@@ -530,7 +531,7 @@ void SAL_CALL OInputCompStream::insertRelationshipByID( const ::rtl::OUString&
throw lang::DisposedException();
}
- if ( m_nStorageType != OFOPXML_STORAGE )
+ if ( m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
throw io::IOException(); // TODO: Access denied
@@ -550,7 +551,7 @@ void SAL_CALL OInputCompStream::removeRelationshipByID( const ::rtl::OUString&
throw lang::DisposedException();
}
- if ( m_nStorageType != OFOPXML_STORAGE )
+ if ( m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
throw io::IOException(); // TODO: Access denied
@@ -570,7 +571,7 @@ void SAL_CALL OInputCompStream::insertRelationships( const uno::Sequence< uno::
throw lang::DisposedException();
}
- if ( m_nStorageType != OFOPXML_STORAGE )
+ if ( m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
throw io::IOException(); // TODO: Access denied
@@ -589,7 +590,7 @@ void SAL_CALL OInputCompStream::clearRelationships()
throw lang::DisposedException();
}
- if ( m_nStorageType != OFOPXML_STORAGE )
+ if ( m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
throw io::IOException(); // TODO: Access denied
diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx
index c5381a11cfea..15e809ef4052 100644
--- a/package/source/xstor/owriteablestream.cxx
+++ b/package/source/xstor/owriteablestream.cxx
@@ -35,6 +35,7 @@
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/io/IOException.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/embed/StorageFormats.hpp>
#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
#include <cppuhelper/typeprovider.hxx>
#include <cppuhelper/exc_hlp.hxx>
@@ -254,7 +255,7 @@ OWriteStream_Impl::OWriteStream_Impl( OStorage_Impl* pParent,
, m_xFactory( xFactory )
, m_pParent( pParent )
, m_bForceEncrypted( bForceEncrypted )
-, m_bUseCommonPass( !bForceEncrypted && nStorageType == PACKAGE_STORAGE )
+, m_bUseCommonPass( !bForceEncrypted && nStorageType == embed::StorageFormats::PACKAGE )
, m_bHasCachedPassword( sal_False )
, m_bCompressedSetExplicit( !bDefaultCompress )
, m_xPackage( xPackage )
@@ -269,7 +270,7 @@ OWriteStream_Impl::OWriteStream_Impl( OStorage_Impl* pParent,
OSL_ENSURE( xPackage.is(), "No package component is provided!\n" );
OSL_ENSURE( m_xFactory.is(), "No package stream is provided!\n" );
OSL_ENSURE( pParent, "No parent storage is provided!\n" );
- OSL_ENSURE( m_nStorageType == OFOPXML_STORAGE || !m_xOrigRelInfoStream.is(), "The Relations info makes sence only for OFOPXML format!\n" );
+ OSL_ENSURE( m_nStorageType == embed::StorageFormats::OFOPXML || !m_xOrigRelInfoStream.is(), "The Relations info makes sence only for OFOPXML format!\n" );
}
//-----------------------------------------------
@@ -359,7 +360,7 @@ void OWriteStream_Impl::InsertIntoPackageFolder( const ::rtl::OUString& aName,
//-----------------------------------------------
sal_Bool OWriteStream_Impl::IsEncrypted()
{
- if ( m_nStorageType != PACKAGE_STORAGE )
+ if ( m_nStorageType != embed::StorageFormats::PACKAGE )
return sal_False;
if ( m_bForceEncrypted || m_bHasCachedPassword )
@@ -419,8 +420,8 @@ sal_Bool OWriteStream_Impl::IsEncrypted()
//-----------------------------------------------
void OWriteStream_Impl::SetDecrypted()
{
- OSL_ENSURE( m_nStorageType == PACKAGE_STORAGE, "The encryption is supported only for package storages!\n" );
- if ( m_nStorageType != PACKAGE_STORAGE )
+ OSL_ENSURE( m_nStorageType == embed::StorageFormats::PACKAGE, "The encryption is supported only for package storages!\n" );
+ if ( m_nStorageType != embed::StorageFormats::PACKAGE )
throw uno::RuntimeException();
GetStreamProperties();
@@ -444,8 +445,8 @@ void OWriteStream_Impl::SetDecrypted()
//-----------------------------------------------
void OWriteStream_Impl::SetEncryptedWithPass( const ::rtl::OUString& aPass )
{
- OSL_ENSURE( m_nStorageType == PACKAGE_STORAGE, "The encryption is supported only for package storages!\n" );
- if ( m_nStorageType != PACKAGE_STORAGE )
+ OSL_ENSURE( m_nStorageType == embed::StorageFormats::PACKAGE, "The encryption is supported only for package storages!\n" );
+ if ( m_nStorageType != embed::StorageFormats::PACKAGE )
throw uno::RuntimeException();
GetStreamProperties();
@@ -789,12 +790,12 @@ void OWriteStream_Impl::InsertStreamDirectly( const uno::Reference< io::XInputSt
bCompressedIsSet = sal_True;
aProps[nInd].Value >>= bCompressed;
}
- else if ( ( m_nStorageType == OFOPXML_STORAGE || m_nStorageType == PACKAGE_STORAGE )
+ else if ( ( m_nStorageType == embed::StorageFormats::OFOPXML || m_nStorageType == embed::StorageFormats::PACKAGE )
&& aProps[nInd].Name.equals( aMedTypePropName ) )
{
xPropertySet->setPropertyValue( aProps[nInd].Name, aProps[nInd].Value );
}
- else if ( m_nStorageType == PACKAGE_STORAGE && aProps[nInd].Name.equalsAscii( "UseCommonStoragePasswordEncryption" ) )
+ else if ( m_nStorageType == embed::StorageFormats::PACKAGE && aProps[nInd].Name.equalsAscii( "UseCommonStoragePasswordEncryption" ) )
aProps[nInd].Value >>= m_bUseCommonPass;
else
throw lang::IllegalArgumentException();
@@ -816,7 +817,7 @@ void OWriteStream_Impl::InsertStreamDirectly( const uno::Reference< io::XInputSt
if ( m_bUseCommonPass )
{
- if ( m_nStorageType != PACKAGE_STORAGE )
+ if ( m_nStorageType != embed::StorageFormats::PACKAGE )
throw uno::RuntimeException();
// set to be encrypted but do not use encryption key
@@ -915,7 +916,7 @@ void OWriteStream_Impl::Commit()
if ( m_bUseCommonPass )
{
- if ( m_nStorageType != PACKAGE_STORAGE )
+ if ( m_nStorageType != embed::StorageFormats::PACKAGE )
throw uno::RuntimeException();
// set to be encrypted but do not use encryption key
@@ -926,7 +927,7 @@ void OWriteStream_Impl::Commit()
}
else if ( m_bHasCachedPassword )
{
- if ( m_nStorageType != PACKAGE_STORAGE )
+ if ( m_nStorageType != embed::StorageFormats::PACKAGE )
throw uno::RuntimeException();
xPropertySet->setPropertyValue( ::rtl::OUString::createFromAscii( "EncryptionKey" ),
@@ -972,7 +973,7 @@ void OWriteStream_Impl::Revert()
m_bHasCachedPassword = sal_False;
m_aPass = ::rtl::OUString();
- if ( m_nStorageType == OFOPXML_STORAGE )
+ if ( m_nStorageType == embed::StorageFormats::OFOPXML )
{
// currently the relations storage is changed only on commit
m_xNewRelInfoStream = uno::Reference< io::XInputStream >();
@@ -1011,7 +1012,7 @@ uno::Sequence< beans::PropertyValue > OWriteStream_Impl::InsertOwnProps(
uno::Sequence< beans::PropertyValue > aResult( aProps );
sal_Int32 nLen = aResult.getLength();
- if ( m_nStorageType == PACKAGE_STORAGE )
+ if ( m_nStorageType == embed::StorageFormats::PACKAGE )
{
for ( sal_Int32 nInd = 0; nInd < nLen; nInd++ )
if ( aResult[nInd].Name.equalsAscii( "UseCommonStoragePasswordEncryption" ) )
@@ -1024,7 +1025,7 @@ uno::Sequence< beans::PropertyValue > OWriteStream_Impl::InsertOwnProps(
aResult[nLen - 1].Name = ::rtl::OUString::createFromAscii( "UseCommonStoragePasswordEncryption" );
aResult[nLen - 1].Value <<= bUseCommonPass;
}
- else if ( m_nStorageType == OFOPXML_STORAGE )
+ else if ( m_nStorageType == embed::StorageFormats::OFOPXML )
{
ReadRelInfoIfNecessary();
@@ -1061,7 +1062,7 @@ sal_Bool OWriteStream_Impl::IsTransacted()
void OWriteStream_Impl::ReadRelInfoIfNecessary()
{
- if ( m_nStorageType != OFOPXML_STORAGE )
+ if ( m_nStorageType != embed::StorageFormats::OFOPXML )
return;
if ( m_nRelInfoStatus == RELINFO_NO_INIT )
@@ -1114,24 +1115,24 @@ void OWriteStream_Impl::ReadRelInfoIfNecessary()
uno::Sequence< beans::PropertyValue > OWriteStream_Impl::ReadPackageStreamProperties()
{
sal_Int32 nPropNum = 0;
- if ( m_nStorageType == ZIP_STORAGE )
+ if ( m_nStorageType == embed::StorageFormats::ZIP )
nPropNum = 2;
- else if ( m_nStorageType == OFOPXML_STORAGE )
+ else if ( m_nStorageType == embed::StorageFormats::OFOPXML )
nPropNum = 3;
- else if ( m_nStorageType == PACKAGE_STORAGE )
+ else if ( m_nStorageType == embed::StorageFormats::PACKAGE )
nPropNum = 4;
uno::Sequence< beans::PropertyValue > aResult( nPropNum );
// The "Compressed" property must be set after "MediaType" property,
// since the setting of the last one can change the value of the first one
- if ( m_nStorageType == OFOPXML_STORAGE || m_nStorageType == PACKAGE_STORAGE )
+ if ( m_nStorageType == embed::StorageFormats::OFOPXML || m_nStorageType == embed::StorageFormats::PACKAGE )
{
aResult[0].Name = ::rtl::OUString::createFromAscii("MediaType");
aResult[1].Name = ::rtl::OUString::createFromAscii("Compressed");
aResult[2].Name = ::rtl::OUString::createFromAscii("Size");
- if ( m_nStorageType == PACKAGE_STORAGE )
+ if ( m_nStorageType == embed::StorageFormats::PACKAGE )
aResult[3].Name = ::rtl::OUString::createFromAscii("Encrypted");
}
else
@@ -1177,7 +1178,7 @@ void OWriteStream_Impl::CopyInternallyTo_Impl( const uno::Reference< io::XStream
OSL_ENSURE( !m_bUseCommonPass, "The stream can not be encrypted!" );
- if ( m_nStorageType != PACKAGE_STORAGE )
+ if ( m_nStorageType != embed::StorageFormats::PACKAGE )
throw packages::NoEncryptionException();
if ( m_pAntiImpl )
@@ -1201,7 +1202,7 @@ void OWriteStream_Impl::CopyInternallyTo_Impl( const uno::Reference< io::XStream
//-----------------------------------------------
uno::Sequence< uno::Sequence< beans::StringPair > > OWriteStream_Impl::GetAllRelationshipsIfAny()
{
- if ( m_nStorageType != OFOPXML_STORAGE )
+ if ( m_nStorageType != embed::StorageFormats::OFOPXML )
return uno::Sequence< uno::Sequence< beans::StringPair > >();
ReadRelInfoIfNecessary();
@@ -1516,7 +1517,7 @@ uno::Reference< io::XInputStream > OWriteStream_Impl::GetRawInStream()
{
::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() ) ;
- if ( m_nStorageType != PACKAGE_STORAGE || !m_pParent )
+ if ( m_nStorageType != embed::StorageFormats::PACKAGE || !m_pParent )
throw packages::NoEncryptionException();
return m_pParent->GetCommonRootPass();
@@ -1702,9 +1703,9 @@ void OWriteStream_Impl::GetCopyOfLastCommit( uno::Reference< io::XStream >& xTar
void OWriteStream_Impl::CommitStreamRelInfo( const uno::Reference< embed::XStorage >& xRelStorage, const ::rtl::OUString& aOrigStreamName, const ::rtl::OUString& aNewStreamName )
{
// at this point of time the old stream must be already cleaned
- OSL_ENSURE( m_nStorageType == OFOPXML_STORAGE, "The method should be used only with OFOPXML format!\n" );
+ OSL_ENSURE( m_nStorageType == embed::StorageFormats::OFOPXML, "The method should be used only with OFOPXML format!\n" );
- if ( m_nStorageType == OFOPXML_STORAGE )
+ if ( m_nStorageType == embed::StorageFormats::OFOPXML )
{
OSL_ENSURE( aOrigStreamName.getLength() && aNewStreamName.getLength() && xRelStorage.is(),
"Wrong relation persistence information is provided!\n" );
@@ -1972,12 +1973,12 @@ void OWriteStream::CopyToStreamInternally_Impl( const uno::Reference< io::XStrea
// the order of the properties setting is not important for StorageStream API
::rtl::OUString aPropName = ::rtl::OUString::createFromAscii( "Compressed" );
xDestProps->setPropertyValue( aPropName, getPropertyValue( aPropName ) );
- if ( m_pData->m_nStorageType == PACKAGE_STORAGE || m_pData->m_nStorageType == OFOPXML_STORAGE )
+ if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE || m_pData->m_nStorageType == embed::StorageFormats::OFOPXML )
{
aPropName = ::rtl::OUString::createFromAscii( "MediaType" );
xDestProps->setPropertyValue( aPropName, getPropertyValue( aPropName ) );
- if ( m_pData->m_nStorageType == PACKAGE_STORAGE )
+ if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE )
{
aPropName = ::rtl::OUString::createFromAscii( "UseCommonStoragePasswordEncryption" );
xDestProps->setPropertyValue( aPropName, getPropertyValue( aPropName ) );
@@ -2023,13 +2024,13 @@ uno::Any SAL_CALL OWriteStream::queryInterface( const uno::Type& rType )
if ( aReturn.hasValue() == sal_True )
return aReturn ;
- if ( m_pData->m_nStorageType == PACKAGE_STORAGE )
+ if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE )
{
aReturn <<= ::cppu::queryInterface
( rType
, static_cast<embed::XEncryptionProtectedSource*> ( this ) );
}
- else if ( m_pData->m_nStorageType == OFOPXML_STORAGE )
+ else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML )
{
aReturn <<= ::cppu::queryInterface
( rType
@@ -2077,7 +2078,7 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
{
if ( m_bTransacted )
{
- if ( m_pData->m_nStorageType == PACKAGE_STORAGE )
+ if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE )
{
m_pData->m_pTypeCollection = new ::cppu::OTypeCollection
( ::getCppuType( ( const uno::Reference< lang::XTypeProvider >* )NULL )
@@ -2093,7 +2094,7 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
, ::getCppuType( ( const uno::Reference< embed::XTransactionBroadcaster >* )NULL )
, ::getCppuType( ( const uno::Reference< beans::XPropertySet >* )NULL ) );
}
- else if ( m_pData->m_nStorageType == OFOPXML_STORAGE )
+ else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML )
{
m_pData->m_pTypeCollection = new ::cppu::OTypeCollection
( ::getCppuType( ( const uno::Reference< lang::XTypeProvider >* )NULL )
@@ -2109,7 +2110,7 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
, ::getCppuType( ( const uno::Reference< embed::XTransactionBroadcaster >* )NULL )
, ::getCppuType( ( const uno::Reference< beans::XPropertySet >* )NULL ) );
}
- else // if ( m_pData->m_nStorageType == ZIP_STORAGE )
+ else // if ( m_pData->m_nStorageType == embed::StorageFormats::ZIP )
{
m_pData->m_pTypeCollection = new ::cppu::OTypeCollection
( ::getCppuType( ( const uno::Reference< lang::XTypeProvider >* )NULL )
@@ -2127,7 +2128,7 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
}
else
{
- if ( m_pData->m_nStorageType == PACKAGE_STORAGE )
+ if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE )
{
m_pData->m_pTypeCollection = new ::cppu::OTypeCollection
( ::getCppuType( ( const uno::Reference< lang::XTypeProvider >* )NULL )
@@ -2140,7 +2141,7 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
, ::getCppuType( ( const uno::Reference< embed::XEncryptionProtectedSource >* )NULL )
, ::getCppuType( ( const uno::Reference< beans::XPropertySet >* )NULL ) );
}
- else if ( m_pData->m_nStorageType == OFOPXML_STORAGE )
+ else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML )
{
m_pData->m_pTypeCollection = new ::cppu::OTypeCollection
( ::getCppuType( ( const uno::Reference< lang::XTypeProvider >* )NULL )
@@ -2153,7 +2154,7 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
, ::getCppuType( ( const uno::Reference< embed::XRelationshipAccess >* )NULL )
, ::getCppuType( ( const uno::Reference< beans::XPropertySet >* )NULL ) );
}
- else // if ( m_pData->m_nStorageType == ZIP_STORAGE )
+ else // if ( m_pData->m_nStorageType == embed::StorageFormats::ZIP )
{
m_pData->m_pTypeCollection = new ::cppu::OTypeCollection
( ::getCppuType( ( const uno::Reference< lang::XTypeProvider >* )NULL )
@@ -2752,7 +2753,7 @@ sal_Bool SAL_CALL OWriteStream::hasByID( const ::rtl::OUString& sID )
throw lang::DisposedException();
}
- if ( m_pData->m_nStorageType != OFOPXML_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
try
@@ -2783,7 +2784,7 @@ sal_Bool SAL_CALL OWriteStream::hasByID( const ::rtl::OUString& sID )
throw lang::DisposedException();
}
- if ( m_pData->m_nStorageType != OFOPXML_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
uno::Sequence< beans::StringPair > aSeq = getRelationshipByID( sID );
@@ -2808,7 +2809,7 @@ sal_Bool SAL_CALL OWriteStream::hasByID( const ::rtl::OUString& sID )
throw lang::DisposedException();
}
- if ( m_pData->m_nStorageType != OFOPXML_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
uno::Sequence< beans::StringPair > aSeq = getRelationshipByID( sID );
@@ -2833,7 +2834,7 @@ uno::Sequence< beans::StringPair > SAL_CALL OWriteStream::getRelationshipByID(
throw lang::DisposedException();
}
- if ( m_pData->m_nStorageType != OFOPXML_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
// TODO/LATER: in future the unification of the ID could be checked
@@ -2863,7 +2864,7 @@ uno::Sequence< uno::Sequence< beans::StringPair > > SAL_CALL OWriteStream::getRe
throw lang::DisposedException();
}
- if ( m_pData->m_nStorageType != OFOPXML_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
uno::Sequence< uno::Sequence< beans::StringPair > > aResult;
@@ -2898,7 +2899,7 @@ uno::Sequence< uno::Sequence< beans::StringPair > > SAL_CALL OWriteStream::getAl
throw lang::DisposedException();
}
- if ( m_pData->m_nStorageType != OFOPXML_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
return m_pImpl->GetAllRelationshipsIfAny();
@@ -2918,7 +2919,7 @@ void SAL_CALL OWriteStream::insertRelationshipByID( const ::rtl::OUString& sID,
throw lang::DisposedException();
}
- if ( m_pData->m_nStorageType != OFOPXML_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
::rtl::OUString aIDTag( RTL_CONSTASCII_USTRINGPARAM( "Id" ) );
@@ -2983,7 +2984,7 @@ void SAL_CALL OWriteStream::removeRelationshipByID( const ::rtl::OUString& sID
throw lang::DisposedException();
}
- if ( m_pData->m_nStorageType != OFOPXML_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
uno::Sequence< uno::Sequence< beans::StringPair > > aSeq = getAllRelationships();
@@ -3025,7 +3026,7 @@ void SAL_CALL OWriteStream::insertRelationships( const uno::Sequence< uno::Sequ
throw lang::DisposedException();
}
- if ( m_pData->m_nStorageType != OFOPXML_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
::rtl::OUString aIDTag( RTL_CONSTASCII_USTRINGPARAM( "Id" ) );
@@ -3107,7 +3108,7 @@ void SAL_CALL OWriteStream::clearRelationships()
throw lang::DisposedException();
}
- if ( m_pData->m_nStorageType != OFOPXML_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException();
m_pImpl->m_aNewRelInfo.realloc( 0 );
@@ -3144,7 +3145,7 @@ void SAL_CALL OWriteStream::setPropertyValue( const ::rtl::OUString& aPropertyNa
m_pImpl->GetStreamProperties();
::rtl::OUString aCompressedString( RTL_CONSTASCII_USTRINGPARAM( "Compressed" ) );
::rtl::OUString aMediaTypeString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) );
- if ( m_pData->m_nStorageType == PACKAGE_STORAGE && aPropertyName.equals( aMediaTypeString ) )
+ if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE && aPropertyName.equals( aMediaTypeString ) )
{
// if the "Compressed" property is not set explicitly, the MediaType can change the default value
sal_Bool bCompressedValueFromType = sal_True;
@@ -3177,7 +3178,7 @@ void SAL_CALL OWriteStream::setPropertyValue( const ::rtl::OUString& aPropertyNa
m_pImpl->m_aProps[nInd].Value = aValue;
}
}
- else if ( m_pData->m_nStorageType == PACKAGE_STORAGE
+ else if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE
&& aPropertyName.equalsAscii( "UseCommonStoragePasswordEncryption" ) )
{
sal_Bool bUseCommonPass = sal_False;
@@ -3202,7 +3203,7 @@ void SAL_CALL OWriteStream::setPropertyValue( const ::rtl::OUString& aPropertyNa
else
throw lang::IllegalArgumentException(); //TODO
}
- else if ( m_pData->m_nStorageType == OFOPXML_STORAGE && aPropertyName.equals( aMediaTypeString ) )
+ else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && aPropertyName.equals( aMediaTypeString ) )
{
for ( sal_Int32 nInd = 0; nInd < m_pImpl->m_aProps.getLength(); nInd++ )
{
@@ -3210,7 +3211,7 @@ void SAL_CALL OWriteStream::setPropertyValue( const ::rtl::OUString& aPropertyNa
m_pImpl->m_aProps[nInd].Value = aValue;
}
}
- else if ( m_pData->m_nStorageType == OFOPXML_STORAGE && aPropertyName.equalsAscii( "RelationsInfoStream" ) )
+ else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && aPropertyName.equalsAscii( "RelationsInfoStream" ) )
{
uno::Reference< io::XInputStream > xInRelStream;
if ( ( aValue >>= xInRelStream ) && xInRelStream.is() )
@@ -3231,7 +3232,7 @@ void SAL_CALL OWriteStream::setPropertyValue( const ::rtl::OUString& aPropertyNa
else
throw lang::IllegalArgumentException(); // TODO
}
- else if ( m_pData->m_nStorageType == OFOPXML_STORAGE && aPropertyName.equalsAscii( "RelationsInfo" ) )
+ else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML && aPropertyName.equalsAscii( "RelationsInfo" ) )
{
if ( aValue >>= m_pImpl->m_aNewRelInfo )
{
@@ -3241,7 +3242,7 @@ void SAL_CALL OWriteStream::setPropertyValue( const ::rtl::OUString& aPropertyNa
}
else if ( aPropertyName.equalsAscii( "Size" ) )
throw beans::PropertyVetoException(); // TODO
- else if ( m_pData->m_nStorageType == PACKAGE_STORAGE
+ else if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE
&& ( aPropertyName.equalsAscii( "IsEncrypted" ) || aPropertyName.equalsAscii( "Encrypted" ) ) )
throw beans::PropertyVetoException(); // TODO
else
@@ -3277,9 +3278,9 @@ uno::Any SAL_CALL OWriteStream::getPropertyValue( const ::rtl::OUString& aProp )
else
aPropertyName = aProp;
- if ( ( ( m_pData->m_nStorageType == PACKAGE_STORAGE || m_pData->m_nStorageType == OFOPXML_STORAGE )
+ if ( ( ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE || m_pData->m_nStorageType == embed::StorageFormats::OFOPXML )
&& aPropertyName.equalsAscii( "MediaType" ) )
- || m_pData->m_nStorageType == PACKAGE_STORAGE && aPropertyName.equalsAscii( "Encrypted" )
+ || m_pData->m_nStorageType == embed::StorageFormats::PACKAGE && aPropertyName.equalsAscii( "Encrypted" )
|| aPropertyName.equalsAscii( "Compressed" ) )
{
m_pImpl->GetStreamProperties();
@@ -3290,7 +3291,7 @@ uno::Any SAL_CALL OWriteStream::getPropertyValue( const ::rtl::OUString& aProp )
return m_pImpl->m_aProps[nInd].Value;
}
}
- else if ( m_pData->m_nStorageType == PACKAGE_STORAGE
+ else if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE
&& aPropertyName.equalsAscii( "UseCommonStoragePasswordEncryption" ) )
return uno::makeAny( m_pImpl->m_bUseCommonPass );
else if ( aPropertyName.equalsAscii( "Size" ) )
diff --git a/package/source/xstor/xfactory.cxx b/package/source/xstor/xfactory.cxx
index e78742641a0b..cfea4af2db87 100644
--- a/package/source/xstor/xfactory.cxx
+++ b/package/source/xstor/xfactory.cxx
@@ -29,9 +29,11 @@
#include "precompiled_package.hxx"
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/embed/StorageFormats.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/io/XSeekable.hpp>
+#include <comphelper/storagehelper.hxx>
#include "xfactory.hxx"
#include "xstorage.hxx"
@@ -101,7 +103,7 @@ uno::Reference< uno::XInterface > SAL_CALL OStorageFactory::createInstance()
embed::ElementModes::READWRITE,
uno::Sequence< beans::PropertyValue >(),
m_xFactory,
- PACKAGE_STORAGE ) ),
+ embed::StorageFormats::PACKAGE ) ),
uno::UNO_QUERY );
}
@@ -184,7 +186,7 @@ uno::Reference< uno::XInterface > SAL_CALL OStorageFactory::createInstanceWithAr
uno::Sequence< beans::PropertyValue > aDescr;
uno::Sequence< beans::PropertyValue > aPropsToSet;
- sal_Int16 nStorageType = PACKAGE_STORAGE;
+ sal_Int16 nStorageType = embed::StorageFormats::PACKAGE;
if ( nArgNum >= 3 )
{
@@ -212,15 +214,29 @@ uno::Reference< uno::XInterface > SAL_CALL OStorageFactory::createInstanceWithAr
else if ( aDescr[nInd].Name.equalsAscii( "StorageFormat" ) )
{
::rtl::OUString aFormatName;
- aDescr[nInd].Value >>= aFormatName;
- if ( aFormatName.equalsAscii( "PackageFormat" ) )
- nStorageType = PACKAGE_STORAGE;
- else if ( aFormatName.equalsAscii( "ZipFormat" ) )
- nStorageType = ZIP_STORAGE;
- else if ( aFormatName.equalsAscii( "OFOPXMLFormat" ) )
- nStorageType = OFOPXML_STORAGE;
+ sal_Int32 nFormatID = 0;
+ if ( aDescr[nInd].Value >>= aFormatName )
+ {
+ if ( aFormatName.equals( PACKAGE_STORAGE_FORMAT_STRING ) )
+ nStorageType = embed::StorageFormats::PACKAGE;
+ else if ( aFormatName.equals( ZIP_STORAGE_FORMAT_STRING ) )
+ nStorageType = embed::StorageFormats::ZIP;
+ else if ( aFormatName.equals( OFOPXML_STORAGE_FORMAT_STRING ) )
+ nStorageType = embed::StorageFormats::OFOPXML;
+ else
+ throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 );
+ }
+ else if ( aDescr[nInd].Value >>= nFormatID )
+ {
+ if ( nFormatID != embed::StorageFormats::PACKAGE
+ && nFormatID != embed::StorageFormats::ZIP
+ && nFormatID != embed::StorageFormats::OFOPXML )
+ throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 );
+
+ nStorageType = nFormatID;
+ }
else
- throw lang::IllegalArgumentException(); // TODO:
+ throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 );
}
else
OSL_ENSURE( sal_False, "Unacceptable property, will be ignored!\n" );
diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx
index 55ff5a87e78d..6926f192534a 100644
--- a/package/source/xstor/xstorage.cxx
+++ b/package/source/xstor/xstorage.cxx
@@ -30,6 +30,7 @@
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/embed/UseBackupException.hpp>
+#include <com/sun/star/embed/StorageFormats.hpp>
#include <com/sun/star/ucb/XProgressHandler.hpp>
#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
#include <com/sun/star/container/XEnumerationAccess.hpp>
@@ -124,13 +125,13 @@ void OStorage_Impl::completeStorageStreamCopy_Impl(
uno::Sequence< ::rtl::OUString > aPropNames( 1 );
aPropNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Compressed" ) );
- if ( nStorageType == PACKAGE_STORAGE )
+ if ( nStorageType == embed::StorageFormats::PACKAGE )
{
aPropNames.realloc( 3 );
aPropNames[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) );
aPropNames[2] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseCommonStoragePasswordEncryption" ) );
}
- else if ( nStorageType == OFOPXML_STORAGE )
+ else if ( nStorageType == embed::StorageFormats::OFOPXML )
{
// TODO/LATER: in future it might make sence to provide the stream if there is one
uno::Reference< embed::XRelationshipAccess > xRelAccess( xDest, uno::UNO_QUERY_THROW );
@@ -356,7 +357,7 @@ OStorage_Impl::~OStorage_Impl()
m_aDeletedList.clear();
- if ( m_nStorageType == OFOPXML_STORAGE && m_pRelStorElement )
+ if ( m_nStorageType == embed::StorageFormats::OFOPXML && m_pRelStorElement )
{
delete m_pRelStorElement;
m_pRelStorElement = NULL;
@@ -500,7 +501,7 @@ void OStorage_Impl::OpenOwnPackage()
}
}
- if ( m_nStorageType == ZIP_STORAGE )
+ if ( m_nStorageType == embed::StorageFormats::ZIP )
{
// let the package support only plain zip format
beans::NamedValue aNamedValue;
@@ -509,7 +510,7 @@ void OStorage_Impl::OpenOwnPackage()
aArguments.realloc( ++nArgNum );
aArguments[nArgNum-1] <<= aNamedValue;
}
- else if ( m_nStorageType == OFOPXML_STORAGE )
+ else if ( m_nStorageType == embed::StorageFormats::OFOPXML )
{
// let the package support OFOPXML media type handling
beans::NamedValue aNamedValue;
@@ -562,7 +563,7 @@ SotElementList_Impl& OStorage_Impl::GetChildrenList()
//-----------------------------------------------
void OStorage_Impl::GetStorageProperties()
{
- if ( m_nStorageType == PACKAGE_STORAGE )
+ if ( m_nStorageType == embed::StorageFormats::PACKAGE )
{
uno::Reference< beans::XPropertySet > xProps( m_xPackageFolder, uno::UNO_QUERY_THROW );
@@ -588,7 +589,7 @@ void OStorage_Impl::GetStorageProperties()
//-----------------------------------------------
void OStorage_Impl::ReadRelInfoIfNecessary()
{
- if ( m_nStorageType != OFOPXML_STORAGE )
+ if ( m_nStorageType != embed::StorageFormats::OFOPXML )
return;
if ( m_nRelInfoStatus == RELINFO_NO_INIT )
@@ -662,7 +663,7 @@ void OStorage_Impl::ReadContents()
uno::Reference< container::XNameContainer > xNameContainer( xNamed, uno::UNO_QUERY );
SotElement_Impl* pNewElement = new SotElement_Impl( aName, xNameContainer.is(), sal_False );
- if ( m_nStorageType == OFOPXML_STORAGE && aName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_rels" ) ) ) )
+ if ( m_nStorageType == embed::StorageFormats::OFOPXML && aName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_rels" ) ) ) )
{
if ( !pNewElement->m_bIsStorage )
throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: Unexpected format
@@ -730,7 +731,7 @@ void OStorage_Impl::CopyToStorage( const uno::Reference< embed::XStorage >& xDes
}
// move storage properties to the destination one ( means changeable properties )
- if ( m_nStorageType == PACKAGE_STORAGE )
+ if ( m_nStorageType == embed::StorageFormats::PACKAGE )
{
::rtl::OUString aMediaTypeString = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) );
::rtl::OUString aVersionString = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Version" ) );
@@ -738,7 +739,7 @@ void OStorage_Impl::CopyToStorage( const uno::Reference< embed::XStorage >& xDes
xPropSet->setPropertyValue( aVersionString, uno::makeAny( m_aVersion ) );
}
- if ( m_nStorageType == PACKAGE_STORAGE )
+ if ( m_nStorageType == embed::StorageFormats::PACKAGE )
{
// if this is a root storage, the common key from current one should be moved there
sal_Bool bIsRoot = sal_False;
@@ -759,7 +760,7 @@ void OStorage_Impl::CopyToStorage( const uno::Reference< embed::XStorage >& xDes
}
}
}
- else if ( m_nStorageType == OFOPXML_STORAGE )
+ else if ( m_nStorageType == embed::StorageFormats::OFOPXML )
{
// TODO/LATER: currently the optimization is not active
@@ -850,13 +851,13 @@ void OStorage_Impl::CopyStorageElement( SotElement_Impl* pElement,
}
}
- if ( m_nStorageType == PACKAGE_STORAGE )
+ if ( m_nStorageType == embed::StorageFormats::PACKAGE )
{
aStrProps.realloc( ++nNum );
aStrProps[nNum-1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseCommonStoragePasswordEncryption" ) );
aStrProps[nNum-1].Value <<= (sal_Bool)( pElement->m_pStream->UsesCommonPass_Impl() );
}
- else if ( m_nStorageType == OFOPXML_STORAGE )
+ else if ( m_nStorageType == embed::StorageFormats::OFOPXML )
{
// TODO/LATER: currently the optimization is not active
// uno::Reference< io::XInputStream > xInStream = GetRelInfoStreamForName( ::rtl::OUString() ); // own rels stream
@@ -907,7 +908,7 @@ void OStorage_Impl::CopyStorageElement( SotElement_Impl* pElement,
pElement->m_pStream->CopyInternallyTo_Impl( xSubStr );
}
}
- else if ( m_nStorageType != PACKAGE_STORAGE )
+ else if ( m_nStorageType != embed::StorageFormats::PACKAGE )
{
OSL_ENSURE( sal_False, "Encryption is only supported in package storage!\n" );
throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
@@ -994,7 +995,7 @@ void OStorage_Impl::CopyStorageElement( SotElement_Impl* pElement,
//-----------------------------------------------
uno::Sequence< uno::Sequence< beans::StringPair > > OStorage_Impl::GetAllRelationshipsIfAny()
{
- if ( m_nStorageType != OFOPXML_STORAGE )
+ if ( m_nStorageType != embed::StorageFormats::OFOPXML )
return uno::Sequence< uno::Sequence< beans::StringPair > >();
ReadRelInfoIfNecessary();
@@ -1088,7 +1089,7 @@ void OStorage_Impl::Commit()
pDeletedIter++ )
{
- if ( m_nStorageType == OFOPXML_STORAGE && !(*pDeletedIter)->m_bIsStorage )
+ if ( m_nStorageType == embed::StorageFormats::OFOPXML && !(*pDeletedIter)->m_bIsStorage )
RemoveStreamRelInfo( (*pDeletedIter)->m_aOriginalName );
// the removed elements are not in new temporary storage
@@ -1108,7 +1109,7 @@ void OStorage_Impl::Commit()
if ( (*pElementIter)->m_bIsRemoved )
{
- if ( m_nStorageType == OFOPXML_STORAGE && !(*pElementIter)->m_bIsStorage )
+ if ( m_nStorageType == embed::StorageFormats::OFOPXML && !(*pElementIter)->m_bIsStorage )
RemoveStreamRelInfo( (*pElementIter)->m_aOriginalName );
// the removed elements are not in new temporary storage
@@ -1158,7 +1159,7 @@ void OStorage_Impl::Commit()
}
else if ( !(*pElementIter)->m_bIsStorage && (*pElementIter)->m_pStream && (*pElementIter)->m_pStream->m_bFlushed )
{
- if ( m_nStorageType == OFOPXML_STORAGE )
+ if ( m_nStorageType == embed::StorageFormats::OFOPXML )
CommitStreamRelInfo( *pElementIter );
// the renamed elements are not in new temporary storage
@@ -1184,7 +1185,7 @@ void OStorage_Impl::Commit()
xNewPackageFolder->removeByName( (*pElementIter)->m_aOriginalName );
xNewPackageFolder->insertByName( (*pElementIter)->m_aName, aPackageElement );
- if ( m_nStorageType == OFOPXML_STORAGE && !(*pElementIter)->m_bIsStorage )
+ if ( m_nStorageType == embed::StorageFormats::OFOPXML && !(*pElementIter)->m_bIsStorage )
{
if ( !(*pElementIter)->m_pStream )
{
@@ -1233,7 +1234,7 @@ void OStorage_Impl::Commit()
if ( (*pElementIter)->m_pStream->m_bFlushed )
{
- if ( m_nStorageType == OFOPXML_STORAGE )
+ if ( m_nStorageType == embed::StorageFormats::OFOPXML )
CommitStreamRelInfo( *pElementIter );
(*pElementIter)->m_pStream->InsertIntoPackageFolder( (*pElementIter)->m_aName, xNewPackageFolder );
@@ -1244,7 +1245,7 @@ void OStorage_Impl::Commit()
}
}
- if ( m_nStorageType == PACKAGE_STORAGE )
+ if ( m_nStorageType == embed::StorageFormats::PACKAGE )
{
// move properties to the destination package folder
uno::Reference< beans::XPropertySet > xProps( xNewPackageFolder, uno::UNO_QUERY );
@@ -1255,7 +1256,7 @@ void OStorage_Impl::Commit()
xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ), uno::makeAny( m_aVersion ) );
}
- if ( m_nStorageType == OFOPXML_STORAGE )
+ if ( m_nStorageType == embed::StorageFormats::OFOPXML )
CommitRelInfo( xNewPackageFolder ); // store own relations and commit complete relations storage
if ( m_bIsRoot )
@@ -1349,7 +1350,7 @@ void OStorage_Impl::Revert()
GetStorageProperties();
- if ( m_nStorageType == OFOPXML_STORAGE )
+ if ( m_nStorageType == embed::StorageFormats::OFOPXML )
{
// currently the relations storage is changed only on commit
m_xNewRelInfoStream = uno::Reference< io::XInputStream >();
@@ -1364,7 +1365,7 @@ void OStorage_Impl::Revert()
{
::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() ) ;
- if ( m_nStorageType != PACKAGE_STORAGE )
+ if ( m_nStorageType != embed::StorageFormats::PACKAGE )
throw packages::NoEncryptionException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
if ( m_bIsRoot )
@@ -1422,8 +1423,8 @@ SotElement_Impl* OStorage_Impl::InsertStream( ::rtl::OUString aName, sal_Bool bE
if ( !xPackageSubStream.is() )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
- OSL_ENSURE( m_nStorageType == PACKAGE_STORAGE || !bEncr, "Only package storage supports encryption!\n" );
- if ( m_nStorageType != PACKAGE_STORAGE && bEncr )
+ OSL_ENSURE( m_nStorageType == embed::StorageFormats::PACKAGE || !bEncr, "Only package storage supports encryption!\n" );
+ if ( m_nStorageType != embed::StorageFormats::PACKAGE && bEncr )
throw packages::NoEncryptionException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
// the mode is not needed for storage stream internal implementation
@@ -1445,7 +1446,7 @@ SotElement_Impl* OStorage_Impl::InsertRawStream( ::rtl::OUString aName, const un
if ( !m_xPackage.is() )
throw embed::InvalidStorageException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
- if ( m_nStorageType != PACKAGE_STORAGE )
+ if ( m_nStorageType != embed::StorageFormats::PACKAGE )
throw packages::NoEncryptionException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
uno::Reference< io::XSeekable > xSeek( xInStream, uno::UNO_QUERY );
@@ -1726,7 +1727,7 @@ void OStorage_Impl::RemoveStreamRelInfo( const ::rtl::OUString& aOriginalName )
// this method should be used only in OStorage_Impl::Commit() method
// the aOriginalName can be empty, in this case the storage relation info should be removed
- if ( m_nStorageType == OFOPXML_STORAGE && m_xRelStorage.is() )
+ if ( m_nStorageType == embed::StorageFormats::OFOPXML && m_xRelStorage.is() )
{
::rtl::OUString aRelStreamName = aOriginalName;
aRelStreamName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".rels" ) );
@@ -1739,7 +1740,7 @@ void OStorage_Impl::RemoveStreamRelInfo( const ::rtl::OUString& aOriginalName )
//-----------------------------------------------
void OStorage_Impl::CreateRelStorage()
{
- if ( m_nStorageType != OFOPXML_STORAGE )
+ if ( m_nStorageType != embed::StorageFormats::OFOPXML )
return;
if ( !m_xRelStorage.is() )
@@ -1772,7 +1773,7 @@ void OStorage_Impl::CommitStreamRelInfo( SotElement_Impl* pStreamElement )
if ( !pStreamElement )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
- if ( m_nStorageType == OFOPXML_STORAGE && pStreamElement->m_pStream )
+ if ( m_nStorageType == embed::StorageFormats::OFOPXML && pStreamElement->m_pStream )
{
OSL_ENSURE( pStreamElement->m_aName.getLength(), "The name must not be empty!\n" );
@@ -1789,7 +1790,7 @@ void OStorage_Impl::CommitStreamRelInfo( SotElement_Impl* pStreamElement )
//-----------------------------------------------
uno::Reference< io::XInputStream > OStorage_Impl::GetRelInfoStreamForName( const ::rtl::OUString& aName )
{
- if ( m_nStorageType == OFOPXML_STORAGE )
+ if ( m_nStorageType == embed::StorageFormats::OFOPXML )
{
ReadContents();
if ( m_xRelStorage.is() )
@@ -1817,7 +1818,7 @@ void OStorage_Impl::CommitRelInfo( const uno::Reference< container::XNameContain
if ( !xNewPackageFolder.is() )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
- if ( m_nStorageType == OFOPXML_STORAGE )
+ if ( m_nStorageType == embed::StorageFormats::OFOPXML )
{
if ( m_nRelInfoStatus == RELINFO_BROKEN || m_nRelInfoStatus == RELINFO_CHANGED_BROKEN )
throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
@@ -2259,7 +2260,7 @@ uno::Any SAL_CALL OStorage::queryInterface( const uno::Type& rType )
if ( aReturn.hasValue() == sal_True )
return aReturn ;
- if ( m_pData->m_nStorageType == PACKAGE_STORAGE )
+ if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE )
{
if ( m_pData->m_bIsRoot )
{
@@ -2275,7 +2276,7 @@ uno::Any SAL_CALL OStorage::queryInterface( const uno::Type& rType )
, static_cast<embed::XStorageRawAccess*> ( this ) );
}
}
- else if ( m_pData->m_nStorageType == OFOPXML_STORAGE )
+ else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML )
{
aReturn <<= ::cppu::queryInterface
( rType
@@ -2314,7 +2315,7 @@ uno::Sequence< uno::Type > SAL_CALL OStorage::getTypes()
if ( m_pData->m_pTypeCollection == NULL )
{
- if ( m_pData->m_nStorageType == PACKAGE_STORAGE )
+ if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE )
{
if ( m_pData->m_bIsRoot )
{
@@ -2340,7 +2341,7 @@ uno::Sequence< uno::Type > SAL_CALL OStorage::getTypes()
, ::getCppuType( ( const uno::Reference< beans::XPropertySet >* )NULL ) );
}
}
- else if ( m_pData->m_nStorageType == OFOPXML_STORAGE )
+ else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML )
{
m_pData->m_pTypeCollection = new ::cppu::OTypeCollection
( ::getCppuType( ( const uno::Reference< lang::XTypeProvider >* )NULL )
@@ -2482,7 +2483,7 @@ uno::Reference< io::XStream > SAL_CALL OStorage::openStreamElement(
if ( !aStreamName.getLength() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStreamName, sal_False ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
- if ( m_pData->m_nStorageType == OFOPXML_STORAGE
+ if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML
&& aStreamName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_rels" ) ) ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 ); // unacceptable element name
@@ -2583,7 +2584,7 @@ uno::Reference< io::XStream > SAL_CALL OStorage::openEncryptedStreamElement(
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
}
- if ( m_pData->m_nStorageType != PACKAGE_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::PACKAGE )
packages::NoEncryptionException();
if ( ( nOpenMode & embed::ElementModes::WRITE ) && m_pData->m_bReadOnlyWrap )
@@ -2693,7 +2694,7 @@ uno::Reference< embed::XStorage > SAL_CALL OStorage::openStorageElement(
if ( !aStorName.getLength() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStorName, sal_False ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
- if ( m_pData->m_nStorageType == OFOPXML_STORAGE
+ if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML
&& aStorName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_rels" ) ) ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 ); // unacceptable storage name
@@ -2848,7 +2849,7 @@ uno::Reference< io::XStream > SAL_CALL OStorage::cloneStreamElement( const ::rtl
if ( !aStreamName.getLength() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStreamName, sal_False ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
- if ( m_pData->m_nStorageType == OFOPXML_STORAGE
+ if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML
&& aStreamName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_rels" ) ) ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 ); // unacceptable storage name
@@ -2930,7 +2931,7 @@ uno::Reference< io::XStream > SAL_CALL OStorage::cloneEncryptedStreamElement(
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
}
- if ( m_pData->m_nStorageType != PACKAGE_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::PACKAGE )
packages::NoEncryptionException();
if ( !aPass.getLength() )
@@ -3087,7 +3088,7 @@ void SAL_CALL OStorage::copyStorageElementLastCommitTo(
if ( !aStorName.getLength() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStorName, sal_False ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
- if ( m_pData->m_nStorageType == OFOPXML_STORAGE
+ if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML
&& aStorName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_rels" ) ) ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 ); // unacceptable storage name
@@ -3181,7 +3182,7 @@ sal_Bool SAL_CALL OStorage::isStreamElement( const ::rtl::OUString& aElementName
if ( !aElementName.getLength() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aElementName, sal_False ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
- if ( m_pData->m_nStorageType == OFOPXML_STORAGE
+ if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML
&& aElementName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_rels" ) ) ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 ); // unacceptable name
@@ -3250,7 +3251,7 @@ sal_Bool SAL_CALL OStorage::isStorageElement( const ::rtl::OUString& aElementNam
if ( !aElementName.getLength() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aElementName, sal_False ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
- if ( m_pData->m_nStorageType == OFOPXML_STORAGE
+ if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML
&& aElementName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_rels" ) ) ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 );
@@ -3323,7 +3324,7 @@ void SAL_CALL OStorage::removeElement( const ::rtl::OUString& aElementName )
if ( !aElementName.getLength() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aElementName, sal_False ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
- if ( m_pData->m_nStorageType == OFOPXML_STORAGE
+ if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML
&& aElementName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_rels" ) ) ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 ); // TODO: unacceptable name
@@ -3418,7 +3419,7 @@ void SAL_CALL OStorage::renameElement( const ::rtl::OUString& aElementName, cons
|| !aNewName.getLength() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aNewName, sal_False ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
- if ( m_pData->m_nStorageType == OFOPXML_STORAGE
+ if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML
&& ( aElementName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_rels" ) ) )
|| aNewName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_rels" ) ) ) ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 0 ); // TODO: unacceptable element name
@@ -3529,7 +3530,7 @@ void SAL_CALL OStorage::copyElementTo( const ::rtl::OUString& aElementName,
// || xDest == uno::Reference< uno::XInterface >( static_cast< OWeakObject* >( this ), uno::UNO_QUERY ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 2 );
- if ( m_pData->m_nStorageType == OFOPXML_STORAGE
+ if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML
&& ( aElementName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_rels" ) ) )
|| aNewName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_rels" ) ) ) ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 0 ); // unacceptable element name
@@ -3633,7 +3634,7 @@ void SAL_CALL OStorage::moveElementTo( const ::rtl::OUString& aElementName,
if ( !xDest.is() || xDest == uno::Reference< uno::XInterface >( static_cast< OWeakObject* >( this ), uno::UNO_QUERY ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 2 );
- if ( m_pData->m_nStorageType == OFOPXML_STORAGE
+ if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML
&& ( aElementName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_rels" ) ) )
|| aNewName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_rels" ) ) ) ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 0 ); // unacceptable element name
@@ -3743,7 +3744,7 @@ uno::Reference< io::XInputStream > SAL_CALL OStorage::getPlainRawStreamElement(
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
}
- if ( m_pData->m_nStorageType == OFOPXML_STORAGE )
+ if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // the interface is not supported and must not be accessible
if ( !sStreamName.getLength() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( sStreamName, sal_False ) )
@@ -3853,7 +3854,7 @@ uno::Reference< io::XInputStream > SAL_CALL OStorage::getRawEncrStreamElement(
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
}
- if ( m_pData->m_nStorageType != PACKAGE_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::PACKAGE )
throw packages::NoEncryptionException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
if ( !sStreamName.getLength() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( sStreamName, sal_False ) )
@@ -3973,7 +3974,7 @@ void SAL_CALL OStorage::insertRawEncrStreamElement( const ::rtl::OUString& aStre
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
}
- if ( m_pData->m_nStorageType != PACKAGE_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::PACKAGE )
throw packages::NoEncryptionException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
if ( !aStreamName.getLength() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStreamName, sal_False ) )
@@ -4334,7 +4335,7 @@ uno::Any SAL_CALL OStorage::getByName( const ::rtl::OUString& aName )
if ( !aName.getLength() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aName, sal_False ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
- if ( m_pData->m_nStorageType == OFOPXML_STORAGE
+ if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML
&& aName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_rels" ) ) ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 ); // unacceptable element name
@@ -4439,7 +4440,7 @@ sal_Bool SAL_CALL OStorage::hasByName( const ::rtl::OUString& aName )
if ( !aName.getLength() )
return sal_False;
- if ( m_pData->m_nStorageType == OFOPXML_STORAGE
+ if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML
&& aName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_rels" ) ) ) )
return sal_False;
@@ -4616,7 +4617,7 @@ void SAL_CALL OStorage::setEncryptionPassword( const ::rtl::OUString& aPass )
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
}
- if ( m_pData->m_nStorageType != PACKAGE_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::PACKAGE )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // the interface must be visible only for package storage
OSL_ENSURE( m_pData->m_bIsRoot, "setEncryptionPassword() method is not available for nonroot storages!\n" );
@@ -4682,7 +4683,7 @@ void SAL_CALL OStorage::removeEncryption()
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
}
- if ( m_pData->m_nStorageType != PACKAGE_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::PACKAGE )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // the interface must be visible only for package storage
OSL_ENSURE( m_pData->m_bIsRoot, "removeEncryption() method is not available for nonroot storages!\n" );
@@ -4783,9 +4784,9 @@ void SAL_CALL OStorage::setPropertyValue( const ::rtl::OUString& aPropertyName,
if ( m_pData->m_bReadOnlyWrap && !aPropertyName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ) ) )
throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: Access denied
- if ( m_pData->m_nStorageType == ZIP_STORAGE )
+ if ( m_pData->m_nStorageType == embed::StorageFormats::ZIP )
throw beans::UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
- else if ( m_pData->m_nStorageType == PACKAGE_STORAGE )
+ else if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE )
{
if ( aPropertyName.equalsAscii( "MediaType" ) )
{
@@ -4818,7 +4819,7 @@ void SAL_CALL OStorage::setPropertyValue( const ::rtl::OUString& aPropertyName,
else
throw beans::UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
}
- else if ( m_pData->m_nStorageType == OFOPXML_STORAGE )
+ else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML )
{
if ( aPropertyName.equalsAscii( "RelationsInfoStream" ) )
{
@@ -4885,7 +4886,7 @@ uno::Any SAL_CALL OStorage::getPropertyValue( const ::rtl::OUString& aPropertyNa
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
}
- if ( m_pData->m_nStorageType == PACKAGE_STORAGE
+ if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE
&& ( aPropertyName.equalsAscii( "MediaType" )
|| aPropertyName.equalsAscii( "MediaTypeFallbackUsed" )
|| aPropertyName.equalsAscii( "Version" ) ) )
@@ -4943,7 +4944,7 @@ uno::Any SAL_CALL OStorage::getPropertyValue( const ::rtl::OUString& aPropertyNa
return uno::makeAny( sal_False ); // RepairPackage
}
- else if ( m_pData->m_nStorageType == PACKAGE_STORAGE
+ else if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE
&& ( aPropertyName.equalsAscii( "HasEncryptedEntries" )
|| aPropertyName.equalsAscii( "HasNonEncryptedEntries" )
|| aPropertyName.equalsAscii( "IsInconsistent" ) ) )
@@ -5078,7 +5079,7 @@ sal_Bool SAL_CALL OStorage::hasByID( const ::rtl::OUString& sID )
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
}
- if ( m_pData->m_nStorageType != OFOPXML_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
try
@@ -5109,7 +5110,7 @@ sal_Bool SAL_CALL OStorage::hasByID( const ::rtl::OUString& sID )
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
}
- if ( m_pData->m_nStorageType != OFOPXML_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
uno::Sequence< beans::StringPair > aSeq = getRelationshipByID( sID );
@@ -5134,7 +5135,7 @@ sal_Bool SAL_CALL OStorage::hasByID( const ::rtl::OUString& sID )
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
}
- if ( m_pData->m_nStorageType != OFOPXML_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
uno::Sequence< beans::StringPair > aSeq = getRelationshipByID( sID );
@@ -5159,7 +5160,7 @@ uno::Sequence< beans::StringPair > SAL_CALL OStorage::getRelationshipByID( cons
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
}
- if ( m_pData->m_nStorageType != OFOPXML_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
// TODO/LATER: in future the unification of the ID could be checked
@@ -5189,7 +5190,7 @@ uno::Sequence< uno::Sequence< beans::StringPair > > SAL_CALL OStorage::getRelati
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
}
- if ( m_pData->m_nStorageType != OFOPXML_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
uno::Sequence< uno::Sequence< beans::StringPair > > aResult;
@@ -5225,7 +5226,7 @@ uno::Sequence< uno::Sequence< beans::StringPair > > SAL_CALL OStorage::getAllRel
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
}
- if ( m_pData->m_nStorageType != OFOPXML_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
return m_pImpl->GetAllRelationshipsIfAny();
@@ -5245,7 +5246,7 @@ void SAL_CALL OStorage::insertRelationshipByID( const ::rtl::OUString& sID, con
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
}
- if ( m_pData->m_nStorageType != OFOPXML_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
::rtl::OUString aIDTag( RTL_CONSTASCII_USTRINGPARAM( "Id" ) );
@@ -5310,7 +5311,7 @@ void SAL_CALL OStorage::removeRelationshipByID( const ::rtl::OUString& sID )
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
}
- if ( m_pData->m_nStorageType != OFOPXML_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
uno::Sequence< uno::Sequence< beans::StringPair > > aSeq = getAllRelationships();
@@ -5352,7 +5353,7 @@ void SAL_CALL OStorage::insertRelationships( const uno::Sequence< uno::Sequence
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
}
- if ( m_pData->m_nStorageType != OFOPXML_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
::rtl::OUString aIDTag( RTL_CONSTASCII_USTRINGPARAM( "Id" ) );
@@ -5434,7 +5435,7 @@ void SAL_CALL OStorage::clearRelationships()
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
}
- if ( m_pData->m_nStorageType != OFOPXML_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::OFOPXML )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
m_pImpl->m_aRelInfo.realloc( 0 );
@@ -5487,7 +5488,7 @@ void SAL_CALL OStorage::insertStreamElementDirect(
if ( !aStreamName.getLength() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStreamName, sal_False ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
- if ( m_pData->m_nStorageType == OFOPXML_STORAGE
+ if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML
&& aStreamName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_rels" ) ) ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 ); // unacceptable storage name
@@ -5584,7 +5585,7 @@ void SAL_CALL OStorage::copyElementDirectlyTo(
if ( !xDest.is() || xDest == uno::Reference< uno::XInterface >( static_cast< OWeakObject* >( this ), uno::UNO_QUERY ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 2 );
- if ( m_pData->m_nStorageType == OFOPXML_STORAGE
+ if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML
&& ( aElementName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_rels" ) ) )
|| aNewName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_rels" ) ) ) ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 0 ); // unacceptable name
@@ -5840,7 +5841,7 @@ uno::Any SAL_CALL OStorage::getElementPropertyValue( const ::rtl::OUString& aEle
if ( !aElementName.getLength() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aElementName, sal_False ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
- if ( m_pData->m_nStorageType == OFOPXML_STORAGE
+ if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML
&& aElementName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_rels" ) ) ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 ); // TODO: unacceptable name
@@ -5851,7 +5852,7 @@ uno::Any SAL_CALL OStorage::getElementPropertyValue( const ::rtl::OUString& aEle
throw container::NoSuchElementException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
// TODO/LATER: Currently it is only implemented for MediaType property of substorages, might be changed in future
- if ( !pElement->m_bIsStorage || m_pData->m_nStorageType != PACKAGE_STORAGE || !aPropertyName.equalsAscii( "MediaType" ) )
+ if ( !pElement->m_bIsStorage || m_pData->m_nStorageType != embed::StorageFormats::PACKAGE || !aPropertyName.equalsAscii( "MediaType" ) )
throw beans::PropertyVetoException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
if ( !pElement->m_pStorage )
@@ -5943,7 +5944,7 @@ void SAL_CALL OStorage::copyStreamElementData( const ::rtl::OUString& aStreamNam
if ( !aStreamName.getLength() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStreamName, sal_False ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
- if ( m_pData->m_nStorageType == OFOPXML_STORAGE
+ if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML
&& aStreamName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_rels" ) ) ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 ); // unacceptable name
@@ -6090,7 +6091,7 @@ uno::Reference< embed::XExtendedStorageStream > SAL_CALL OStorage::openEncrypted
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
}
- if ( m_pData->m_nStorageType != PACKAGE_STORAGE )
+ if ( m_pData->m_nStorageType != embed::StorageFormats::PACKAGE )
throw packages::NoEncryptionException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
if ( !aStreamPath.getLength() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStreamPath, sal_True ) )
diff --git a/package/source/xstor/xstorage.hxx b/package/source/xstor/xstorage.hxx
index bc90b71e4d93..7e712e0ca691 100644
--- a/package/source/xstor/xstorage.hxx
+++ b/package/source/xstor/xstorage.hxx
@@ -57,11 +57,6 @@
#include "mutexholder.hxx"
-
-#define PACKAGE_STORAGE 0
-#define ZIP_STORAGE 1
-#define OFOPXML_STORAGE 2
-
#define RELINFO_NO_INIT 1
#define RELINFO_READ 2
#define RELINFO_CHANGED 3
@@ -179,7 +174,7 @@ struct OStorage_Impl
sal_Int16 m_nStorageType; // the mode in wich the storage is used
- // the _rels substorage that is handled in a special way in OFOPXML_STORAGE
+ // the _rels substorage that is handled in a special way in embed::StorageFormats::OFOPXML
SotElement_Impl* m_pRelStorElement;
::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > m_xRelStorage;
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::StringPair > > m_aRelInfo;
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index 5c22bad46a6a..a92ed254200a 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -61,6 +61,7 @@
#include <com/sun/star/io/XActiveDataStreamer.hpp>
#include <com/sun/star/embed/XTransactedObject.hpp>
#include <com/sun/star/embed/UseBackupException.hpp>
+#include <com/sun/star/embed/StorageFormats.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
#include <cppuhelper/implbase1.hxx>
#include <ContentInfo.hxx>
@@ -661,13 +662,27 @@ void SAL_CALL ZipPackage::initialize( const Sequence< Any >& aArguments )
else if ( aNamedValue.Name.equalsAscii( "StorageFormat" ) )
{
::rtl::OUString aFormatName;
- aNamedValue.Value >>= aFormatName;
- if ( aFormatName.equals( PACKAGE_STORAGE_FORMAT_STRING ) )
- m_nFormat = PACKAGE_FORMAT;
- else if ( aFormatName.equals( ZIP_STORAGE_FORMAT_STRING ) )
- m_nFormat = ZIP_FORMAT;
- else if ( aFormatName.equals( OFOPXML_STORAGE_FORMAT_STRING ) )
- m_nFormat = OFOPXML_FORMAT;
+ sal_Int32 nFormatID = 0;
+ if ( aNamedValue.Value >>= aFormatName )
+ {
+ if ( aFormatName.equals( PACKAGE_STORAGE_FORMAT_STRING ) )
+ m_nFormat = PACKAGE_FORMAT;
+ else if ( aFormatName.equals( ZIP_STORAGE_FORMAT_STRING ) )
+ m_nFormat = ZIP_FORMAT;
+ else if ( aFormatName.equals( OFOPXML_STORAGE_FORMAT_STRING ) )
+ m_nFormat = OFOPXML_FORMAT;
+ else
+ throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 );
+ }
+ else if ( aNamedValue.Value >>= nFormatID )
+ {
+ if ( nFormatID != embed::StorageFormats::PACKAGE
+ && nFormatID != embed::StorageFormats::ZIP
+ && nFormatID != embed::StorageFormats::OFOPXML )
+ throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 );
+
+ m_nFormat = nFormatID;
+ }
else
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 );