summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorKai Sommerfeld <kso@openoffice.org>2001-10-11 13:18:56 +0000
committerKai Sommerfeld <kso@openoffice.org>2001-10-11 13:18:56 +0000
commitdcc4e67af54d75295f820c69ac9c008307ef0e9b (patch)
tree0c12c8f0d89b3f49c44850895f2f0bf2173d2179 /ucb
parent98c148fb406f70aa82aa3ac88868e2bbd46f5c68 (diff)
#92268# - Added support for property "EncryptionKey" for package streams.
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/ucp/package/pkgcontent.cxx164
-rw-r--r--ucb/source/ucp/package/pkgcontent.hxx5
2 files changed, 96 insertions, 73 deletions
diff --git a/ucb/source/ucp/package/pkgcontent.cxx b/ucb/source/ucp/package/pkgcontent.cxx
index b034cffb3be2..0d507670b5f3 100644
--- a/ucb/source/ucp/package/pkgcontent.cxx
+++ b/ucb/source/ucp/package/pkgcontent.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: pkgcontent.cxx,v $
*
- * $Revision: 1.37 $
+ * $Revision: 1.38 $
*
- * last change: $Author: obo $ $Date: 2001-09-28 08:25:10 $
+ * last change: $Author: kso $ $Date: 2001-10-11 14:18:56 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -193,6 +193,7 @@ using namespace package_ucp;
#define COMPRESSED_MODIFIED sal_uInt32( 0x02 )
#define ENCRYPTED_MODIFIED sal_uInt32( 0x04 )
#define SEGMENTSIZE_MODIFIED sal_uInt32( 0x08 )
+#define ENCRYPTIONKEY_MODIFIED sal_uInt32( 0x10 )
//=========================================================================
//=========================================================================
@@ -1383,51 +1384,31 @@ uno::Sequence< uno::Any > Content::setPropertyValues(
// @@@ This is a temporary solution. In the future submitting
// the key should be done using an interaction handler!
- // Write-Only property. Only supported by root folder ( all
- // streams of a package have the same encryption key ).
- if ( m_aUri.isRootFolder() )
+ // Write-Only property. Only supported by root folder and streams
+ // (all non-root folders of a package have the same encryption key).
+ if ( m_aUri.isRootFolder() || m_aProps.bIsDocument )
{
- uno::Reference< beans::XPropertySet > xPropSet(
- getPackage(), uno::UNO_QUERY );
-
- OSL_ENSURE( xPropSet.is(),
- "Content::setPropertyValues - "
- "Got no XPropertySet interface from package!" );
-
- if ( xPropSet.is() )
+ rtl::OUString aNewValue;
+ if ( rValue.Value >>= aNewValue )
{
- try
- {
- xPropSet->setPropertyValue(
- rtl::OUString::createFromAscii( "EncryptionKey" ),
- rValue.Value );
- }
- catch ( beans::UnknownPropertyException const & e )
- {
- // setPropertyValue
- aRet[ n ] <<= e;
- }
- catch ( beans::PropertyVetoException const & e )
- {
- // setPropertyValue
- aRet[ n ] <<= e;
- }
- catch ( lang::IllegalArgumentException const & e )
+ if ( aNewValue != m_aProps.aEncryptionKey )
{
- // setPropertyValue
- aRet[ n ] <<= e;
- }
- catch ( lang::WrappedTargetException const & e )
- {
- // setPropertyValue
- aRet[ n ] <<= e;
+ aEvent.PropertyName = rValue.Name;
+ aEvent.OldValue = uno::makeAny(
+ m_aProps.aEncryptionKey );
+ aEvent.NewValue = uno::makeAny( aNewValue );
+
+ m_aProps.aEncryptionKey = aNewValue;
+ nChanged++;
+ bStore = sal_True;
+ m_nModifiedProps |= ENCRYPTIONKEY_MODIFIED;
}
}
else
{
- aRet[ n ] <<= uno::Exception(
+ aRet[ n ] <<= beans::IllegalTypeException(
rtl::OUString::createFromAscii(
- "No property set for storing the value!" ),
+ "Property value has wrong type!" ),
static_cast< cppu::OWeakObject * >( this ) );
}
}
@@ -1435,7 +1416,7 @@ uno::Sequence< uno::Any > Content::setPropertyValues(
{
aRet[ n ] <<= beans::UnknownPropertyException(
rtl::OUString::createFromAscii(
- "EncryptionKey only supported by root folder!" ),
+ "EncryptionKey not supported by non-root folder!" ),
static_cast< cppu::OWeakObject * >( this ) );
}
}
@@ -1544,7 +1525,8 @@ uno::Sequence< uno::Any > Content::setPropertyValues(
if ( nChanged > 0 )
{
// Save changes, if content was already made persistent.
- if ( bStore && ( m_eState == PERSISTENT ) )
+ if ( ( m_nModifiedProps & ENCRYPTIONKEY_MODIFIED ) ||
+ ( bStore && ( m_eState == PERSISTENT ) ) )
{
if ( !storeData( uno::Reference< io::XInputStream >() ) )
{
@@ -2703,43 +2685,73 @@ sal_Bool Content::storeData( const uno::Reference< io::XInputStream >& xStream )
if ( !xNA.is() )
return sal_False;
+ uno::Reference< beans::XPropertySet > xPackagePropSet(
+ xNA, uno::UNO_QUERY );
+ OSL_ENSURE( xPackagePropSet.is(),
+ "Content::storeData - "
+ "Got no XPropertySet interface from package!" );
+
+ if ( !xPackagePropSet.is() )
+ return sal_False;
+
if ( m_nModifiedProps & SEGMENTSIZE_MODIFIED )
{
if ( m_aUri.isRootFolder() )
{
- // Properties available only from package
- uno::Reference< beans::XPropertySet > xPackagePropSet(
- xNA, uno::UNO_QUERY );
-
- OSL_ENSURE( xPackagePropSet.is(),
- "Content::storeData - "
- "Got no XPropertySet interface from package!" );
-
- if ( xPackagePropSet.is() )
+ // Property available only from package
+ try
{
- try
- {
- xPackagePropSet->setPropertyValue(
+ xPackagePropSet->setPropertyValue(
rtl::OUString::createFromAscii( "SegmentSize" ),
uno::makeAny( m_aProps.nSegmentSize ) );
- m_nModifiedProps &= ~SEGMENTSIZE_MODIFIED;
- }
- catch ( beans::UnknownPropertyException const & )
- {
- // setPropertyValue
- }
- catch ( beans::PropertyVetoException const & )
- {
- // setPropertyValue
- }
- catch ( lang::IllegalArgumentException const & )
- {
- // setPropertyValue
- }
- catch ( lang::WrappedTargetException const & )
- {
- // setPropertyValue
- }
+ m_nModifiedProps &= ~SEGMENTSIZE_MODIFIED;
+ }
+ catch ( beans::UnknownPropertyException const & )
+ {
+ // setPropertyValue
+ }
+ catch ( beans::PropertyVetoException const & )
+ {
+ // setPropertyValue
+ }
+ catch ( lang::IllegalArgumentException const & )
+ {
+ // setPropertyValue
+ }
+ catch ( lang::WrappedTargetException const & )
+ {
+ // setPropertyValue
+ }
+ }
+ }
+
+ if ( m_nModifiedProps & ENCRYPTIONKEY_MODIFIED )
+ {
+ if ( m_aUri.isRootFolder() )
+ {
+ // Property available only from package and from streams (see below)
+ try
+ {
+ xPackagePropSet->setPropertyValue(
+ rtl::OUString::createFromAscii( "EncryptionKey" ),
+ uno::makeAny( m_aProps.aEncryptionKey ) );
+ m_nModifiedProps &= ~ENCRYPTIONKEY_MODIFIED;
+ }
+ catch ( beans::UnknownPropertyException const & )
+ {
+ // setPropertyValue
+ }
+ catch ( beans::PropertyVetoException const & )
+ {
+ // setPropertyValue
+ }
+ catch ( lang::IllegalArgumentException const & )
+ {
+ // setPropertyValue
+ }
+ catch ( lang::WrappedTargetException const & )
+ {
+ // setPropertyValue
}
}
}
@@ -2879,6 +2891,16 @@ sal_Bool Content::storeData( const uno::Reference< io::XInputStream >& xStream )
m_nModifiedProps &= ~ENCRYPTED_MODIFIED;
}
+ if ( m_nModifiedProps & ENCRYPTIONKEY_MODIFIED )
+ {
+ if ( !isFolder() )
+ xPropSet->setPropertyValue(
+ rtl::OUString::createFromAscii( "EncryptionKey" ),
+ uno::makeAny( m_aProps.aEncryptionKey ) );
+
+ m_nModifiedProps &= ~ENCRYPTIONKEY_MODIFIED;
+ }
+
//////////////////////////////////////////////////////////////////
// Store data stream...
//////////////////////////////////////////////////////////////////
diff --git a/ucb/source/ucp/package/pkgcontent.hxx b/ucb/source/ucp/package/pkgcontent.hxx
index 4c95b313c675..49df3beb4a0b 100644
--- a/ucb/source/ucp/package/pkgcontent.hxx
+++ b/ucb/source/ucp/package/pkgcontent.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: pkgcontent.hxx,v $
*
- * $Revision: 1.22 $
+ * $Revision: 1.23 $
*
- * last change: $Author: kso $ $Date: 2001-07-06 09:32:34 $
+ * last change: $Author: kso $ $Date: 2001-10-11 14:18:56 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -129,6 +129,7 @@ struct ContentProperties
sal_Bool bIsDocument; // IsDocument
sal_Bool bIsFolder; // IsFolder
::rtl::OUString aMediaType; // MediaType
+ ::rtl::OUString aEncryptionKey; // EncryptionKey
sal_Int64 nSize; // Size
sal_Int32 nSegmentSize; // SegmentSize
sal_Bool bCompressed; // Compressed