From f57baefbd3c4c5d8e5ec28e8702c91d60ffc5de2 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 8 Sep 2011 13:50:30 +0100 Subject: add chaff to encrypted documents --- package/source/xstor/owriteablestream.cxx | 17 +++++++++++++++++ package/source/xstor/owriteablestream.hxx | 1 + package/source/xstor/xstorage.cxx | 9 +++++++++ package/source/xstor/xstorage.hxx | 3 +++ 4 files changed, 30 insertions(+) (limited to 'package/source') diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx index 56b308b60478..29afc8649228 100644 --- a/package/source/xstor/owriteablestream.cxx +++ b/package/source/xstor/owriteablestream.cxx @@ -2749,6 +2749,23 @@ void SAL_CALL OWriteStream::setEncryptionData( const uno::Sequence< beans::Named ModifyParentUnlockMutex_Impl( aGuard ); } +//----------------------------------------------- +sal_Bool SAL_CALL OWriteStream::hasEncryptionData() + throw (uno::RuntimeException) +{ + ::osl::ResettableMutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() ); + + if (!m_pImpl) + return sal_False; + + sal_Bool bRet = m_pImpl->IsEncrypted(); + + if (!bRet && m_pImpl->m_bUseCommonEncryption && m_pImpl->m_pParent) + bRet = m_pImpl->m_pParent->m_bHasCommonEncryptionData; + + return bRet; +} + //----------------------------------------------- sal_Bool SAL_CALL OWriteStream::hasByID( const ::rtl::OUString& sID ) throw ( io::IOException, diff --git a/package/source/xstor/owriteablestream.hxx b/package/source/xstor/owriteablestream.hxx index 0e9884bd75cb..aefe0b82002c 100644 --- a/package/source/xstor/owriteablestream.hxx +++ b/package/source/xstor/owriteablestream.hxx @@ -372,6 +372,7 @@ public: //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); + virtual sal_Bool SAL_CALL hasEncryptionData() throw (::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); diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx index 9c0c117f5e35..40b129ff509a 100644 --- a/package/source/xstor/xstorage.cxx +++ b/package/source/xstor/xstorage.cxx @@ -4806,6 +4806,15 @@ void SAL_CALL OStorage::setEncryptionData( const uno::Sequence< beans::NamedValu } } +sal_Bool SAL_CALL OStorage::hasEncryptionData() + throw ( uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_pData->m_rSharedMutexRef->GetMutex() ); + + return m_pImpl && m_pImpl->m_bHasCommonEncryptionData; +} + + //____________________________________________________________________________________________________ // XEncryptionProtectedStorage //____________________________________________________________________________________________________ diff --git a/package/source/xstor/xstorage.hxx b/package/source/xstor/xstorage.hxx index f472444556c2..f1770e5e372f 100644 --- a/package/source/xstor/xstorage.hxx +++ b/package/source/xstor/xstorage.hxx @@ -647,6 +647,9 @@ public: throw ( ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL hasEncryptionData() + throw ( ::com::sun::star::uno::RuntimeException ); + //____________________________________________________________________________________________________ // XEncryptionProtectedStorage //____________________________________________________________________________________________________ -- cgit