[Libreoffice-commits] .: 2 commits - sfx2/inc sfx2/source
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Thu Jul 28 15:35:12 PDT 2011
sfx2/inc/sfx2/filedlghelper.hxx | 10 --
sfx2/source/dialog/dinfdlg.cxx | 30 +++----
sfx2/source/dialog/filedlghelper.cxx | 147 ++++++++++++++++-------------------
3 files changed, 88 insertions(+), 99 deletions(-)
New commits:
commit d2c280e91e6a7411672c987a635bf3142d3e89dd
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Jul 29 00:31:08 2011 +0200
fix for fdo37628: change password button is always disabled
Note: changing the password to modify doc is not working, and we'll
leave that as a known bug for now.
diff --git a/sfx2/inc/sfx2/filedlghelper.hxx b/sfx2/inc/sfx2/filedlghelper.hxx
index 9938f40..33e8aee 100644
--- a/sfx2/inc/sfx2/filedlghelper.hxx
+++ b/sfx2/inc/sfx2/filedlghelper.hxx
@@ -43,6 +43,7 @@
#include <vcl/graph.hxx>
#include <sfx2/sfxdefs.hxx>
#include <sfx2/sfxuno.hxx>
+#include <sfx2/docfilt.hxx>
//-----------------------------------------------------------------------------
@@ -303,6 +304,9 @@ ErrCode FileOpenDialog_Impl( sal_Int64 nFlags,
sal_Int16 nDialog = SFX2_IMPL_DIALOG_CONFIG,
const String& rStandardDir = String::CreateFromAscii( "" ),
const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rBlackList = ::com::sun::star::uno::Sequence< ::rtl::OUString >());
+
+
+ErrCode RequestPassword(const SfxFilter* pCurrentFilter, rtl::OUString& aURL, SfxItemSet* pSet);
}
//-----------------------------------------------------------------------------
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index 7770ded..08f6925 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -69,6 +69,7 @@
#include <sfx2/viewfrm.hxx>
#include <sfx2/request.hxx>
#include <sfx2/passwd.hxx>
+#include <sfx2/filedlghelper.hxx>
#include "helper.hxx"
#include <sfx2/objsh.hxx>
#include <sfx2/docfile.hxx>
@@ -924,15 +925,12 @@ IMPL_LINK( SfxDocumentPage, ChangePassHdl, PushButton*, EMPTYARG )
SfxItemSet* pMedSet = pShell->GetMedium()->GetItemSet();
if (!pMedSet)
break;
+ const SfxFilter* pFilter = pShell->GetMedium()->GetFilter();
+ if (!pFilter)
+ break;
- ::std::auto_ptr<SfxPasswordDialog> pDlg(new SfxPasswordDialog(this));
- pDlg->SetMinLen(1);
- pDlg->ShowExtras(SHOWEXTRAS_CONFIRM);
- if (pDlg->Execute() != RET_OK)
- break;
-
- String aNewPass = pDlg->GetPassword();
- pMedSet->Put( SfxStringItem(SID_PASSWORD, aNewPass) );
+ rtl::OUString aDocName;
+ sfx2::RequestPassword(pFilter, aDocName, pMedSet);
pShell->SetModified(true);
}
while (false);
@@ -986,15 +984,15 @@ void SfxDocumentPage::ImplCheckPasswordState()
if (!pMedSet)
break;
- const SfxPoolItem* pItem;
- if (!pMedSet->GetItemState(SID_PASSWORD, true, &pItem))
- break;
-
- const SfxStringItem* pStrItem = dynamic_cast<const SfxStringItem*>(pItem);
- if (!pStrItem)
- break;
+ SFX_ITEMSET_ARG( pMedSet, pEncryptionDataItem, SfxUnoAnyItem, SID_ENCRYPTIONDATA, sal_False);
+ uno::Sequence< beans::NamedValue > aEncryptionData;
+ if (pEncryptionDataItem)
+ pEncryptionDataItem->GetValue() >>= aEncryptionData;
+ else
+ break;
- String aPass = pStrItem->GetValue();
+ if (!aEncryptionData.getLength())
+ break;
aChangePassBtn.Enable();
return;
}
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index e7f5da3..a7c7bf0 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -1557,69 +1557,10 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList,
if ( ( aValue >>= bPassWord ) && bPassWord )
{
// ask for a password
- uno::Reference < ::com::sun::star::task::XInteractionHandler > xInteractionHandler( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.uui.UUIInteractionHandler"))), UNO_QUERY );
-
- if( xInteractionHandler.is() )
- {
- // TODO: need a save way to distinguish MS filters from other filters
- // for now MS-filters are the only alien filters that support encryption
- sal_Bool bMSType = !pCurrentFilter->IsOwnFormat();
- ::comphelper::DocPasswordRequestType eType = bMSType ?
- ::comphelper::DocPasswordRequestType_MS :
- ::comphelper::DocPasswordRequestType_STANDARD;
-
- ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest( new ::comphelper::DocPasswordRequest( eType, ::com::sun::star::task::PasswordRequestMode_PASSWORD_CREATE, *(rpURLList->GetObject(0)), ( pCurrentFilter->GetFilterFlags() & SFX_FILTER_PASSWORDTOMODIFY ) != 0 ) );
-
- uno::Reference< com::sun::star::task::XInteractionRequest > rRequest( pPasswordRequest.get() );
- xInteractionHandler->handle( rRequest );
- if ( pPasswordRequest->isPassword() )
- {
- if ( pPasswordRequest->getPassword().getLength() )
- {
- // TODO/LATER: The filters should show the password dialog themself in future
- if ( bMSType )
- {
- // all the current MS-filters use MSCodec_Std97 implementation
- uno::Sequence< sal_Int8 > aUniqueID = ::comphelper::DocPasswordHelper::GenerateRandomByteSequence( 16 );
- uno::Sequence< sal_Int8 > aEncryptionKey = ::comphelper::DocPasswordHelper::GenerateStd97Key( pPasswordRequest->getPassword(), aUniqueID );
-
- if ( aEncryptionKey.getLength() )
- {
- ::comphelper::SequenceAsHashMap aHashData;
- aHashData[ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "STD97EncryptionKey" ) ) ] <<= aEncryptionKey;
- aHashData[ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "STD97UniqueID" ) ) ] <<= aUniqueID;
-
- rpSet->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( aHashData.getAsConstNamedValueList() ) ) );
- }
- else
- return ERRCODE_IO_NOTSUPPORTED;
- }
- else
- {
- rpSet->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( ::comphelper::OStorageHelper::CreatePackageEncryptionData( pPasswordRequest->getPassword() ) ) ) );
- }
- }
-
- if ( pPasswordRequest->getRecommendReadOnly() )
- rpSet->Put( SfxBoolItem( SID_RECOMMENDREADONLY, sal_True ) );
-
- if ( bMSType )
- {
- // the empty password has 0 as Hash
- sal_Int32 nHash = SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ).equals( pCurrentFilter->GetServiceName() ) );
- if ( nHash )
- rpSet->Put( SfxUnoAnyItem( SID_MODIFYPASSWORDINFO, uno::makeAny( nHash ) ) );
- }
- else
- {
- uno::Sequence< beans::PropertyValue > aModifyPasswordInfo = ::comphelper::DocPasswordHelper::GenerateNewModifyPasswordInfo( pPasswordRequest->getPasswordToModify() );
- if ( aModifyPasswordInfo.getLength() )
- rpSet->Put( SfxUnoAnyItem( SID_MODIFYPASSWORDINFO, uno::makeAny( aModifyPasswordInfo ) ) );
- }
- }
- else
- return ERRCODE_ABORT;
- }
+ rtl::OUString aDocName(*(rpURLList->GetObject(0)));
+ ErrCode errCode = RequestPassword(pCurrentFilter, aDocName, rpSet);
+ if (errCode != ERRCODE_NONE)
+ return errCode;
}
}
catch( const IllegalArgumentException& ){}
@@ -2764,6 +2705,72 @@ ErrCode FileOpenDialog_Impl( sal_Int64 nFlags,
return nRet;
}
+ErrCode RequestPassword(const SfxFilter* pCurrentFilter, rtl::OUString& aURL, SfxItemSet* pSet)
+{
+ uno::Reference < ::com::sun::star::task::XInteractionHandler > xInteractionHandler( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.uui.UUIInteractionHandler"))), UNO_QUERY );
+ if( xInteractionHandler.is() )
+ {
+ // TODO: need a save way to distinguish MS filters from other filters
+ // for now MS-filters are the only alien filters that support encryption
+ sal_Bool bMSType = !pCurrentFilter->IsOwnFormat();
+ ::comphelper::DocPasswordRequestType eType = bMSType ?
+ ::comphelper::DocPasswordRequestType_MS :
+ ::comphelper::DocPasswordRequestType_STANDARD;
+
+ ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest( new ::comphelper::DocPasswordRequest( eType, ::com::sun::star::task::PasswordRequestMode_PASSWORD_CREATE, aURL, ( pCurrentFilter->GetFilterFlags() & SFX_FILTER_PASSWORDTOMODIFY ) != 0 ) );
+
+ uno::Reference< com::sun::star::task::XInteractionRequest > rRequest( pPasswordRequest.get() );
+ xInteractionHandler->handle( rRequest );
+ if ( pPasswordRequest->isPassword() )
+ {
+ if ( pPasswordRequest->getPassword().getLength() )
+ {
+ // TODO/LATER: The filters should show the password dialog themself in future
+ if ( bMSType )
+ {
+ // all the current MS-filters use MSCodec_Std97 implementation
+ uno::Sequence< sal_Int8 > aUniqueID = ::comphelper::DocPasswordHelper::GenerateRandomByteSequence( 16 );
+ uno::Sequence< sal_Int8 > aEncryptionKey = ::comphelper::DocPasswordHelper::GenerateStd97Key( pPasswordRequest->getPassword(), aUniqueID );
+
+ if ( aEncryptionKey.getLength() )
+ {
+ ::comphelper::SequenceAsHashMap aHashData;
+ aHashData[ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "STD97EncryptionKey" ) ) ] <<= aEncryptionKey;
+ aHashData[ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "STD97UniqueID" ) ) ] <<= aUniqueID;
+
+ pSet->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( aHashData.getAsConstNamedValueList() ) ) );
+ }
+ else
+ return ERRCODE_IO_NOTSUPPORTED;
+ }
+ else
+ {
+ pSet->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( ::comphelper::OStorageHelper::CreatePackageEncryptionData( pPasswordRequest->getPassword() ) ) ) );
+ }
+ }
+
+ if ( pPasswordRequest->getRecommendReadOnly() )
+ pSet->Put( SfxBoolItem( SID_RECOMMENDREADONLY, sal_True ) );
+
+ if ( bMSType )
+ {
+ // the empty password has 0 as Hash
+ sal_Int32 nHash = SfxMedium::CreatePasswordToModifyHash( pPasswordRequest->getPasswordToModify(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ).equals( pCurrentFilter->GetServiceName() ) );
+ if ( nHash )
+ pSet->Put( SfxUnoAnyItem( SID_MODIFYPASSWORDINFO, uno::makeAny( nHash ) ) );
+ }
+ else
+ {
+ uno::Sequence< beans::PropertyValue > aModifyPasswordInfo = ::comphelper::DocPasswordHelper::GenerateNewModifyPasswordInfo( pPasswordRequest->getPasswordToModify() );
+ if ( aModifyPasswordInfo.getLength() )
+ pSet->Put( SfxUnoAnyItem( SID_MODIFYPASSWORDINFO, uno::makeAny( aModifyPasswordInfo ) ) );
+ }
+ }
+ else
+ return ERRCODE_ABORT;
+ }
+ return ERRCODE_NONE;
+}
// ------------------------------------------------------------------------
String EncodeSpaces_Impl( const String& rSource )
commit adfa9a176e6e6c638441f69e342998f66631974e
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Jul 28 19:12:00 2011 +0200
callcatcher: remove unused constructor
diff --git a/sfx2/inc/sfx2/filedlghelper.hxx b/sfx2/inc/sfx2/filedlghelper.hxx
index 4f9d38c..9938f40 100644
--- a/sfx2/inc/sfx2/filedlghelper.hxx
+++ b/sfx2/inc/sfx2/filedlghelper.hxx
@@ -139,12 +139,6 @@ private:
public:
FileDialogHelper( sal_Int64 nFlags,
- const String& rFactory,
- sal_Int16 nDialog,
- SfxFilterFlags nMust,
- SfxFilterFlags nDont );
-
- FileDialogHelper( sal_Int64 nFlags,
const String& rFact,
sal_Int16 nDialog,
SfxFilterFlags nMust,
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index 996e181..e7f5da3 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -2289,20 +2289,6 @@ FileDialogHelper::FileDialogHelper(
mpImp->addFilters( nFlags, SfxObjectShell::GetServiceNameFromFactory(rFact), nMust, nDont );
}
-FileDialogHelper::FileDialogHelper(
- sal_Int64 nFlags,
- const String& rFact,
- sal_Int16 nDialog,
- SfxFilterFlags nMust,
- SfxFilterFlags nDont )
-{
- mpImp = new FileDialogHelper_Impl( this, getDialogType( nFlags ), nFlags, nDialog );
- mxImp = mpImp;
-
- // create the list of filters
- mpImp->addFilters( nFlags, SfxObjectShell::GetServiceNameFromFactory(rFact), nMust, nDont );
-}
-
// ------------------------------------------------------------------------
FileDialogHelper::FileDialogHelper( sal_Int64 nFlags )
{
More information about the Libreoffice-commits
mailing list