summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Sommerfeld <kso@openoffice.org>2001-04-27 12:19:44 +0000
committerKai Sommerfeld <kso@openoffice.org>2001-04-27 12:19:44 +0000
commit47c8fd5e04637e316a0553a98a2f6aa6330fc5db (patch)
tree048ee3066d1fc77bba5c9454e6ab74c6748cfa47
parent28452d9a8a4f7334f3a92c458246017134ddbfe5 (diff)
#86409# - Added support for properties "Encrypted" and EncryptionKey.
Property "Size" no longer supported at package folders.
-rw-r--r--ucb/source/ucp/package/pkgcontent.cxx224
-rw-r--r--ucb/source/ucp/package/pkgcontent.hxx11
-rw-r--r--ucb/source/ucp/package/pkgcontentcaps.cxx27
-rw-r--r--ucb/source/ucp/package/pkgprovider.cxx8
4 files changed, 197 insertions, 73 deletions
diff --git a/ucb/source/ucp/package/pkgcontent.cxx b/ucb/source/ucp/package/pkgcontent.cxx
index c06789bceb05..ab2d5b85b196 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.22 $
+ * $Revision: 1.23 $
*
- * last change: $Author: kso $ $Date: 2001-04-19 14:59:37 $
+ * last change: $Author: kso $ $Date: 2001-04-27 13:19:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -160,6 +160,7 @@ using namespace package_ucp;
#define NONE_MODIFIED sal_uInt32( 0x00 )
#define MEDIATYPE_MODIFIED sal_uInt32( 0x01 )
#define COMPRESSED_MODIFIED sal_uInt32( 0x02 )
+#define ENCRYPTED_MODIFIED sal_uInt32( 0x03 )
//=========================================================================
//=========================================================================
@@ -171,9 +172,10 @@ using namespace package_ucp;
ContentProperties::ContentProperties( const OUString& rContentType )
: aContentType( rContentType ),
-#if SUPD>616
+#if SUPD>614
nSize( 0 ),
- bCompressed( sal_True )
+ bCompressed( sal_True ),
+ bCompressed( sal_False )
#else
nSize( 0 )
#endif
@@ -808,9 +810,13 @@ Reference< XRow > Content::getPropertyValues(
}
else if ( rProp.Name.compareToAscii( "Size" ) == 0 )
{
- xRow->appendLong ( rProp, rData.nSize );
+ // Property only available for streams.
+ if ( rData.bIsDocument )
+ xRow->appendLong( rProp, rData.nSize );
+ else
+ xRow->appendVoid( rProp );
}
-#if SUPD>616
+#if SUPD>614
else if ( rProp.Name.compareToAscii( "Compressed" ) == 0 )
{
// Property only available for streams.
@@ -819,6 +825,14 @@ Reference< XRow > Content::getPropertyValues(
else
xRow->appendVoid( rProp );
}
+ else if ( rProp.Name.compareToAscii( "Encrypted" ) == 0 )
+ {
+ // Property only available for streams.
+ if ( rData.bIsDocument )
+ xRow->appendBoolean( rProp, rData.bEncrypted );
+ else
+ xRow->appendVoid( rProp );
+ }
#endif
else
{
@@ -885,14 +899,17 @@ Reference< XRow > Content::getPropertyValues(
getCppuType( static_cast< const OUString * >( 0 ) ),
PropertyAttribute::BOUND ),
rData.aMediaType );
- xRow->appendLong (
- Property( OUString::createFromAscii( "Size" ),
- -1,
- getCppuType( static_cast< const sal_Int64 * >( 0 ) ),
- PropertyAttribute::BOUND | PropertyAttribute::READONLY ),
- rData.nSize );
+ // Property only available for streams.
+ if ( rData.bIsDocument )
+ xRow->appendLong (
+ Property( OUString::createFromAscii( "Size" ),
+ -1,
+ getCppuType( static_cast< const sal_Int64 * >( 0 ) ),
+ PropertyAttribute::BOUND
+ | PropertyAttribute::READONLY ),
+ rData.nSize );
-#if SUPD>616
+#if SUPD>614
// Property only available for streams.
if ( rData.bIsDocument )
xRow->appendBoolean(
@@ -901,6 +918,15 @@ Reference< XRow > Content::getPropertyValues(
getCppuBooleanType(),
PropertyAttribute::BOUND ),
rData.bCompressed );
+
+ // Property only available for streams.
+ if ( rData.bIsDocument )
+ xRow->appendBoolean(
+ Property( OUString::createFromAscii( "Encrypted" ),
+ -1,
+ getCppuBooleanType(),
+ PropertyAttribute::BOUND ),
+ rData.bEncrypted );
#endif
// Append all Additional Core Properties.
@@ -1014,7 +1040,7 @@ void Content::setPropertyValues( const Sequence< PropertyValue >& rValues )
{
// Read-only property!
}
-#if SUPD>616
+#if SUPD>614
else if ( rValue.Name.compareToAscii( "Compressed" ) == 0 )
{
// Property only available for streams.
@@ -1039,6 +1065,72 @@ void Content::setPropertyValues( const Sequence< PropertyValue >& rValues )
}
}
}
+ else if ( rValue.Name.compareToAscii( "Encrypted" ) == 0 )
+ {
+ // Property only available for streams.
+ if ( m_aProps.bIsDocument )
+ {
+ sal_Bool bNewValue;
+ if ( rValue.Value >>= bNewValue )
+ {
+ if ( bNewValue != m_aProps.bEncrypted )
+ {
+ osl::Guard< osl::Mutex > aGuard( m_aMutex );
+
+ aEvent.PropertyName = rValue.Name;
+ aEvent.OldValue = makeAny( m_aProps.bEncrypted );
+ aEvent.NewValue = makeAny( bNewValue );
+
+ m_aProps.bEncrypted = bNewValue;
+ nChanged++;
+ bStore = sal_True;
+ m_nModifiedProps |= ENCRYPTED_MODIFIED;
+ }
+ }
+ }
+ }
+ else if ( rValue.Name.compareToAscii( "EncryptionKey" ) == 0 )
+ {
+ // @@@ 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.getPath().compareToAscii( "/" ) == 0 )
+ {
+ Reference< XPropertySet > xPropSet( getPackage(), UNO_QUERY );
+
+ OSL_ENSURE( xPropSet.is(),
+ "Content::setPropertyValues - "
+ "Got no XPropertySet interface from package!" );
+
+ if ( xPropSet.is() )
+ {
+ try
+ {
+ xPropSet->setPropertyValue(
+ OUString::createFromAscii( "EncryptionKey" ),
+ rValue.Value );
+ }
+ catch ( UnknownPropertyException & )
+ {
+ // setPropertyValue
+ }
+ catch ( PropertyVetoException & )
+ {
+ // setPropertyValue
+ }
+ catch ( IllegalArgumentException & )
+ {
+ // setPropertyValue
+ }
+ catch ( WrappedTargetException & )
+ {
+ // setPropertyValue
+ }
+ }
+ }
+ }
#endif
else
{
@@ -1823,32 +1915,6 @@ sal_Bool Content::loadData( ContentProvider* pProvider,
return sal_False;
}
- // Size
- try
- {
- Any aSize
- = xPropSet->getPropertyValue(
- OUString::createFromAscii( "Size" ) );
- if ( !( aSize >>= rProps.nSize ) )
- {
- VOS_ENSURE( sal_False,
- "Content::loadData - Got no Size value!" );
- return sal_False;
- }
- }
- catch ( UnknownPropertyException & )
- {
- VOS_ENSURE( sal_False,
- "Content::loadData - Got no Size value!" );
- return sal_False;
- }
- catch ( WrappedTargetException & )
- {
- VOS_ENSURE( sal_False,
- "Content::loadData - Got no Size value!" );
- return sal_False;
- }
-
Reference< XEnumerationAccess > xEnumAccess;
aEntry >>= xEnumAccess;
@@ -1870,10 +1936,35 @@ sal_Bool Content::loadData( ContentProvider* pProvider,
rProps.bIsFolder = sal_False;
}
-#if SUPD>616
- // Compressed ( only available for streams )
if ( rProps.bIsDocument )
{
+ // Size ( only available for streams )
+ try
+ {
+ Any aSize
+ = xPropSet->getPropertyValue(
+ OUString::createFromAscii( "Size" ) );
+ if ( !( aSize >>= rProps.nSize ) )
+ {
+ VOS_ENSURE( sal_False,
+ "Content::loadData - Got no Size value!" );
+ return sal_False;
+ }
+ }
+ catch ( UnknownPropertyException & )
+ {
+ VOS_ENSURE( sal_False,
+ "Content::loadData - Got no Size value!" );
+ return sal_False;
+ }
+ catch ( WrappedTargetException & )
+ {
+ VOS_ENSURE( sal_False,
+ "Content::loadData - Got no Size value!" );
+ return sal_False;
+ }
+#if SUPD>614
+ // Compressed ( only available for streams )
try
{
Any aCompressed
@@ -1882,24 +1973,50 @@ sal_Bool Content::loadData( ContentProvider* pProvider,
if ( !( aCompressed >>= rProps.bCompressed ) )
{
VOS_ENSURE( sal_False,
- "Content::loadData - Got no Commpress value!" );
+ "Content::loadData - Got no Compressed value!" );
return sal_False;
}
}
catch ( UnknownPropertyException & )
{
VOS_ENSURE( sal_False,
- "Content::loadData - Got no Compress value!" );
+ "Content::loadData - Got no Compressed value!" );
return sal_False;
}
catch ( WrappedTargetException & )
{
VOS_ENSURE( sal_False,
- "Content::loadData - Got no Compress value!" );
+ "Content::loadData - Got no Compressed value!" );
+ return sal_False;
+ }
+
+ // Encrypted ( only available for streams )
+ try
+ {
+ Any aEncrypted
+ = xPropSet->getPropertyValue(
+ OUString::createFromAscii( "Encrypted" ) );
+ if ( !( aEncrypted >>= rProps.bEncrypted ) )
+ {
+ VOS_ENSURE( sal_False,
+ "Content::loadData - Got no Encrypted value!" );
+ return sal_False;
+ }
+ }
+ catch ( UnknownPropertyException & )
+ {
+ VOS_ENSURE( sal_False,
+ "Content::loadData - Got no Encrypted value!" );
+ return sal_False;
+ }
+ catch ( WrappedTargetException & )
+ {
+ VOS_ENSURE( sal_False,
+ "Content::loadData - Got no Encrypted value!" );
return sal_False;
}
- }
#endif
+ }
return sal_True;
}
}
@@ -2052,9 +2169,8 @@ sal_Bool Content::storeData( const Reference< XInputStream >& xStream )
try
{
- Any aEntry = xNA->getByHierarchicalName( m_aUri.getPath() );
Reference< XPropertySet > xPropSet;
- aEntry >>= xPropSet;
+ xNA->getByHierarchicalName( m_aUri.getPath() ) >>= xPropSet;
if ( !xPropSet.is() )
{
@@ -2075,7 +2191,7 @@ sal_Bool Content::storeData( const Reference< XInputStream >& xStream )
m_nModifiedProps &= ~MEDIATYPE_MODIFIED;
}
-#if SUPD>616
+#if SUPD>614
if ( m_nModifiedProps & COMPRESSED_MODIFIED )
{
if ( !isFolder() )
@@ -2085,6 +2201,16 @@ sal_Bool Content::storeData( const Reference< XInputStream >& xStream )
m_nModifiedProps &= ~COMPRESSED_MODIFIED;
}
+
+ if ( m_nModifiedProps & ENCRYPTED_MODIFIED )
+ {
+ if ( !isFolder() )
+ xPropSet->setPropertyValue(
+ OUString::createFromAscii( "Encrypted" ),
+ makeAny( m_aProps.bEncrypted ) );
+
+ m_nModifiedProps &= ~ENCRYPTED_MODIFIED;
+ }
#endif
//////////////////////////////////////////////////////////////////
diff --git a/ucb/source/ucp/package/pkgcontent.hxx b/ucb/source/ucp/package/pkgcontent.hxx
index 414d44c450c6..501cc52b8d43 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.14 $
+ * $Revision: 1.15 $
*
- * last change: $Author: kso $ $Date: 2001-04-19 14:59:37 $
+ * last change: $Author: kso $ $Date: 2001-04-27 13:19:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -129,14 +129,15 @@ struct ContentProperties
sal_Bool bIsFolder; // IsFolder
::rtl::OUString aMediaType; // MediaType
sal_Int64 nSize; // Size
-#if SUPD>616
+#if SUPD>614
sal_Bool bCompressed; // Compressed
+ sal_Bool bEncrypted; // Encrypted
#endif
-#if SUPD>616
+#if SUPD>614
ContentProperties()
: bIsDocument( sal_True ), bIsFolder( sal_False ), nSize( 0 ),
- bCompressed( sal_True ) {}
+ bCompressed( sal_True ), bEncrypted( sal_False ) {}
#else
ContentProperties()
: bIsDocument( sal_True ), bIsFolder( sal_False ), nSize( 0 ) {}
diff --git a/ucb/source/ucp/package/pkgcontentcaps.cxx b/ucb/source/ucp/package/pkgcontentcaps.cxx
index 65447cd27eb7..8e36b1455285 100644
--- a/ucb/source/ucp/package/pkgcontentcaps.cxx
+++ b/ucb/source/ucp/package/pkgcontentcaps.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: pkgcontentcaps.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: kso $ $Date: 2001-03-27 14:08:51 $
+ * last change: $Author: kso $ $Date: 2001-04-27 13:19:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -71,10 +71,11 @@
IsDocument x x
IsFolder x x
MediaType (x) x
- Size x x
Title x x
-#if SUPD>616
+ Size x
+#if SUPD>614
Compressed x
+ Encrypted x
#endif
getCommandInfo x x
@@ -186,12 +187,6 @@ Sequence< Property > Content::getProperties(
-1,
getCppuType( static_cast< const OUString * >( 0 ) ),
PropertyAttribute::BOUND
- ),
- Property(
- OUString( RTL_CONSTASCII_USTRINGPARAM( "Size" ) ),
- -1,
- getCppuType( static_cast< const sal_Int64 * >( 0 ) ),
- PropertyAttribute::BOUND | PropertyAttribute::READONLY
)
///////////////////////////////////////////////////////////////
// New properties
@@ -250,7 +245,7 @@ Sequence< Property > Content::getProperties(
-1,
getCppuType( static_cast< const sal_Int64 * >( 0 ) ),
PropertyAttribute::BOUND | PropertyAttribute::READONLY
-#if SUPD>616
+#if SUPD>614
),
///////////////////////////////////////////////////////////////
// New properties
@@ -260,11 +255,17 @@ Sequence< Property > Content::getProperties(
-1,
getCppuType( static_cast< const sal_Bool * >( 0 ) ),
PropertyAttribute::BOUND
+ ),
+ Property(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "Encrypted" ) ),
+ -1,
+ getCppuType( static_cast< const sal_Bool * >( 0 ) ),
+ PropertyAttribute::BOUND
#endif
)
};
-#if SUPD>616
- return Sequence< Property >( aStreamPropertyInfoTable, 7 );
+#if SUPD>614
+ return Sequence< Property >( aStreamPropertyInfoTable, 8 );
#else
return Sequence< Property >( aStreamPropertyInfoTable, 6 );
#endif
diff --git a/ucb/source/ucp/package/pkgprovider.cxx b/ucb/source/ucp/package/pkgprovider.cxx
index afdf18b2dbd5..913731f81b07 100644
--- a/ucb/source/ucp/package/pkgprovider.cxx
+++ b/ucb/source/ucp/package/pkgprovider.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: pkgprovider.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: kso $ $Date: 2001-04-05 09:48:30 $
+ * last change: $Author: kso $ $Date: 2001-04-27 13:19:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -325,12 +325,8 @@ Reference< XHierarchicalNameAccess > ContentProvider::createPackage(
Reference< XInterface > xIfc
= m_xSMgr->createInstanceWithArguments(
-#if SUPD>625
OUString::createFromAscii(
"com.sun.star.packages.comp.ZipPackage" ),
-#else
- OUString::createFromAscii( "com.sun.star.package.Package" ),
-#endif
aArguments );
if ( xIfc.is() )