summaryrefslogtreecommitdiff
path: root/comphelper/source/misc
diff options
context:
space:
mode:
Diffstat (limited to 'comphelper/source/misc')
-rwxr-xr-xcomphelper/source/misc/anycompare.cxx131
-rw-r--r--comphelper/source/misc/componentmodule.cxx58
-rw-r--r--comphelper/source/misc/docpasswordhelper.cxx152
-rwxr-xr-x[-rw-r--r--]comphelper/source/misc/docpasswordrequest.cxx67
-rw-r--r--comphelper/source/misc/makefile.mk101
-rw-r--r--comphelper/source/misc/mediadescriptor.cxx42
-rw-r--r--comphelper/source/misc/mimeconfighelper.cxx200
-rw-r--r--comphelper/source/misc/namedvaluecollection.cxx47
-rw-r--r--comphelper/source/misc/querydeep.cxx78
-rw-r--r--comphelper/source/misc/scopeguard.cxx10
-rw-r--r--comphelper/source/misc/servicedecl.cxx31
-rw-r--r--comphelper/source/misc/storagehelper.cxx52
-rw-r--r--comphelper/source/misc/uieventslogger.cxx9
13 files changed, 610 insertions, 368 deletions
diff --git a/comphelper/source/misc/anycompare.cxx b/comphelper/source/misc/anycompare.cxx
new file mode 100755
index 000000000000..a86174daf08e
--- /dev/null
+++ b/comphelper/source/misc/anycompare.cxx
@@ -0,0 +1,131 @@
+/*************************************************************************
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_comphelper.hxx"
+
+#include "comphelper/anycompare.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+//......................................................................................................................
+namespace comphelper
+{
+//......................................................................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::uno::TypeClass_CHAR;
+ using ::com::sun::star::uno::TypeClass_BOOLEAN;
+ using ::com::sun::star::uno::TypeClass_BYTE;
+ using ::com::sun::star::uno::TypeClass_SHORT;
+ using ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT;
+ using ::com::sun::star::uno::TypeClass_LONG;
+ using ::com::sun::star::uno::TypeClass_UNSIGNED_LONG;
+ using ::com::sun::star::uno::TypeClass_HYPER;
+ using ::com::sun::star::uno::TypeClass_UNSIGNED_HYPER;
+ using ::com::sun::star::uno::TypeClass_FLOAT;
+ using ::com::sun::star::uno::TypeClass_DOUBLE;
+ using ::com::sun::star::uno::TypeClass_STRING;
+ using ::com::sun::star::uno::TypeClass_TYPE;
+ using ::com::sun::star::uno::TypeClass_ENUM;
+ using ::com::sun::star::uno::TypeClass_INTERFACE;
+ using ::com::sun::star::i18n::XCollator;
+ /** === end UNO using === **/
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::std::auto_ptr< IKeyPredicateLess > getStandardLessPredicate( Type const & i_type, Reference< XCollator > const & i_collator )
+ {
+ ::std::auto_ptr< IKeyPredicateLess > pComparator;
+ switch ( i_type.getTypeClass() )
+ {
+ case TypeClass_CHAR:
+ pComparator.reset( new ScalarPredicateLess< sal_Unicode >() );
+ break;
+ case TypeClass_BOOLEAN:
+ pComparator.reset( new ScalarPredicateLess< sal_Bool >() );
+ break;
+ case TypeClass_BYTE:
+ pComparator.reset( new ScalarPredicateLess< sal_Int8 >() );
+ break;
+ case TypeClass_SHORT:
+ pComparator.reset( new ScalarPredicateLess< sal_Int16 >() );
+ break;
+ case TypeClass_UNSIGNED_SHORT:
+ pComparator.reset( new ScalarPredicateLess< sal_uInt16 >() );
+ break;
+ case TypeClass_LONG:
+ pComparator.reset( new ScalarPredicateLess< sal_Int32 >() );
+ break;
+ case TypeClass_UNSIGNED_LONG:
+ pComparator.reset( new ScalarPredicateLess< sal_uInt32 >() );
+ break;
+ case TypeClass_HYPER:
+ pComparator.reset( new ScalarPredicateLess< sal_Int64 >() );
+ break;
+ case TypeClass_UNSIGNED_HYPER:
+ pComparator.reset( new ScalarPredicateLess< sal_uInt64 >() );
+ break;
+ case TypeClass_FLOAT:
+ pComparator.reset( new ScalarPredicateLess< float >() );
+ break;
+ case TypeClass_DOUBLE:
+ pComparator.reset( new ScalarPredicateLess< double >() );
+ break;
+ case TypeClass_STRING:
+ if ( i_collator.is() )
+ pComparator.reset( new StringCollationPredicateLess( i_collator ) );
+ else
+ pComparator.reset( new StringPredicateLess() );
+ break;
+ case TypeClass_TYPE:
+ pComparator.reset( new TypePredicateLess() );
+ break;
+ case TypeClass_ENUM:
+ pComparator.reset( new EnumPredicateLess( i_type ) );
+ break;
+ case TypeClass_INTERFACE:
+ pComparator.reset( new InterfacePredicateLess() );
+ break;
+ default:
+ break;
+ }
+ return pComparator;
+ }
+
+//......................................................................................................................
+} // namespace comphelper
+//......................................................................................................................
diff --git a/comphelper/source/misc/componentmodule.cxx b/comphelper/source/misc/componentmodule.cxx
index 3e52a5875b7a..c42308c71508 100644
--- a/comphelper/source/misc/componentmodule.cxx
+++ b/comphelper/source/misc/componentmodule.cxx
@@ -136,64 +136,6 @@ namespace comphelper
}
//--------------------------------------------------------------------------
- sal_Bool OModule::writeComponentInfos( void* pServiceManager, void* pRegistryKey )
- {
- Reference< XMultiServiceFactory > xFactory( static_cast< XMultiServiceFactory* >( pServiceManager ) );
- Reference< XRegistryKey > xRegistryKey( static_cast< XRegistryKey* >( pRegistryKey ) );
- return writeComponentInfos( xFactory, xRegistryKey );
- }
-
- //--------------------------------------------------------------------------
- sal_Bool OModule::writeComponentInfos(
- const Reference< XMultiServiceFactory >& /*_rxServiceManager*/,
- const Reference< XRegistryKey >& _rxRootKey )
- {
- OSL_ENSURE( _rxRootKey.is(), "OModule::writeComponentInfos: invalid argument!" );
-
- ::rtl::OUString sRootKey( "/", 1, RTL_TEXTENCODING_ASCII_US );
-
- for ( ComponentDescriptions::const_iterator component = m_pImpl->m_aRegisteredComponents.begin();
- component != m_pImpl->m_aRegisteredComponents.end();
- ++component
- )
- {
- ::rtl::OUString sMainKeyName( sRootKey );
- sMainKeyName += component->sImplementationName;
- sMainKeyName += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
-
- try
- {
- Reference< XRegistryKey > xNewKey( _rxRootKey->createKey( sMainKeyName ) );
-
- const ::rtl::OUString* pService = component->aSupportedServices.getConstArray();
- const ::rtl::OUString* pServiceEnd = component->aSupportedServices.getConstArray() + component->aSupportedServices.getLength();
- for ( ; pService != pServiceEnd; ++pService )
- xNewKey->createKey( *pService );
-
- if ( component->sSingletonName.getLength() )
- {
- OSL_ENSURE( component->aSupportedServices.getLength() == 1, "OModule::writeComponentInfos: singletons should support exactly one service, shouldn't they?" );
-
- ::rtl::OUString sSingletonKeyName( sRootKey );
- sSingletonKeyName += component->sImplementationName;
- sSingletonKeyName += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SINGLETONS/"));
- sSingletonKeyName += component->sSingletonName;
-
- xNewKey = _rxRootKey->createKey( sSingletonKeyName );
- xNewKey->setStringValue( component->aSupportedServices[ 0 ] );
- }
- }
- catch( Exception& )
- {
- OSL_FAIL( "OModule::writeComponentInfos: something went wrong while creating the keys!" );
- return sal_False;
- }
- }
-
- return sal_True;
- }
-
- //--------------------------------------------------------------------------
void* OModule::getComponentFactory( const sal_Char* _pImplementationName, void* _pServiceManager, void* /*_pRegistryKey*/ )
{
Reference< XInterface > xFactory( getComponentFactory(
diff --git a/comphelper/source/misc/docpasswordhelper.cxx b/comphelper/source/misc/docpasswordhelper.cxx
index ccc680729482..36cb3cd15aff 100644
--- a/comphelper/source/misc/docpasswordhelper.cxx
+++ b/comphelper/source/misc/docpasswordhelper.cxx
@@ -85,16 +85,9 @@ uno::Sequence< beans::PropertyValue > DocPasswordHelper::GenerateNewModifyPasswo
{
uno::Sequence< beans::PropertyValue > aResult;
- uno::Sequence< sal_Int8 > aSalt( 16 );
+ uno::Sequence< sal_Int8 > aSalt = GenerateRandomByteSequence( 16 );
sal_Int32 nCount = 1024;
- TimeValue aTime;
- osl_getSystemTime( &aTime );
- rtlRandomPool aRandomPool = rtl_random_createPool ();
- rtl_random_addBytes ( aRandomPool, &aTime, 8 );
-
- rtl_random_getBytes ( aRandomPool, aSalt.getArray(), 16 );
-
uno::Sequence< sal_Int8 > aNewHash = GeneratePBKDF2Hash( aPassword, aSalt, nCount, 16 );
if ( aNewHash.getLength() )
{
@@ -109,9 +102,6 @@ uno::Sequence< beans::PropertyValue > DocPasswordHelper::GenerateNewModifyPasswo
aResult[3].Value <<= aNewHash;
}
- // Clean up random pool memory
- rtl_random_destroyPool ( aRandomPool );
-
return aResult;
}
@@ -283,9 +273,98 @@ Sequence< sal_Int8 > DocPasswordHelper::GetXLHashAsSequence(
}
// ============================================================================
+/*static*/ uno::Sequence< sal_Int8 > DocPasswordHelper::GenerateRandomByteSequence( sal_Int32 nLength )
+{
+ uno::Sequence< sal_Int8 > aResult( nLength );
+
+ TimeValue aTime;
+ osl_getSystemTime( &aTime );
+ rtlRandomPool aRandomPool = rtl_random_createPool ();
+ rtl_random_addBytes ( aRandomPool, &aTime, 8 );
+ rtl_random_getBytes ( aRandomPool, aResult.getArray(), nLength );
+ rtl_random_destroyPool ( aRandomPool );
-/*static*/ OUString DocPasswordHelper::requestAndVerifyDocPassword(
+ return aResult;
+}
+
+
+// ============================================================================
+/*static*/ uno::Sequence< sal_Int8 > DocPasswordHelper::GenerateStd97Key( const ::rtl::OUString& aPassword, const uno::Sequence< sal_Int8 >& aDocId )
+{
+ uno::Sequence< sal_Int8 > aResultKey;
+ if ( aPassword.getLength() && aDocId.getLength() == 16 )
+ {
+ sal_uInt16 pPassData[16];
+ rtl_zeroMemory( pPassData, sizeof(pPassData) );
+
+ sal_Int32 nPassLen = ::std::min< sal_Int32 >( aPassword.getLength(), 15 );
+ rtl_copyMemory( pPassData, aPassword.getStr(), nPassLen * sizeof(pPassData[0]) );
+
+ aResultKey = GenerateStd97Key( pPassData, aDocId );
+ }
+
+ return aResultKey;
+}
+
+// ============================================================================
+/*static*/ uno::Sequence< sal_Int8 > DocPasswordHelper::GenerateStd97Key( const sal_uInt16 pPassData[16], const uno::Sequence< sal_Int8 >& aDocId )
+{
+ uno::Sequence< sal_Int8 > aResultKey;
+ if ( pPassData[0] && aDocId.getLength() == 16 )
+ {
+ sal_uInt8 pKeyData[64];
+ rtl_zeroMemory( pKeyData, sizeof(pKeyData) );
+
+ sal_Int32 nInd = 0;
+
+ // Fill PassData into KeyData.
+ for ( nInd = 0; nInd < 16 && pPassData[nInd]; nInd++)
+ {
+ pKeyData[2*nInd] = sal::static_int_cast< sal_uInt8 >( (pPassData[nInd] >> 0) & 0xff );
+ pKeyData[2*nInd + 1] = sal::static_int_cast< sal_uInt8 >( (pPassData[nInd] >> 8) & 0xff );
+ }
+
+ pKeyData[2*nInd] = 0x80;
+ pKeyData[56] = sal::static_int_cast< sal_uInt8 >( nInd << 4 );
+
+ // Fill raw digest of KeyData into KeyData.
+ rtlDigest hDigest = rtl_digest_create ( rtl_Digest_AlgorithmMD5 );
+ (void)rtl_digest_updateMD5 (
+ hDigest, pKeyData, sizeof(pKeyData));
+ (void)rtl_digest_rawMD5 (
+ hDigest, pKeyData, RTL_DIGEST_LENGTH_MD5);
+
+ // Update digest with KeyData and Unique.
+ for ( nInd = 0; nInd < 16; nInd++ )
+ {
+ rtl_digest_updateMD5( hDigest, pKeyData, 5 );
+ rtl_digest_updateMD5( hDigest, (const sal_uInt8*)aDocId.getConstArray(), aDocId.getLength() );
+ }
+
+ // Update digest with padding.
+ pKeyData[16] = 0x80;
+ rtl_zeroMemory( pKeyData + 17, sizeof(pKeyData) - 17 );
+ pKeyData[56] = 0x80;
+ pKeyData[57] = 0x0a;
+
+ rtl_digest_updateMD5( hDigest, &(pKeyData[16]), sizeof(pKeyData) - 16 );
+
+ // Fill raw digest of above updates
+ aResultKey.realloc( RTL_DIGEST_LENGTH_MD5 );
+ rtl_digest_rawMD5 ( hDigest, (sal_uInt8*)aResultKey.getArray(), aResultKey.getLength() );
+
+ // Erase KeyData array and leave.
+ rtl_zeroMemory( pKeyData, sizeof(pKeyData) );
+ }
+
+ return aResultKey;
+}
+
+// ============================================================================
+
+/*static*/ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > DocPasswordHelper::requestAndVerifyDocPassword(
IDocPasswordVerifier& rVerifier,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rMediaEncData,
const OUString& rMediaPassword,
const Reference< XInteractionHandler >& rxInteractHandler,
const OUString& rDocumentName,
@@ -293,7 +372,7 @@ Sequence< sal_Int8 > DocPasswordHelper::GetXLHashAsSequence(
const ::std::vector< OUString >* pDefaultPasswords,
bool* pbIsDefaultPassword )
{
- OUString aPassword;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > aEncData;
DocPasswordVerifierResult eResult = DocPasswordVerifierResult_WRONG_PASSWORD;
// first, try provided default passwords
@@ -303,23 +382,32 @@ Sequence< sal_Int8 > DocPasswordHelper::GetXLHashAsSequence(
{
for( ::std::vector< OUString >::const_iterator aIt = pDefaultPasswords->begin(), aEnd = pDefaultPasswords->end(); (eResult == DocPasswordVerifierResult_WRONG_PASSWORD) && (aIt != aEnd); ++aIt )
{
- aPassword = *aIt;
- OSL_ENSURE( aPassword.getLength() > 0, "DocPasswordHelper::requestAndVerifyDocPassword - unexpected empty default password" );
- if( aPassword.getLength() > 0 )
+ OSL_ENSURE( aIt->getLength() > 0, "DocPasswordHelper::requestAndVerifyDocPassword - unexpected empty default password" );
+ if( aIt->getLength() > 0 )
{
- eResult = rVerifier.verifyPassword( aPassword );
+ eResult = rVerifier.verifyPassword( *aIt, aEncData );
if( pbIsDefaultPassword )
*pbIsDefaultPassword = eResult == DocPasswordVerifierResult_OK;
}
}
}
+ // try media encryption data (skip, if result is OK or ABORT)
+ if( eResult == DocPasswordVerifierResult_WRONG_PASSWORD )
+ {
+ if( rMediaEncData.getLength() > 0 )
+ {
+ eResult = rVerifier.verifyEncryptionData( rMediaEncData );
+ if( eResult == DocPasswordVerifierResult_OK )
+ aEncData = rMediaEncData;
+ }
+ }
+
// try media password (skip, if result is OK or ABORT)
if( eResult == DocPasswordVerifierResult_WRONG_PASSWORD )
{
- aPassword = rMediaPassword;
- if( aPassword.getLength() > 0 )
- eResult = rVerifier.verifyPassword( aPassword );
+ if( rMediaPassword.getLength() > 0 )
+ eResult = rVerifier.verifyPassword( rMediaPassword, aEncData );
}
// request a password (skip, if result is OK or ABORT)
@@ -333,9 +421,8 @@ Sequence< sal_Int8 > DocPasswordHelper::GetXLHashAsSequence(
rxInteractHandler->handle( xRequest );
if( pRequest->isPassword() )
{
- aPassword = pRequest->getPassword();
- if( aPassword.getLength() > 0 )
- eResult = rVerifier.verifyPassword( aPassword );
+ if( pRequest->getPassword().getLength() > 0 )
+ eResult = rVerifier.verifyPassword( pRequest->getPassword(), aEncData );
}
else
{
@@ -348,15 +435,17 @@ Sequence< sal_Int8 > DocPasswordHelper::GetXLHashAsSequence(
{
}
- return (eResult == DocPasswordVerifierResult_OK) ? aPassword : OUString();
+ return (eResult == DocPasswordVerifierResult_OK) ? aEncData : uno::Sequence< beans::NamedValue >();
}
-/*static*/ OUString DocPasswordHelper::requestAndVerifyDocPassword(
+/*static*/ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > DocPasswordHelper::requestAndVerifyDocPassword(
IDocPasswordVerifier& rVerifier,
MediaDescriptor& rMediaDesc,
DocPasswordRequestType eRequestType,
const ::std::vector< OUString >* pDefaultPasswords )
{
+ uno::Sequence< beans::NamedValue > aMediaEncData = rMediaDesc.getUnpackedValueOrDefault(
+ MediaDescriptor::PROP_ENCRYPTIONDATA(), uno::Sequence< beans::NamedValue >() );
OUString aMediaPassword = rMediaDesc.getUnpackedValueOrDefault(
MediaDescriptor::PROP_PASSWORD(), OUString() );
Reference< XInteractionHandler > xInteractHandler = rMediaDesc.getUnpackedValueOrDefault(
@@ -365,14 +454,17 @@ Sequence< sal_Int8 > DocPasswordHelper::GetXLHashAsSequence(
MediaDescriptor::PROP_URL(), OUString() );
bool bIsDefaultPassword = false;
- OUString aPassword = requestAndVerifyDocPassword(
- rVerifier, aMediaPassword, xInteractHandler, aDocumentName, eRequestType, pDefaultPasswords, &bIsDefaultPassword );
+ uno::Sequence< beans::NamedValue > aEncryptionData = requestAndVerifyDocPassword(
+ rVerifier, aMediaEncData, aMediaPassword, xInteractHandler, aDocumentName, eRequestType, pDefaultPasswords, &bIsDefaultPassword );
+
+ rMediaDesc.erase( MediaDescriptor::PROP_PASSWORD() );
+ rMediaDesc.erase( MediaDescriptor::PROP_ENCRYPTIONDATA() );
// insert valid password into media descriptor (but not a default password)
- if( (aPassword.getLength() > 0) && !bIsDefaultPassword )
- rMediaDesc[ MediaDescriptor::PROP_PASSWORD() ] <<= aPassword;
+ if( (aEncryptionData.getLength() > 0) && !bIsDefaultPassword )
+ rMediaDesc[ MediaDescriptor::PROP_ENCRYPTIONDATA() ] <<= aEncryptionData;
- return aPassword;
+ return aEncryptionData;
}
// ============================================================================
diff --git a/comphelper/source/misc/docpasswordrequest.cxx b/comphelper/source/misc/docpasswordrequest.cxx
index a4381a3d89c7..ec9cf0ca21ed 100644..100755
--- a/comphelper/source/misc/docpasswordrequest.cxx
+++ b/comphelper/source/misc/docpasswordrequest.cxx
@@ -32,6 +32,7 @@
#include "comphelper/docpasswordrequest.hxx"
#include <com/sun/star/task/DocumentMSPasswordRequest2.hpp>
#include <com/sun/star/task/DocumentPasswordRequest2.hpp>
+#include <com/sun/star/task/PasswordRequest.hpp>
#include <com/sun/star/task/XInteractionAbort.hpp>
#include <com/sun/star/task/XInteractionPassword2.hpp>
@@ -45,6 +46,7 @@ using ::com::sun::star::uno::XInterface;
using ::com::sun::star::task::InteractionClassification_QUERY;
using ::com::sun::star::task::DocumentMSPasswordRequest2;
using ::com::sun::star::task::DocumentPasswordRequest2;
+using ::com::sun::star::task::PasswordRequest;
using ::com::sun::star::task::PasswordRequestMode;
using ::com::sun::star::task::XInteractionAbort;
using ::com::sun::star::task::XInteractionContinuation;
@@ -99,11 +101,74 @@ private:
// ============================================================================
+SimplePasswordRequest::SimplePasswordRequest( PasswordRequestMode eMode )
+: mpAbort( NULL )
+, mpPassword( NULL )
+{
+ PasswordRequest aRequest( OUString(), Reference< XInterface >(),
+ InteractionClassification_QUERY, eMode );
+ maRequest <<= aRequest;
+
+ maContinuations.realloc( 2 );
+ maContinuations[ 0 ].set( mpAbort = new AbortContinuation );
+ maContinuations[ 1 ].set( mpPassword = new PasswordContinuation );
+}
+
+SimplePasswordRequest::~SimplePasswordRequest()
+{
+}
+
+/*uno::*/Any SAL_CALL SimplePasswordRequest::queryInterface( const /*uno::*/Type& rType ) throw (RuntimeException)
+{
+ return ::cppu::queryInterface ( rType,
+ // OWeakObject interfaces
+ dynamic_cast< XInterface* > ( (XInteractionRequest *) this ),
+ static_cast< XWeak* > ( this ),
+ // my own interfaces
+ static_cast< XInteractionRequest* > ( this ) );
+}
+
+void SAL_CALL SimplePasswordRequest::acquire( ) throw ()
+{
+ OWeakObject::acquire();
+}
+
+void SAL_CALL SimplePasswordRequest::release( ) throw ()
+{
+ OWeakObject::release();
+}
+
+sal_Bool SimplePasswordRequest::isAbort() const
+{
+ return mpAbort->isSelected();
+}
+
+sal_Bool SimplePasswordRequest::isPassword() const
+{
+ return mpPassword->isSelected();
+}
+
+OUString SimplePasswordRequest::getPassword() const
+{
+ return mpPassword->getPassword();
+}
+
+Any SAL_CALL SimplePasswordRequest::getRequest() throw( RuntimeException )
+{
+ return maRequest;
+}
+
+Sequence< Reference< XInteractionContinuation > > SAL_CALL SimplePasswordRequest::getContinuations() throw( RuntimeException )
+{
+ return maContinuations;
+}
+
+// ============================================================================
+
DocPasswordRequest::DocPasswordRequest( DocPasswordRequestType eType,
PasswordRequestMode eMode, const OUString& rDocumentName, sal_Bool bPasswordToModify )
: mpAbort( NULL )
, mpPassword( NULL )
-, mbPasswordToModify( bPasswordToModify )
{
switch( eType )
{
diff --git a/comphelper/source/misc/makefile.mk b/comphelper/source/misc/makefile.mk
deleted file mode 100644
index cecba554b332..000000000000
--- a/comphelper/source/misc/makefile.mk
+++ /dev/null
@@ -1,101 +0,0 @@
-#*************************************************************************
-#
-# 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.
-#
-#*************************************************************************
-
-PRJ=..$/..
-PRJNAME=comphelper
-TARGET=misc
-
-ENABLE_EXCEPTIONS=TRUE
-
-# --- Settings ----------------------------------
-
-.INCLUDE : settings.mk
-.INCLUDE : $(PRJ)$/util$/makefile.pmk
-
-# --- Files -------------------------------------
-
-SLOFILES= \
- $(SLO)$/accessiblecomponenthelper.obj \
- $(SLO)$/accessiblecontexthelper.obj \
- $(SLO)$/accessibleeventbuffer.obj \
- $(SLO)$/accessibleeventnotifier.obj \
- $(SLO)$/accessiblekeybindinghelper.obj \
- $(SLO)$/accessibleselectionhelper.obj \
- $(SLO)$/accessibletexthelper.obj \
- $(SLO)$/accessiblewrapper.obj \
- $(SLO)$/accimplaccess.obj \
- $(SLO)$/anytostring.obj \
- $(SLO)$/asyncnotification.obj \
- $(SLO)$/componentcontext.obj \
- $(SLO)$/componentmodule.obj \
- $(SLO)$/configurationhelper.obj \
- $(SLO)$/docpasswordhelper.obj \
- $(SLO)$/docpasswordrequest.obj \
- $(SLO)$/documentinfo.obj \
- $(SLO)$/evtmethodhelper.obj \
- $(SLO)$/documentiologring.obj \
- $(SLO)$/evtlistenerhlp.obj \
- $(SLO)$/ihwrapnofilter.obj \
- $(SLO)$/instancelocker.obj \
- $(SLO)$/interaction.obj \
- $(SLO)$/legacysingletonfactory.obj \
- $(SLO)$/listenernotification.obj \
- $(SLO)$/locale.obj \
- $(SLO)$/logging.obj \
- $(SLO)$/mediadescriptor.obj \
- $(SLO)$/mimeconfighelper.obj \
- $(SLO)$/namedvaluecollection.obj \
- $(SLO)$/numberedcollection.obj \
- $(SLO)$/numbers.obj \
- $(SLO)$/officeresourcebundle.obj \
- $(SLO)$/officerestartmanager.obj \
- $(SLO)$/proxyaggregation.obj \
- $(SLO)$/querydeep.obj \
- $(SLO)$/regpathhelper.obj \
- $(SLO)$/scopeguard.obj \
- $(SLO)$/SelectionMultiplex.obj \
- $(SLO)$/sequenceashashmap.obj \
- $(SLO)$/sequence.obj \
- $(SLO)$/servicedecl.obj \
- $(SLO)$/serviceinfohelper.obj \
- $(SLO)$/sharedmutex.obj \
- $(SLO)$/synchronousdispatch.obj \
- $(SLO)$/storagehelper.obj \
- $(SLO)$/string.obj \
- $(SLO)$/types.obj \
- $(SLO)$/uieventslogger.obj \
- $(SLO)$/weakeventlistener.obj \
- $(SLO)$/weak.obj \
- $(SLO)$/comphelper_module.obj \
- $(SLO)$/comphelper_services.obj \
- $(SLO)$/componentbase.obj \
- $(SLO)$/stillreadwriteinteraction.obj \
-
-# --- Targets ----------------------------------
-
-.INCLUDE : target.mk
-
diff --git a/comphelper/source/misc/mediadescriptor.cxx b/comphelper/source/misc/mediadescriptor.cxx
index 8dbe084cd3f5..6a67e1ba43da 100644
--- a/comphelper/source/misc/mediadescriptor.cxx
+++ b/comphelper/source/misc/mediadescriptor.cxx
@@ -29,6 +29,7 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_comphelper.hxx"
#include <comphelper/mediadescriptor.hxx>
+#include <comphelper/namedvaluecollection.hxx>
#include <comphelper/stillreadwriteinteraction.hxx>
#include <com/sun/star/ucb/XContent.hpp>
@@ -110,6 +111,12 @@ const ::rtl::OUString& MediaDescriptor::PROP_DOCUMENTSERVICE()
return sProp;
}
+const ::rtl::OUString& MediaDescriptor::PROP_ENCRYPTIONDATA()
+{
+ static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("EncryptionData"));
+ return sProp;
+}
+
const ::rtl::OUString& MediaDescriptor::PROP_EXTENSION()
{
static const ::rtl::OUString sProp(RTL_CONSTASCII_USTRINGPARAM("Extension"));
@@ -463,27 +470,30 @@ sal_Bool MediaDescriptor::isStreamReadOnly() const
css::uno::Any MediaDescriptor::getComponentDataEntry( const ::rtl::OUString& rName ) const
{
- SequenceAsHashMap aCompDataMap( getUnpackedValueOrDefault( PROP_COMPONENTDATA(), ComponentDataSequence() ) );
- SequenceAsHashMap::iterator aIt = aCompDataMap.find( rName );
- return (aIt == aCompDataMap.end()) ? css::uno::Any() : aIt->second;
+ css::uno::Any aEntry;
+ SequenceAsHashMap::const_iterator aPropertyIter = find( PROP_COMPONENTDATA() );
+ if( aPropertyIter != end() )
+ return NamedValueCollection( aPropertyIter->second ).get( rName );
+ return css::uno::Any();
}
void MediaDescriptor::setComponentDataEntry( const ::rtl::OUString& rName, const css::uno::Any& rValue )
{
if( rValue.hasValue() )
{
- // get or craete the 'ComponentData' property entry
+ // get or create the 'ComponentData' property entry
css::uno::Any& rCompDataAny = operator[]( PROP_COMPONENTDATA() );
- // check type, insert the value
- OSL_ENSURE( !rCompDataAny.hasValue() || rCompDataAny.has< ComponentDataSequence >(),
- "MediaDescriptor::setComponentDataEntry - incompatible 'ComponentData' property in media descriptor" );
- if( !rCompDataAny.hasValue() || rCompDataAny.has< ComponentDataSequence >() )
+ // insert the value (retain sequence type, create NamedValue elements by default)
+ bool bHasNamedValues = !rCompDataAny.hasValue() || rCompDataAny.has< css::uno::Sequence< css::beans::NamedValue > >();
+ bool bHasPropValues = rCompDataAny.has< css::uno::Sequence< css::beans::PropertyValue > >();
+ OSL_ENSURE( bHasNamedValues || bHasPropValues, "MediaDescriptor::setComponentDataEntry - incompatible 'ComponentData' property in media descriptor" );
+ if( bHasNamedValues || bHasPropValues )
{
// insert or overwrite the passed value
SequenceAsHashMap aCompDataMap( rCompDataAny );
aCompDataMap[ rName ] = rValue;
- // write back the sequence (sal_False = use NamedValue instead of PropertyValue)
- rCompDataAny = aCompDataMap.getAsConstAny( sal_False );
+ // write back the sequence (restore sequence with correct element type)
+ rCompDataAny = aCompDataMap.getAsConstAny( bHasPropValues );
}
}
else
@@ -498,18 +508,20 @@ void MediaDescriptor::clearComponentDataEntry( const ::rtl::OUString& rName )
SequenceAsHashMap::iterator aPropertyIter = find( PROP_COMPONENTDATA() );
if( aPropertyIter != end() )
{
- OSL_ENSURE( aPropertyIter->second.has< ComponentDataSequence >(),
- "MediaDescriptor::clearComponentDataEntry - incompatible 'ComponentData' property in media descriptor" );
- if( aPropertyIter->second.has< ComponentDataSequence >() )
+ css::uno::Any& rCompDataAny = aPropertyIter->second;
+ bool bHasNamedValues = rCompDataAny.has< css::uno::Sequence< css::beans::NamedValue > >();
+ bool bHasPropValues = rCompDataAny.has< css::uno::Sequence< css::beans::PropertyValue > >();
+ OSL_ENSURE( bHasNamedValues || bHasPropValues, "MediaDescriptor::clearComponentDataEntry - incompatible 'ComponentData' property in media descriptor" );
+ if( bHasNamedValues || bHasPropValues )
{
// remove the value with the passed name
- SequenceAsHashMap aCompDataMap( aPropertyIter->second );
+ SequenceAsHashMap aCompDataMap( rCompDataAny );
aCompDataMap.erase( rName );
// write back the sequence, or remove it completely if it is empty
if( aCompDataMap.empty() )
erase( aPropertyIter );
else
- aPropertyIter->second = aCompDataMap.getAsConstAny( sal_False );
+ rCompDataAny = aCompDataMap.getAsConstAny( bHasPropValues );
}
}
}
diff --git a/comphelper/source/misc/mimeconfighelper.cxx b/comphelper/source/misc/mimeconfighelper.cxx
index 3b5e3c9ef652..fb6936ea6d1f 100644
--- a/comphelper/source/misc/mimeconfighelper.cxx
+++ b/comphelper/source/misc/mimeconfighelper.cxx
@@ -36,6 +36,7 @@
#include <comphelper/mimeconfighelper.hxx>
#include <comphelper/classids.hxx>
#include <comphelper/sequenceashashmap.hxx>
+#include <comphelper/documentconstants.hxx>
using namespace ::com::sun::star;
@@ -188,6 +189,46 @@ uno::Reference< container::XNameAccess > MimeConfigurationHelper::GetMediaTypeCo
return m_xMediaTypeConfig;
}
+
+//-----------------------------------------------------------------------
+uno::Reference< container::XNameAccess > MimeConfigurationHelper::GetFilterFactory()
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_xFilterFactory.is() )
+ m_xFilterFactory.set(
+ m_xFactory->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.document.FilterFactory" ) ),
+ uno::UNO_QUERY );
+
+ return m_xFilterFactory;
+}
+
+//-----------------------------------------------------------------------
+sal_Int32 MimeConfigurationHelper::GetFilterFlags( const ::rtl::OUString& aFilterName )
+{
+ sal_Int32 nFlags = 0;
+ try
+ {
+ if ( aFilterName.getLength() )
+ {
+ uno::Reference< container::XNameAccess > xFilterFactory(
+ GetFilterFactory(),
+ uno::UNO_SET_THROW );
+
+ uno::Any aFilterAny = xFilterFactory->getByName( aFilterName );
+ uno::Sequence< beans::PropertyValue > aData;
+ if ( aFilterAny >>= aData )
+ {
+ SequenceAsHashMap aFilterHM( aData );
+ nFlags = aFilterHM.getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii( "Flags" ), (sal_Int32)0 );
+ }
+ }
+ } catch( uno::Exception& )
+ {}
+
+ return nFlags;
+}
+
//-------------------------------------------------------------------------
::rtl::OUString MimeConfigurationHelper::GetDocServiceNameFromFilter( const ::rtl::OUString& aFilterName )
{
@@ -196,8 +237,8 @@ uno::Reference< container::XNameAccess > MimeConfigurationHelper::GetMediaTypeCo
try
{
uno::Reference< container::XNameAccess > xFilterFactory(
- m_xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.FilterFactory" )) ),
- uno::UNO_QUERY_THROW );
+ GetFilterFactory(),
+ uno::UNO_SET_THROW );
uno::Any aFilterAnyData = xFilterFactory->getByName( aFilterName );
uno::Sequence< beans::PropertyValue > aFilterData;
@@ -669,36 +710,17 @@ uno::Sequence< beans::NamedValue > MimeConfigurationHelper::GetObjectPropsByDocu
sal_Bool MimeConfigurationHelper::AddFilterNameCheckOwnFile(
uno::Sequence< beans::PropertyValue >& aMediaDescr )
{
+ sal_Bool bResult = sal_False;
+
::rtl::OUString aFilterName = UpdateMediaDescriptorWithFilterName( aMediaDescr, sal_False );
if ( aFilterName.getLength() )
{
- try
- {
- uno::Reference< container::XNameAccess > xFilterFactory(
- m_xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.FilterFactory" )) ),
- uno::UNO_QUERY_THROW );
-
- uno::Any aFilterAnyData = xFilterFactory->getByName( aFilterName );
- uno::Sequence< beans::PropertyValue > aFilterData;
- if ( aFilterAnyData >>= aFilterData )
- {
- for ( sal_Int32 nInd = 0; nInd < aFilterData.getLength(); nInd++ )
- if ( aFilterData[nInd].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Flags" ) ) )
- {
- uno::Any aVal = aFilterData[nInd].Value;
- sal_Int32 nFlags = 0;
- // check the OWN flag
- if ( ( aFilterData[nInd].Value >>= nFlags ) && ( nFlags & 0x20 ) )
- return sal_True;
- break;
- }
- }
- }
- catch( uno::Exception& )
- {}
+ sal_Int32 nFlags = GetFilterFlags( aFilterName );
+ // check the OWN flag
+ bResult = ( nFlags & SFX_FILTER_OWN );
}
- return sal_False;
+ return bResult;
}
//-----------------------------------------------------------
@@ -710,7 +732,7 @@ sal_Bool MimeConfigurationHelper::AddFilterNameCheckOwnFile(
try
{
uno::Reference< container::XContainerQuery > xFilterQuery(
- m_xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.FilterFactory" )) ),
+ GetFilterFactory(),
uno::UNO_QUERY_THROW );
uno::Sequence< beans::NamedValue > aSearchRequest( 2 );
@@ -735,14 +757,15 @@ sal_Bool MimeConfigurationHelper::AddFilterNameCheckOwnFile(
(sal_Int32)0 );
// that should be import, export, own filter and not a template filter ( TemplatePath flag )
- if ( ( ( nFlags & 0x23L ) == 0x23L ) && !( nFlags & 0x10 ) )
+ sal_Int32 nRequired = ( SFX_FILTER_OWN | SFX_FILTER_EXPORT | SFX_FILTER_IMPORT );
+ if ( ( ( nFlags & nRequired ) == nRequired ) && !( nFlags & SFX_FILTER_TEMPLATEPATH ) )
{
// if there are more than one filter the preffered one should be used
// if there is no preffered filter the first one will be used
- if ( !aResult.getLength() || ( nFlags & 0x10000000L ) )
+ if ( !aResult.getLength() || ( nFlags & SFX_FILTER_PREFERED ) )
aResult = aPropsHM.getUnpackedValueOrDefault( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" )),
::rtl::OUString() );
- if ( nFlags & 0x10000000L )
+ if ( nFlags & SFX_FILTER_PREFERED )
break; // the preffered filter was found
}
}
@@ -753,6 +776,116 @@ sal_Bool MimeConfigurationHelper::AddFilterNameCheckOwnFile(
return aResult;
}
+
+//-------------------------------------------------------------------------
+::rtl::OUString MimeConfigurationHelper::GetExportFilterFromImportFilter( const ::rtl::OUString& aImportFilterName )
+{
+ ::rtl::OUString aExportFilterName;
+
+ try
+ {
+ if ( aImportFilterName.getLength() )
+ {
+ uno::Reference< container::XNameAccess > xFilterFactory(
+ GetFilterFactory(),
+ uno::UNO_SET_THROW );
+
+ uno::Any aImpFilterAny = xFilterFactory->getByName( aImportFilterName );
+ uno::Sequence< beans::PropertyValue > aImpData;
+ if ( aImpFilterAny >>= aImpData )
+ {
+ SequenceAsHashMap aImpFilterHM( aImpData );
+ sal_Int32 nFlags = aImpFilterHM.getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii( "Flags" ),
+ (sal_Int32)0 );
+
+ if ( !( nFlags & SFX_FILTER_IMPORT ) )
+ {
+ OSL_ENSURE( sal_False, "This is no import filter!" );
+ throw uno::Exception();
+ }
+
+ if ( nFlags & SFX_FILTER_EXPORT )
+ {
+ aExportFilterName = aImportFilterName;
+ }
+ else
+ {
+ ::rtl::OUString aDocumentServiceName = aImpFilterHM.getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii( "DocumentService" ), ::rtl::OUString() );
+ ::rtl::OUString aTypeName = aImpFilterHM.getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii( "Type" ), ::rtl::OUString() );
+
+ OSL_ENSURE( aDocumentServiceName.getLength() && aTypeName.getLength(), "Incomplete filter data!" );
+ if ( aDocumentServiceName.getLength() && aTypeName.getLength() )
+ {
+ uno::Sequence< beans::NamedValue > aSearchRequest( 2 );
+ aSearchRequest[0].Name = ::rtl::OUString::createFromAscii( "Type" );
+ aSearchRequest[0].Value <<= aTypeName;
+ aSearchRequest[1].Name = ::rtl::OUString::createFromAscii( "DocumentService" );
+ aSearchRequest[1].Value <<= aDocumentServiceName;
+
+ uno::Sequence< beans::PropertyValue > aExportFilterProps = SearchForFilter(
+ uno::Reference< container::XContainerQuery >( xFilterFactory, uno::UNO_QUERY_THROW ),
+ aSearchRequest,
+ SFX_FILTER_EXPORT,
+ SFX_FILTER_INTERNAL );
+
+ if ( aExportFilterProps.getLength() )
+ {
+ SequenceAsHashMap aExpPropsHM( aExportFilterProps );
+ aExportFilterName = aExpPropsHM.getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii( "Name" ), ::rtl::OUString() );
+ }
+ }
+ }
+ }
+ }
+ }
+ catch( uno::Exception& )
+ {}
+
+ return aExportFilterName;
+}
+
+//-------------------------------------------------------------------------
+// static
+uno::Sequence< beans::PropertyValue > MimeConfigurationHelper::SearchForFilter(
+ const uno::Reference< container::XContainerQuery >& xFilterQuery,
+ const uno::Sequence< beans::NamedValue >& aSearchRequest,
+ sal_Int32 nMustFlags,
+ sal_Int32 nDontFlags )
+{
+ uno::Sequence< beans::PropertyValue > aFilterProps;
+ uno::Reference< container::XEnumeration > xFilterEnum =
+ xFilterQuery->createSubSetEnumerationByProperties( aSearchRequest );
+
+ // the first default filter will be taken,
+ // if there is no filter with flag default the first acceptable filter will be taken
+ if ( xFilterEnum.is() )
+ {
+ while ( xFilterEnum->hasMoreElements() )
+ {
+ uno::Sequence< beans::PropertyValue > aProps;
+ if ( xFilterEnum->nextElement() >>= aProps )
+ {
+ SequenceAsHashMap aPropsHM( aProps );
+ sal_Int32 nFlags = aPropsHM.getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii( "Flags" ),
+ (sal_Int32)0 );
+ if ( ( ( nFlags & nMustFlags ) == nMustFlags ) && !( nFlags & nDontFlags ) )
+ {
+ if ( ( nFlags & SFX_FILTER_DEFAULT ) == SFX_FILTER_DEFAULT )
+ {
+ aFilterProps = aProps;
+ break;
+ }
+ else if ( !aFilterProps.getLength() )
+ aFilterProps = aProps;
+ }
+ }
+ }
+ }
+
+ return aFilterProps;
+}
+
+
//-------------------------------------------------------------------------
sal_Bool MimeConfigurationHelper::ClassIDsEqual( const uno::Sequence< sal_Int8 >& aClassID1, const uno::Sequence< sal_Int8 >& aClassID2 )
{
@@ -765,7 +898,8 @@ sal_Bool MimeConfigurationHelper::ClassIDsEqual( const uno::Sequence< sal_Int8 >
return sal_True;
}
-//----------------------------------------------
+
+//-------------------------------------------------------------------------
uno::Sequence< sal_Int8 > MimeConfigurationHelper::GetSequenceClassID( sal_uInt32 n1, sal_uInt16 n2, sal_uInt16 n3,
sal_uInt8 b8, sal_uInt8 b9, sal_uInt8 b10, sal_uInt8 b11,
sal_uInt8 b12, sal_uInt8 b13, sal_uInt8 b14, sal_uInt8 b15 )
@@ -790,6 +924,8 @@ uno::Sequence< sal_Int8 > MimeConfigurationHelper::GetSequenceClassID( sal_uInt3
return aResult;
}
+
+//-------------------------------------------------------------------------
uno::Sequence<sal_Int8> MimeConfigurationHelper::GetSequenceClassIDFromObjectName(const ::rtl::OUString& _sObjectName)
{
uno::Sequence<sal_Int8> aClassId;
diff --git a/comphelper/source/misc/namedvaluecollection.cxx b/comphelper/source/misc/namedvaluecollection.cxx
index 3effa876c4c2..8e4cac00f932 100644
--- a/comphelper/source/misc/namedvaluecollection.cxx
+++ b/comphelper/source/misc/namedvaluecollection.cxx
@@ -100,21 +100,7 @@ namespace comphelper
NamedValueCollection::NamedValueCollection( const Any& _rElements )
:m_pImpl( new NamedValueCollection_Impl )
{
- Sequence< NamedValue > aNamedValues;
- Sequence< PropertyValue > aPropertyValues;
- NamedValue aNamedValue;
- PropertyValue aPropertyValue;
-
- if ( _rElements >>= aNamedValues )
- impl_assign( aNamedValues );
- else if ( _rElements >>= aPropertyValues )
- impl_assign( aPropertyValues );
- else if ( _rElements >>= aNamedValue )
- impl_assign( Sequence< NamedValue >( &aNamedValue, 1 ) );
- else if ( _rElements >>= aPropertyValue )
- impl_assign( Sequence< PropertyValue >( &aPropertyValue, 1 ) );
- else
- OSL_ENSURE( !_rElements.hasValue(), "NamedValueCollection::NamedValueCollection(Any): unsupported type!" );
+ impl_assign( _rElements );
}
//--------------------------------------------------------------------
@@ -171,6 +157,37 @@ namespace comphelper
}
//--------------------------------------------------------------------
+ ::std::vector< ::rtl::OUString > NamedValueCollection::getNames() const
+ {
+ ::std::vector< ::rtl::OUString > aNames;
+ for ( NamedValueRepository::const_iterator it = m_pImpl->aValues.begin(), end = m_pImpl->aValues.end(); it != end; ++it )
+ {
+ aNames.push_back( it->first );
+ }
+ return aNames;
+ }
+
+ //--------------------------------------------------------------------
+ void NamedValueCollection::impl_assign( const Any& i_rWrappedElements )
+ {
+ Sequence< NamedValue > aNamedValues;
+ Sequence< PropertyValue > aPropertyValues;
+ NamedValue aNamedValue;
+ PropertyValue aPropertyValue;
+
+ if ( i_rWrappedElements >>= aNamedValues )
+ impl_assign( aNamedValues );
+ else if ( i_rWrappedElements >>= aPropertyValues )
+ impl_assign( aPropertyValues );
+ else if ( i_rWrappedElements >>= aNamedValue )
+ impl_assign( Sequence< NamedValue >( &aNamedValue, 1 ) );
+ else if ( i_rWrappedElements >>= aPropertyValue )
+ impl_assign( Sequence< PropertyValue >( &aPropertyValue, 1 ) );
+ else
+ OSL_ENSURE( !i_rWrappedElements.hasValue(), "NamedValueCollection::impl_assign(Any): unsupported type!" );
+ }
+
+ //--------------------------------------------------------------------
void NamedValueCollection::impl_assign( const Sequence< Any >& _rArguments )
{
{
diff --git a/comphelper/source/misc/querydeep.cxx b/comphelper/source/misc/querydeep.cxx
deleted file mode 100644
index 61cfb6c173f2..000000000000
--- a/comphelper/source/misc/querydeep.cxx
+++ /dev/null
@@ -1,78 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * 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.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_comphelper.hxx"
-#include <comphelper/querydeep.hxx>
-#include <typelib/typedescription.h>
-
-//__________________________________________________________________________________________________
-
-sal_Bool comphelper::isDerivedFrom(
- const ::com::sun::star::uno::Type & rBaseType,
- const ::com::sun::star::uno::Type & rType )
-{
- using namespace ::com::sun::star::uno;
-
- TypeClass eClass = rBaseType.getTypeClass();
-
- if (eClass != TypeClass_INTERFACE)
- return sal_False;
-
- // supported TypeClass - do the types match ?
- if (eClass != rType.getTypeClass())
- return sal_False;
-
- sal_Bool bRet;
-
- // shortcut for simple case
- if (rBaseType == ::getCppuType(static_cast<const Reference< XInterface > *>(0)))
- {
- bRet = sal_True;
- }
- else
- {
- // now ask in cppu (aka typelib)
- ::typelib_TypeDescription *pBaseTD = 0, *pTD = 0;
-
- rBaseType. getDescription(&pBaseTD);
- rType. getDescription(&pTD);
-
- // interfaces are assignable to a base
- bRet = ::typelib_typedescription_isAssignableFrom(pBaseTD, pTD);
-
- ::typelib_typedescription_release(pBaseTD);
- ::typelib_typedescription_release(pTD);
- }
-
- return bRet;
-}
-
-
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/comphelper/source/misc/scopeguard.cxx b/comphelper/source/misc/scopeguard.cxx
index 66cfd231293d..db2a6d872359 100644
--- a/comphelper/source/misc/scopeguard.cxx
+++ b/comphelper/source/misc/scopeguard.cxx
@@ -29,7 +29,7 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_comphelper.hxx"
-#include "comphelper/scopeguard.hxx"
+#include "comphelper/flagguard.hxx"
#include "osl/diagnose.h"
#include "com/sun/star/uno/Exception.hpp"
@@ -68,6 +68,14 @@ void ScopeGuard::dismiss()
m_func.clear();
}
+FlagGuard::~FlagGuard()
+{
+}
+
+FlagRestorationGuard::~FlagRestorationGuard()
+{
+}
+
} // namespace comphelper
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/comphelper/source/misc/servicedecl.cxx b/comphelper/source/misc/servicedecl.cxx
index 92e3b3ef7e44..6048709fd061 100644
--- a/comphelper/source/misc/servicedecl.cxx
+++ b/comphelper/source/misc/servicedecl.cxx
@@ -117,37 +117,6 @@ ServiceDecl::Factory::createInstanceWithArgumentsAndContext(
m_rServiceDecl, args, xContext );
}
-bool ServiceDecl::writeInfo( registry::XRegistryKey * xKey ) const
-{
- bool bRet = false;
- if (xKey != 0) {
- rtl::OUStringBuffer buf;
- buf.append( static_cast<sal_Unicode>('/') );
- buf.appendAscii( m_pImplName );
- buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("/UNO/SERVICES") );
- try {
- uno::Reference<registry::XRegistryKey> const xNewKey(
- xKey->createKey( buf.makeStringAndClear() ) );
-
- rtl::OString const str(m_pServiceNames);
- sal_Int32 nIndex = 0;
- do {
- rtl::OString const token( str.getToken( 0, m_cDelim, nIndex ) );
- xNewKey->createKey(
- rtl::OUString( token.getStr(), token.getLength(),
- RTL_TEXTENCODING_ASCII_US ) );
- }
- while (nIndex >= 0);
-
- bRet = true;
- }
- catch (registry::InvalidRegistryException const&) {
- OSL_ENSURE( false, "### InvalidRegistryException!" );
- }
- }
- return bRet;
-}
-
void * ServiceDecl::getFactory( sal_Char const* pImplName ) const
{
if (rtl_str_compare(m_pImplName, pImplName) == 0) {
diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx
index 4d14069be369..039ad82dacb3 100644
--- a/comphelper/source/misc/storagehelper.cxx
+++ b/comphelper/source/misc/storagehelper.cxx
@@ -29,12 +29,15 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_comphelper.hxx"
#include <com/sun/star/embed/ElementModes.hpp>
-#include <com/sun/star/embed/XEncryptionProtectedSource.hpp>
+#include <com/sun/star/embed/XEncryptionProtectedSource2.hpp>
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
#include <com/sun/star/beans/IllegalTypeException.hpp>
+#include <rtl/digest.h>
+
#include <ucbhelper/content.hxx>
#include <comphelper/fileformat.h>
@@ -237,16 +240,16 @@ uno::Reference< io::XInputStream > OStorageHelper::GetInputStreamFromURL(
}
// ----------------------------------------------------------------------
-void OStorageHelper::SetCommonStoragePassword(
+void OStorageHelper::SetCommonStorageEncryptionData(
const uno::Reference< embed::XStorage >& xStorage,
- const ::rtl::OUString& aPass )
+ const uno::Sequence< beans::NamedValue >& aEncryptionData )
throw ( uno::Exception )
{
- uno::Reference< embed::XEncryptionProtectedSource > xEncrSet( xStorage, uno::UNO_QUERY );
+ uno::Reference< embed::XEncryptionProtectedSource2 > xEncrSet( xStorage, uno::UNO_QUERY );
if ( !xEncrSet.is() )
throw io::IOException(); // TODO
- xEncrSet->setEncryptionPassword( aPass );
+ xEncrSet->setEncryptionData( aEncryptionData );
}
// ----------------------------------------------------------------------
@@ -420,6 +423,45 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageOfFormatFromStream(
}
// ----------------------------------------------------------------------
+uno::Sequence< beans::NamedValue > OStorageHelper::CreatePackageEncryptionData( const ::rtl::OUString& aPassword )
+{
+ // TODO/LATER: Should not the method be part of DocPasswordHelper?
+ uno::Sequence< beans::NamedValue > aEncryptionData;
+ if ( aPassword.getLength() )
+ {
+ // 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
+ aEncryptionData.realloc( 2 );
+ aEncryptionData[0].Name = PACKAGE_ENCRYPTIONDATA_SHA1UTF8;
+ aEncryptionData[1].Name = PACKAGE_ENCRYPTIONDATA_SHA1MS1252;
+
+ rtl_TextEncoding pEncoding[2] = { RTL_TEXTENCODING_UTF8, RTL_TEXTENCODING_MS_1252 };
+
+ for ( sal_Int32 nInd = 0; nInd < 2; nInd++ )
+ {
+ ::rtl::OString aByteStrPass = ::rtl::OUStringToOString( aPassword, pEncoding[nInd] );
+
+ 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 )
+ {
+ aEncryptionData.realloc( 0 );
+ break;
+ }
+
+ aEncryptionData[nInd].Value <<= uno::Sequence< sal_Int8 >( (sal_Int8*)pBuffer, RTL_DIGEST_LENGTH_SHA1 );
+ }
+ }
+
+ return aEncryptionData;
+}
+
+// ----------------------------------------------------------------------
sal_Bool OStorageHelper::IsValidZipEntryFileName( const ::rtl::OUString& aName, sal_Bool bSlashAllowed )
{
return IsValidZipEntryFileName( aName.getStr(), aName.getLength(), bSlashAllowed );
diff --git a/comphelper/source/misc/uieventslogger.cxx b/comphelper/source/misc/uieventslogger.cxx
index 99df5958200c..ab25d70c6e24 100644
--- a/comphelper/source/misc/uieventslogger.cxx
+++ b/comphelper/source/misc/uieventslogger.cxx
@@ -176,6 +176,7 @@ namespace comphelper
static const OUString FN_ROTATEDLOG;
static const OUString LOGROTATE_EVENTNAME;
static const OUString URL_UNO;
+ static const OUString URL_SPECIAL;
static const OUString URL_FILE;
};
}
@@ -210,6 +211,7 @@ namespace comphelper
const OUString UiEventsLogger_Impl::LOGROTATE_EVENTNAME(RTL_CONSTASCII_USTRINGPARAM("onOOoImprovementLogRotated"));
const OUString UiEventsLogger_Impl::URL_UNO(RTL_CONSTASCII_USTRINGPARAM(".uno:"));
+ const OUString UiEventsLogger_Impl::URL_SPECIAL(RTL_CONSTASCII_USTRINGPARAM(".special:"));
const OUString UiEventsLogger_Impl::URL_FILE(RTL_CONSTASCII_USTRINGPARAM("file:"));
@@ -348,7 +350,12 @@ namespace comphelper
const Sequence<PropertyValue>& args)
{
if(!m_Active) return;
- if(!url.Complete.match(URL_UNO) && !url.Complete.match(URL_FILE)) return;
+ if(!url.Complete.match(URL_UNO)
+ && !url.Complete.match(URL_FILE)
+ && !url.Complete.match(URL_SPECIAL))
+ {
+ return;
+ }
checkIdleTimeout();
Sequence<OUString> logdata = Sequence<OUString>(COLUMNS);