fwk138: #i87496# Use the UNO constants

This commit is contained in:
Mikhail Voytenko 2010-04-13 10:20:02 +02:00
parent ad157a9cb3
commit 8d92fa14a0
5 changed files with 26 additions and 30 deletions

View file

@ -33,10 +33,6 @@ const sal_Int32 n_ConstBufferSize = 32768;
const sal_Int32 n_ConstMaxMemoryStreamSize = 20480;
const sal_Int32 n_ConstDigestLength = 1024;
#define PACKAGE_FORMAT 1
#define ZIP_FORMAT 2
#define OFOPXML_FORMAT 3
// the constants related to the manifest.xml entries
#define PKG_MNFST_MEDIATYPE 0
#define PKG_MNFST_VERSION 1

View file

@ -93,7 +93,7 @@ protected:
sal_Bool m_bForceRecovery;
sal_Bool m_bMediaTypeFallbackUsed;
sal_Int16 m_nFormat;
sal_Int32 m_nFormat;
sal_Bool m_bAllowRemoveOnInsert;
InitialisationMode m_eMode;

View file

@ -184,7 +184,7 @@ ZipPackage::ZipPackage (const uno::Reference < XMultiServiceFactory > &xNewFacto
, m_bUseManifest ( sal_True )
, m_bForceRecovery ( sal_False )
, m_bMediaTypeFallbackUsed ( sal_False )
, m_nFormat( PACKAGE_FORMAT ) // package is the default format
, m_nFormat( embed::StorageFormats::PACKAGE ) // package is the default format
, m_bAllowRemoveOnInsert( sal_True )
, m_eMode ( e_IMode_None )
, m_xFactory( xNewFactory )
@ -218,7 +218,7 @@ ZipPackage::~ZipPackage( void )
void ZipPackage::parseManifest()
{
if ( m_nFormat == PACKAGE_FORMAT )
if ( m_nFormat == embed::StorageFormats::PACKAGE )
{
sal_Bool bManifestParsed = sal_False;
const OUString sMeta ( RTL_CONSTASCII_USTRINGPARAM ( "META-INF" ) );
@ -428,7 +428,7 @@ void ZipPackage::parseManifest()
void ZipPackage::parseContentType()
{
if ( m_nFormat == OFOPXML_FORMAT )
if ( m_nFormat == embed::StorageFormats::OFOPXML )
{
const ::rtl::OUString aContentTypes( RTL_CONSTASCII_USTRINGPARAM ( "[Content_Types].xml" ) );
try {
@ -559,9 +559,9 @@ void ZipPackage::getZipFileContents()
}
}
if ( m_nFormat == PACKAGE_FORMAT )
if ( m_nFormat == embed::StorageFormats::PACKAGE )
parseManifest();
else if ( m_nFormat == OFOPXML_FORMAT )
else if ( m_nFormat == embed::StorageFormats::OFOPXML )
parseContentType();
}
@ -601,13 +601,13 @@ void SAL_CALL ZipPackage::initialize( const Sequence< Any >& aArguments )
}
else if ( aCommand.equals( OUString::createFromAscii( "purezip" ) ) )
{
m_nFormat = ZIP_FORMAT;
m_nFormat = embed::StorageFormats::ZIP;
m_pRootFolder->setPackageFormat_Impl( m_nFormat );
break;
}
else if ( aCommand.equals( OUString::createFromAscii( "ofopxml" ) ) )
{
m_nFormat = OFOPXML_FORMAT;
m_nFormat = embed::StorageFormats::OFOPXML;
m_pRootFolder->setPackageFormat_Impl( m_nFormat );
break;
}
@ -662,7 +662,7 @@ void SAL_CALL ZipPackage::initialize( const Sequence< Any >& aArguments )
sal_Bool bPackFormat = sal_True;
aNamedValue.Value >>= bPackFormat;
if ( !bPackFormat )
m_nFormat = ZIP_FORMAT;
m_nFormat = embed::StorageFormats::ZIP;
m_pRootFolder->setPackageFormat_Impl( m_nFormat );
}
@ -673,11 +673,11 @@ void SAL_CALL ZipPackage::initialize( const Sequence< Any >& aArguments )
if ( aNamedValue.Value >>= aFormatName )
{
if ( aFormatName.equals( PACKAGE_STORAGE_FORMAT_STRING ) )
m_nFormat = PACKAGE_FORMAT;
m_nFormat = embed::StorageFormats::PACKAGE;
else if ( aFormatName.equals( ZIP_STORAGE_FORMAT_STRING ) )
m_nFormat = ZIP_FORMAT;
m_nFormat = embed::StorageFormats::ZIP;
else if ( aFormatName.equals( OFOPXML_STORAGE_FORMAT_STRING ) )
m_nFormat = OFOPXML_FORMAT;
m_nFormat = embed::StorageFormats::OFOPXML;
else
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 1 );
}
@ -1157,7 +1157,7 @@ uno::Reference< io::XInputStream > ZipPackage::writeTempFile()
try
{
if ( m_nFormat == PACKAGE_FORMAT )
if ( m_nFormat == embed::StorageFormats::PACKAGE )
{
// Remove the old manifest.xml file as the
// manifest will be re-generated and the
@ -1179,7 +1179,7 @@ uno::Reference< io::XInputStream > ZipPackage::writeTempFile()
// Write a magic file with mimetype
WriteMimetypeMagicFile( aZipOut );
}
else if ( m_nFormat == OFOPXML_FORMAT )
else if ( m_nFormat == embed::StorageFormats::OFOPXML )
{
// Remove the old [Content_Types].xml file as the
// file will be re-generated
@ -1197,7 +1197,7 @@ uno::Reference< io::XInputStream > ZipPackage::writeTempFile()
const OUString sVersion ( RTL_CONSTASCII_USTRINGPARAM ( "Version" ) );
const OUString sFullPath ( RTL_CONSTASCII_USTRINGPARAM ( "FullPath" ) );
if ( m_nFormat == PACKAGE_FORMAT )
if ( m_nFormat == embed::StorageFormats::PACKAGE )
{
Sequence < PropertyValue > aPropSeq ( PKG_SIZE_NOENCR_MNFST );
aPropSeq [PKG_MNFST_MEDIATYPE].Name = sMediaType;
@ -1226,11 +1226,11 @@ uno::Reference< io::XInputStream > ZipPackage::writeTempFile()
// Clean up random pool memory
rtl_random_destroyPool ( aRandomPool );
if( m_bUseManifest && m_nFormat == PACKAGE_FORMAT )
if( m_bUseManifest && m_nFormat == embed::StorageFormats::PACKAGE )
{
WriteManifest( aZipOut, aManList );
}
else if( m_nFormat == OFOPXML_FORMAT )
else if( m_nFormat == embed::StorageFormats::OFOPXML )
{
WriteContentTypes( aZipOut, aManList );
}
@ -1640,7 +1640,7 @@ uno::Reference< XPropertySetInfo > SAL_CALL ZipPackage::getPropertySetInfo( )
void SAL_CALL ZipPackage::setPropertyValue( const OUString& aPropertyName, const Any& aValue )
throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
{
if ( m_nFormat != PACKAGE_FORMAT )
if ( m_nFormat != embed::StorageFormats::PACKAGE )
throw UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("HasEncryptedEntries") )
@ -1665,7 +1665,7 @@ Any SAL_CALL ZipPackage::getPropertyValue( const OUString& PropertyName )
throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
{
// TODO/LATER: Activate the check when zip-ucp is ready
// if ( m_nFormat != PACKAGE_FORMAT )
// if ( m_nFormat != embed::StorageFormats::PACKAGE )
// throw UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
Any aAny;

View file

@ -317,7 +317,7 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
sal_Bool bHaveEncryptionKey = rEncryptionKey.getLength() ? sal_True : sal_False;
if ( maContents.begin() == maContents.end() && rPath.getLength() && m_nFormat != OFOPXML_FORMAT )
if ( maContents.begin() == maContents.end() && rPath.getLength() && m_nFormat != embed::StorageFormats::OFOPXML )
{
// it is an empty subfolder, use workaround to store it
ZipEntry* pTempEntry = new ZipEntry();
@ -689,7 +689,7 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
}
// folder can have a mediatype only in package format
if ( m_nFormat == PACKAGE_FORMAT || ( m_nFormat == OFOPXML_FORMAT && !rInfo.bFolder ) )
if ( m_nFormat == embed::StorageFormats::PACKAGE || ( m_nFormat == embed::StorageFormats::OFOPXML && !rInfo.bFolder ) )
rManList.push_back( aPropSet );
}
@ -741,7 +741,7 @@ void SAL_CALL ZipPackageFolder::setPropertyValue( const OUString& aPropertyName,
if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("MediaType")))
{
// TODO/LATER: activate when zip ucp is ready
// if ( m_nFormat != PACKAGE_FORMAT )
// if ( m_nFormat != embed::StorageFormats::PACKAGE )
// throw UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
aValue >>= sMediaType;
@ -759,7 +759,7 @@ Any SAL_CALL ZipPackageFolder::getPropertyValue( const OUString& PropertyName )
if (PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "MediaType" ) ) )
{
// TODO/LATER: activate when zip ucp is ready
// if ( m_nFormat != PACKAGE_FORMAT )
// if ( m_nFormat != embed::StorageFormats::PACKAGE )
// throw UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
return makeAny ( sMediaType );

View file

@ -611,7 +611,7 @@ void SAL_CALL ZipPackageStream::setPropertyValue( const OUString& aPropertyName,
{
if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("MediaType")))
{
if ( rZipPackage.getFormat() != PACKAGE_FORMAT && rZipPackage.getFormat() != OFOPXML_FORMAT )
if ( rZipPackage.getFormat() != embed::StorageFormats::PACKAGE && rZipPackage.getFormat() != embed::StorageFormats::OFOPXML )
throw beans::PropertyVetoException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
if ( aValue >>= sMediaType )
@ -640,7 +640,7 @@ void SAL_CALL ZipPackageStream::setPropertyValue( const OUString& aPropertyName,
}
else if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Encrypted") ) )
{
if ( rZipPackage.getFormat() != PACKAGE_FORMAT )
if ( rZipPackage.getFormat() != embed::StorageFormats::PACKAGE )
throw beans::PropertyVetoException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
sal_Bool bEnc = sal_False;
@ -664,7 +664,7 @@ void SAL_CALL ZipPackageStream::setPropertyValue( const OUString& aPropertyName,
}
else if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("EncryptionKey") ) )
{
if ( rZipPackage.getFormat() != PACKAGE_FORMAT )
if ( rZipPackage.getFormat() != embed::StorageFormats::PACKAGE )
throw beans::PropertyVetoException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
Sequence < sal_Int8 > aNewKey;