summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2011-03-18 15:35:18 +0100
committerJan Holesovsky <kendy@suse.cz>2011-03-18 15:35:18 +0100
commit6a75a47be7b3aafbb655ffa70609fd2ed7ca4b3e (patch)
treed00d2024213e09b8eba4704b8b6660eb42c3921c /package
parent7fb1e1ea8c9f8d3ef13524d1327272824df7110d (diff)
parenteee3dbc7af039669d447d2e55abd896ea3383df1 (diff)
Merge remote-tracking branch 'origin/integration/dev300_m101'
Conflicts: automation/source/communi/communi.cxx automation/source/server/recorder.cxx automation/source/server/server.cxx basctl/source/basicide/basobj2.cxx
Diffstat (limited to 'package')
-rw-r--r--package/prj/build.lst2
-rw-r--r--package/prj/d.lst2
-rw-r--r--package/source/manifest/UnoRegister.cxx63
-rw-r--r--package/source/xstor/makefile.mk8
-rw-r--r--package/source/xstor/ohierarchyholder.cxx21
-rw-r--r--package/source/xstor/ohierarchyholder.hxx18
-rw-r--r--package/source/xstor/owriteablestream.cxx206
-rw-r--r--package/source/xstor/owriteablestream.hxx40
-rw-r--r--package/source/xstor/register.cxx28
-rw-r--r--package/source/xstor/xstor.component35
-rw-r--r--package/source/xstor/xstor.dxp1
-rw-r--r--package/source/xstor/xstorage.cxx586
-rw-r--r--package/source/xstor/xstorage.hxx66
-rw-r--r--package/source/zippackage/ZipPackage.cxx2
-rw-r--r--package/source/zippackage/ZipPackageFolder.cxx62
-rw-r--r--package/source/zippackage/ZipPackageStream.cxx1
-rw-r--r--package/util/exports.dxp1
-rw-r--r--package/util/makefile.mk8
-rw-r--r--package/util/package2.component44
19 files changed, 683 insertions, 511 deletions
diff --git a/package/prj/build.lst b/package/prj/build.lst
index 0b508271765c..6afa434558a4 100644
--- a/package/prj/build.lst
+++ b/package/prj/build.lst
@@ -1,4 +1,4 @@
-pk package : cppu cppuhelper comphelper ucbhelper sal ZLIB:zlib NULL
+pk package : cppu cppuhelper comphelper ucbhelper sal ZLIB:zlib LIBXSLT:libxslt NULL
pk package usr1 - all pk_mkout NULL
pk package\inc nmake - all pk_inc NULL
pk package\source\zipapi nmake - all pk_zipapi pk_inc NULL
diff --git a/package/prj/d.lst b/package/prj/d.lst
index 23966d0cfeae..919a1719aa09 100644
--- a/package/prj/d.lst
+++ b/package/prj/d.lst
@@ -3,3 +3,5 @@
..\%__SRC%\lib\lib*.so %_DEST%\lib%_EXT%\lib*.so
..\%__SRC%\lib\*.dylib %_DEST%\lib%_EXT%\*.dylib
..\dtd\*.dtd %_DEST%\bin%_EXT%\*.*
+..\%__SRC%\misc\package2.component %_DEST%\xml%_EXT%\package2.component
+..\%__SRC%\misc\xstor.component %_DEST%\xml%_EXT%\xstor.component
diff --git a/package/source/manifest/UnoRegister.cxx b/package/source/manifest/UnoRegister.cxx
index 51b7ea431de5..e8bf0e9604d3 100644
--- a/package/source/manifest/UnoRegister.cxx
+++ b/package/source/manifest/UnoRegister.cxx
@@ -46,43 +46,6 @@ using namespace ::com::sun::star::packages::manifest;
using rtl::OUString;
-static sal_Bool writeInfo( void * pRegistryKey,
- const OUString & rImplementationName,
- Sequence< OUString > const & rServiceNames )
-{
- OUString aKeyName( OUString(RTL_CONSTASCII_USTRINGPARAM( "/" )) );
- aKeyName += rImplementationName;
- aKeyName += OUString(RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES" ));
-
- Reference< XRegistryKey > xKey;
- try
- {
- xKey = static_cast< XRegistryKey * >(
- pRegistryKey )->createKey( aKeyName );
- }
- catch ( InvalidRegistryException const & )
- {
- }
-
- if ( !xKey.is() )
- return sal_False;
-
- sal_Bool bSuccess = sal_True;
-
- for ( sal_Int32 n = 0; n < rServiceNames.getLength(); ++n )
- {
- try
- {
- xKey->createKey( rServiceNames[ n ] );
- }
- catch ( InvalidRegistryException const & )
- {
- bSuccess = sal_False;
- break;
- }
- }
- return bSuccess;
-}
// C functions to implement this as a component
extern "C" void SAL_CALL component_getImplementationEnvironment(
@@ -92,32 +55,6 @@ extern "C" void SAL_CALL component_getImplementationEnvironment(
}
/**
- * This function creates an implementation section in the registry and another subkey
- * for each supported service.
- * @param pServiceManager generic uno interface providing a service manager
- * @param pRegistryKey generic uno interface providing registry key to write
- */
-extern "C" sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey )
-{
- return pRegistryKey &&
- writeInfo (pRegistryKey,
- ManifestReader::static_getImplementationName(),
- ManifestReader::static_getSupportedServiceNames() ) &&
- writeInfo (pRegistryKey,
- ManifestWriter::static_getImplementationName(),
- ManifestWriter::static_getSupportedServiceNames() ) &&
- writeInfo (pRegistryKey,
- ZipPackage::static_getImplementationName(),
- ZipPackage::static_getSupportedServiceNames() ) &&
-
- writeInfo (pRegistryKey,
- OZipFileAccess::impl_staticGetImplementationName(),
- OZipFileAccess::impl_staticGetSupportedServiceNames() );
-
-}
-
-
-/**
* This function is called to get service factories for an implementation.
* @param pImplName name of implementation
* @param pServiceManager generic uno interface providing a service manager to instantiate components
diff --git a/package/source/xstor/makefile.mk b/package/source/xstor/makefile.mk
index 76494cb7dbe7..5c381ba4c803 100644
--- a/package/source/xstor/makefile.mk
+++ b/package/source/xstor/makefile.mk
@@ -73,3 +73,11 @@ DEF1EXPORTFILE=$(SHL1TARGET).dxp
.INCLUDE : target.mk
+
+ALLTAR : $(MISC)/xstor.component
+
+$(MISC)/xstor.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \
+ xstor.component
+ $(XSLTPROC) --nonet --stringparam uri \
+ '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \
+ $(SOLARENV)/bin/createcomponent.xslt xstor.component
diff --git a/package/source/xstor/ohierarchyholder.cxx b/package/source/xstor/ohierarchyholder.cxx
index bfccbf6449a1..8a4908e27cbc 100644
--- a/package/source/xstor/ohierarchyholder.cxx
+++ b/package/source/xstor/ohierarchyholder.cxx
@@ -30,7 +30,7 @@
#include "precompiled_package.hxx"
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/embed/ElementModes.hpp>
-#include <com/sun/star/embed/XHierarchicalStorageAccess.hpp>
+#include <com/sun/star/embed/XHierarchicalStorageAccess2.hpp>
#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
#include "ohierarchyholder.hxx"
@@ -42,7 +42,7 @@ using namespace ::com::sun::star;
//===============================================
//-----------------------------------------------
-uno::Reference< embed::XExtendedStorageStream > OHierarchyHolder_Impl::GetStreamHierarchically( sal_Int32 nStorageMode, OStringList_Impl& aListPath, sal_Int32 nStreamMode, const ::rtl::OUString& aPass )
+uno::Reference< embed::XExtendedStorageStream > OHierarchyHolder_Impl::GetStreamHierarchically( sal_Int32 nStorageMode, OStringList_Impl& aListPath, sal_Int32 nStreamMode, const ::comphelper::SequenceAsHashMap& aEncryptionData )
{
uno::Reference< embed::XStorage > xOwnStor( m_xWeakOwnStorage.get(), uno::UNO_QUERY_THROW );
@@ -50,7 +50,7 @@ uno::Reference< embed::XExtendedStorageStream > OHierarchyHolder_Impl::GetStream
throw io::IOException();
uno::Reference< embed::XExtendedStorageStream > xResult =
- m_xChild->GetStreamHierarchically( nStorageMode, aListPath, nStreamMode, aPass );
+ m_xChild->GetStreamHierarchically( nStorageMode, aListPath, nStreamMode, aEncryptionData );
if ( !xResult.is() )
throw uno::RuntimeException();
@@ -89,7 +89,7 @@ OStringList_Impl OHierarchyHolder_Impl::GetListPathFromString( const ::rtl::OUSt
//===============================================
//-----------------------------------------------
-uno::Reference< embed::XExtendedStorageStream > OHierarchyElement_Impl::GetStreamHierarchically( sal_Int32 nStorageMode, OStringList_Impl& aListPath, sal_Int32 nStreamMode, const ::rtl::OUString& aPass )
+uno::Reference< embed::XExtendedStorageStream > OHierarchyElement_Impl::GetStreamHierarchically( sal_Int32 nStorageMode, OStringList_Impl& aListPath, sal_Int32 nStreamMode, const ::comphelper::SequenceAsHashMap& aEncryptionData )
{
::osl::MutexGuard aGuard( m_aMutex );
@@ -111,11 +111,16 @@ uno::Reference< embed::XExtendedStorageStream > OHierarchyElement_Impl::GetStrea
if ( !aListPath.size() )
{
- uno::Reference< embed::XHierarchicalStorageAccess > xHStorage( xOwnStor, uno::UNO_QUERY_THROW );
- if ( !aPass.getLength() )
+ if ( !aEncryptionData.size() )
+ {
+ uno::Reference< embed::XHierarchicalStorageAccess > xHStorage( xOwnStor, uno::UNO_QUERY_THROW );
xResult = xHStorage->openStreamElementByHierarchicalName( aNextName, nStreamMode );
+ }
else
- xResult = xHStorage->openEncryptedStreamElementByHierarchicalName( aNextName, nStreamMode, aPass );
+ {
+ uno::Reference< embed::XHierarchicalStorageAccess2 > xHStorage( xOwnStor, uno::UNO_QUERY_THROW );
+ xResult = xHStorage->openEncryptedStreamByHierarchicalName( aNextName, nStreamMode, aEncryptionData.getAsConstNamedValueList() );
+ }
uno::Reference< embed::XTransactedObject > xTransact( xResult, uno::UNO_QUERY );
if ( xTransact.is() )
@@ -151,7 +156,7 @@ uno::Reference< embed::XExtendedStorageStream > OHierarchyElement_Impl::GetStrea
aElement = new OHierarchyElement_Impl( NULL, xChildStorage );
}
- xResult = aElement->GetStreamHierarchically( nStorageMode, aListPath, nStreamMode, aPass );
+ xResult = aElement->GetStreamHierarchically( nStorageMode, aListPath, nStreamMode, aEncryptionData );
if ( !xResult.is() )
throw uno::RuntimeException();
diff --git a/package/source/xstor/ohierarchyholder.hxx b/package/source/xstor/ohierarchyholder.hxx
index 8a8f6a3f6ae1..15c207ff5ab9 100644
--- a/package/source/xstor/ohierarchyholder.hxx
+++ b/package/source/xstor/ohierarchyholder.hxx
@@ -34,6 +34,8 @@
#include <com/sun/star/embed/XExtendedStorageStream.hpp>
#include <cppuhelper/implbase1.hxx>
+#include <comphelper/sequenceashashmap.hxx>
+
#include <rtl/ref.hxx>
#include <boost/unordered_map.hpp>
@@ -91,10 +93,10 @@ public:
void RemoveElement( const ::rtl::Reference< OHierarchyElement_Impl >& aRef );
::com::sun::star::uno::Reference< ::com::sun::star::embed::XExtendedStorageStream >
- GetStreamHierarchically( sal_Int32 nStorageMode,
- OStringList_Impl& aPath,
- sal_Int32 nStreamMode,
- const ::rtl::OUString& aPassword = ::rtl::OUString() );
+ GetStreamHierarchically( sal_Int32 nStorageMode,
+ OStringList_Impl& aPath,
+ sal_Int32 nStreamMode,
+ const ::comphelper::SequenceAsHashMap& aEncryptionData = ::comphelper::SequenceAsHashMap() );
void RemoveStreamHierarchically( OStringList_Impl& aListPath );
@@ -128,10 +130,10 @@ public:
static OStringList_Impl GetListPathFromString( const ::rtl::OUString& aPath );
::com::sun::star::uno::Reference< ::com::sun::star::embed::XExtendedStorageStream >
- GetStreamHierarchically( sal_Int32 nStorageMode,
- OStringList_Impl& aListPath,
- sal_Int32 nStreamMode,
- const ::rtl::OUString& aPassword = ::rtl::OUString() );
+ GetStreamHierarchically( sal_Int32 nStorageMode,
+ OStringList_Impl& aListPath,
+ sal_Int32 nStreamMode,
+ const ::comphelper::SequenceAsHashMap& aEncryptionData = ::comphelper::SequenceAsHashMap() );
void RemoveStreamHierarchically( OStringList_Impl& aListPath );
};
diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx
index c95c46113d67..bb1eb8598705 100644
--- a/package/source/xstor/owriteablestream.cxx
+++ b/package/source/xstor/owriteablestream.cxx
@@ -66,29 +66,25 @@ using namespace ::com::sun::star;
namespace package
{
//-----------------------------------------------
-uno::Sequence< sal_Int8 > MakeKeyFromPass( const ::rtl::OUString& aPass, sal_Bool bUseUTF )
+bool PackageEncryptionDatasEqual( const ::comphelper::SequenceAsHashMap& aHash1, const ::comphelper::SequenceAsHashMap& aHash2 )
{
- // MS_1252 encoding was used for SO60 document format password encoding,
- // this encoding supports only a minor subset of nonascii characters,
- // but for compatibility reasons it has to be used for old document formats
-
- ::rtl::OString aByteStrPass;
- if ( bUseUTF )
- aByteStrPass = ::rtl::OUStringToOString( aPass, RTL_TEXTENCODING_UTF8 );
- else
- aByteStrPass = ::rtl::OUStringToOString( aPass, RTL_TEXTENCODING_MS_1252 );
-
- sal_uInt8 pBuffer[RTL_DIGEST_LENGTH_SHA1];
- rtlDigestError nError = rtl_digest_SHA1( aByteStrPass.getStr(),
- aByteStrPass.getLength(),
- pBuffer,
- RTL_DIGEST_LENGTH_SHA1 );
-
- if ( nError != rtl_Digest_E_None )
- throw uno::RuntimeException();
-
- return uno::Sequence< sal_Int8 >( (sal_Int8*)pBuffer, RTL_DIGEST_LENGTH_SHA1 );
+ bool bResult = ( aHash1.size() && aHash1.size() == aHash2.size() );
+ for ( ::comphelper::SequenceAsHashMap::const_iterator aIter = aHash1.begin();
+ bResult && aIter != aHash1.end();
+ aIter++ )
+ {
+ uno::Sequence< sal_Int8 > aKey1;
+ bResult = ( ( aIter->second >>= aKey1 ) && aKey1.getLength() );
+ if ( bResult )
+ {
+ uno::Sequence< sal_Int8 > aKey2 = aHash2.getUnpackedValueOrDefault( aIter->first, uno::Sequence< sal_Int8 >() );
+ bResult = ( aKey1.getLength() == aKey2.getLength() );
+ for ( sal_Int32 nInd = 0; bResult && nInd < aKey1.getLength(); nInd++ )
+ bResult = ( aKey1[nInd] == aKey2[nInd] );
+ }
+ }
+ return bResult;
}
//-----------------------------------------------
@@ -257,8 +253,8 @@ OWriteStream_Impl::OWriteStream_Impl( OStorage_Impl* pParent,
, m_xFactory( xFactory )
, m_pParent( pParent )
, m_bForceEncrypted( bForceEncrypted )
-, m_bUseCommonPass( !bForceEncrypted && nStorageType == embed::StorageFormats::PACKAGE )
-, m_bHasCachedPassword( sal_False )
+, m_bUseCommonEncryption( !bForceEncrypted && nStorageType == embed::StorageFormats::PACKAGE )
+, m_bHasCachedEncryptionData( sal_False )
, m_bCompressedSetExplicit( !bDefaultCompress )
, m_xPackage( xPackage )
, m_bHasInsertedStreamOptimization( sal_False )
@@ -365,7 +361,7 @@ sal_Bool OWriteStream_Impl::IsEncrypted()
if ( m_nStorageType != embed::StorageFormats::PACKAGE )
return sal_False;
- if ( m_bForceEncrypted || m_bHasCachedPassword )
+ if ( m_bForceEncrypted || m_bHasCachedEncryptionData )
return sal_True;
if ( m_aTempURL.getLength() || m_xCacheStream.is() )
@@ -412,7 +408,7 @@ sal_Bool OWriteStream_Impl::IsEncrypted()
if ( !bWasEncr && bToBeEncr && !aKey.getLength() )
{
// the stream is intended to use common storage password
- m_bUseCommonPass = sal_True;
+ m_bUseCommonEncryption = sal_True;
return sal_False;
}
else
@@ -434,8 +430,8 @@ void OWriteStream_Impl::SetDecrypted()
// remove encryption
m_bForceEncrypted = sal_False;
- m_bHasCachedPassword = sal_False;
- m_aPass = ::rtl::OUString();
+ m_bHasCachedEncryptionData = sal_False;
+ m_aEncryptionData.clear();
for ( sal_Int32 nInd = 0; nInd < m_aProps.getLength(); nInd++ )
{
@@ -445,12 +441,15 @@ void OWriteStream_Impl::SetDecrypted()
}
//-----------------------------------------------
-void OWriteStream_Impl::SetEncryptedWithPass( const ::rtl::OUString& aPass )
+void OWriteStream_Impl::SetEncrypted( const ::comphelper::SequenceAsHashMap& aEncryptionData )
{
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();
+ if ( !aEncryptionData.size() )
+ throw uno::RuntimeException();
+
GetStreamProperties();
// let the stream be modified
@@ -464,10 +463,10 @@ void OWriteStream_Impl::SetEncryptedWithPass( const ::rtl::OUString& aPass )
m_aProps[nInd].Value <<= sal_True;
}
- m_bUseCommonPass = sal_False; // very important to set it to false
+ m_bUseCommonEncryption = sal_False; // very important to set it to false
- m_bHasCachedPassword = sal_True;
- m_aPass = aPass;
+ m_bHasCachedEncryptionData = sal_True;
+ m_aEncryptionData = aEncryptionData;
}
//-----------------------------------------------
@@ -798,7 +797,7 @@ void OWriteStream_Impl::InsertStreamDirectly( const uno::Reference< io::XInputSt
xPropertySet->setPropertyValue( aProps[nInd].Name, aProps[nInd].Value );
}
else if ( m_nStorageType == embed::StorageFormats::PACKAGE && aProps[nInd].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "UseCommonStoragePasswordEncryption" ) ) )
- aProps[nInd].Value >>= m_bUseCommonPass;
+ aProps[nInd].Value >>= m_bUseCommonEncryption;
else
throw lang::IllegalArgumentException();
@@ -817,7 +816,7 @@ void OWriteStream_Impl::InsertStreamDirectly( const uno::Reference< io::XInputSt
m_bCompressedSetExplicit = sal_True;
}
- if ( m_bUseCommonPass )
+ if ( m_bUseCommonEncryption )
{
if ( m_nStorageType != embed::StorageFormats::PACKAGE )
throw uno::RuntimeException();
@@ -916,7 +915,7 @@ void OWriteStream_Impl::Commit()
xPropertySet->setPropertyValue( m_aProps[nInd].Name, m_aProps[nInd].Value );
}
- if ( m_bUseCommonPass )
+ if ( m_bUseCommonEncryption )
{
if ( m_nStorageType != embed::StorageFormats::PACKAGE )
throw uno::RuntimeException();
@@ -927,13 +926,13 @@ void OWriteStream_Impl::Commit()
xPropertySet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Encrypted") ),
uno::makeAny( sal_True ) );
}
- else if ( m_bHasCachedPassword )
+ else if ( m_bHasCachedEncryptionData )
{
if ( m_nStorageType != embed::StorageFormats::PACKAGE )
throw uno::RuntimeException();
xPropertySet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EncryptionKey") ),
- uno::makeAny( ::package::MakeKeyFromPass( m_aPass, sal_True ) ) );
+ uno::makeAny( m_aEncryptionData.getUnpackedValueOrDefault( PACKAGE_ENCRYPTIONDATA_SHA1UTF8, uno::Sequence< sal_Int8 >() ) ) );
}
// the stream should be free soon, after package is stored
@@ -971,9 +970,9 @@ void OWriteStream_Impl::Revert()
m_bHasDataToFlush = sal_False;
- m_bUseCommonPass = sal_True;
- m_bHasCachedPassword = sal_False;
- m_aPass = ::rtl::OUString();
+ m_bUseCommonEncryption = sal_True;
+ m_bHasCachedEncryptionData = sal_False;
+ m_aEncryptionData.clear();
if ( m_nStorageType == embed::StorageFormats::OFOPXML )
{
@@ -1009,7 +1008,7 @@ uno::Sequence< beans::PropertyValue > OWriteStream_Impl::GetStreamProperties()
//-----------------------------------------------
uno::Sequence< beans::PropertyValue > OWriteStream_Impl::InsertOwnProps(
const uno::Sequence< beans::PropertyValue >& aProps,
- sal_Bool bUseCommonPass )
+ sal_Bool bUseCommonEncryption )
{
uno::Sequence< beans::PropertyValue > aResult( aProps );
sal_Int32 nLen = aResult.getLength();
@@ -1019,13 +1018,13 @@ uno::Sequence< beans::PropertyValue > OWriteStream_Impl::InsertOwnProps(
for ( sal_Int32 nInd = 0; nInd < nLen; nInd++ )
if ( aResult[nInd].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "UseCommonStoragePasswordEncryption" ) ) )
{
- aResult[nInd].Value <<= bUseCommonPass;
+ aResult[nInd].Value <<= bUseCommonEncryption;
return aResult;
}
aResult.realloc( ++nLen );
aResult[nLen - 1].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseCommonStoragePasswordEncryption") );
- aResult[nLen - 1].Value <<= bUseCommonPass;
+ aResult[nLen - 1].Value <<= bUseCommonEncryption;
}
else if ( m_nStorageType == embed::StorageFormats::OFOPXML )
{
@@ -1174,11 +1173,11 @@ uno::Sequence< beans::PropertyValue > OWriteStream_Impl::ReadPackageStreamProper
//-----------------------------------------------
void OWriteStream_Impl::CopyInternallyTo_Impl( const uno::Reference< io::XStream >& xDestStream,
- const ::rtl::OUString& aPass )
+ const ::comphelper::SequenceAsHashMap& aEncryptionData )
{
::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() ) ;
- OSL_ENSURE( !m_bUseCommonPass, "The stream can not be encrypted!" );
+ OSL_ENSURE( !m_bUseCommonEncryption, "The stream can not be encrypted!" );
if ( m_nStorageType != embed::StorageFormats::PACKAGE )
throw packages::NoEncryptionException();
@@ -1189,16 +1188,16 @@ void OWriteStream_Impl::CopyInternallyTo_Impl( const uno::Reference< io::XStream
}
else
{
- uno::Reference< io::XStream > xOwnStream = GetStream( embed::ElementModes::READ, aPass, sal_False );
+ uno::Reference< io::XStream > xOwnStream = GetStream( embed::ElementModes::READ, aEncryptionData, sal_False );
if ( !xOwnStream.is() )
throw io::IOException(); // TODO
OStorage_Impl::completeStorageStreamCopy_Impl( xOwnStream, xDestStream, m_nStorageType, GetAllRelationshipsIfAny() );
}
- uno::Reference< embed::XEncryptionProtectedSource > xEncr( xDestStream, uno::UNO_QUERY );
+ uno::Reference< embed::XEncryptionProtectedSource2 > xEncr( xDestStream, uno::UNO_QUERY );
if ( xEncr.is() )
- xEncr->setEncryptionPassword( aPass );
+ xEncr->setEncryptionData( aEncryptionData.getAsConstNamedValueList() );
}
//-----------------------------------------------
@@ -1238,7 +1237,7 @@ void OWriteStream_Impl::CopyInternallyTo_Impl( const uno::Reference< io::XStream
}
//-----------------------------------------------
-uno::Reference< io::XStream > OWriteStream_Impl::GetStream( sal_Int32 nStreamMode, const ::rtl::OUString& aPass, sal_Bool bHierarchyAccess )
+uno::Reference< io::XStream > OWriteStream_Impl::GetStream( sal_Int32 nStreamMode, const ::comphelper::SequenceAsHashMap& aEncryptionData, sal_Bool bHierarchyAccess )
{
::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() ) ;
@@ -1256,9 +1255,9 @@ uno::Reference< io::XStream > OWriteStream_Impl::GetStream( sal_Int32 nStreamMod
if ( !xPropertySet.is() )
throw uno::RuntimeException();
- if ( m_bHasCachedPassword )
+ if ( m_bHasCachedEncryptionData )
{
- if ( !m_aPass.equals( aPass ) )
+ if ( !::package::PackageEncryptionDatasEqual( m_aEncryptionData, aEncryptionData ) )
throw packages::WrongPasswordException();
// the correct key must be set already
@@ -1266,26 +1265,26 @@ uno::Reference< io::XStream > OWriteStream_Impl::GetStream( sal_Int32 nStreamMod
}
else
{
- SetEncryptionKeyProperty_Impl( xPropertySet, ::package::MakeKeyFromPass( aPass, sal_True ) );
+ SetEncryptionKeyProperty_Impl( xPropertySet, aEncryptionData.getUnpackedValueOrDefault( PACKAGE_ENCRYPTIONDATA_SHA1UTF8, uno::Sequence< sal_Int8 >() ) );
try {
xResultStream = GetStream_Impl( nStreamMode, bHierarchyAccess );
- m_bUseCommonPass = sal_False; // very important to set it to false
- m_bHasCachedPassword = sal_True;
- m_aPass = aPass;
+ m_bUseCommonEncryption = sal_False; // very important to set it to false
+ m_bHasCachedEncryptionData = sal_True;
+ m_aEncryptionData = aEncryptionData;
}
catch( packages::WrongPasswordException& )
{
// retry with different encoding
- SetEncryptionKeyProperty_Impl( xPropertySet, ::package::MakeKeyFromPass( aPass, sal_False ) );
+ SetEncryptionKeyProperty_Impl( xPropertySet, aEncryptionData.getUnpackedValueOrDefault( PACKAGE_ENCRYPTIONDATA_SHA1MS1252, uno::Sequence< sal_Int8 >() ) );
try {
// the stream must be cashed to be resaved
xResultStream = GetStream_Impl( nStreamMode | embed::ElementModes::SEEKABLE, bHierarchyAccess );
- m_bUseCommonPass = sal_False; // very important to set it to false
- m_bHasCachedPassword = sal_True;
- m_aPass = aPass;
+ m_bUseCommonEncryption = sal_False; // very important to set it to false
+ m_bHasCachedEncryptionData = sal_True;
+ m_aEncryptionData = aEncryptionData;
// the stream must be resaved with new password encryption
if ( nStreamMode & embed::ElementModes::WRITE )
@@ -1345,10 +1344,10 @@ uno::Reference< io::XStream > OWriteStream_Impl::GetStream( sal_Int32 nStreamMod
if ( IsEncrypted() )
{
- ::rtl::OUString aGlobalPass;
+ ::comphelper::SequenceAsHashMap aGlobalEncryptionData;
try
{
- aGlobalPass = GetCommonRootPass();
+ aGlobalEncryptionData = GetCommonRootEncryptionData();
}
catch( packages::NoEncryptionException& aNoEncryptionException )
{
@@ -1358,7 +1357,7 @@ uno::Reference< io::XStream > OWriteStream_Impl::GetStream( sal_Int32 nStreamMod
throw packages::WrongPasswordException();
}
- xResultStream = GetStream( nStreamMode, aGlobalPass, bHierarchyAccess );
+ xResultStream = GetStream( nStreamMode, aGlobalEncryptionData, bHierarchyAccess );
}
else
xResultStream = GetStream_Impl( nStreamMode, bHierarchyAccess );
@@ -1387,7 +1386,7 @@ uno::Reference< io::XStream > OWriteStream_Impl::GetStream_Impl( sal_Int32 nStre
if ( !xInStream.is() )
throw io::IOException();
- OInputCompStream* pStream = new OInputCompStream( *this, xInStream, InsertOwnProps( m_aProps, m_bUseCommonPass ), m_nStorageType );
+ OInputCompStream* pStream = new OInputCompStream( *this, xInStream, InsertOwnProps( m_aProps, m_bUseCommonEncryption ), m_nStorageType );
uno::Reference< io::XStream > xCompStream(
static_cast< ::cppu::OWeakObject* >( pStream ),
uno::UNO_QUERY );
@@ -1412,7 +1411,7 @@ uno::Reference< io::XStream > OWriteStream_Impl::GetStream_Impl( sal_Int32 nStre
if ( !xInStream.is() )
throw io::IOException();
- OInputSeekStream* pStream = new OInputSeekStream( *this, xInStream, InsertOwnProps( m_aProps, m_bUseCommonPass ), m_nStorageType );
+ OInputSeekStream* pStream = new OInputSeekStream( *this, xInStream, InsertOwnProps( m_aProps, m_bUseCommonEncryption ), m_nStorageType );
uno::Reference< io::XStream > xSeekStream(
static_cast< ::cppu::OWeakObject* >( pStream ),
uno::UNO_QUERY );
@@ -1514,7 +1513,7 @@ uno::Reference< io::XInputStream > OWriteStream_Impl::GetRawInStream()
}
//-----------------------------------------------
-::rtl::OUString OWriteStream_Impl::GetCommonRootPass()
+::comphelper::SequenceAsHashMap OWriteStream_Impl::GetCommonRootEncryptionData()
throw ( packages::NoEncryptionException )
{
::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() ) ;
@@ -1522,7 +1521,7 @@ uno::Reference< io::XInputStream > OWriteStream_Impl::GetRawInStream()
if ( m_nStorageType != embed::StorageFormats::PACKAGE || !m_pParent )
throw packages::NoEncryptionException();
- return m_pParent->GetCommonRootPass();
+ return m_pParent->GetCommonRootEncryptionData();
}
//-----------------------------------------------
@@ -1561,11 +1560,11 @@ void OWriteStream_Impl::CreateReadonlyCopyBasedOnData( const uno::Reference< io:
if ( !xInStream.is() )
throw io::IOException();
- // TODO: remember last state of m_bUseCommonPass
+ // TODO: remember last state of m_bUseCommonEncryption
if ( !xTargetStream.is() )
xTargetStream = uno::Reference< io::XStream > (
static_cast< ::cppu::OWeakObject* >(
- new OInputSeekStream( xInStream, InsertOwnProps( aProps, m_bUseCommonPass ), m_nStorageType ) ),
+ new OInputSeekStream( xInStream, InsertOwnProps( aProps, m_bUseCommonEncryption ), m_nStorageType ) ),
uno::UNO_QUERY_THROW );
}
@@ -1582,10 +1581,10 @@ void OWriteStream_Impl::GetCopyOfLastCommit( uno::Reference< io::XStream >& xTar
if ( IsEncrypted() )
{
// an encrypted stream must contain input stream
- ::rtl::OUString aGlobalPass;
+ ::comphelper::SequenceAsHashMap aGlobalEncryptionData;
try
{
- aGlobalPass = GetCommonRootPass();
+ aGlobalEncryptionData = GetCommonRootEncryptionData();
}
catch( packages::NoEncryptionException& aNoEncryptionException )
{
@@ -1595,7 +1594,7 @@ void OWriteStream_Impl::GetCopyOfLastCommit( uno::Reference< io::XStream >& xTar
throw packages::WrongPasswordException();
}
- GetCopyOfLastCommit( xTargetStream, aGlobalPass );
+ GetCopyOfLastCommit( xTargetStream, aGlobalEncryptionData );
}
else
{
@@ -1604,12 +1603,12 @@ void OWriteStream_Impl::GetCopyOfLastCommit( uno::Reference< io::XStream >& xTar
// in case of new inserted package stream it is possible that input stream still was not set
GetStreamProperties();
- CreateReadonlyCopyBasedOnData( xDataToCopy, m_aProps, m_bUseCommonPass, xTargetStream );
+ CreateReadonlyCopyBasedOnData( xDataToCopy, m_aProps, m_bUseCommonEncryption, xTargetStream );
}
}
//-----------------------------------------------
-void OWriteStream_Impl::GetCopyOfLastCommit( uno::Reference< io::XStream >& xTargetStream, const ::rtl::OUString& aPass )
+void OWriteStream_Impl::GetCopyOfLastCommit( uno::Reference< io::XStream >& xTargetStream, const ::comphelper::SequenceAsHashMap& aEncryptionData )
{
::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() );
@@ -1622,12 +1621,12 @@ void OWriteStream_Impl::GetCopyOfLastCommit( uno::Reference< io::XStream >& xTar
uno::Reference< io::XInputStream > xDataToCopy;
- if ( m_bHasCachedPassword )
+ if ( m_bHasCachedEncryptionData )
{
// TODO: introduce last commited cashed password information and use it here
// that means "use common pass" also should be remembered on flash
- uno::Sequence< sal_Int8 > aNewKey = ::package::MakeKeyFromPass( aPass, sal_True );
- uno::Sequence< sal_Int8 > aOldKey = ::package::MakeKeyFromPass( aPass, sal_False );
+ uno::Sequence< sal_Int8 > aNewKey = aEncryptionData.getUnpackedValueOrDefault( PACKAGE_ENCRYPTIONDATA_SHA1UTF8, uno::Sequence< sal_Int8 >() );
+ uno::Sequence< sal_Int8 > aOldKey = aEncryptionData.getUnpackedValueOrDefault( PACKAGE_ENCRYPTIONDATA_SHA1MS1252, uno::Sequence< sal_Int8 >() );
uno::Reference< beans::XPropertySet > xProps( m_xPackageStream, uno::UNO_QUERY );
if ( !xProps.is() )
@@ -1649,7 +1648,7 @@ void OWriteStream_Impl::GetCopyOfLastCommit( uno::Reference< io::XStream >& xTar
else
{
uno::Reference< beans::XPropertySet > xPropertySet( m_xPackageStream, uno::UNO_QUERY );
- SetEncryptionKeyProperty_Impl( xPropertySet, ::package::MakeKeyFromPass( aPass, sal_True ) );
+ SetEncryptionKeyProperty_Impl( xPropertySet, aEncryptionData.getUnpackedValueOrDefault( PACKAGE_ENCRYPTIONDATA_SHA1UTF8, uno::Sequence< sal_Int8 >() ) );
try {
xDataToCopy = m_xPackageStream->getDataStream();
@@ -1662,7 +1661,7 @@ void OWriteStream_Impl::GetCopyOfLastCommit( uno::Reference< io::XStream >& xTar
}
catch( packages::WrongPasswordException& aWrongPasswordException )
{
- SetEncryptionKeyProperty_Impl( xPropertySet, ::package::MakeKeyFromPass( aPass, sal_False ) );
+ SetEncryptionKeyProperty_Impl( xPropertySet, aEncryptionData.getUnpackedValueOrDefault( PACKAGE_ENCRYPTIONDATA_SHA1MS1252, uno::Sequence< sal_Int8 >() ) );
try {
xDataToCopy = m_xPackageStream->getDataStream();
@@ -1698,7 +1697,7 @@ void OWriteStream_Impl::GetCopyOfLastCommit( uno::Reference< io::XStream >& xTar
// in case of new inserted package stream it is possible that input stream still was not set
GetStreamProperties();
- CreateReadonlyCopyBasedOnData( xDataToCopy, m_aProps, m_bUseCommonPass, xTargetStream );
+ CreateReadonlyCopyBasedOnData( xDataToCopy, m_aProps, m_bUseCommonEncryption, xTargetStream );
}
//-----------------------------------------------
@@ -2030,6 +2029,7 @@ uno::Any SAL_CALL OWriteStream::queryInterface( const uno::Type& rType )
{
aReturn <<= ::cppu::queryInterface
( rType
+ , static_cast<embed::XEncryptionProtectedSource2*> ( this )
, static_cast<embed::XEncryptionProtectedSource*> ( this ) );
}
else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML )
@@ -2082,7 +2082,7 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
{
if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE )
{
- m_pData->m_pTypeCollection = new ::cppu::OTypeCollection
+ ::cppu::OTypeCollection aTmpCollection
( ::getCppuType( ( const uno::Reference< lang::XTypeProvider >* )NULL )
, ::getCppuType( ( const uno::Reference< io::XInputStream >* )NULL )
, ::getCppuType( ( const uno::Reference< io::XOutputStream >* )NULL )
@@ -2090,11 +2090,15 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
, ::getCppuType( ( const uno::Reference< io::XSeekable >* )NULL )
, ::getCppuType( ( const uno::Reference< io::XTruncate >* )NULL )
, ::getCppuType( ( const uno::Reference< lang::XComponent >* )NULL )
+ , ::getCppuType( ( const uno::Reference< embed::XEncryptionProtectedSource2 >* )NULL )
, ::getCppuType( ( const uno::Reference< embed::XEncryptionProtectedSource >* )NULL )
, ::getCppuType( ( const uno::Reference< embed::XExtendedStorageStream >* )NULL )
, ::getCppuType( ( const uno::Reference< embed::XTransactedObject >* )NULL )
- , ::getCppuType( ( const uno::Reference< embed::XTransactionBroadcaster >* )NULL )
- , ::getCppuType( ( const uno::Reference< beans::XPropertySet >* )NULL ) );
+ , ::getCppuType( ( const uno::Reference< embed::XTransactionBroadcaster >* )NULL ) );
+
+ m_pData->m_pTypeCollection = new ::cppu::OTypeCollection
+ ( ::getCppuType( ( const uno::Reference< beans::XPropertySet >* )NULL )
+ , aTmpCollection.getTypes() );
}
else if ( m_pData->m_nStorageType == embed::StorageFormats::OFOPXML )
{
@@ -2140,6 +2144,7 @@ uno::Sequence< uno::Type > SAL_CALL OWriteStream::getTypes()
, ::getCppuType( ( const uno::Reference< io::XSeekable >* )NULL )
, ::getCppuType( ( const uno::Reference< io::XTruncate >* )NULL )
, ::getCppuType( ( const uno::Reference< lang::XComponent >* )NULL )
+ , ::getCppuType( ( const uno::Reference< embed::XEncryptionProtectedSource2 >* )NULL )
, ::getCppuType( ( const uno::Reference< embed::XEncryptionProtectedSource >* )NULL )
, ::getCppuType( ( const uno::Reference< beans::XPropertySet >* )NULL ) );
}
@@ -2704,7 +2709,7 @@ void SAL_CALL OWriteStream::setEncryptionPassword( const ::rtl::OUString& aPass
OSL_ENSURE( m_pImpl->m_xPackageStream.is(), "No package stream is set!\n" );
- m_pImpl->SetEncryptedWithPass( aPass );
+ m_pImpl->SetEncrypted( ::comphelper::OStorageHelper::CreatePackageEncryptionData( aPass ) );
ModifyParentUnlockMutex_Impl( aGuard );
}
@@ -2732,6 +2737,27 @@ void SAL_CALL OWriteStream::removeEncryption()
}
//-----------------------------------------------
+void SAL_CALL OWriteStream::setEncryptionData( const uno::Sequence< beans::NamedValue >& aEncryptionData )
+ throw (io::IOException, uno::RuntimeException)
+{
+ ::osl::ResettableMutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
+
+ CheckInitOnDemand();
+
+ if ( !m_pImpl )
+ {
+ ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
+ throw lang::DisposedException();
+ }
+
+ OSL_ENSURE( m_pImpl->m_xPackageStream.is(), "No package stream is set!\n" );
+
+ m_pImpl->SetEncrypted( aEncryptionData );
+
+ ModifyParentUnlockMutex_Impl( aGuard );
+}
+
+//-----------------------------------------------
sal_Bool SAL_CALL OWriteStream::hasByID( const ::rtl::OUString& sID )
throw ( io::IOException,
uno::RuntimeException )
@@ -3172,24 +3198,24 @@ void SAL_CALL OWriteStream::setPropertyValue( const ::rtl::OUString& aPropertyNa
else if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE
&& aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "UseCommonStoragePasswordEncryption" ) ) )
{
- sal_Bool bUseCommonPass = sal_False;
- if ( aValue >>= bUseCommonPass )
+ sal_Bool bUseCommonEncryption = sal_False;
+ if ( aValue >>= bUseCommonEncryption )
{
if ( m_bInitOnDemand && m_pImpl->m_bHasInsertedStreamOptimization )
{
// the data stream is provided to the packagestream directly
- m_pImpl->m_bUseCommonPass = bUseCommonPass;
+ m_pImpl->m_bUseCommonEncryption = bUseCommonEncryption;
}
- else if ( bUseCommonPass )
+ else if ( bUseCommonEncryption )
{
- if ( !m_pImpl->m_bUseCommonPass )
+ if ( !m_pImpl->m_bUseCommonEncryption )
{
m_pImpl->SetDecrypted();
- m_pImpl->m_bUseCommonPass = sal_True;
+ m_pImpl->m_bUseCommonEncryption = sal_True;
}
}
else
- m_pImpl->m_bUseCommonPass = sal_False;
+ m_pImpl->m_bUseCommonEncryption = sal_False;
}
else
throw lang::IllegalArgumentException(); //TODO
@@ -3284,7 +3310,7 @@ uno::Any SAL_CALL OWriteStream::getPropertyValue( const ::rtl::OUString& aProp )
}
else if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE
&& aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "UseCommonStoragePasswordEncryption" ) ) )
- return uno::makeAny( m_pImpl->m_bUseCommonPass );
+ return uno::makeAny( m_pImpl->m_bUseCommonEncryption );
else if ( aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Size" ) ) )
{
CheckInitOnDemand();
diff --git a/package/source/xstor/owriteablestream.hxx b/package/source/xstor/owriteablestream.hxx
index 6bc90f7f3a3e..0e9884bd75cb 100644
--- a/package/source/xstor/owriteablestream.hxx
+++ b/package/source/xstor/owriteablestream.hxx
@@ -39,7 +39,7 @@
#include <com/sun/star/lang/XEventListener.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/lang/XComponent.hpp>
-#include <com/sun/star/embed/XEncryptionProtectedSource.hpp>
+#include <com/sun/star/embed/XEncryptionProtectedSource2.hpp>
#include <com/sun/star/embed/XStorage.hpp>
#include <com/sun/star/embed/XRelationshipAccess.hpp>
#include <com/sun/star/embed/XExtendedStorageStream.hpp>
@@ -54,6 +54,8 @@
#include <cppuhelper/weak.hxx>
#include <cppuhelper/interfacecontainer.h>
+#include <comphelper/sequenceashashmap.hxx>
+
#include <list>
#include "ocompinstream.hxx"
@@ -76,7 +78,7 @@ namespace cppu {
namespace package {
void StaticAddLog( const ::rtl::OUString& aMessage );
- ::com::sun::star::uno::Sequence< sal_Int8 > MakeKeyFromPass( const ::rtl::OUString& aPass, sal_Bool bUseUTF );
+ bool PackageEncryptionDatasEqual( const ::comphelper::SequenceAsHashMap& aHash1, const ::comphelper::SequenceAsHashMap& aHash2 );
}
struct WSInternalData_Impl
@@ -128,9 +130,9 @@ struct OWriteStream_Impl : public PreCreationStruct
sal_Bool m_bForceEncrypted;
- sal_Bool m_bUseCommonPass;
- sal_Bool m_bHasCachedPassword;
- ::rtl::OUString m_aPass;
+ sal_Bool m_bUseCommonEncryption;
+ sal_Bool m_bHasCachedEncryptionData;
+ ::comphelper::SequenceAsHashMap m_aEncryptionData;
sal_Bool m_bCompressedSetExplicit;
@@ -162,12 +164,12 @@ private:
::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > GetStream_Impl( sal_Int32 nStreamMode,
sal_Bool bHierarchyAccess );
- ::rtl::OUString GetCommonRootPass() throw ( ::com::sun::star::packages::NoEncryptionException );
+ ::comphelper::SequenceAsHashMap GetCommonRootEncryptionData() throw ( ::com::sun::star::packages::NoEncryptionException );
::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > ReadPackageStreamProperties();
::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > InsertOwnProps(
const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aProps,
- sal_Bool bUseCommonPass );
+ sal_Bool bUseCommonEncryption );
public:
OWriteStream_Impl(
@@ -187,7 +189,7 @@ public:
void AddLog( const ::rtl::OUString& aMessage );
- sal_Bool UsesCommonPass_Impl() const { return m_bUseCommonPass; }
+ sal_Bool UsesCommonEncryption_Impl() { return m_bUseCommonEncryption; }
sal_Bool HasTempFile_Impl() const { return ( m_aTempURL.getLength() != 0 ); }
sal_Bool IsTransacted();
@@ -199,13 +201,14 @@ public:
void SetToBeCommited() { m_bFlushed = sal_True; }
- sal_Bool HasCachedPassword() const { return m_bHasCachedPassword; }
- ::rtl::OUString GetCachedPassword() const { return m_aPass; }
- sal_Bool IsModified() const { return m_bHasDataToFlush || m_bFlushed; }
+ sal_Bool HasCachedEncryptionData() { return m_bHasCachedEncryptionData; }
+ ::comphelper::SequenceAsHashMap& GetCachedEncryptionData() { return m_aEncryptionData; }
+
+ sal_Bool IsModified() { return m_bHasDataToFlush || m_bFlushed; }
sal_Bool IsEncrypted();
void SetDecrypted();
- void SetEncryptedWithPass( const ::rtl::OUString& aPass );
+ void SetEncrypted( const ::comphelper::SequenceAsHashMap& aEncryptionData );
void DisposeWrappers();
@@ -227,12 +230,12 @@ public:
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::StringPair > > GetAllRelationshipsIfAny();
void CopyInternallyTo_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& xDestStream,
- const ::rtl::OUString& aPass );
+ const ::comphelper::SequenceAsHashMap& aEncryptionData );
void CopyInternallyTo_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& xDestStream );
::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > GetStream(
sal_Int32 nStreamMode,
- const ::rtl::OUString& aPass,
+ const ::comphelper::SequenceAsHashMap& aEncryptionData,
sal_Bool bHierarchyAccess );
::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > GetStream(
@@ -248,13 +251,13 @@ public:
void CreateReadonlyCopyBasedOnData(
const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xDataToCopy,
const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aProps,
- sal_Bool bUseCommonPass,
+ sal_Bool bUseCommonEncryption,
::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& xTargetStream );
void GetCopyOfLastCommit( ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& xTargetStream );
void GetCopyOfLastCommit(
::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& xTargetStream,
- const ::rtl::OUString& aPass );
+ const ::comphelper::SequenceAsHashMap& aEncryptionData );
void CommitStreamRelInfo(
@@ -273,7 +276,7 @@ class OWriteStream : ::com::sun::star::lang::XTypeProvider
, public ::com::sun::star::embed::XExtendedStorageStream
, public ::com::sun::star::io::XSeekable
, public ::com::sun::star::io::XTruncate
- , public ::com::sun::star::embed::XEncryptionProtectedSource
+ , public ::com::sun::star::embed::XEncryptionProtectedSource2
, public ::com::sun::star::embed::XRelationshipAccess
, public ::com::sun::star::embed::XTransactedObject
, public ::com::sun::star::embed::XTransactionBroadcaster
@@ -367,6 +370,9 @@ public:
throw ( ::com::sun::star::uno::RuntimeException,
::com::sun::star::io::IOException );
+ //XEncryptionProtectedSource2
+ virtual void SAL_CALL setEncryptionData( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& aEncryptionData ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+
//XRelationshipAccess
virtual ::sal_Bool SAL_CALL hasByID( const ::rtl::OUString& sID ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getTargetByID( const ::rtl::OUString& sID ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
diff --git a/package/source/xstor/register.cxx b/package/source/xstor/register.cxx
index b398b61e7f5e..022091b0a3c9 100644
--- a/package/source/xstor/register.cxx
+++ b/package/source/xstor/register.cxx
@@ -70,34 +70,6 @@ void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServic
return pRet;
}
-sal_Bool SAL_CALL component_writeInfo( void * /*pServiceManager*/, void * pRegistryKey )
-{
- if (pRegistryKey)
- {
- try
- {
- uno::Reference< registry::XRegistryKey > xKey( reinterpret_cast< registry::XRegistryKey* >( pRegistryKey ) );
-
- uno::Reference< registry::XRegistryKey > xNewKey;
-
- xNewKey = xKey->createKey( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) +
- OStorageFactory::impl_staticGetImplementationName() +
- ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") ) );
-
- const uno::Sequence< ::rtl::OUString > aServices = OStorageFactory::impl_staticGetSupportedServiceNames();
- for( sal_Int32 ind = 0; ind < aServices.getLength(); ind++ )
- xNewKey->createKey( aServices.getConstArray()[ind] );
-
- return sal_True;
- }
- catch (registry::InvalidRegistryException &)
- {
- OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
- }
- }
- return sal_False;
-}
-
} // extern "C"
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/package/source/xstor/xstor.component b/package/source/xstor/xstor.component
new file mode 100644
index 000000000000..f338d6a546cb
--- /dev/null
+++ b/package/source/xstor/xstor.component
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--**********************************************************************
+*
+* 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
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+**********************************************************************-->
+
+<component loader="com.sun.star.loader.SharedLibrary"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.comp.embed.StorageFactory">
+ <service name="com.sun.star.comp.embed.StorageFactory"/>
+ <service name="com.sun.star.embed.StorageFactory"/>
+ </implementation>
+</component>
diff --git a/package/source/xstor/xstor.dxp b/package/source/xstor/xstor.dxp
index 9630d7e06768..f0e1c69934bc 100644
--- a/package/source/xstor/xstor.dxp
+++ b/package/source/xstor/xstor.dxp
@@ -1,3 +1,2 @@
component_getImplementationEnvironment
-component_writeInfo
component_getFactory
diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx
index e89eeb480fa7..79728a00a9d6 100644
--- a/package/source/xstor/xstorage.cxx
+++ b/package/source/xstor/xstorage.cxx
@@ -209,7 +209,7 @@ OStorage_Impl::OStorage_Impl( uno::Reference< io::XInputStream > xInputStream,
, m_bListCreated( sal_False )
, m_xFactory( xFactory )
, m_xProperties( xProperties )
-, m_bHasCommonPassword( sal_False )
+, m_bHasCommonEncryptionData( sal_False )
, m_pParent( NULL )
, m_bControlMediaType( sal_False )
, m_bMTFallbackUsed( sal_False )
@@ -249,7 +249,7 @@ OStorage_Impl::OStorage_Impl( uno::Reference< io::XStream > xStream,
, m_bListCreated( sal_False )
, m_xFactory( xFactory )
, m_xProperties( xProperties )
-, m_bHasCommonPassword( sal_False )
+, m_bHasCommonEncryptionData( sal_False )
, m_pParent( NULL )
, m_bControlMediaType( sal_False )
, m_bMTFallbackUsed( sal_False )
@@ -293,7 +293,7 @@ OStorage_Impl::OStorage_Impl( OStorage_Impl* pParent,
, m_xPackageFolder( xPackageFolder )
, m_xPackage( xPackage )
, m_xFactory( xFactory )
-, m_bHasCommonPassword( sal_False )
+, m_bHasCommonEncryptionData( sal_False )
, m_pParent( pParent ) // can be empty in case of temporary readonly substorages and relation storage
, m_bControlMediaType( sal_False )
, m_bMTFallbackUsed( sal_False )
@@ -750,10 +750,9 @@ void OStorage_Impl::CopyToStorage( const uno::Reference< embed::XStorage >& xDes
{
try
{
- ::rtl::OUString aCommonPass = GetCommonRootPass();
- uno::Reference< embed::XEncryptionProtectedSource > xEncr( xDest, uno::UNO_QUERY );
+ uno::Reference< embed::XEncryptionProtectedSource2 > xEncr( xDest, uno::UNO_QUERY );
if ( xEncr.is() )
- xEncr->setEncryptionPassword( aCommonPass );
+ xEncr->setEncryptionData( GetCommonRootEncryptionData().getAsConstNamedValueList() );
}
catch( packages::NoEncryptionException& aNoEncryptionException )
{
@@ -857,7 +856,7 @@ void OStorage_Impl::CopyStorageElement( SotElement_Impl* pElement,
{
aStrProps.realloc( ++nNum );
aStrProps[nNum-1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseCommonStoragePasswordEncryption" ) );
- aStrProps[nNum-1].Value <<= (sal_Bool)( pElement->m_pStream->UsesCommonPass_Impl() );
+ aStrProps[nNum-1].Value <<= (sal_Bool)( pElement->m_pStream->UsesCommonEncryption_Impl() );
}
else if ( m_nStorageType == embed::StorageFormats::OFOPXML )
{
@@ -915,15 +914,15 @@ void OStorage_Impl::CopyStorageElement( SotElement_Impl* pElement,
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 >() );
}
- else if ( pElement->m_pStream->HasCachedPassword()
+ else if ( pElement->m_pStream->HasCachedEncryptionData()
&& ( pElement->m_pStream->IsModified() || pElement->m_pStream->HasWriteOwner_Impl() ) )
{
- ::rtl::OUString aCommonPass;
- sal_Bool bHasCommonPass = sal_False;
+ ::comphelper::SequenceAsHashMap aCommonEncryptionData;
+ sal_Bool bHasCommonEncryptionData = sal_False;
try
{
- aCommonPass = GetCommonRootPass();
- bHasCommonPass = sal_True;
+ aCommonEncryptionData = GetCommonRootEncryptionData();
+ bHasCommonEncryptionData = sal_True;
}
catch( packages::NoEncryptionException& aNoEncryptionException )
{
@@ -931,7 +930,7 @@ void OStorage_Impl::CopyStorageElement( SotElement_Impl* pElement,
AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "No Encryption" ) ) );
}
- if ( bHasCommonPass && pElement->m_pStream->GetCachedPassword().equals( aCommonPass ) )
+ if ( bHasCommonEncryptionData && ::package::PackageEncryptionDatasEqual( pElement->m_pStream->GetCachedEncryptionData(), aCommonEncryptionData ) )
{
// If the stream can be opened with the common storage password
// it must be stored with the common storage password as well
@@ -949,13 +948,14 @@ void OStorage_Impl::CopyStorageElement( SotElement_Impl* pElement,
else
{
// the stream is already opened for writing or was changed
+ uno::Reference< embed::XStorage2 > xDest2( xDest, uno::UNO_QUERY_THROW );
uno::Reference< io::XStream > xSubStr =
- xDest->openEncryptedStreamElement( aName,
+ xDest2->openEncryptedStream( aName,
embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE,
- pElement->m_pStream->GetCachedPassword() );
+ pElement->m_pStream->GetCachedEncryptionData().getAsConstNamedValueList() );
OSL_ENSURE( xSubStr.is(), "No destination substream!\n" );
- pElement->m_pStream->CopyInternallyTo_Impl( xSubStr, pElement->m_pStream->GetCachedPassword() );
+ pElement->m_pStream->CopyInternallyTo_Impl( xSubStr, pElement->m_pStream->GetCachedEncryptionData() );
}
}
else
@@ -1362,7 +1362,7 @@ void OStorage_Impl::Revert()
}
//-----------------------------------------------
-::rtl::OUString OStorage_Impl::GetCommonRootPass()
+::comphelper::SequenceAsHashMap OStorage_Impl::GetCommonRootEncryptionData()
throw ( packages::NoEncryptionException )
{
::osl::MutexGuard aGuard( m_rMutexRef->GetMutex() ) ;
@@ -1372,17 +1372,17 @@ void OStorage_Impl::Revert()
if ( m_bIsRoot )
{
- if ( !m_bHasCommonPassword )
+ if ( !m_bHasCommonEncryptionData )
throw packages::NoEncryptionException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
- return m_aCommonPassword;
+ return m_aCommonEncryptionData;
}
else
{
if ( !m_pParent )
throw packages::NoEncryptionException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
- return m_pParent->GetCommonRootPass();
+ return m_pParent->GetCommonRootEncryptionData();
}
}
@@ -1681,8 +1681,8 @@ void OStorage_Impl::ClearElement( SotElement_Impl* pElement )
//-----------------------------------------------
void OStorage_Impl::CloneStreamElement( const ::rtl::OUString& aStreamName,
- sal_Bool bPassProvided,
- const ::rtl::OUString& aPass,
+ sal_Bool bEncryptionDataProvided,
+ const ::comphelper::SequenceAsHashMap& aEncryptionData,
uno::Reference< io::XStream >& xTargetStream )
throw ( embed::InvalidStorageException,
lang::IllegalArgumentException,
@@ -1714,8 +1714,8 @@ void OStorage_Impl::CloneStreamElement( const ::rtl::OUString& aStreamName,
// storage. The only problem is that some package streams can be accessed from outside
// at the same time ( now solwed by wrappers that remember own position ).
- if ( bPassProvided )
- pElement->m_pStream->GetCopyOfLastCommit( xTargetStream, aPass );
+ if ( bEncryptionDataProvided )
+ pElement->m_pStream->GetCopyOfLastCommit( xTargetStream, aEncryptionData );
else
pElement->m_pStream->GetCopyOfLastCommit( xTargetStream );
}
@@ -2249,6 +2249,7 @@ uno::Any SAL_CALL OStorage::queryInterface( const uno::Type& rType )
( rType
, static_cast<lang::XTypeProvider*> ( this )
, static_cast<embed::XStorage*> ( this )
+ , static_cast<embed::XStorage2*> ( this )
, static_cast<embed::XTransactedObject*> ( this )
, static_cast<embed::XTransactionBroadcaster*> ( this )
, static_cast<util::XModifiable*> ( this )
@@ -2256,8 +2257,15 @@ uno::Any SAL_CALL OStorage::queryInterface( const uno::Type& rType )
, static_cast<container::XElementAccess*> ( this )
, static_cast<lang::XComponent*> ( this )
, static_cast<beans::XPropertySet*> ( this )
- , static_cast<embed::XOptimizedStorage*> ( this )
- , static_cast<embed::XHierarchicalStorageAccess*> ( this ) );
+ , static_cast<embed::XOptimizedStorage*> ( this ) );
+
+ if ( aReturn.hasValue() == sal_True )
+ return aReturn ;
+
+ aReturn <<= ::cppu::queryInterface
+ ( rType
+ , static_cast<embed::XHierarchicalStorageAccess*> ( this )
+ , static_cast<embed::XHierarchicalStorageAccess2*> ( this ) );
if ( aReturn.hasValue() == sal_True )
return aReturn ;
@@ -2269,7 +2277,8 @@ uno::Any SAL_CALL OStorage::queryInterface( const uno::Type& rType )
aReturn <<= ::cppu::queryInterface
( rType
, static_cast<embed::XStorageRawAccess*> ( this )
- , static_cast<embed::XEncryptionProtectedSource*> ( this ) );
+ , static_cast<embed::XEncryptionProtectedSource*> ( this )
+ , static_cast<embed::XEncryptionProtectedSource2*> ( this ) );
}
else
{
@@ -2324,10 +2333,12 @@ uno::Sequence< uno::Type > SAL_CALL OStorage::getTypes()
m_pData->m_pTypeCollection = new ::cppu::OTypeCollection
( ::getCppuType( ( const uno::Reference< lang::XTypeProvider >* )NULL )
, ::getCppuType( ( const uno::Reference< embed::XStorage >* )NULL )
+ , ::getCppuType( ( const uno::Reference< embed::XStorage2 >* )NULL )
, ::getCppuType( ( const uno::Reference< embed::XStorageRawAccess >* )NULL )
, ::getCppuType( ( const uno::Reference< embed::XTransactedObject >* )NULL )
, ::getCppuType( ( const uno::Reference< embed::XTransactionBroadcaster >* )NULL )
, ::getCppuType( ( const uno::Reference< util::XModifiable >* )NULL )
+ , ::getCppuType( ( const uno::Reference< embed::XEncryptionProtectedSource2 >* )NULL )
, ::getCppuType( ( const uno::Reference< embed::XEncryptionProtectedSource >* )NULL )
, ::getCppuType( ( const uno::Reference< beans::XPropertySet >* )NULL ) );
}
@@ -2336,6 +2347,7 @@ uno::Sequence< uno::Type > SAL_CALL OStorage::getTypes()
m_pData->m_pTypeCollection = new ::cppu::OTypeCollection
( ::getCppuType( ( const uno::Reference< lang::XTypeProvider >* )NULL )
, ::getCppuType( ( const uno::Reference< embed::XStorage >* )NULL )
+ , ::getCppuType( ( const uno::Reference< embed::XStorage2 >* )NULL )
, ::getCppuType( ( const uno::Reference< embed::XStorageRawAccess >* )NULL )
, ::getCppuType( ( const uno::Reference< embed::XTransactedObject >* )NULL )
, ::getCppuType( ( const uno::Reference< embed::XTransactionBroadcaster >* )NULL )
@@ -2567,100 +2579,7 @@ uno::Reference< io::XStream > SAL_CALL OStorage::openEncryptedStreamElement(
{
RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::openEncryptedStreamElement" );
- ::osl::ResettableMutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
-
- if ( !m_pImpl )
- {
- ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
- throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
- }
-
- if ( m_pData->m_nStorageType != embed::StorageFormats::PACKAGE )
- packages::NoEncryptionException();
-
- if ( ( nOpenMode & embed::ElementModes::WRITE ) && m_pData->m_bReadOnlyWrap )
- throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: access denied
-
- if ( !aPass.getLength() )
- throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 3 );
-
- uno::Reference< io::XStream > xResult;
- try
- {
- SotElement_Impl *pElement = OpenStreamElement_Impl( aStreamName, nOpenMode, sal_True );
- OSL_ENSURE( pElement && pElement->m_pStream, "In case element can not be created an exception must be thrown!" );
-
- xResult = pElement->m_pStream->GetStream( nOpenMode, aPass, sal_False );
- OSL_ENSURE( xResult.is(), "The method must throw exception instead of removing empty result!\n" );
-
- if ( m_pData->m_bReadOnlyWrap )
- {
- // before the storage disposes the stream it must deregister itself as listener
- uno::Reference< lang::XComponent > xStreamComponent( xResult, uno::UNO_QUERY );
- if ( !xStreamComponent.is() )
- throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
-
- MakeLinkToSubComponent_Impl( xStreamComponent );
- }
- }
- catch( embed::InvalidStorageException& aInvalidStorageException )
- {
- m_pImpl->AddLog( aInvalidStorageException.Message );
- m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
- throw;
- }
- catch( lang::IllegalArgumentException& aIllegalArgumentException )
- {
- m_pImpl->AddLog( aIllegalArgumentException.Message );
- m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
- throw;
- }
- catch( packages::NoEncryptionException& aNoEncryptionException )
- {
- m_pImpl->AddLog( aNoEncryptionException.Message );
- m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
- throw;
- }
- catch( packages::WrongPasswordException& aWrongPasswordException )
- {
- m_pImpl->AddLog( aWrongPasswordException.Message );
- m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
- throw;
- }
- catch( embed::StorageWrappedTargetException& aStorageWrappedTargetException )
- {
- m_pImpl->AddLog( aStorageWrappedTargetException.Message );
- m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
- throw;
- }
- catch( io::IOException& aIOException )
- {
- m_pImpl->AddLog( aIOException.Message );
- m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
- throw;
- }
- catch( uno::RuntimeException& aRuntimeException )
- {
- m_pImpl->AddLog( aRuntimeException.Message );
- m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
- throw;
- }
- catch( uno::Exception& aException )
- {
- m_pImpl->AddLog( aException.Message );
- m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
-
- uno::Any aCaught( ::cppu::getCaughtException() );
- throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't open encrypted stream stream!" ) ),
- uno::Reference< io::XInputStream >(),
- aCaught );
- }
-
- aGuard.clear();
-
- BroadcastModifiedIfNecessary();
-
- return xResult;
+ return openEncryptedStream( aStreamName, nOpenMode, ::comphelper::OStorageHelper::CreatePackageEncryptionData( aPass ) );
}
//-----------------------------------------------
@@ -2847,7 +2766,7 @@ uno::Reference< io::XStream > SAL_CALL OStorage::cloneStreamElement( const ::rtl
try
{
uno::Reference< io::XStream > xResult;
- m_pImpl->CloneStreamElement( aStreamName, sal_False, ::rtl::OUString(), xResult );
+ m_pImpl->CloneStreamElement( aStreamName, sal_False, ::comphelper::SequenceAsHashMap(), xResult );
if ( !xResult.is() )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
return xResult;
@@ -2914,80 +2833,7 @@ uno::Reference< io::XStream > SAL_CALL OStorage::cloneEncryptedStreamElement(
{
RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::cloneEncryptedStreamElement" );
- ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
-
- if ( !m_pImpl )
- {
- ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
- throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
- }
-
- if ( m_pData->m_nStorageType != embed::StorageFormats::PACKAGE )
- packages::NoEncryptionException();
-
- if ( !aPass.getLength() )
- throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 2 );
-
- try
- {
- uno::Reference< io::XStream > xResult;
- m_pImpl->CloneStreamElement( aStreamName, sal_True, aPass, xResult );
- if ( !xResult.is() )
- throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
- return xResult;
- }
- catch( embed::InvalidStorageException& aInvalidStorageException )
- {
- m_pImpl->AddLog( aInvalidStorageException.Message );
- m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
- throw;
- }
- catch( lang::IllegalArgumentException& aIllegalArgumentException )
- {
- m_pImpl->AddLog( aIllegalArgumentException.Message );
- m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
- throw;
- }
- catch( packages::NoEncryptionException& aNoEncryptionException )
- {
- m_pImpl->AddLog( aNoEncryptionException.Message );
- m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
- throw;
- }
- catch( packages::WrongPasswordException& aWrongPasswordException )
- {
- m_pImpl->AddLog( aWrongPasswordException.Message );
- m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
- throw;
- }
- catch( io::IOException& aIOException )
- {
- m_pImpl->AddLog( aIOException.Message );
- m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
- throw;
- }
- catch( embed::StorageWrappedTargetException& aStorageWrappedTargetException )
- {
- m_pImpl->AddLog( aStorageWrappedTargetException.Message );
- m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
- throw;
- }
- catch( uno::RuntimeException& aRuntimeException )
- {
- m_pImpl->AddLog( aRuntimeException.Message );
- m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
- throw;
- }
- catch( uno::Exception& aException )
- {
- m_pImpl->AddLog( aException.Message );
- m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
-
- uno::Any aCaught( ::cppu::getCaughtException() );
- throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't clone encrypted stream!" ) ),
- uno::Reference< io::XInputStream >(),
- aCaught );
- }
+ return cloneEncryptedStream( aStreamName, ::comphelper::OStorageHelper::CreatePackageEncryptionData( aPass ) );
}
//-----------------------------------------------
@@ -3712,6 +3558,210 @@ void SAL_CALL OStorage::moveElementTo( const ::rtl::OUString& aElementName,
}
//____________________________________________________________________________________________________
+// XStorage2
+//____________________________________________________________________________________________________
+
+//-----------------------------------------------
+uno::Reference< io::XStream > SAL_CALL OStorage::openEncryptedStream(
+ const ::rtl::OUString& aStreamName, sal_Int32 nOpenMode, const uno::Sequence< beans::NamedValue >& aEncryptionData )
+ throw ( embed::InvalidStorageException,
+ lang::IllegalArgumentException,
+ packages::NoEncryptionException,
+ packages::WrongPasswordException,
+ io::IOException,
+ embed::StorageWrappedTargetException,
+ uno::RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::openEncryptedStream" );
+
+ ::osl::ResettableMutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
+
+ if ( !m_pImpl )
+ {
+ ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
+ throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
+ }
+
+ if ( m_pData->m_nStorageType != embed::StorageFormats::PACKAGE )
+ packages::NoEncryptionException();
+
+ if ( ( nOpenMode & embed::ElementModes::WRITE ) && m_pData->m_bReadOnlyWrap )
+ throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // TODO: access denied
+
+ if ( !aEncryptionData.getLength() )
+ throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 3 );
+
+ uno::Reference< io::XStream > xResult;
+ try
+ {
+ SotElement_Impl *pElement = OpenStreamElement_Impl( aStreamName, nOpenMode, sal_True );
+ OSL_ENSURE( pElement && pElement->m_pStream, "In case element can not be created an exception must be thrown!" );
+
+ xResult = pElement->m_pStream->GetStream( nOpenMode, aEncryptionData, sal_False );
+ OSL_ENSURE( xResult.is(), "The method must throw exception instead of removing empty result!\n" );
+
+ if ( m_pData->m_bReadOnlyWrap )
+ {
+ // before the storage disposes the stream it must deregister itself as listener
+ uno::Reference< lang::XComponent > xStreamComponent( xResult, uno::UNO_QUERY );
+ if ( !xStreamComponent.is() )
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
+
+ MakeLinkToSubComponent_Impl( xStreamComponent );
+ }
+ }
+ catch( embed::InvalidStorageException& aInvalidStorageException )
+ {
+ m_pImpl->AddLog( aInvalidStorageException.Message );
+ m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
+ throw;
+ }
+ catch( lang::IllegalArgumentException& aIllegalArgumentException )
+ {
+ m_pImpl->AddLog( aIllegalArgumentException.Message );
+ m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
+ throw;
+ }
+ catch( packages::NoEncryptionException& aNoEncryptionException )
+ {
+ m_pImpl->AddLog( aNoEncryptionException.Message );
+ m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
+ throw;
+ }
+ catch( packages::WrongPasswordException& aWrongPasswordException )
+ {
+ m_pImpl->AddLog( aWrongPasswordException.Message );
+ m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
+ throw;
+ }
+ catch( embed::StorageWrappedTargetException& aStorageWrappedTargetException )
+ {
+ m_pImpl->AddLog( aStorageWrappedTargetException.Message );
+ m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
+ throw;
+ }
+ catch( io::IOException& aIOException )
+ {
+ m_pImpl->AddLog( aIOException.Message );
+ m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
+ throw;
+ }
+ catch( uno::RuntimeException& aRuntimeException )
+ {
+ m_pImpl->AddLog( aRuntimeException.Message );
+ m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
+ throw;
+ }
+ catch( uno::Exception& aException )
+ {
+ m_pImpl->AddLog( aException.Message );
+ m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
+
+ uno::Any aCaught( ::cppu::getCaughtException() );
+ throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't open encrypted stream stream!" ) ),
+ uno::Reference< io::XInputStream >(),
+ aCaught );
+ }
+
+ aGuard.clear();
+
+ BroadcastModifiedIfNecessary();
+
+ return xResult;
+}
+
+//-----------------------------------------------
+uno::Reference< io::XStream > SAL_CALL OStorage::cloneEncryptedStream(
+ const ::rtl::OUString& aStreamName,
+ const uno::Sequence< beans::NamedValue >& aEncryptionData )
+ throw ( embed::InvalidStorageException,
+ lang::IllegalArgumentException,
+ packages::NoEncryptionException,
+ packages::WrongPasswordException,
+ io::IOException,
+ embed::StorageWrappedTargetException,
+ uno::RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::cloneEncryptedStream" );
+
+ ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
+
+ if ( !m_pImpl )
+ {
+ ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
+ throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
+ }
+
+ if ( m_pData->m_nStorageType != embed::StorageFormats::PACKAGE )
+ packages::NoEncryptionException();
+
+ if ( !aEncryptionData.getLength() )
+ throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 2 );
+
+ try
+ {
+ uno::Reference< io::XStream > xResult;
+ m_pImpl->CloneStreamElement( aStreamName, sal_True, aEncryptionData, xResult );
+ if ( !xResult.is() )
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
+ return xResult;
+ }
+ catch( embed::InvalidStorageException& aInvalidStorageException )
+ {
+ m_pImpl->AddLog( aInvalidStorageException.Message );
+ m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
+ throw;
+ }
+ catch( lang::IllegalArgumentException& aIllegalArgumentException )
+ {
+ m_pImpl->AddLog( aIllegalArgumentException.Message );
+ m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
+ throw;
+ }
+ catch( packages::NoEncryptionException& aNoEncryptionException )
+ {
+ m_pImpl->AddLog( aNoEncryptionException.Message );
+ m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
+ throw;
+ }
+ catch( packages::WrongPasswordException& aWrongPasswordException )
+ {
+ m_pImpl->AddLog( aWrongPasswordException.Message );
+ m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
+ throw;
+ }
+ catch( io::IOException& aIOException )
+ {
+ m_pImpl->AddLog( aIOException.Message );
+ m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
+ throw;
+ }
+ catch( embed::StorageWrappedTargetException& aStorageWrappedTargetException )
+ {
+ m_pImpl->AddLog( aStorageWrappedTargetException.Message );
+ m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
+ throw;
+ }
+ catch( uno::RuntimeException& aRuntimeException )
+ {
+ m_pImpl->AddLog( aRuntimeException.Message );
+ m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
+ throw;
+ }
+ catch( uno::Exception& aException )
+ {
+ m_pImpl->AddLog( aException.Message );
+ m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
+
+ uno::Any aCaught( ::cppu::getCaughtException() );
+ throw embed::StorageWrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can't clone encrypted stream!" ) ),
+ uno::Reference< io::XInputStream >(),
+ aCaught );
+ }
+}
+
+
+//____________________________________________________________________________________________________
// XStorageRawAccess
//____________________________________________________________________________________________________
@@ -4599,6 +4649,15 @@ void SAL_CALL OStorage::setEncryptionPassword( const ::rtl::OUString& aPass )
io::IOException )
{
RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::setEncryptionPassword" );
+ setEncryptionData( ::comphelper::OStorageHelper::CreatePackageEncryptionData( aPass ) );
+}
+
+//-----------------------------------------------
+void SAL_CALL OStorage::removeEncryption()
+ throw ( uno::RuntimeException,
+ io::IOException )
+{
+ RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::removeEncryption" );
::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
@@ -4611,8 +4670,7 @@ void SAL_CALL OStorage::setEncryptionPassword( const ::rtl::OUString& aPass )
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" );
-
+ OSL_ENSURE( m_pData->m_bIsRoot, "removeEncryption() method is not available for nonroot storages!\n" );
if ( m_pData->m_bIsRoot )
{
try {
@@ -4630,12 +4688,15 @@ void SAL_CALL OStorage::setEncryptionPassword( const ::rtl::OUString& aPass )
m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
uno::Any aCaught( ::cppu::getCaughtException() );
- throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can not open package!\n" ) ),
+ throw lang::WrappedTargetRuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can not open package!\n" ) ),
uno::Reference< uno::XInterface >( static_cast< OWeakObject* >( this ),
uno::UNO_QUERY ),
aCaught );
}
+ // TODO: check if the password is valid
+ // update all streams that was encrypted with old password
+
uno::Reference< beans::XPropertySet > xPackPropSet( m_pImpl->m_xPackage, uno::UNO_QUERY );
if ( !xPackPropSet.is() )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
@@ -4643,10 +4704,10 @@ void SAL_CALL OStorage::setEncryptionPassword( const ::rtl::OUString& aPass )
try
{
xPackPropSet->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EncryptionKey" ) ),
- uno::makeAny( ::package::MakeKeyFromPass( aPass, sal_True ) ) );
+ uno::makeAny( uno::Sequence< sal_Int8 >() ) );
- m_pImpl->m_bHasCommonPassword = sal_True;
- m_pImpl->m_aCommonPassword = aPass;
+ m_pImpl->m_bHasCommonEncryptionData = sal_False;
+ m_pImpl->m_aCommonEncryptionData.clear();
}
catch( uno::Exception& aException )
{
@@ -4659,12 +4720,15 @@ void SAL_CALL OStorage::setEncryptionPassword( const ::rtl::OUString& aPass )
}
}
-//-----------------------------------------------
-void SAL_CALL OStorage::removeEncryption()
- throw ( uno::RuntimeException,
- io::IOException )
+//____________________________________________________________________________________________________
+// XEncryptionProtectedSource2
+//____________________________________________________________________________________________________
+
+void SAL_CALL OStorage::setEncryptionData( const uno::Sequence< beans::NamedValue >& aEncryptionData )
+ throw ( io::IOException,
+ uno::RuntimeException )
{
- RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::removeEncryption" );
+ RTL_LOGFILE_CONTEXT( aLog, "package (mv76033) OStorage::setEncryptionData" );
::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
@@ -4677,8 +4741,10 @@ void SAL_CALL OStorage::removeEncryption()
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" );
+ if ( !aEncryptionData.getLength() )
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected empty encryption data!") ), uno::Reference< uno::XInterface >() );
+ OSL_ENSURE( m_pData->m_bIsRoot, "setEncryptionData() method is not available for nonroot storages!\n" );
if ( m_pData->m_bIsRoot )
{
try {
@@ -4696,38 +4762,37 @@ void SAL_CALL OStorage::removeEncryption()
m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
uno::Any aCaught( ::cppu::getCaughtException() );
- throw lang::WrappedTargetRuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can not open package!\n" ) ),
+ throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Can not open package!\n" ) ),
uno::Reference< uno::XInterface >( static_cast< OWeakObject* >( this ),
uno::UNO_QUERY ),
aCaught );
}
- // TODO: check if the password is valid
- // update all streams that was encrypted with old password
-
uno::Reference< beans::XPropertySet > xPackPropSet( m_pImpl->m_xPackage, uno::UNO_QUERY );
if ( !xPackPropSet.is() )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
try
{
+ ::comphelper::SequenceAsHashMap aEncryptionMap( aEncryptionData );
xPackPropSet->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EncryptionKey" ) ),
- uno::makeAny( uno::Sequence< sal_Int8 >() ) );
+ uno::makeAny( aEncryptionMap.getUnpackedValueOrDefault( PACKAGE_ENCRYPTIONDATA_SHA1UTF8, uno::Sequence< sal_Int8 >() ) ) );
- m_pImpl->m_bHasCommonPassword = sal_False;
- m_pImpl->m_aCommonPassword = ::rtl::OUString();
+ m_pImpl->m_bHasCommonEncryptionData = sal_True;
+ m_pImpl->m_aCommonEncryptionData = aEncryptionMap;
}
catch( uno::Exception& aException )
{
m_pImpl->AddLog( aException.Message );
m_pImpl->AddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Rethrow" ) ) );
- OSL_ENSURE( sal_False, "The call must not fail, it is pretty simple!" );
throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
}
}
+
}
+
//____________________________________________________________________________________________________
// XPropertySet
//____________________________________________________________________________________________________
@@ -5945,7 +6010,7 @@ void SAL_CALL OStorage::copyStreamElementData( const ::rtl::OUString& aStreamNam
try
{
uno::Reference< io::XStream > xNonconstRef = xTargetStream;
- m_pImpl->CloneStreamElement( aStreamName, sal_False, ::rtl::OUString(), xNonconstRef );
+ m_pImpl->CloneStreamElement( aStreamName, sal_False, ::comphelper::SequenceAsHashMap(), xNonconstRef );
OSL_ENSURE( xNonconstRef == xTargetStream, "The provided stream reference seems not be filled in correctly!\n" );
if ( xNonconstRef != xTargetStream )
@@ -6074,6 +6139,55 @@ uno::Reference< embed::XExtendedStorageStream > SAL_CALL OStorage::openEncrypted
embed::StorageWrappedTargetException,
uno::RuntimeException )
{
+ return openEncryptedStreamByHierarchicalName( aStreamPath, nOpenMode, ::comphelper::OStorageHelper::CreatePackageEncryptionData( sPassword ) );
+}
+
+//-----------------------------------------------
+void SAL_CALL OStorage::removeStreamElementByHierarchicalName( const ::rtl::OUString& aStreamPath )
+ throw ( embed::InvalidStorageException,
+ lang::IllegalArgumentException,
+ container::NoSuchElementException,
+ io::IOException,
+ embed::StorageWrappedTargetException,
+ uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
+
+ if ( !m_pImpl )
+ {
+ ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
+ throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
+ }
+
+ if ( !aStreamPath.getLength() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStreamPath, sal_True ) )
+ throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
+
+ if ( !( m_pImpl->m_nStorageMode & embed::ElementModes::WRITE ) )
+ throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // Access denied
+
+ OStringList_Impl aListPath = OHierarchyHolder_Impl::GetListPathFromString( aStreamPath );
+ OSL_ENSURE( aListPath.size(), "The result list must not be empty!" );
+
+ if ( !m_pData->m_rHierarchyHolder.is() )
+ m_pData->m_rHierarchyHolder = new OHierarchyHolder_Impl(
+ uno::Reference< embed::XStorage >( static_cast< embed::XStorage* >( this ) ) );
+
+ m_pData->m_rHierarchyHolder->RemoveStreamHierarchically( aListPath );
+}
+
+//____________________________________________________________________________________________________
+// XHierarchicalStorageAccess2
+//____________________________________________________________________________________________________
+
+uno::Reference< embed::XExtendedStorageStream > SAL_CALL OStorage::openEncryptedStreamByHierarchicalName( const ::rtl::OUString& aStreamPath, ::sal_Int32 nOpenMode, const uno::Sequence< beans::NamedValue >& aEncryptionData )
+ throw ( embed::InvalidStorageException,
+ lang::IllegalArgumentException,
+ packages::NoEncryptionException,
+ packages::WrongPasswordException,
+ io::IOException,
+ embed::StorageWrappedTargetException,
+ uno::RuntimeException )
+{
::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
if ( !m_pImpl )
@@ -6088,7 +6202,7 @@ uno::Reference< embed::XExtendedStorageStream > SAL_CALL OStorage::openEncrypted
if ( !aStreamPath.getLength() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStreamPath, sal_True ) )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
- if ( !sPassword.getLength() )
+ if ( !aEncryptionData.getLength() )
throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 3 );
if ( !( m_pImpl->m_nStorageMode & embed::ElementModes::WRITE )
@@ -6108,7 +6222,7 @@ uno::Reference< embed::XExtendedStorageStream > SAL_CALL OStorage::openEncrypted
OSL_ENSURE( pElement && pElement->m_pStream, "In case element can not be created an exception must be thrown!" );
xResult = uno::Reference< embed::XExtendedStorageStream >(
- pElement->m_pStream->GetStream( nOpenMode, sPassword, sal_True ),
+ pElement->m_pStream->GetStream( nOpenMode, aEncryptionData, sal_True ),
uno::UNO_QUERY_THROW );
}
else
@@ -6122,7 +6236,7 @@ uno::Reference< embed::XExtendedStorageStream > SAL_CALL OStorage::openEncrypted
( m_pImpl->m_nStorageMode & embed::ElementModes::READWRITE ),
aListPath,
nOpenMode,
- sPassword );
+ aEncryptionData );
}
if ( !xResult.is() )
@@ -6131,37 +6245,5 @@ uno::Reference< embed::XExtendedStorageStream > SAL_CALL OStorage::openEncrypted
return xResult;
}
-//-----------------------------------------------
-void SAL_CALL OStorage::removeStreamElementByHierarchicalName( const ::rtl::OUString& aStreamPath )
- throw ( embed::InvalidStorageException,
- lang::IllegalArgumentException,
- container::NoSuchElementException,
- io::IOException,
- embed::StorageWrappedTargetException,
- uno::RuntimeException )
-{
- ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() );
-
- if ( !m_pImpl )
- {
- ::package::StaticAddLog( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Disposed!" ) ) );
- throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
- }
-
- if ( !aStreamPath.getLength() || !::comphelper::OStorageHelper::IsValidZipEntryFileName( aStreamPath, sal_True ) )
- throw lang::IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected entry name syntax." ) ), uno::Reference< uno::XInterface >(), 1 );
-
- if ( !( m_pImpl->m_nStorageMode & embed::ElementModes::WRITE ) )
- throw io::IOException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() ); // Access denied
-
- OStringList_Impl aListPath = OHierarchyHolder_Impl::GetListPathFromString( aStreamPath );
- OSL_ENSURE( aListPath.size(), "The result list must not be empty!" );
-
- if ( !m_pData->m_rHierarchyHolder.is() )
- m_pData->m_rHierarchyHolder = new OHierarchyHolder_Impl(
- uno::Reference< embed::XStorage >( static_cast< embed::XStorage* >( this ) ) );
-
- m_pData->m_rHierarchyHolder->RemoveStreamHierarchically( aListPath );
-}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/package/source/xstor/xstorage.hxx b/package/source/xstor/xstorage.hxx
index e00239f85112..2811616424c0 100644
--- a/package/source/xstor/xstorage.hxx
+++ b/package/source/xstor/xstorage.hxx
@@ -30,14 +30,14 @@
#define __XSTORAGE_HXX_
#include <com/sun/star/uno/Sequence.hxx>
-#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/embed/XStorage2.hpp>
#include <com/sun/star/embed/XOptimizedStorage.hpp>
-#include <com/sun/star/embed/XHierarchicalStorageAccess.hpp>
+#include <com/sun/star/embed/XHierarchicalStorageAccess2.hpp>
#include <com/sun/star/embed/XStorageRawAccess.hpp>
#include <com/sun/star/embed/XTransactedObject.hpp>
#include <com/sun/star/embed/XTransactionBroadcaster.hpp>
#include <com/sun/star/embed/XClassifiedObject.hpp>
-#include <com/sun/star/embed/XEncryptionProtectedSource.hpp>
+#include <com/sun/star/embed/XEncryptionProtectedSource2.hpp>
#include <com/sun/star/embed/XRelationshipAccess.hpp>
#include <com/sun/star/util/XModifiable.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
@@ -53,8 +53,10 @@
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/packages/NoEncryptionException.hpp>
#include <com/sun/star/logging/XSimpleLogRing.hpp>
+
#include <cppuhelper/weak.hxx>
#include <cppuhelper/interfacecontainer.h>
+#include <comphelper/sequenceashashmap.hxx>
#include "mutexholder.hxx"
@@ -158,8 +160,8 @@ struct OStorage_Impl
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > m_xInputStream; // ??? may be stored in properties
::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > m_xStream; // ??? may be stored in properties
::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > m_xProperties;
- sal_Bool m_bHasCommonPassword;
- ::rtl::OUString m_aCommonPassword;
+ sal_Bool m_bHasCommonEncryptionData;
+ ::comphelper::SequenceAsHashMap m_aCommonEncryptionData;
// must be empty in case of root storage
OStorage_Impl* m_pParent;
@@ -232,7 +234,7 @@ struct OStorage_Impl
void Commit();
void Revert();
- ::rtl::OUString GetCommonRootPass() throw ( ::com::sun::star::packages::NoEncryptionException );
+ ::comphelper::SequenceAsHashMap GetCommonRootEncryptionData() throw ( ::com::sun::star::packages::NoEncryptionException );
void CopyToStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xDest,
sal_Bool bDirect );
@@ -265,7 +267,7 @@ struct OStorage_Impl
void CloneStreamElement(
const ::rtl::OUString& aStreamName,
sal_Bool bPassProvided,
- const ::rtl::OUString& aPass,
+ const ::comphelper::SequenceAsHashMap& aEncryptionData,
::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& xTargetStream )
throw ( ::com::sun::star::embed::InvalidStorageException,
::com::sun::star::lang::IllegalArgumentException,
@@ -290,16 +292,16 @@ struct OStorage_Impl
class OStorage : public ::com::sun::star::lang::XTypeProvider
- , public ::com::sun::star::embed::XStorage
+ , public ::com::sun::star::embed::XStorage2
, public ::com::sun::star::embed::XStorageRawAccess
, public ::com::sun::star::embed::XTransactedObject
, public ::com::sun::star::embed::XTransactionBroadcaster
, public ::com::sun::star::util::XModifiable
- , public ::com::sun::star::embed::XEncryptionProtectedSource
+ , public ::com::sun::star::embed::XEncryptionProtectedSource2
, public ::com::sun::star::beans::XPropertySet
, public ::com::sun::star::embed::XOptimizedStorage
, public ::com::sun::star::embed::XRelationshipAccess
- , public ::com::sun::star::embed::XHierarchicalStorageAccess
+ , public ::com::sun::star::embed::XHierarchicalStorageAccess2
, public ::cppu::OWeakObject
{
OStorage_Impl* m_pImpl;
@@ -489,6 +491,28 @@ public:
::com::sun::star::uno::RuntimeException );
//____________________________________________________________________________________________________
+ // XStorage2
+ //____________________________________________________________________________________________________
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > SAL_CALL openEncryptedStream( const ::rtl::OUString& sStreamName, ::sal_Int32 nOpenMode, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& aEncryptionData )
+ throw ( ::com::sun::star::embed::InvalidStorageException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::packages::NoEncryptionException,
+ ::com::sun::star::packages::WrongPasswordException,
+ ::com::sun::star::io::IOException,
+ ::com::sun::star::embed::StorageWrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > SAL_CALL cloneEncryptedStream( const ::rtl::OUString& sStreamName, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& aEncryptionData )
+ throw ( ::com::sun::star::embed::InvalidStorageException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::packages::NoEncryptionException,
+ ::com::sun::star::packages::WrongPasswordException,
+ ::com::sun::star::io::IOException,
+ ::com::sun::star::embed::StorageWrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+
+ //____________________________________________________________________________________________________
// XStorageRawAccess
//____________________________________________________________________________________________________
@@ -615,6 +639,16 @@ public:
::com::sun::star::io::IOException );
//____________________________________________________________________________________________________
+ // XEncryptionProtectedSource2
+ //____________________________________________________________________________________________________
+
+ virtual void SAL_CALL setEncryptionData(
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& aEncryptionData )
+ throw ( ::com::sun::star::io::IOException,
+ ::com::sun::star::uno::RuntimeException );
+
+
+ //____________________________________________________________________________________________________
// XPropertySet
//____________________________________________________________________________________________________
@@ -799,6 +833,18 @@ public:
::com::sun::star::embed::StorageWrappedTargetException,
::com::sun::star::uno::RuntimeException);
+ //____________________________________________________________________________________________________
+ // XHierarchicalStorageAccess2
+ //____________________________________________________________________________________________________
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XExtendedStorageStream > SAL_CALL openEncryptedStreamByHierarchicalName( const ::rtl::OUString& sStreamName, ::sal_Int32 nOpenMode, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& aEncryptionData )
+ throw ( ::com::sun::star::embed::InvalidStorageException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::packages::NoEncryptionException,
+ ::com::sun::star::packages::WrongPasswordException,
+ ::com::sun::star::io::IOException,
+ ::com::sun::star::embed::StorageWrappedTargetException,
+ ::com::sun::star::uno::RuntimeException );
};
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index 2ce94b126ba2..454a4e66094f 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -1646,7 +1646,7 @@ void SAL_CALL ZipPackage::setPropertyValue( const OUString& aPropertyName, const
throw PropertyVetoException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
else if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("EncryptionKey") ) )
{
- if (!( aValue >>= m_aEncryptionKey ) )
+ if (!( aValue >>= m_aEncryptionKey ) || m_aEncryptionKey.getLength() == 0 )
throw IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >(), 2 );
}
else if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("UseManifest") ) )
diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx
index 002d62d96319..c771e65e0a89 100644
--- a/package/source/zippackage/ZipPackageFolder.cxx
+++ b/package/source/zippackage/ZipPackageFolder.cxx
@@ -60,7 +60,6 @@ using namespace std;
using namespace ::com::sun::star;
using rtl::OUString;
-
namespace { struct lcl_CachedImplId : public rtl::Static< Sequence < sal_Int8 >, lcl_CachedImplId > {}; }
ZipPackageFolder::ZipPackageFolder ( const Reference< XMultiServiceFactory >& xFactory,
@@ -272,11 +271,10 @@ Sequence< OUString > SAL_CALL ZipPackageFolder::getElementNames( )
{
sal_uInt32 i=0, nSize = maContents.size();
Sequence < OUString > aSequence ( nSize );
- OUString *pNames = aSequence.getArray();
for ( ContentHash::const_iterator aIterator = maContents.begin(), aEnd = maContents.end();
aIterator != aEnd;
++i, ++aIterator)
- pNames[i] = (*aIterator).first;
+ aSequence[i] = (*aIterator).first;
return aSequence;
}
sal_Bool SAL_CALL ZipPackageFolder::hasByName( const OUString& aName )
@@ -359,7 +357,6 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
const ContentInfo &rInfo = *(*aCI).second;
Sequence < PropertyValue > aPropSet (PKG_SIZE_NOENCR_MNFST);
- PropertyValue *pValue = aPropSet.getArray();
if ( rInfo.bFolder )
pFolder = rInfo.pFolder;
@@ -370,12 +367,17 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
{
OUString sTempName = rPath + rShortName + OUString( RTL_CONSTASCII_USTRINGPARAM ( "/" ) );
- pValue[PKG_MNFST_MEDIATYPE].Name = sMediaTypeProperty;
- pValue[PKG_MNFST_MEDIATYPE].Value <<= pFolder->GetMediaType();
- pValue[PKG_MNFST_VERSION].Name = sVersionProperty;
- pValue[PKG_MNFST_VERSION].Value <<= pFolder->GetVersion();
- pValue[PKG_MNFST_FULLPATH].Name = sFullPathProperty;
- pValue[PKG_MNFST_FULLPATH].Value <<= sTempName;
+ if ( pFolder->GetMediaType().getLength() )
+ {
+ aPropSet[PKG_MNFST_MEDIATYPE].Name = sMediaTypeProperty;
+ aPropSet[PKG_MNFST_MEDIATYPE].Value <<= pFolder->GetMediaType();
+ aPropSet[PKG_MNFST_VERSION].Name = sVersionProperty;
+ aPropSet[PKG_MNFST_VERSION].Value <<= pFolder->GetVersion();
+ aPropSet[PKG_MNFST_FULLPATH].Name = sFullPathProperty;
+ aPropSet[PKG_MNFST_FULLPATH].Value <<= sTempName;
+ }
+ else
+ aPropSet.realloc( 0 );
pFolder->saveContents( sTempName, rManList, rZipOut, rEncryptionKey, rRandomPool);
}
@@ -396,12 +398,12 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
sal_Bool bToBeEncrypted = pStream->IsToBeEncrypted() && (bHaveEncryptionKey || pStream->HasOwnKey());
sal_Bool bToBeCompressed = bToBeEncrypted ? sal_True : pStream->IsToBeCompressed();
- pValue[PKG_MNFST_MEDIATYPE].Name = sMediaTypeProperty;
- pValue[PKG_MNFST_MEDIATYPE].Value <<= pStream->GetMediaType( );
- pValue[PKG_MNFST_VERSION].Name = sVersionProperty;
- pValue[PKG_MNFST_VERSION].Value <<= ::rtl::OUString(); // no version is stored for streams currently
- pValue[PKG_MNFST_FULLPATH].Name = sFullPathProperty;
- pValue[PKG_MNFST_FULLPATH].Value <<= pTempEntry->sPath;
+ aPropSet[PKG_MNFST_MEDIATYPE].Name = sMediaTypeProperty;
+ aPropSet[PKG_MNFST_MEDIATYPE].Value <<= pStream->GetMediaType( );
+ aPropSet[PKG_MNFST_VERSION].Name = sVersionProperty;
+ aPropSet[PKG_MNFST_VERSION].Value <<= ::rtl::OUString(); // no version is stored for streams currently
+ aPropSet[PKG_MNFST_FULLPATH].Name = sFullPathProperty;
+ aPropSet[PKG_MNFST_FULLPATH].Value <<= pTempEntry->sPath;
OSL_ENSURE( pStream->GetStreamMode() != PACKAGE_STREAM_NOTSET, "Unacceptable ZipPackageStream mode!" );
@@ -523,23 +525,22 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
// a magic header
aPropSet.realloc(PKG_SIZE_ENCR_MNFST);
- pValue = aPropSet.getArray();
- pValue[PKG_MNFST_INIVECTOR].Name = sInitialisationVectorProperty;
- pValue[PKG_MNFST_INIVECTOR].Value <<= pStream->getInitialisationVector();
- pValue[PKG_MNFST_SALT].Name = sSaltProperty;
- pValue[PKG_MNFST_SALT].Value <<= pStream->getSalt();
- pValue[PKG_MNFST_ITERATION].Name = sIterationCountProperty;
- pValue[PKG_MNFST_ITERATION].Value <<= pStream->getIterationCount ();
+ aPropSet[PKG_MNFST_INIVECTOR].Name = sInitialisationVectorProperty;
+ aPropSet[PKG_MNFST_INIVECTOR].Value <<= pStream->getInitialisationVector();
+ aPropSet[PKG_MNFST_SALT].Name = sSaltProperty;
+ aPropSet[PKG_MNFST_SALT].Value <<= pStream->getSalt();
+ aPropSet[PKG_MNFST_ITERATION].Name = sIterationCountProperty;
+ aPropSet[PKG_MNFST_ITERATION].Value <<= pStream->getIterationCount ();
// Need to store the uncompressed size in the manifest
OSL_ENSURE( nOwnStreamOrigSize >= 0, "The stream size was not correctly initialized!\n" );
- pValue[PKG_MNFST_UCOMPSIZE].Name = sSizeProperty;
- pValue[PKG_MNFST_UCOMPSIZE].Value <<= nOwnStreamOrigSize;
+ aPropSet[PKG_MNFST_UCOMPSIZE].Name = sSizeProperty;
+ aPropSet[PKG_MNFST_UCOMPSIZE].Value <<= nOwnStreamOrigSize;
if ( bRawStream || bTransportOwnEncrStreamAsRaw )
{
- pValue[PKG_MNFST_DIGEST].Name = sDigestProperty;
- pValue[PKG_MNFST_DIGEST].Value <<= pStream->getDigest();
+ aPropSet[PKG_MNFST_DIGEST].Name = sDigestProperty;
+ aPropSet[PKG_MNFST_DIGEST].Value <<= pStream->getDigest();
}
}
}
@@ -656,8 +657,8 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
if ( bToBeEncrypted )
{
- pValue[PKG_MNFST_DIGEST].Name = sDigestProperty;
- pValue[PKG_MNFST_DIGEST].Value <<= pStream->getDigest();
+ aPropSet[PKG_MNFST_DIGEST].Name = sDigestProperty;
+ aPropSet[PKG_MNFST_DIGEST].Value <<= pStream->getDigest();
pStream->SetIsEncrypted ( sal_True );
}
}
@@ -696,7 +697,8 @@ void ZipPackageFolder::saveContents(OUString &rPath, std::vector < Sequence < Pr
}
// folder can have a mediatype only in package format
- if ( m_nFormat == embed::StorageFormats::PACKAGE || ( m_nFormat == embed::StorageFormats::OFOPXML && !rInfo.bFolder ) )
+ if ( aPropSet.getLength()
+ && ( m_nFormat == embed::StorageFormats::PACKAGE || ( m_nFormat == embed::StorageFormats::OFOPXML && !rInfo.bFolder ) ) )
rManList.push_back( aPropSet );
}
diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx
index 7a299ce33262..06a4413492c1 100644
--- a/package/source/zippackage/ZipPackageStream.cxx
+++ b/package/source/zippackage/ZipPackageStream.cxx
@@ -59,7 +59,6 @@ using namespace com::sun::star;
using namespace cppu;
using rtl::OUString;
-
namespace { struct lcl_CachedImplId : public rtl::Static< Sequence < sal_Int8 >, lcl_CachedImplId > {}; }
const ::com::sun::star::uno::Sequence < sal_Int8 >& ZipPackageStream::static_getImplementationId()
diff --git a/package/util/exports.dxp b/package/util/exports.dxp
index 9630d7e06768..f0e1c69934bc 100644
--- a/package/util/exports.dxp
+++ b/package/util/exports.dxp
@@ -1,3 +1,2 @@
component_getImplementationEnvironment
-component_writeInfo
component_getFactory
diff --git a/package/util/makefile.mk b/package/util/makefile.mk
index 20732c102007..344b2cf1346f 100644
--- a/package/util/makefile.mk
+++ b/package/util/makefile.mk
@@ -75,3 +75,11 @@ DEF1NAME=$(SHL1TARGET)
.INCLUDE : target.mk
+
+ALLTAR : $(MISC)/package2.component
+
+$(MISC)/package2.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \
+ package2.component
+ $(XSLTPROC) --nonet --stringparam uri \
+ '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \
+ $(SOLARENV)/bin/createcomponent.xslt package2.component
diff --git a/package/util/package2.component b/package/util/package2.component
new file mode 100644
index 000000000000..cdfa842d0db6
--- /dev/null
+++ b/package/util/package2.component
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--**********************************************************************
+*
+* 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
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+**********************************************************************-->
+
+<component loader="com.sun.star.loader.SharedLibrary"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.comp.package.zip.ZipFileAccess">
+ <service name="com.sun.star.comp.packages.zip.ZipFileAccess"/>
+ <service name="com.sun.star.packages.zip.ZipFileAccess"/>
+ </implementation>
+ <implementation name="com.sun.star.packages.comp.ZipPackage">
+ <service name="com.sun.star.packages.Package"/>
+ </implementation>
+ <implementation name="com.sun.star.packages.manifest.comp.ManifestReader">
+ <service name="com.sun.star.packages.manifest.ManifestReader"/>
+ </implementation>
+ <implementation name="com.sun.star.packages.manifest.comp.ManifestWriter">
+ <service name="com.sun.star.packages.manifest.ManifestWriter"/>
+ </implementation>
+</component>