diff options
author | Norbert Thiebaud <nthiebaud@gmail.com> | 2010-10-15 12:18:51 -0500 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2010-10-25 19:55:29 -0500 |
commit | d6181f976b230ce1cdc5f794e8d389518edfa02c (patch) | |
tree | 0902494badd4af68a9a506f5ec6649e9a69a883a | |
parent | 8956b3e47d307899fd9dec41a58a006dc5fac319 (diff) |
merge vosremoval-reference.diff
24 files changed, 232 insertions, 236 deletions
diff --git a/cui/inc/pch/precompiled_cui.hxx b/cui/inc/pch/precompiled_cui.hxx index 403e6bcc1..2be413714 100644 --- a/cui/inc/pch/precompiled_cui.hxx +++ b/cui/inc/pch/precompiled_cui.hxx @@ -943,8 +943,6 @@ #include "vcl/wall.hxx" #include "vcl/wintypes.hxx" #include "vos/mutex.hxx" -#include "vos/ref.hxx" -#include "vos/refernce.hxx" #include "vos/thread.hxx" #include "vos/xception.hxx" #include "xmloff/DashStyle.hxx" diff --git a/extensions/inc/pch/precompiled_extensions.hxx b/extensions/inc/pch/precompiled_extensions.hxx index fd4276f8f..abe058b8a 100644 --- a/extensions/inc/pch/precompiled_extensions.hxx +++ b/extensions/inc/pch/precompiled_extensions.hxx @@ -489,6 +489,7 @@ #include "rtl/math.hxx" #include "rtl/memory.h" #include "rtl/process.h" +#include "rtl/ref.hxx" #include "rtl/strbuf.hxx" #include "rtl/string.h" #include "rtl/string.hxx" @@ -541,8 +542,6 @@ #include "vos/macros.hxx" #include "vos/module.hxx" #include "vos/mutex.hxx" -#include "vos/ref.hxx" -#include "vos/refernce.hxx" #include "xmloff/nmspmap.hxx" //---MARKER--- diff --git a/extensions/source/bibliography/loadlisteneradapter.cxx b/extensions/source/bibliography/loadlisteneradapter.cxx index 7eb2cc6d6..928fb020a 100644 --- a/extensions/source/bibliography/loadlisteneradapter.cxx +++ b/extensions/source/bibliography/loadlisteneradapter.cxx @@ -30,7 +30,7 @@ #include "precompiled_extensions.hxx" #include "loadlisteneradapter.hxx" #include <osl/diagnose.h> -#include <vos/ref.hxx> +#include <rtl/ref.hxx> //......................................................................... namespace bib @@ -118,7 +118,7 @@ namespace bib { if ( m_bListening ) { - ::vos::ORef< OComponentAdapterBase > xPreventDelete(this); + ::rtl::Reference< OComponentAdapterBase > xPreventDelete(this); disposing(); diff --git a/extensions/source/ole/servprov.hxx b/extensions/source/ole/servprov.hxx index 6ed2932c7..6f57b58b1 100644 --- a/extensions/source/ole/servprov.hxx +++ b/extensions/source/ole/servprov.hxx @@ -147,7 +147,6 @@ public: protected: - //ORefCount m_refCount; oslInterlockedCount m_refCount; Reference<XInterface> m_xInst; GUID m_guid; diff --git a/extensions/source/ole/unoobjw.cxx b/extensions/source/ole/unoobjw.cxx index 9dd9745d0..dc96ed0b8 100644 --- a/extensions/source/ole/unoobjw.cxx +++ b/extensions/source/ole/unoobjw.cxx @@ -41,7 +41,7 @@ #include <osl/diagnose.h> -#include <vos/refernce.hxx> +#include <salhelper/simplereferenceobject.hxx> #include <tools/debug.hxx> #include <rtl/ustring.hxx> #include <com/sun/star/beans/MethodConcept.hpp> diff --git a/extensions/source/ole/unoobjw.hxx b/extensions/source/ole/unoobjw.hxx index ca67df2bb..c8bd49c37 100644 --- a/extensions/source/ole/unoobjw.hxx +++ b/extensions/source/ole/unoobjw.hxx @@ -32,7 +32,7 @@ #include <com/sun/star/beans/XExactName.hpp> #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/script/InvocationInfo.hpp> -#include <vos/refernce.hxx> +#include <salhelper/simplereferenceobject.hxx> #include <tools/presys.h> #include "comifaces.hxx" @@ -220,7 +220,6 @@ protected: sal_Bool getInvocationInfoForCall(DISPID id, InvocationInfo& info); -// vos::ORefCount m_refCount; Reference<XInvocation> m_xInvocation; Reference<XExactName> m_xExactName; Reference<XInterface> m_xOrigin; diff --git a/package/inc/HashMaps.hxx b/package/inc/HashMaps.hxx index 24e86bc24..5845e4ab7 100644 --- a/package/inc/HashMaps.hxx +++ b/package/inc/HashMaps.hxx @@ -28,7 +28,7 @@ #define _HASHMAPS_HXX #include <ZipEntry.hxx> -#include <vos/ref.hxx> +#include <rtl/ref.hxx> #include <hash_map> struct eqFunc @@ -51,7 +51,7 @@ typedef std::hash_map < rtl::OUString, eqFunc > FolderHash; typedef std::hash_map < rtl::OUString, - vos::ORef < com::sun::star::packages::ContentInfo >, + rtl::Reference < com::sun::star::packages::ContentInfo >, ::rtl::OUStringHash, eqFunc > ContentHash; diff --git a/package/inc/ZipFile.hxx b/package/inc/ZipFile.hxx index eba878ee0..f5892ddd8 100644 --- a/package/inc/ZipFile.hxx +++ b/package/inc/ZipFile.hxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -41,13 +41,13 @@ namespace com { namespace sun { namespace star { namespace lang { class XMultiServiceFactory; } namespace ucb { class XProgressHandler; } } } } -namespace vos +namespace rtl { - template < class T > class ORef; + template < class T > class Reference; } -/* +/* * We impose arbitrary but reasonable limit on ZIP files. - */ + */ #define ZIP_MAXNAMELEN 512 #define ZIP_MAXEXTRA 256 @@ -73,15 +73,15 @@ protected: sal_Bool bRecoveryMode; - com::sun::star::uno::Reference < com::sun::star::io::XInputStream > createMemoryStream( + com::sun::star::uno::Reference < com::sun::star::io::XInputStream > createMemoryStream( ZipEntry & rEntry, - const vos::ORef < EncryptionData > &rData, + const rtl::Reference < EncryptionData > &rData, sal_Bool bRawStream, sal_Bool bDecrypt ); com::sun::star::uno::Reference < com::sun::star::io::XInputStream > createFileStream( ZipEntry & rEntry, - const vos::ORef < EncryptionData > &rData, + const rtl::Reference < EncryptionData > &rData, sal_Bool bRawStream, sal_Bool bDecrypt ); @@ -89,12 +89,12 @@ protected: com::sun::star::uno::Reference < com::sun::star::io::XInputStream > createUnbufferedStream( SotMutexHolderRef aMutexHolder, ZipEntry & rEntry, - const vos::ORef < EncryptionData > &rData, + const rtl::Reference < EncryptionData > &rData, sal_Int8 nStreamMode, sal_Bool bDecrypt, ::rtl::OUString aMediaType = ::rtl::OUString() ); - sal_Bool hasValidPassword ( ZipEntry & rEntry, const vos::ORef < EncryptionData > &rData ); + sal_Bool hasValidPassword ( ZipEntry & rEntry, const rtl::Reference < EncryptionData > &rData ); sal_Bool checkSizeAndCRC( const ZipEntry& aEntry ); @@ -104,14 +104,14 @@ protected: public: - ZipFile( com::sun::star::uno::Reference < com::sun::star::io::XInputStream > &xInput, - const com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > &xNewFactory, + ZipFile( com::sun::star::uno::Reference < com::sun::star::io::XInputStream > &xInput, + const com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > &xNewFactory, sal_Bool bInitialise ) throw(::com::sun::star::io::IOException, com::sun::star::packages::zip::ZipException, com::sun::star::uno::RuntimeException); - ZipFile( com::sun::star::uno::Reference < com::sun::star::io::XInputStream > &xInput, - const com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > &xNewFactory, + ZipFile( com::sun::star::uno::Reference < com::sun::star::io::XInputStream > &xInput, + const com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > &xNewFactory, sal_Bool bInitialise, sal_Bool bForceRecover, ::com::sun::star::uno::Reference < ::com::sun::star::ucb::XProgressHandler > xProgress @@ -123,46 +123,46 @@ public: EntryHash& GetEntryHash() { return aEntries; } void setInputStream ( com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xNewStream ); - ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getRawData( + ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getRawData( ZipEntry& rEntry, - const vos::ORef < EncryptionData > &rData, + const rtl::Reference < EncryptionData > &rData, sal_Bool bDecrypt, SotMutexHolderRef aMutexHolder ) throw(::com::sun::star::io::IOException, ::com::sun::star::packages::zip::ZipException, ::com::sun::star::uno::RuntimeException); - - static sal_Bool StaticGetCipher ( const vos::ORef < EncryptionData > & xEncryptionData, rtlCipher &rCipher, sal_Bool bDecode ); - static void StaticFillHeader ( const vos::ORef < EncryptionData > & rData, + static sal_Bool StaticGetCipher ( const rtl::Reference < EncryptionData > & xEncryptionData, rtlCipher &rCipher, sal_Bool bDecode ); + + static void StaticFillHeader ( const rtl::Reference < EncryptionData > & rData, sal_Int32 nSize, const ::rtl::OUString& aMediaType, sal_Int8 * & pHeader ); - static sal_Bool StaticFillData ( vos::ORef < EncryptionData > & rData, + static sal_Bool StaticFillData ( rtl::Reference < EncryptionData > & rData, sal_Int32 &rSize, ::rtl::OUString& aMediaType, ::com::sun::star::uno::Reference < com::sun::star::io::XInputStream > &rStream ); static ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > StaticGetDataFromRawStream( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xStream, - const vos::ORef < EncryptionData > &rData ) + const rtl::Reference < EncryptionData > &rData ) throw ( ::com::sun::star::packages::WrongPasswordException, ::com::sun::star::packages::zip::ZipIOException, ::com::sun::star::uno::RuntimeException ); - + static sal_Bool StaticHasValidPassword ( const ::com::sun::star::uno::Sequence< sal_Int8 > &aReadBuffer, - const vos::ORef < EncryptionData > &rData ); - + const rtl::Reference < EncryptionData > &rData ); + - ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream( + ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream( ZipEntry& rEntry, - const vos::ORef < EncryptionData > &rData, + const rtl::Reference < EncryptionData > &rData, sal_Bool bDecrypt, SotMutexHolderRef aMutexHolder ) throw(::com::sun::star::io::IOException, ::com::sun::star::packages::zip::ZipException, ::com::sun::star::uno::RuntimeException); - ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getDataStream( + ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getDataStream( ZipEntry& rEntry, - const vos::ORef < EncryptionData > &rData, + const rtl::Reference < EncryptionData > &rData, sal_Bool bDecrypt, SotMutexHolderRef aMutexHolder ) throw ( ::com::sun::star::packages::WrongPasswordException, @@ -170,9 +170,9 @@ public: ::com::sun::star::packages::zip::ZipException, ::com::sun::star::uno::RuntimeException ); - ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getWrappedRawStream( + ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getWrappedRawStream( ZipEntry& rEntry, - const vos::ORef < EncryptionData > &rData, + const rtl::Reference < EncryptionData > &rData, const ::rtl::OUString& aMediaType, SotMutexHolderRef aMutexHolder ) throw ( ::com::sun::star::packages::NoEncryptionException, diff --git a/package/inc/ZipOutputStream.hxx b/package/inc/ZipOutputStream.hxx index ae412850c..de3e3b458 100644 --- a/package/inc/ZipOutputStream.hxx +++ b/package/inc/ZipOutputStream.hxx @@ -37,9 +37,9 @@ struct ZipEntry; class EncryptionData; -namespace vos +namespace rtl { - template < class T > class ORef; + template < class T > class Reference; } class ZipOutputStream { @@ -74,7 +74,7 @@ public: void SAL_CALL setLevel( sal_Int32 nNewLevel ) throw(::com::sun::star::uno::RuntimeException); void SAL_CALL putNextEntry( ZipEntry& rEntry, - vos::ORef < EncryptionData > &rData, + rtl::Reference < EncryptionData > &rData, sal_Bool bEncrypt = sal_False ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); void SAL_CALL closeEntry( ) diff --git a/package/source/manifest/ManifestReader.cxx b/package/source/manifest/ManifestReader.cxx index e9020ce20..34fe9e262 100644 --- a/package/source/manifest/ManifestReader.cxx +++ b/package/source/manifest/ManifestReader.cxx @@ -36,9 +36,8 @@ #include <com/sun/star/xml/sax/XParser.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <vector> +#include <vector> -using namespace ::rtl; using namespace ::std; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; @@ -48,6 +47,7 @@ using namespace ::com::sun::star::registry; using namespace ::com::sun::star::packages; using namespace ::com::sun::star::xml::sax; using namespace ::com::sun::star::packages::manifest; +using ::rtl::OUString; ManifestReader::ManifestReader( const Reference < XMultiServiceFactory > & xNewFactory ) : xFactory ( xNewFactory ) diff --git a/package/source/manifest/UnoRegister.cxx b/package/source/manifest/UnoRegister.cxx index 9a3883c4d..8a234a750 100644 --- a/package/source/manifest/UnoRegister.cxx +++ b/package/source/manifest/UnoRegister.cxx @@ -37,7 +37,6 @@ #include <zipfileaccess.hxx> -using namespace ::rtl; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::lang; @@ -45,6 +44,8 @@ using namespace ::com::sun::star::registry; using namespace ::com::sun::star::packages; using namespace ::com::sun::star::packages::manifest; +using rtl::OUString; + static sal_Bool writeInfo( void * pRegistryKey, const OUString & rImplementationName, Sequence< OUString > const & rServiceNames ) diff --git a/package/source/zipapi/EntryInputStream.cxx b/package/source/zipapi/EntryInputStream.cxx index 677ef9f1d..eb8964691 100644 --- a/package/source/zipapi/EntryInputStream.cxx +++ b/package/source/zipapi/EntryInputStream.cxx @@ -53,7 +53,7 @@ using namespace com::sun::star::packages::zip::ZipConstants; EntryInputStream::EntryInputStream( Reference < io::XInputStream > xNewInput, const ZipEntry & rNewEntry, - const vos::ORef < EncryptionData > &xEncryptData, + const rtl::Reference < EncryptionData > &xEncryptData, sal_Bool bGetRawStream) : xStream( xNewInput ) , xSeek( xNewInput, UNO_QUERY ) diff --git a/package/source/zipapi/EntryInputStream.hxx b/package/source/zipapi/EntryInputStream.hxx index 4696d5e42..9d9c45d99 100644 --- a/package/source/zipapi/EntryInputStream.hxx +++ b/package/source/zipapi/EntryInputStream.hxx @@ -32,7 +32,7 @@ #include <com/sun/star/io/XSeekable.hpp> #include <Inflater.hxx> #include <com/sun/star/packages/zip/ZipEntry.hpp> -#include <vos/ref.hxx> +#include <rtl/ref.hxx> #include <EncryptionData.hxx> class EntryInputStream : public cppu::WeakImplHelper2< com::sun::star::io::XInputStream, com::sun::star::io::XSeekable > @@ -43,7 +43,7 @@ protected: sal_Int64 nEnd, nCurrent, nUncompressedSize; sal_Bool bRawStream, bHaveInMemory, bEncrypted; com::sun::star::uno::Sequence < sal_Int8 > aBuffer; - const vos::ORef < EncryptionData > xEncryptionData; + const rtl::Reference < EncryptionData > xEncryptionData; const com::sun::star::packages::zip::ZipEntry aEntry; Inflater aInflater; void readIntoMemory() @@ -51,7 +51,7 @@ protected: public: EntryInputStream( com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xInput, const com::sun::star::packages::zip::ZipEntry &rNewEntry, - const vos::ORef < EncryptionData > &xEncryptData, + const rtl::Reference < EncryptionData > &xEncryptData, sal_Bool bGetRawStream = sal_False); virtual ~EntryInputStream(); diff --git a/package/source/zipapi/XFileStream.cxx b/package/source/zipapi/XFileStream.cxx index b1ab1027d..6afe8079c 100644 --- a/package/source/zipapi/XFileStream.cxx +++ b/package/source/zipapi/XFileStream.cxx @@ -2,7 +2,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -46,7 +46,7 @@ using ::rtl::OUString; XFileStream::XFileStream( ZipEntry & rEntry, com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xNewZipStream, com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xNewTempStream, - const vos::ORef < EncryptionData > &rData, + const rtl::Reference < EncryptionData > &rData, sal_Bool bNewRawStream, sal_Bool bIsEncrypted ) : maEntry ( rEntry ) @@ -86,8 +86,8 @@ XFileStream::XFileStream( ZipEntry & rEntry, else { // Put in the EncryptedDataHeader - Sequence < sal_Int8 > aEncryptedDataHeader ( n_ConstHeaderSize + - rData->aInitVector.getLength() + + Sequence < sal_Int8 > aEncryptedDataHeader ( n_ConstHeaderSize + + rData->aInitVector.getLength() + rData->aSalt.getLength() + rData->aDigest.getLength() ); sal_Int8 * pHeader = aEncryptedDataHeader.getArray(); @@ -100,7 +100,7 @@ XFileStream::XFileStream( ZipEntry & rEntry, } } -XFileStream::~XFileStream() +XFileStream::~XFileStream() { if ( maCipher ) rtl_cipher_destroy ( maCipher ); @@ -124,7 +124,7 @@ void XFileStream::fill( sal_Int64 nUntil) // some error handling ? return; } - + sal_Int64 nDiff = mnZipEnd - mnZipCurrent; if ( nDiff > 0 ) { @@ -167,7 +167,7 @@ void XFileStream::fill( sal_Int64 nUntil) mxTempSeek->seek ( nPosition ); } -sal_Int32 SAL_CALL XFileStream::readBytes( Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) +sal_Int32 SAL_CALL XFileStream::readBytes( Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException) { sal_Int64 nPosition = mxTempSeek->getPosition(); @@ -183,28 +183,28 @@ sal_Int32 SAL_CALL XFileStream::readBytes( Sequence< sal_Int8 >& aData, sal_Int3 return nRead; } -sal_Int32 SAL_CALL XFileStream::readSomeBytes( Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) +sal_Int32 SAL_CALL XFileStream::readSomeBytes( Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException) { return readBytes ( aData, nMaxBytesToRead ); } -void SAL_CALL XFileStream::skipBytes( sal_Int32 nBytesToSkip ) +void SAL_CALL XFileStream::skipBytes( sal_Int32 nBytesToSkip ) throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException) { seek ( mxTempSeek->getPosition() + nBytesToSkip ); } -sal_Int32 SAL_CALL XFileStream::available( ) +sal_Int32 SAL_CALL XFileStream::available( ) throw( NotConnectedException, IOException, RuntimeException) { return static_cast < sal_Int32 > ( mnZipSize - mxTempSeek->getPosition() ); } -void SAL_CALL XFileStream::closeInput( ) +void SAL_CALL XFileStream::closeInput( ) throw( NotConnectedException, IOException, RuntimeException) { } -void SAL_CALL XFileStream::seek( sal_Int64 location ) +void SAL_CALL XFileStream::seek( sal_Int64 location ) throw( IllegalArgumentException, IOException, RuntimeException) { if ( location > mnZipSize || location < 0 ) @@ -216,12 +216,12 @@ void SAL_CALL XFileStream::seek( sal_Int64 location ) } mxTempSeek->seek ( location ); } -sal_Int64 SAL_CALL XFileStream::getPosition( ) +sal_Int64 SAL_CALL XFileStream::getPosition( ) throw(IOException, RuntimeException) { return mxTempSeek->getPosition(); } -sal_Int64 SAL_CALL XFileStream::getLength( ) +sal_Int64 SAL_CALL XFileStream::getLength( ) throw(IOException, RuntimeException) { return mnZipSize; diff --git a/package/source/zipapi/XFileStream.hxx b/package/source/zipapi/XFileStream.hxx index 9c147586f..4fc279fad 100644 --- a/package/source/zipapi/XFileStream.hxx +++ b/package/source/zipapi/XFileStream.hxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -31,7 +31,7 @@ #include <com/sun/star/io/XSeekable.hpp> #include <com/sun/star/io/XInputStream.hpp> #include <cppuhelper/implbase2.hxx> -#include <vos/ref.hxx> +#include <rtl/ref.hxx> #include <Inflater.hxx> #include <ZipEntry.hxx> @@ -54,7 +54,7 @@ protected: com::sun::star::uno::Reference < com::sun::star::io::XOutputStream > mxTempOut; com::sun::star::uno::Sequence < sal_Int8 > maBuffer, maCompBuffer; ZipEntry maEntry; - vos::ORef < EncryptionData > mxData; + rtl::Reference < EncryptionData > mxData; rtlCipher maCipher; Inflater maInflater; sal_Bool mbRawStream, mbFinished; @@ -65,28 +65,28 @@ public: XFileStream( ZipEntry & rEntry, com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xNewZipStream, com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xNewTempStream, - const vos::ORef < EncryptionData > &rData, + const rtl::Reference < EncryptionData > &rData, sal_Bool bRawStream, sal_Bool bIsEncrypted ); virtual ~XFileStream(); // XInputStream - virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) + virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) + virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) + virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL available( ) + virtual sal_Int32 SAL_CALL available( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL closeInput( ) + virtual void SAL_CALL closeInput( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); // XSeekable - virtual void SAL_CALL seek( sal_Int64 location ) + virtual void SAL_CALL seek( sal_Int64 location ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int64 SAL_CALL getPosition( ) + virtual sal_Int64 SAL_CALL getPosition( ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int64 SAL_CALL getLength( ) + virtual sal_Int64 SAL_CALL getLength( ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); }; #endif diff --git a/package/source/zipapi/XUnbufferedStream.cxx b/package/source/zipapi/XUnbufferedStream.cxx index 0e33d7054..de2a69f64 100644 --- a/package/source/zipapi/XUnbufferedStream.cxx +++ b/package/source/zipapi/XUnbufferedStream.cxx @@ -2,7 +2,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -58,7 +58,7 @@ using ::rtl::OUString; XUnbufferedStream::XUnbufferedStream( SotMutexHolderRef aMutexHolder, ZipEntry & rEntry, Reference < XInputStream > xNewZipStream, - const vos::ORef < EncryptionData > &rData, + const rtl::Reference < EncryptionData > &rData, sal_Int8 nStreamMode, sal_Bool bIsEncrypted, const ::rtl::OUString& aMediaType, @@ -91,9 +91,9 @@ XUnbufferedStream::XUnbufferedStream( SotMutexHolderRef aMutexHolder, mnZipSize = maEntry.nSize; mnZipEnd = maEntry.nMethod == DEFLATED ? maEntry.nOffset + maEntry.nCompressedSize : maEntry.nOffset + maEntry.nSize; } - sal_Bool bHaveEncryptData = ( !rData.isEmpty() && rData->aSalt.getLength() && rData->aInitVector.getLength() && rData->nIterationCount != 0 ) ? sal_True : sal_False; + sal_Bool bHaveEncryptData = ( rData.is() && rData->aSalt.getLength() && rData->aInitVector.getLength() && rData->nIterationCount != 0 ) ? sal_True : sal_False; sal_Bool bMustDecrypt = ( nStreamMode == UNBUFF_STREAM_DATA && bHaveEncryptData && bIsEncrypted ) ? sal_True : sal_False; - + if ( bMustDecrypt ) ZipFile::StaticGetCipher ( rData, maCipher, sal_True ); if ( bHaveEncryptData && mbWrappedRaw && bIsEncrypted ) @@ -104,8 +104,8 @@ XUnbufferedStream::XUnbufferedStream( SotMutexHolderRef aMutexHolder, // Make a buffer big enough to hold both the header and the data itself maHeader.realloc ( n_ConstHeaderSize + - rData->aInitVector.getLength() + - rData->aSalt.getLength() + + rData->aInitVector.getLength() + + rData->aSalt.getLength() + rData->aDigest.getLength() + aMediaType.getLength() * sizeof( sal_Unicode ) ); sal_Int8 * pHeader = maHeader.getArray(); @@ -116,7 +116,7 @@ XUnbufferedStream::XUnbufferedStream( SotMutexHolderRef aMutexHolder, // allows to read package raw stream XUnbufferedStream::XUnbufferedStream( const Reference < XInputStream >& xRawStream, - const vos::ORef < EncryptionData > &rData ) + const rtl::Reference < EncryptionData > &rData ) : maMutexHolder( new SotMutexHolder ) , mxZipStream ( xRawStream ) , mxZipSeek ( xRawStream, UNO_QUERY ) @@ -137,7 +137,7 @@ XUnbufferedStream::XUnbufferedStream( const Reference < XInputStream >& xRawStre OSL_ENSURE( mxZipSeek.is(), "The stream must be seekable!\n" ); // skip raw header, it must be already parsed to rData - mnZipCurrent = n_ConstHeaderSize + rData->aInitVector.getLength() + + mnZipCurrent = n_ConstHeaderSize + rData->aInitVector.getLength() + rData->aSalt.getLength() + rData->aDigest.getLength(); try { @@ -147,19 +147,19 @@ XUnbufferedStream::XUnbufferedStream( const Reference < XInputStream >& xRawStre { // in case of problem the size will stay set to 0 } - + mnZipEnd = mnZipCurrent + mnZipSize; ZipFile::StaticGetCipher ( rData, maCipher, sal_True ); } -XUnbufferedStream::~XUnbufferedStream() +XUnbufferedStream::~XUnbufferedStream() { if ( maCipher ) rtl_cipher_destroy ( maCipher ); } -sal_Int32 SAL_CALL XUnbufferedStream::readBytes( Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) +sal_Int32 SAL_CALL XUnbufferedStream::readBytes( Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException) { ::osl::MutexGuard aGuard( maMutexHolder->GetMutex() ); @@ -171,7 +171,7 @@ sal_Int32 SAL_CALL XUnbufferedStream::readBytes( Sequence< sal_Int8 >& aData, sa sal_Int32 nRead = 0, nLastRead = 0, nTotal = 0; aData.realloc ( nRequestedBytes ); - if ( nRequestedBytes ) + if ( nRequestedBytes ) { if ( mbRawStream ) { @@ -212,8 +212,8 @@ sal_Int32 SAL_CALL XUnbufferedStream::readBytes( Sequence< sal_Int8 >& aData, sa { mxZipSeek->seek ( mnZipCurrent ); - nRead = mxZipStream->readBytes ( - aData, + nRead = mxZipStream->readBytes ( + aData, static_cast < sal_Int32 > ( nDiff < nRequestedBytes ? nDiff : nRequestedBytes ) ); mnZipCurrent += nRead; @@ -225,16 +225,16 @@ sal_Int32 SAL_CALL XUnbufferedStream::readBytes( Sequence< sal_Int8 >& aData, sa } else { - while ( 0 == ( nLastRead = maInflater.doInflateSegment( aData, nRead, aData.getLength() - nRead ) ) || + while ( 0 == ( nLastRead = maInflater.doInflateSegment( aData, nRead, aData.getLength() - nRead ) ) || ( nRead + nLastRead != nRequestedBytes && mnZipCurrent < mnZipEnd ) ) { nRead += nLastRead; if ( nRead > nRequestedBytes ) - throw RuntimeException( + throw RuntimeException( OUString( RTL_CONSTASCII_USTRINGPARAM( "Should not be possible to read more then requested!" ) ), Reference< XInterface >() ); - + if ( maInflater.finished() || maInflater.getLastInflateError() ) throw ZipIOException( OUString( RTL_CONSTASCII_USTRINGPARAM( "The stream seems to be broken!" ) ), Reference< XInterface >() ); @@ -262,7 +262,7 @@ sal_Int32 SAL_CALL XUnbufferedStream::readBytes( Sequence< sal_Int8 >& aData, sa maCRC.update( maCompBuffer ); Sequence < sal_Int8 > aCryptBuffer ( nZipRead ); - rtlCipherError aResult = + rtlCipherError aResult = rtl_cipher_decode ( maCipher, maCompBuffer.getConstArray(), nZipRead, @@ -308,22 +308,22 @@ sal_Int32 SAL_CALL XUnbufferedStream::readBytes( Sequence< sal_Int8 >& aData, sa } } #endif - + if ( mnZipSize + maHeader.getLength() == mnMyCurrent && maCRC.getValue() != maEntry.nCrc ) throw ZipIOException( OUString( RTL_CONSTASCII_USTRINGPARAM( "The stream seems to be broken!" ) ), Reference< XInterface >() ); } } - + return nTotal; } -sal_Int32 SAL_CALL XUnbufferedStream::readSomeBytes( Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) +sal_Int32 SAL_CALL XUnbufferedStream::readSomeBytes( Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException) { return readBytes ( aData, nMaxBytesToRead ); } -void SAL_CALL XUnbufferedStream::skipBytes( sal_Int32 nBytesToSkip ) +void SAL_CALL XUnbufferedStream::skipBytes( sal_Int32 nBytesToSkip ) throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException) { if ( nBytesToSkip ) @@ -333,27 +333,27 @@ void SAL_CALL XUnbufferedStream::skipBytes( sal_Int32 nBytesToSkip ) } } -sal_Int32 SAL_CALL XUnbufferedStream::available( ) +sal_Int32 SAL_CALL XUnbufferedStream::available( ) throw( NotConnectedException, IOException, RuntimeException) { return static_cast < sal_Int32 > ( mnZipSize - mnMyCurrent ); } -void SAL_CALL XUnbufferedStream::closeInput( ) +void SAL_CALL XUnbufferedStream::closeInput( ) throw( NotConnectedException, IOException, RuntimeException) { } /* -void SAL_CALL XUnbufferedStream::seek( sal_Int64 location ) +void SAL_CALL XUnbufferedStream::seek( sal_Int64 location ) throw( IllegalArgumentException, IOException, RuntimeException) { } -sal_Int64 SAL_CALL XUnbufferedStream::getPosition( ) +sal_Int64 SAL_CALL XUnbufferedStream::getPosition( ) throw(IOException, RuntimeException) { return mnMyCurrent; } -sal_Int64 SAL_CALL XUnbufferedStream::getLength( ) +sal_Int64 SAL_CALL XUnbufferedStream::getLength( ) throw(IOException, RuntimeException) { return mnZipSize; diff --git a/package/source/zipapi/XUnbufferedStream.hxx b/package/source/zipapi/XUnbufferedStream.hxx index fda438663..14ff93e0a 100644 --- a/package/source/zipapi/XUnbufferedStream.hxx +++ b/package/source/zipapi/XUnbufferedStream.hxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -33,7 +33,7 @@ #include <com/sun/star/io/XInputStream.hpp> #include <com/sun/star/io/XOutputStream.hpp> #include <cppuhelper/implbase1.hxx> -#include <vos/ref.hxx> +#include <rtl/ref.hxx> #include <Inflater.hxx> #include <ZipEntry.hxx> #include <CRC32.hxx> @@ -57,7 +57,7 @@ protected: com::sun::star::uno::Reference < com::sun::star::io::XSeekable > mxZipSeek; com::sun::star::uno::Sequence < sal_Int8 > maCompBuffer, maHeader; ZipEntry maEntry; - vos::ORef < EncryptionData > mxData; + rtl::Reference < EncryptionData > mxData; rtlCipher maCipher; Inflater maInflater; sal_Bool mbRawStream, mbWrappedRaw, mbFinished; @@ -71,7 +71,7 @@ public: SotMutexHolderRef aMutexHolder, ZipEntry & rEntry, com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xNewZipStream, - const vos::ORef < EncryptionData > &rData, + const rtl::Reference < EncryptionData > &rData, sal_Int8 nStreamMode, sal_Bool bIsEncrypted, const ::rtl::OUString& aMediaType, @@ -79,29 +79,29 @@ public: // allows to read package raw stream XUnbufferedStream( const com::sun::star::uno::Reference < com::sun::star::io::XInputStream >& xRawStream, - const vos::ORef < EncryptionData > &rData ); + const rtl::Reference < EncryptionData > &rData ); virtual ~XUnbufferedStream(); // XInputStream - virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) + virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) + virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) + virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL available( ) + virtual sal_Int32 SAL_CALL available( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL closeInput( ) + virtual void SAL_CALL closeInput( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); // XSeekable /* - virtual void SAL_CALL seek( sal_Int64 location ) + virtual void SAL_CALL seek( sal_Int64 location ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int64 SAL_CALL getPosition( ) + virtual sal_Int64 SAL_CALL getPosition( ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); - virtual sal_Int64 SAL_CALL getLength( ) + virtual sal_Int64 SAL_CALL getLength( ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); */ }; diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx index e5ae80681..2d2f602ce 100644 --- a/package/source/zipapi/ZipFile.cxx +++ b/package/source/zipapi/ZipFile.cxx @@ -2,7 +2,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -52,8 +52,6 @@ #include <comphelper/storagehelper.hxx> -using namespace vos; -using namespace rtl; using namespace com::sun::star; using namespace com::sun::star::io; using namespace com::sun::star::uno; @@ -63,6 +61,7 @@ using namespace com::sun::star::packages; using namespace com::sun::star::packages::zip; using namespace com::sun::star::packages::zip::ZipConstants; +using rtl::OUString; /** This class is used to read entries from a zip file */ @@ -125,10 +124,10 @@ void ZipFile::setInputStream ( Reference < XInputStream > xNewStream ) aGrabber.setInputStream ( xStream ); } -sal_Bool ZipFile::StaticGetCipher ( const ORef < EncryptionData > & xEncryptionData, rtlCipher &rCipher, sal_Bool bDecode ) +sal_Bool ZipFile::StaticGetCipher ( const rtl::Reference < EncryptionData > & xEncryptionData, rtlCipher &rCipher, sal_Bool bDecode ) { sal_Bool bResult = sal_False; - if ( ! xEncryptionData.isEmpty() ) + if ( xEncryptionData.is() ) { Sequence < sal_uInt8 > aDerivedKey (16); rtlCipherError aResult; @@ -156,7 +155,7 @@ sal_Bool ZipFile::StaticGetCipher ( const ORef < EncryptionData > & xEncryptionD return bResult; } -void ZipFile::StaticFillHeader ( const ORef < EncryptionData > & rData, +void ZipFile::StaticFillHeader ( const rtl::Reference < EncryptionData > & rData, sal_Int32 nSize, const ::rtl::OUString& aMediaType, sal_Int8 * & pHeader ) @@ -207,23 +206,23 @@ void ZipFile::StaticFillHeader ( const ORef < EncryptionData > & rData, *(pHeader++) = static_cast< sal_Int8 >(( nMediaTypeLength >> 8 ) & 0xFF); // Then the salt content - memcpy ( pHeader, rData->aSalt.getConstArray(), nSaltLength ); + memcpy ( pHeader, rData->aSalt.getConstArray(), nSaltLength ); pHeader += nSaltLength; // Then the IV content - memcpy ( pHeader, rData->aInitVector.getConstArray(), nIVLength ); + memcpy ( pHeader, rData->aInitVector.getConstArray(), nIVLength ); pHeader += nIVLength; // Then the digest content - memcpy ( pHeader, rData->aDigest.getConstArray(), nDigestLength ); + memcpy ( pHeader, rData->aDigest.getConstArray(), nDigestLength ); pHeader += nDigestLength; // Then the mediatype itself - memcpy ( pHeader, aMediaType.getStr(), nMediaTypeLength ); + memcpy ( pHeader, aMediaType.getStr(), nMediaTypeLength ); pHeader += nMediaTypeLength; } -sal_Bool ZipFile::StaticFillData ( ORef < EncryptionData > & rData, +sal_Bool ZipFile::StaticFillData ( rtl::Reference < EncryptionData > & rData, sal_Int32 &rSize, ::rtl::OUString& aMediaType, Reference < XInputStream > &rStream ) @@ -288,10 +287,10 @@ sal_Bool ZipFile::StaticFillData ( ORef < EncryptionData > & rData, } Reference< XInputStream > ZipFile::StaticGetDataFromRawStream( const Reference< XInputStream >& xStream, - const ORef < EncryptionData > &rData ) + const rtl::Reference < EncryptionData > &rData ) throw ( packages::WrongPasswordException, ZipIOException, RuntimeException ) { - if ( rData.isEmpty() ) + if ( !rData.is() ) throw ZipIOException( OUString::createFromAscii( "Encrypted stream without encryption data!\n" ), Reference< XInterface >() ); @@ -313,14 +312,14 @@ Reference< XInputStream > ZipFile::StaticGetDataFromRawStream( const Reference< nSize = nSize > n_ConstDigestLength ? n_ConstDigestLength : nSize; // skip header - xSeek->seek( n_ConstHeaderSize + rData->aInitVector.getLength() + + xSeek->seek( n_ConstHeaderSize + rData->aInitVector.getLength() + rData->aSalt.getLength() + rData->aDigest.getLength() ); // Only want to read enough to verify the digest Sequence < sal_Int8 > aReadBuffer ( nSize ); - xStream->readBytes( aReadBuffer, nSize ); - + xStream->readBytes( aReadBuffer, nSize ); + if ( !StaticHasValidPassword( aReadBuffer, rData ) ) throw packages::WrongPasswordException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); } @@ -328,9 +327,9 @@ Reference< XInputStream > ZipFile::StaticGetDataFromRawStream( const Reference< return new XUnbufferedStream ( xStream, rData ); } -sal_Bool ZipFile::StaticHasValidPassword( const Sequence< sal_Int8 > &aReadBuffer, const ORef < EncryptionData > &rData ) +sal_Bool ZipFile::StaticHasValidPassword( const Sequence< sal_Int8 > &aReadBuffer, const rtl::Reference < EncryptionData > &rData ) { - if ( !rData.isValid() || !rData->aKey.getLength() ) + if ( !rData.is() || !rData->aKey.getLength() ) return sal_False; sal_Bool bRet = sal_False; @@ -352,7 +351,7 @@ sal_Bool ZipFile::StaticHasValidPassword( const Sequence< sal_Int8 > &aReadBuffe if(aResult != rtl_Cipher_E_None ) { OSL_ASSERT ( aResult == rtl_Cipher_E_None); } - + aDigestResult = rtl_digest_updateSHA1 ( aDigest, static_cast < const void * > ( aDecryptBuffer.getConstArray() ), nSize ); OSL_ASSERT ( aDigestResult == rtl_Digest_E_None ); @@ -361,10 +360,10 @@ sal_Bool ZipFile::StaticHasValidPassword( const Sequence< sal_Int8 > &aReadBuffe OSL_ASSERT ( aDigestResult == rtl_Digest_E_None ); // If we don't have a digest, then we have to assume that the password is correct - if ( rData->aDigest.getLength() != 0 && + if ( rData->aDigest.getLength() != 0 && ( aDigestSeq.getLength() != rData->aDigest.getLength() || - 0 != rtl_compareMemory ( aDigestSeq.getConstArray(), - rData->aDigest.getConstArray(), + 0 != rtl_compareMemory ( aDigestSeq.getConstArray(), + rData->aDigest.getConstArray(), aDigestSeq.getLength() ) ) ) { // We should probably tell the user that the password they entered was wrong @@ -377,7 +376,7 @@ sal_Bool ZipFile::StaticHasValidPassword( const Sequence< sal_Int8 > &aReadBuffe return bRet; } -sal_Bool ZipFile::hasValidPassword ( ZipEntry & rEntry, const ORef < EncryptionData > &rData ) +sal_Bool ZipFile::hasValidPassword ( ZipEntry & rEntry, const rtl::Reference < EncryptionData > &rData ) { ::osl::MutexGuard aGuard( m_aMutex ); @@ -391,7 +390,7 @@ sal_Bool ZipFile::hasValidPassword ( ZipEntry & rEntry, const ORef < EncryptionD nSize = nSize > n_ConstDigestLength ? n_ConstDigestLength : nSize; Sequence < sal_Int8 > aReadBuffer ( nSize ); - xStream->readBytes( aReadBuffer, nSize ); + xStream->readBytes( aReadBuffer, nSize ); bRet = StaticHasValidPassword( aReadBuffer, rData ); } @@ -401,7 +400,7 @@ sal_Bool ZipFile::hasValidPassword ( ZipEntry & rEntry, const ORef < EncryptionD #if 0 Reference < XInputStream > ZipFile::createFileStream( ZipEntry & rEntry, - const ORef < EncryptionData > &rData, + const rtl::Reference < EncryptionData > &rData, sal_Bool bRawStream, sal_Bool bIsEncrypted ) { @@ -411,8 +410,8 @@ Reference < XInputStream > ZipFile::createFileStream( } Reference < XInputStream > ZipFile::createMemoryStream( ZipEntry & rEntry, - const ORef < EncryptionData > &rData, - sal_Bool bRawStream, + const rtl::Reference < EncryptionData > &rData, + sal_Bool bRawStream, sal_Bool bIsEncrypted ) { sal_Int32 nUncompressedSize, nEnd; @@ -433,8 +432,8 @@ Reference < XInputStream > ZipFile::createMemoryStream( // If the encryption key is zero, we need to return the raw stream. First check if // we have the salt. If we have the salt, then check if we have the encryption key // if not, return rawStream instead. - - sal_Bool bHaveEncryptData = ( !rData.isEmpty() && rData->aSalt.getLength() && rData->aInitVector.getLength() && rData->nIterationCount != 0 ) ? sal_True : sal_False; + + sal_Bool bHaveEncryptData = ( rData.is() && rData->aSalt.getLength() && rData->aInitVector.getLength() && rData->nIterationCount != 0 ) ? sal_True : sal_False; sal_Bool bMustDecrypt = ( !bRawStream && bHaveEncryptData && bIsEncrypted ) ? sal_True : sal_False; if ( bMustDecrypt ) @@ -476,10 +475,10 @@ Reference < XInputStream > ZipFile::createMemoryStream( // data to the stream // Make a buffer big enough to hold both the header and the data itself - Sequence < sal_Int8 > aEncryptedDataHeader ( n_ConstHeaderSize + - rData->aInitVector.getLength() + - rData->aSalt.getLength() + - rData->aDigest.getLength() + + Sequence < sal_Int8 > aEncryptedDataHeader ( n_ConstHeaderSize + + rData->aInitVector.getLength() + + rData->aSalt.getLength() + + rData->aDigest.getLength() + aWriteBuffer.getLength() ); sal_Int8 * pHeader = aEncryptedDataHeader.getArray(); StaticFillHeader ( rData, rEntry.nSize, pHeader ); @@ -494,7 +493,7 @@ Reference < XInputStream > ZipFile::createMemoryStream( Reference < XInputStream > ZipFile::createUnbufferedStream( SotMutexHolderRef aMutexHolder, ZipEntry & rEntry, - const ORef < EncryptionData > &rData, + const rtl::Reference < EncryptionData > &rData, sal_Int8 nStreamMode, sal_Bool bIsEncrypted, ::rtl::OUString aMediaType ) @@ -511,7 +510,7 @@ ZipEnumeration * SAL_CALL ZipFile::entries( ) } Reference< XInputStream > SAL_CALL ZipFile::getInputStream( ZipEntry& rEntry, - const vos::ORef < EncryptionData > &rData, + const rtl::Reference < EncryptionData > &rData, sal_Bool bIsEncrypted, SotMutexHolderRef aMutexHolder ) throw(IOException, ZipException, RuntimeException) @@ -521,14 +520,14 @@ Reference< XInputStream > SAL_CALL ZipFile::getInputStream( ZipEntry& rEntry, if ( rEntry.nOffset <= 0 ) readLOC( rEntry ); - // We want to return a rawStream if we either don't have a key or if the + // We want to return a rawStream if we either don't have a key or if the // key is wrong - + sal_Bool bNeedRawStream = rEntry.nMethod == STORED; - + // if we have a digest, then this file is an encrypted one and we should // check if we can decrypt it or not - if ( bIsEncrypted && !rData.isEmpty() && rData->aDigest.getLength() ) + if ( bIsEncrypted && rData.is() && rData->aDigest.getLength() ) bNeedRawStream = !hasValidPassword ( rEntry, rData ); return createUnbufferedStream ( aMutexHolder, @@ -539,7 +538,7 @@ Reference< XInputStream > SAL_CALL ZipFile::getInputStream( ZipEntry& rEntry, } Reference< XInputStream > SAL_CALL ZipFile::getDataStream( ZipEntry& rEntry, - const vos::ORef < EncryptionData > &rData, + const rtl::Reference < EncryptionData > &rData, sal_Bool bIsEncrypted, SotMutexHolderRef aMutexHolder ) throw ( packages::WrongPasswordException, @@ -552,14 +551,14 @@ Reference< XInputStream > SAL_CALL ZipFile::getDataStream( ZipEntry& rEntry, if ( rEntry.nOffset <= 0 ) readLOC( rEntry ); - // An exception must be thrown in case stream is encrypted and + // An exception must be thrown in case stream is encrypted and // there is no key or the key is wrong sal_Bool bNeedRawStream = sal_False; if ( bIsEncrypted ) { // in case no digest is provided there is no way // to detect password correctness - if ( rData.isEmpty() ) + if ( !rData.is() ) throw ZipException( OUString::createFromAscii( "Encrypted stream without encryption data!\n" ), Reference< XInterface >() ); @@ -580,7 +579,7 @@ Reference< XInputStream > SAL_CALL ZipFile::getDataStream( ZipEntry& rEntry, } Reference< XInputStream > SAL_CALL ZipFile::getRawData( ZipEntry& rEntry, - const vos::ORef < EncryptionData > &rData, + const rtl::Reference < EncryptionData > &rData, sal_Bool bIsEncrypted, SotMutexHolderRef aMutexHolder ) throw(IOException, ZipException, RuntimeException) @@ -595,7 +594,7 @@ Reference< XInputStream > SAL_CALL ZipFile::getRawData( ZipEntry& rEntry, Reference< XInputStream > SAL_CALL ZipFile::getWrappedRawStream( ZipEntry& rEntry, - const vos::ORef < EncryptionData > &rData, + const rtl::Reference < EncryptionData > &rData, const ::rtl::OUString& aMediaType, SotMutexHolderRef aMutexHolder ) throw ( packages::NoEncryptionException, @@ -605,7 +604,7 @@ Reference< XInputStream > SAL_CALL ZipFile::getWrappedRawStream( { ::osl::MutexGuard aGuard( m_aMutex ); - if ( rData.isEmpty() ) + if ( !rData.is() ) throw packages::NoEncryptionException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); if ( rEntry.nOffset <= 0 ) @@ -645,8 +644,8 @@ sal_Bool ZipFile::readLOC( ZipEntry &rEntry ) if ( nRead < aNameBuffer.getLength() ) aNameBuffer.realloc( nRead ); - ::rtl::OUString sLOCPath = rtl::OUString::intern( (sal_Char *) aNameBuffer.getArray(), - aNameBuffer.getLength(), + ::rtl::OUString sLOCPath = rtl::OUString::intern( (sal_Char *) aNameBuffer.getArray(), + aNameBuffer.getLength(), RTL_TEXTENCODING_UTF8 ); if ( rEntry.nPathLen == -1 ) // the file was created @@ -796,15 +795,15 @@ sal_Int32 ZipFile::readCEN() throw ZipException( OUString( RTL_CONSTASCII_USTRINGPARAM ( "unexpected extra header info length") ), Reference < XInterface > () ); // read always in UTF8, some tools seem not to set UTF8 bit - aEntry.sPath = rtl::OUString::intern ( (sal_Char *) aMemGrabber.getCurrentPos(), - aEntry.nPathLen, + aEntry.sPath = rtl::OUString::intern ( (sal_Char *) aMemGrabber.getCurrentPos(), + aEntry.nPathLen, RTL_TEXTENCODING_UTF8 ); if ( !::comphelper::OStorageHelper::IsValidZipEntryFileName( aEntry.sPath, sal_True ) ) throw ZipException( OUString( RTL_CONSTASCII_USTRINGPARAM ( "Zip entry has an invalid name.") ), Reference < XInterface > () ); aMemGrabber.skipBytes( aEntry.nPathLen + aEntry.nExtraLen + nCommentLen ); - aEntries[aEntry.sPath] = aEntry; + aEntries[aEntry.sPath] = aEntry; } if (nCount != nTotal) @@ -863,7 +862,7 @@ sal_Int32 ZipFile::recover() aMemGrabber >> aEntry.nPathLen; aMemGrabber >> aEntry.nExtraLen; - sal_Int32 nDescrLength = + sal_Int32 nDescrLength = ( aEntry.nMethod == DEFLATED && ( aEntry.nFlag & 8 ) ) ? 16 : 0; @@ -883,16 +882,16 @@ sal_Int32 ZipFile::recover() { // read always in UTF8, some tools seem not to set UTF8 bit if( nPos + 30 + aEntry.nPathLen <= nBufSize ) - aEntry.sPath = OUString ( (sal_Char *) &pBuffer[nPos + 30], - aEntry.nPathLen, + aEntry.sPath = OUString ( (sal_Char *) &pBuffer[nPos + 30], + aEntry.nPathLen, RTL_TEXTENCODING_UTF8 ); else { Sequence < sal_Int8 > aFileName; aGrabber.seek( nGenPos + nPos + 30 ); aGrabber.readBytes( aFileName, aEntry.nPathLen ); - aEntry.sPath = OUString ( (sal_Char *) aFileName.getArray(), - aFileName.getLength(), + aEntry.sPath = OUString ( (sal_Char *) aFileName.getArray(), + aFileName.getLength(), RTL_TEXTENCODING_UTF8 ); aEntry.nPathLen = static_cast< sal_Int16 >(aFileName.getLength()); } @@ -1046,7 +1045,7 @@ void ZipFile::getSizeAndCRC( sal_Int32 nOffset, sal_Int32 nCompressedSize, sal_I aCRC.updateSegment( aData, 0, nLastInflated ); nInBlock += nLastInflated; } while( !aInflater.finished() && nLastInflated ); - + nRealSize += nInBlock; } diff --git a/package/source/zipapi/ZipOutputStream.cxx b/package/source/zipapi/ZipOutputStream.cxx index 65a4c8806..d4778a87b 100644 --- a/package/source/zipapi/ZipOutputStream.cxx +++ b/package/source/zipapi/ZipOutputStream.cxx @@ -35,12 +35,11 @@ #include <PackageConstants.hxx> #include <ZipEntry.hxx> #include <ZipFile.hxx> -#include <vos/ref.hxx> +#include <rtl/ref.hxx> #include <com/sun/star/io/XOutputStream.hpp> #include <comphelper/storagehelper.hxx> -using namespace rtl; using namespace com::sun::star::io; using namespace com::sun::star::uno; using namespace com::sun::star::packages; @@ -81,7 +80,7 @@ void SAL_CALL ZipOutputStream::setLevel( sal_Int32 nNewLevel ) } void SAL_CALL ZipOutputStream::putNextEntry( ZipEntry& rEntry, - vos::ORef < EncryptionData > &xEncryptData, + rtl::Reference < EncryptionData > &xEncryptData, sal_Bool bEncrypt) throw(IOException, RuntimeException) { @@ -106,7 +105,7 @@ void SAL_CALL ZipOutputStream::putNextEntry( ZipEntry& rEntry, aDigest = rtl_digest_createSHA1(); mnDigested = 0; rEntry.nFlag |= 1 << 4; - pCurrentEncryptData = xEncryptData.getBodyPtr(); + pCurrentEncryptData = xEncryptData.get(); } sal_Int32 nLOCLength = writeLOC(rEntry); rEntry.nOffset = static_cast < sal_Int32 > (aChucker.GetPosition()) - nLOCLength; diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx index 0e903067b..89767c9ac 100644 --- a/package/source/zippackage/ZipPackage.cxx +++ b/package/source/zippackage/ZipPackage.cxx @@ -980,7 +980,7 @@ void ZipPackage::WriteMimetypeMagicFile( ZipOutputStream& aZipOut ) try { - vos::ORef < EncryptionData > xEmpty; + rtl::Reference < EncryptionData > xEmpty; aZipOut.putNextEntry( *pEntry, xEmpty ); aZipOut.write( aType, 0, nBufferLength ); aZipOut.closeEntry(); @@ -1025,7 +1025,7 @@ void ZipPackage::WriteManifest( ZipOutputStream& aZipOut, const vector< Sequence pBuffer->realloc( nBufferLength ); // the manifest.xml is never encrypted - so pass an empty reference - vos::ORef < EncryptionData > xEmpty; + rtl::Reference < EncryptionData > xEmpty; aZipOut.putNextEntry( *pEntry, xEmpty ); aZipOut.write( pBuffer->getSequence(), 0, nBufferLength ); aZipOut.closeEntry(); @@ -1088,7 +1088,7 @@ void ZipPackage::WriteContentTypes( ZipOutputStream& aZipOut, const vector< Sequ pBuffer->realloc( nBufferLength ); // there is no encryption in this format currently - vos::ORef < EncryptionData > xEmpty; + rtl::Reference < EncryptionData > xEmpty; aZipOut.putNextEntry( *pEntry, xEmpty ); aZipOut.write( pBuffer->getSequence(), 0, nBufferLength ); aZipOut.closeEntry(); diff --git a/package/source/zippackage/ZipPackageEntry.cxx b/package/source/zippackage/ZipPackageEntry.cxx index ca2132d50..6d764133e 100644 --- a/package/source/zippackage/ZipPackageEntry.cxx +++ b/package/source/zippackage/ZipPackageEntry.cxx @@ -38,7 +38,6 @@ #include <comphelper/storagehelper.hxx> -using namespace rtl; using namespace com::sun::star; using namespace com::sun::star::uno; using namespace com::sun::star::lang; @@ -46,6 +45,8 @@ using namespace com::sun::star::container; using namespace com::sun::star::packages::zip; using namespace com::sun::star::packages::zip::ZipConstants; +using rtl::OUString; + ZipPackageEntry::ZipPackageEntry ( bool bNewFolder ) : mbIsFolder ( bNewFolder ) , mbAllowRemoveOnInsert( sal_True ) diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx index d5da0686e..cdff1b230 100644 --- a/package/source/zippackage/ZipPackageFolder.cxx +++ b/package/source/zippackage/ZipPackageFolder.cxx @@ -56,10 +56,10 @@ using namespace com::sun::star::lang; using namespace com::sun::star::uno; using namespace com::sun::star::io; using namespace cppu; -using namespace rtl; using namespace std; using namespace ::com::sun::star; -using vos::ORef; + +using rtl::OUString; namespace { struct lcl_CachedImplId : public rtl::Static< Sequence < sal_Int8 >, lcl_CachedImplId > {}; } @@ -335,7 +335,7 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr try { - vos::ORef < EncryptionData > aEmptyEncr; + rtl::Reference < EncryptionData > aEmptyEncr; rZipOut.putNextEntry ( *pTempEntry, aEmptyEncr, sal_False ); rZipOut.rawCloseEntry(); } diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx index 0bdabdee0..f3c6d713f 100644 --- a/package/source/zippackage/ZipPackageStream.cxx +++ b/package/source/zippackage/ZipPackageStream.cxx @@ -2,7 +2,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2000, 2010 Oracle and/or its affiliates. * * OpenOffice.org - a multi-platform office productivity suite @@ -57,7 +57,8 @@ using namespace com::sun::star::uno; using namespace com::sun::star::lang; using namespace com::sun::star; using namespace cppu; -using namespace rtl; + +using rtl::OUString; namespace { struct lcl_CachedImplId : public rtl::Static< Sequence < sal_Int8 >, lcl_CachedImplId > {}; } @@ -68,7 +69,7 @@ const ::com::sun::star::uno::Sequence < sal_Int8 >& ZipPackageStream::static_get ZipPackageStream::ZipPackageStream ( ZipPackage & rNewPackage, const Reference< XMultiServiceFactory >& xFactory, - sal_Bool bAllowRemoveOnInsert ) + sal_Bool bAllowRemoveOnInsert ) : m_xFactory( xFactory ) , rZipPackage(rNewPackage) , bToBeCompressed ( sal_True ) @@ -82,7 +83,7 @@ ZipPackageStream::ZipPackageStream ( ZipPackage & rNewPackage, , m_bHasSeekable( sal_False ) , m_bCompressedIsSetFromOutside( sal_False ) , m_bFromManifest( sal_False ) -{ +{ OSL_ENSURE( m_xFactory.is(), "No factory is provided to ZipPackageStream!\n" ); this->mbAllowRemoveOnInsert = bAllowRemoveOnInsert; @@ -164,7 +165,7 @@ uno::Reference< io::XInputStream > ZipPackageStream::GetRawEncrStreamNoHeaderCop if ( m_nStreamMode != PACKAGE_STREAM_RAW || !GetOwnSeekStream().is() ) throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); - if ( xEncryptionData.isEmpty() ) + if ( !xEncryptionData.is() ) throw ZipIOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Encrypted stream without encryption data!\n" ) ), Reference< XInterface >() ); @@ -174,11 +175,11 @@ uno::Reference< io::XInputStream > ZipPackageStream::GetRawEncrStreamNoHeaderCop Reference< XInterface >() ); // skip header - xSeek->seek( n_ConstHeaderSize + xEncryptionData->aInitVector.getLength() + + xSeek->seek( n_ConstHeaderSize + xEncryptionData->aInitVector.getLength() + xEncryptionData->aSalt.getLength() + xEncryptionData->aDigest.getLength() ); // create temporary stream - uno::Reference < io::XOutputStream > xTempOut( + uno::Reference < io::XOutputStream > xTempOut( m_xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.io.TempFile" ) ) ), uno::UNO_QUERY ); uno::Reference < io::XInputStream > xTempIn( xTempOut, UNO_QUERY ); @@ -201,10 +202,10 @@ Reference< io::XInputStream > ZipPackageStream::TryToGetRawFromDataStream( sal_B throw packages::NoEncryptionException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); Sequence< sal_Int8 > aKey; - + if ( bToBeEncrypted ) { - aKey = ( xEncryptionData.isEmpty() || !bHaveOwnKey ) ? rZipPackage.getEncryptionKey() : + aKey = ( !xEncryptionData.is() || !bHaveOwnKey ) ? rZipPackage.getEncryptionKey() : xEncryptionData->aKey; if ( !aKey.getLength() ) throw packages::NoEncryptionException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); @@ -213,30 +214,30 @@ Reference< io::XInputStream > ZipPackageStream::TryToGetRawFromDataStream( sal_B try { // create temporary file - uno::Reference < io::XStream > xTempStream( + uno::Reference < io::XStream > xTempStream( m_xFactory->createInstance ( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.io.TempFile" ) ) ), uno::UNO_QUERY ); if ( !xTempStream.is() ) throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); - + // create a package based on it ZipPackage* pPackage = new ZipPackage( m_xFactory ); Reference< XSingleServiceFactory > xPackageAsFactory( static_cast< XSingleServiceFactory* >( pPackage ) ); if ( !xPackageAsFactory.is() ) throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); - + Sequence< Any > aArgs( 1 ); aArgs[0] <<= xTempStream; pPackage->initialize( aArgs ); - + // create a new package stream Reference< XDataSinkEncrSupport > xNewPackStream( xPackageAsFactory->createInstance(), UNO_QUERY ); if ( !xNewPackStream.is() ) throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); - + xNewPackStream->setDataStream( static_cast< io::XInputStream* >( new WrapStreamForShare( GetOwnSeekStream(), rZipPackage.GetSharedMutexRef() ) ) ); - + Reference< XPropertySet > xNewPSProps( xNewPackStream, UNO_QUERY ); if ( !xNewPSProps.is() ) throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); @@ -257,7 +258,7 @@ Reference< io::XInputStream > ZipPackageStream::TryToGetRawFromDataStream( sal_B Reference< container::XNameContainer > xRootNameContainer( xTunnel, UNO_QUERY ); if ( !xRootNameContainer.is() ) throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); - + Reference< XUnoTunnel > xNPSTunnel( xNewPackStream, UNO_QUERY ); xRootNameContainer->insertByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "dummy" ) ), makeAny( xNPSTunnel ) ); @@ -270,9 +271,9 @@ Reference< io::XInputStream > ZipPackageStream::TryToGetRawFromDataStream( sal_B xInRaw = xNewPackStream->getRawStream(); else xInRaw = xNewPackStream->getPlainRawStream(); - + // create another temporary file - uno::Reference < io::XOutputStream > xTempOut( + uno::Reference < io::XOutputStream > xTempOut( m_xFactory->createInstance ( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.io.TempFile" ) ) ), uno::UNO_QUERY ); uno::Reference < io::XInputStream > xTempIn( xTempOut, UNO_QUERY ); @@ -306,7 +307,7 @@ Reference< io::XInputStream > ZipPackageStream::TryToGetRawFromDataStream( sal_B throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); } - + //-------------------------------------------------------------------------- sal_Bool ZipPackageStream::ParsePackageRawStream() { @@ -317,11 +318,11 @@ sal_Bool ZipPackageStream::ParsePackageRawStream() sal_Bool bOk = sal_False; - vos::ORef < EncryptionData > xTempEncrData; + rtl::Reference < EncryptionData > xTempEncrData; sal_Int32 nMagHackSize = 0; Sequence < sal_Int8 > aHeader ( 4 ); - try + try { if ( GetOwnSeekStream()->readBytes ( aHeader, 4 ) == 4 ) { @@ -334,19 +335,19 @@ sal_Bool ZipPackageStream::ParsePackageRawStream() { // this is one of our god-awful, but extremely devious hacks, everyone cheer xTempEncrData = new EncryptionData; - + ::rtl::OUString aMediaType; if ( ZipFile::StaticFillData ( xTempEncrData, nMagHackSize, aMediaType, GetOwnSeekStream() ) ) { // We'll want to skip the data we've just read, so calculate how much we just read // and remember it - m_nMagicalHackPos = n_ConstHeaderSize + xTempEncrData->aSalt.getLength() + m_nMagicalHackPos = n_ConstHeaderSize + xTempEncrData->aSalt.getLength() + xTempEncrData->aInitVector.getLength() + xTempEncrData->aDigest.getLength() + aMediaType.getLength() * sizeof( sal_Unicode ); m_nMagicalHackSize = nMagHackSize; sMediaType = aMediaType; - + bOk = sal_True; } } @@ -371,7 +372,7 @@ sal_Bool ZipPackageStream::ParsePackageRawStream() } void ZipPackageStream::SetPackageMember( sal_Bool bNewValue ) -{ +{ if ( bNewValue ) { m_nStreamMode = PACKAGE_STREAM_PACKAGEMEMBER; @@ -384,7 +385,7 @@ void ZipPackageStream::SetPackageMember( sal_Bool bNewValue ) // XActiveDataSink //-------------------------------------------------------------------------- -void SAL_CALL ZipPackageStream::setInputStream( const Reference< io::XInputStream >& aStream ) +void SAL_CALL ZipPackageStream::setInputStream( const Reference< io::XInputStream >& aStream ) throw(RuntimeException) { // if seekable access is required the wrapping will be done on demand @@ -403,7 +404,7 @@ Reference< io::XInputStream > SAL_CALL ZipPackageStream::getRawData() { if (IsPackageMember()) { - if ( !xEncryptionData.isEmpty() && !bHaveOwnKey ) + if ( xEncryptionData.is() && !bHaveOwnKey ) xEncryptionData->aKey = rZipPackage.getEncryptionKey(); return rZipPackage.getZipFile().getRawData( aEntry, xEncryptionData, bIsEncrypted, rZipPackage.GetSharedMutexRef() ); } @@ -427,14 +428,14 @@ Reference< io::XInputStream > SAL_CALL ZipPackageStream::getRawData() } //-------------------------------------------------------------------------- -Reference< io::XInputStream > SAL_CALL ZipPackageStream::getInputStream( ) +Reference< io::XInputStream > SAL_CALL ZipPackageStream::getInputStream( ) throw(RuntimeException) { try { if (IsPackageMember()) { - if ( !xEncryptionData.isEmpty() && !bHaveOwnKey ) + if ( xEncryptionData.is() && !bHaveOwnKey ) xEncryptionData->aKey = rZipPackage.getEncryptionKey(); return rZipPackage.getZipFile().getInputStream( aEntry, xEncryptionData, bIsEncrypted, rZipPackage.GetSharedMutexRef() ); } @@ -472,12 +473,12 @@ Reference< io::XInputStream > SAL_CALL ZipPackageStream::getDataStream() if ( m_nStreamMode == PACKAGE_STREAM_DETECT ) throw packages::zip::ZipIOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); - if ( !xEncryptionData.isEmpty() && !bHaveOwnKey ) + if ( xEncryptionData.is() && !bHaveOwnKey ) xEncryptionData->aKey = rZipPackage.getEncryptionKey(); if (IsPackageMember()) { - if ( !xEncryptionData.isEmpty() && !bHaveOwnKey ) + if ( xEncryptionData.is() && !bHaveOwnKey ) xEncryptionData->aKey = rZipPackage.getEncryptionKey(); return rZipPackage.getZipFile().getDataStream( aEntry, xEncryptionData, bIsEncrypted, rZipPackage.GetSharedMutexRef() ); @@ -508,7 +509,7 @@ Reference< io::XInputStream > SAL_CALL ZipPackageStream::getRawStream() if (IsPackageMember()) { - if ( !bIsEncrypted || xEncryptionData.isEmpty() ) + if ( !bIsEncrypted || !xEncryptionData.is() ) throw packages::NoEncryptionException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); return rZipPackage.getZipFile().getWrappedRawStream( aEntry, xEncryptionData, sMediaType, rZipPackage.GetSharedMutexRef() ); @@ -522,7 +523,7 @@ Reference< io::XInputStream > SAL_CALL ZipPackageStream::getRawStream() else if ( m_nStreamMode == PACKAGE_STREAM_DATA && bToBeEncrypted ) return TryToGetRawFromDataStream( sal_True ); } - + throw packages::NoEncryptionException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); } @@ -561,7 +562,7 @@ void SAL_CALL ZipPackageStream::setRawStream( const Reference< io::XInputStream // the raw stream MUST have seekable access m_bHasSeekable = sal_True; - + SetPackageMember ( sal_False ); aEntry.nTime = -1; m_nStreamMode = PACKAGE_STREAM_RAW; @@ -594,18 +595,18 @@ uno::Reference< io::XInputStream > SAL_CALL ZipPackageStream::getPlainRawStream( else if ( m_nStreamMode == PACKAGE_STREAM_DATA ) return TryToGetRawFromDataStream( sal_False ); } - + return Reference< io::XInputStream >(); } // XUnoTunnel //-------------------------------------------------------------------------- -sal_Int64 SAL_CALL ZipPackageStream::getSomething( const Sequence< sal_Int8 >& aIdentifier ) +sal_Int64 SAL_CALL ZipPackageStream::getSomething( const Sequence< sal_Int8 >& aIdentifier ) throw(RuntimeException) -{ +{ sal_Int64 nMe = 0; - if ( aIdentifier.getLength() == 16 && + if ( aIdentifier.getLength() == 16 && 0 == rtl_compareMemory( static_getImplementationId().getConstArray(), aIdentifier.getConstArray(), 16 ) ) nMe = reinterpret_cast < sal_Int64 > ( this ); return nMe; @@ -613,7 +614,7 @@ sal_Int64 SAL_CALL ZipPackageStream::getSomething( const Sequence< sal_Int8 >& a // XPropertySet //-------------------------------------------------------------------------- -void SAL_CALL ZipPackageStream::setPropertyValue( const OUString& aPropertyName, const Any& aValue ) +void SAL_CALL ZipPackageStream::setPropertyValue( const OUString& aPropertyName, const Any& aValue ) throw(beans::UnknownPropertyException, beans::PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException) { if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("MediaType"))) @@ -660,7 +661,7 @@ void SAL_CALL ZipPackageStream::setPropertyValue( const OUString& aPropertyName, 2 ); bToBeEncrypted = bEnc; - if ( bToBeEncrypted && xEncryptionData.isEmpty()) + if ( bToBeEncrypted && !xEncryptionData.is()) xEncryptionData = new EncryptionData; } else @@ -697,7 +698,7 @@ void SAL_CALL ZipPackageStream::setPropertyValue( const OUString& aPropertyName, if ( aNewKey.getLength() ) { - if ( xEncryptionData.isEmpty()) + if ( !xEncryptionData.is()) xEncryptionData = new EncryptionData; xEncryptionData->aKey = aNewKey; @@ -712,7 +713,7 @@ void SAL_CALL ZipPackageStream::setPropertyValue( const OUString& aPropertyName, else if (aPropertyName.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "Compressed" ) ) ) { sal_Bool bCompr = sal_False; - + if ( aValue >>= bCompr ) { // In case of new raw stream, the stream must not be encrypted on storing @@ -734,7 +735,7 @@ void SAL_CALL ZipPackageStream::setPropertyValue( const OUString& aPropertyName, } //-------------------------------------------------------------------------- -Any SAL_CALL ZipPackageStream::getPropertyValue( const OUString& PropertyName ) +Any SAL_CALL ZipPackageStream::getPropertyValue( const OUString& PropertyName ) throw(beans::UnknownPropertyException, WrappedTargetException, RuntimeException) { Any aAny; @@ -765,7 +766,7 @@ Any SAL_CALL ZipPackageStream::getPropertyValue( const OUString& PropertyName ) } else if (PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "EncryptionKey" ) ) ) { - aAny <<= xEncryptionData.isEmpty () ? Sequence < sal_Int8 > () : xEncryptionData->aKey; + aAny <<= !xEncryptionData.is() ? Sequence < sal_Int8 > () : xEncryptionData->aKey; return aAny; } else @@ -774,7 +775,7 @@ Any SAL_CALL ZipPackageStream::getPropertyValue( const OUString& PropertyName ) //-------------------------------------------------------------------------- void ZipPackageStream::setSize (const sal_Int32 nNewSize) -{ +{ if (aEntry.nCompressedSize != nNewSize ) aEntry.nMethod = DEFLATED; aEntry.nSize = nNewSize; diff --git a/package/source/zippackage/ZipPackageStream.hxx b/package/source/zippackage/ZipPackageStream.hxx index 510ab6982..f5738cf8a 100644 --- a/package/source/zippackage/ZipPackageStream.hxx +++ b/package/source/zippackage/ZipPackageStream.hxx @@ -31,7 +31,7 @@ #include <com/sun/star/io/XSeekable.hpp> #include <com/sun/star/packages/XDataSinkEncrSupport.hpp> #include <ZipPackageEntry.hxx> -#include <vos/ref.hxx> +#include <rtl/ref.hxx> #include <EncryptionData.hxx> #include <cppuhelper/implbase2.hxx> #include <mutexholder.hxx> @@ -56,7 +56,7 @@ protected: const ::com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > m_xFactory; ZipPackage &rZipPackage; sal_Bool bToBeCompressed, bToBeEncrypted, bHaveOwnKey, bIsEncrypted; - vos::ORef < EncryptionData > xEncryptionData; + rtl::Reference < EncryptionData > xEncryptionData; sal_uInt8 m_nStreamMode; sal_uInt32 m_nMagicalHackPos; @@ -80,7 +80,7 @@ public: sal_Bool IsFromManifest() const { return m_bFromManifest; } void SetFromManifest( sal_Bool bValue ) { m_bFromManifest = bValue; } - vos::ORef < EncryptionData > & getEncryptionData () + rtl::Reference < EncryptionData > & getEncryptionData () { return xEncryptionData;} const com::sun::star::uno::Sequence < sal_Int8 >& getKey () const { return xEncryptionData->aKey;} @@ -104,10 +104,10 @@ public: void SetToBeEncrypted (sal_Bool bNewValue) { bToBeEncrypted = bNewValue; - if ( bToBeEncrypted && xEncryptionData.isEmpty()) + if ( bToBeEncrypted && !xEncryptionData.is()) xEncryptionData = new EncryptionData; - else if ( !bToBeEncrypted && !xEncryptionData.isEmpty() ) - xEncryptionData.unbind(); + else if ( !bToBeEncrypted && xEncryptionData.is() ) + xEncryptionData.clear(); } void SetPackageMember (sal_Bool bNewValue); void setKey (const com::sun::star::uno::Sequence < sal_Int8 >& rNewKey ) |