From 8d92fa14a00c9bf63a6fd39f58a7bc49aff3a05b Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Tue, 13 Apr 2010 10:20:02 +0200 Subject: [PATCH] fwk138: #i87496# Use the UNO constants --- package/inc/PackageConstants.hxx | 4 --- package/inc/ZipPackage.hxx | 2 +- package/source/zippackage/ZipPackage.cxx | 36 +++++++++---------- .../source/zippackage/ZipPackageFolder.cxx | 8 ++--- .../source/zippackage/ZipPackageStream.cxx | 6 ++-- 5 files changed, 26 insertions(+), 30 deletions(-) diff --git a/package/inc/PackageConstants.hxx b/package/inc/PackageConstants.hxx index e088dceef126..a23a22fcb888 100644 --- a/package/inc/PackageConstants.hxx +++ b/package/inc/PackageConstants.hxx @@ -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 diff --git a/package/inc/ZipPackage.hxx b/package/inc/ZipPackage.hxx index 367bd1d80de5..b46fc46b7b2f 100644 --- a/package/inc/ZipPackage.hxx +++ b/package/inc/ZipPackage.hxx @@ -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; diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx index 9ec103758289..9ba26e0100c5 100644 --- a/package/source/zippackage/ZipPackage.cxx +++ b/package/source/zippackage/ZipPackage.cxx @@ -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; diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx index 25c479aac962..61bd2866a556 100644 --- a/package/source/zippackage/ZipPackageFolder.cxx +++ b/package/source/zippackage/ZipPackageFolder.cxx @@ -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 ); diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx index b6893b5cb2ad..d8a175c0d9cf 100644 --- a/package/source/zippackage/ZipPackageStream.cxx +++ b/package/source/zippackage/ZipPackageStream.cxx @@ -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;