diff options
Diffstat (limited to 'sfx2/source/dialog')
-rw-r--r-- | sfx2/source/dialog/filedlghelper.cxx | 31 | ||||
-rw-r--r-- | sfx2/source/dialog/mailmodelapi.cxx | 2 | ||||
-rw-r--r--[-rwxr-xr-x] | sfx2/source/dialog/makefile.mk | 2 | ||||
-rw-r--r-- | sfx2/source/dialog/passwd.cxx | 179 | ||||
-rw-r--r-- | sfx2/source/dialog/passwd.hrc | 5 | ||||
-rw-r--r-- | sfx2/source/dialog/passwd.src | 30 | ||||
-rw-r--r-- | sfx2/source/dialog/versdlg.cxx | 8 |
7 files changed, 174 insertions, 83 deletions
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 02b9003f59d2..5045f1e9d75c 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -1522,8 +1522,8 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, // check password checkbox if the document had password before if( mbHasPassword ) { - SFX_ITEMSET_ARG( rpSet, pPassItem, SfxStringItem, SID_PASSWORD, FALSE ); - mbPwdCheckBoxState = ( pPassItem != NULL ); + SFX_ITEMSET_ARG( rpSet, pPassItem, SfxBoolItem, SID_PASSWORDINTERACTION, FALSE ); + mbPwdCheckBoxState = ( pPassItem != NULL && pPassItem->GetValue() ); // in case the document has password to modify, the dialog should be shown SFX_ITEMSET_ARG( rpSet, pPassToModifyItem, SfxUnoAnyItem, SID_MODIFYPASSWORDINFO, FALSE ); @@ -1537,7 +1537,9 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, mbSelectionEnabled = sal_False; // the password will be set in case user decide so + rpSet->ClearItem( SID_PASSWORDINTERACTION ); rpSet->ClearItem( SID_PASSWORD ); + rpSet->ClearItem( SID_ENCRYPTIONDATA ); rpSet->ClearItem( SID_RECOMMENDREADONLY ); rpSet->ClearItem( SID_MODIFYPASSWORDINFO ); @@ -1652,7 +1654,30 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, if ( pPasswordRequest->isPassword() ) { if ( pPasswordRequest->getPassword().getLength() ) - rpSet->Put( SfxStringItem( SID_PASSWORD, pPasswordRequest->getPassword() ) ); + { + // 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 ) ); diff --git a/sfx2/source/dialog/mailmodelapi.cxx b/sfx2/source/dialog/mailmodelapi.cxx index 16d12f469205..223807d37b11 100644 --- a/sfx2/source/dialog/mailmodelapi.cxx +++ b/sfx2/source/dialog/mailmodelapi.cxx @@ -79,8 +79,6 @@ #include <toolkit/helper/vclunohelper.hxx> #include <tools/urlobj.hxx> -extern sal_Bool GetPasswd_Impl( const SfxItemSet* pSet, String& rPasswd ); - // -------------------------------------------------------------- using namespace ::com::sun::star::beans; using namespace ::com::sun::star::frame; diff --git a/sfx2/source/dialog/makefile.mk b/sfx2/source/dialog/makefile.mk index 4c56cd683e34..572053557e00 100755..100644 --- a/sfx2/source/dialog/makefile.mk +++ b/sfx2/source/dialog/makefile.mk @@ -46,6 +46,7 @@ EXCEPTIONSFILES=\ $(SLO)$/templdlg.obj \ $(SLO)$/dinfdlg.obj \ $(SLO)$/dockwin.obj \ + $(SLO)$/passwd.obj \ $(SLO)$/taskpane.obj SLOFILES =\ @@ -58,7 +59,6 @@ SLOFILES =\ $(SLO)$/mgetempl.obj \ $(SLO)$/navigat.obj \ $(SLO)$/newstyle.obj \ - $(SLO)$/passwd.obj \ $(SLO)$/printopt.obj \ $(SLO)$/sfxdlg.obj \ $(SLO)$/splitwin.obj \ diff --git a/sfx2/source/dialog/passwd.cxx b/sfx2/source/dialog/passwd.cxx index e7cc73ca04bf..52c6acedd4ea 100644 --- a/sfx2/source/dialog/passwd.cxx +++ b/sfx2/source/dialog/passwd.cxx @@ -41,14 +41,15 @@ #include "passwd.hrc" #include "vcl/sound.hxx" +#include "vcl/arrange.hxx" // ----------------------------------------------------------------------- -IMPL_LINK_INLINE_START( SfxPasswordDialog, EditModifyHdl, Edit *, EMPTYARG ) +IMPL_LINK_INLINE_START( SfxPasswordDialog, EditModifyHdl, Edit *, pEdit ) { - if( mbAsciiOnly ) + if( mbAsciiOnly && (pEdit == &maPasswordED || pEdit == &maPassword2ED) ) { - rtl::OUString aTest( maPasswordED.GetText() ); + rtl::OUString aTest( pEdit->GetText() ); const sal_Unicode* pTest = aTest.getStr(); sal_Int32 nLen = aTest.getLength(); rtl::OUStringBuffer aFilter( nLen ); @@ -64,12 +65,15 @@ IMPL_LINK_INLINE_START( SfxPasswordDialog, EditModifyHdl, Edit *, EMPTYARG ) if( bReset ) { Sound::Beep( SOUND_ERROR ); - maPasswordED.SetSelection( Selection( 0, nLen ) ); - maPasswordED.ReplaceSelected( aFilter.makeStringAndClear() ); + pEdit->SetSelection( Selection( 0, nLen ) ); + pEdit->ReplaceSelected( aFilter.makeStringAndClear() ); } } - maOKBtn.Enable( maPasswordED.GetText().Len() >= mnMinLen ); + bool bEnable = maPasswordED.GetText().Len() >= mnMinLen; + if( maPassword2ED.IsVisible() ) + bEnable = (bEnable && (maPassword2ED.GetText().Len() >= mnMinLen)); + maOKBtn.Enable( bEnable ); return 0; } IMPL_LINK_INLINE_END( SfxPasswordDialog, EditModifyHdl, Edit *, EMPTYARG ) @@ -78,8 +82,11 @@ IMPL_LINK_INLINE_END( SfxPasswordDialog, EditModifyHdl, Edit *, EMPTYARG ) IMPL_LINK( SfxPasswordDialog, OKHdl, OKButton *, EMPTYARG ) { - if ( ( ( mnExtras & SHOWEXTRAS_CONFIRM ) == SHOWEXTRAS_CONFIRM ) && - ( GetConfirm() != GetPassword() ) ) + bool bConfirmFailed = ( ( mnExtras & SHOWEXTRAS_CONFIRM ) == SHOWEXTRAS_CONFIRM ) && + ( GetConfirm() != GetPassword() ); + if( ( mnExtras & SHOWEXTRAS_CONFIRM2 ) == SHOWEXTRAS_CONFIRM2 && ( GetConfirm2() != GetPassword2() ) ) + bConfirmFailed = true; + if ( bConfirmFailed ) { ErrorBox aBox( this, SfxResId( MSG_ERROR_WRONG_CONFIRM ) ); aBox.Execute(); @@ -97,27 +104,83 @@ SfxPasswordDialog::SfxPasswordDialog( Window* pParent, const String* pGroupText ModalDialog( pParent, SfxResId ( DLG_PASSWD ) ), + maPasswordBox ( this, SfxResId( GB_PASSWD_PASSWORD ) ), maUserFT ( this, SfxResId( FT_PASSWD_USER ) ), maUserED ( this, SfxResId( ED_PASSWD_USER ) ), maPasswordFT ( this, SfxResId( FT_PASSWD_PASSWORD ) ), maPasswordED ( this, SfxResId( ED_PASSWD_PASSWORD ) ), maConfirmFT ( this, SfxResId( FT_PASSWD_CONFIRM ) ), maConfirmED ( this, SfxResId( ED_PASSWD_CONFIRM ) ), - maPasswordBox ( this, SfxResId( GB_PASSWD_PASSWORD ) ), + maPassword2Box ( this, 0 ), + maPassword2FT ( this, SfxResId( FT_PASSWD_PASSWORD2 ) ), + maPassword2ED ( this, SfxResId( ED_PASSWD_PASSWORD2 ) ), + maConfirm2FT ( this, SfxResId( FT_PASSWD_CONFIRM2 ) ), + maConfirm2ED ( this, SfxResId( ED_PASSWD_CONFIRM2 ) ), maOKBtn ( this, SfxResId( BTN_PASSWD_OK ) ), maCancelBtn ( this, SfxResId( BTN_PASSWD_CANCEL ) ), maHelpBtn ( this, SfxResId( BTN_PASSWD_HELP ) ), - maConfirmStr ( SfxResId( STR_PASSWD_CONFIRM ) ), - mnMinLen ( 5 ), + mnMinLen ( 1 ), mnExtras ( 0 ), mbAsciiOnly ( false ) { FreeResource(); + // setup layout + boost::shared_ptr<vcl::RowOrColumn> xLayout = + boost::dynamic_pointer_cast<vcl::RowOrColumn>( getLayout() ); + xLayout->setOuterBorder( 0 ); + + // get edit size, should be used as minimum + Size aEditSize( maUserED.GetSizePixel() ); + + // add labelcolumn for the labeled edit fields + boost::shared_ptr<vcl::LabelColumn> xEdits( new vcl::LabelColumn( xLayout.get() ) ); + size_t nChildIndex = xLayout->addChild( xEdits ); + xLayout->setBorders( nChildIndex, -2, -2, -2, 0 ); + + // add group box + xEdits->addWindow( &maPasswordBox ); + + // add user line + xEdits->addRow( &maUserFT, &maUserED, -2, aEditSize ); + + // add password line + xEdits->addRow( &maPasswordFT, &maPasswordED, -2, aEditSize ); + + // add confirm line + xEdits->addRow( &maConfirmFT, &maConfirmED, -2, aEditSize ); + + // add second group box + xEdits->addWindow( &maPassword2Box ); + + // add second password line + xEdits->addRow( &maPassword2FT, &maPassword2ED, -2, aEditSize ); + + // add second confirm line + xEdits->addRow( &maConfirm2FT, &maConfirm2ED, -2, aEditSize ); + + // add a FixedLine + FixedLine* pLine = new FixedLine( this, 0 ); + pLine->Show(); + addWindow( pLine, true ); + xLayout->addWindow( pLine ); + + // add button column + Size aBtnSize( maCancelBtn.GetSizePixel() ); + boost::shared_ptr<vcl::RowOrColumn> xButtons( new vcl::RowOrColumn( xLayout.get(), false ) ); + nChildIndex = xLayout->addChild( xButtons ); + xLayout->setBorders( nChildIndex, -2, 0, -2, -2 ); + + size_t nBtnIndex = xButtons->addWindow( &maHelpBtn, 0, aBtnSize ); + xButtons->addChild( new vcl::Spacer( xButtons.get() ) ); + nBtnIndex = xButtons->addWindow( &maOKBtn, 0, aBtnSize ); + nBtnIndex = xButtons->addWindow( &maCancelBtn, 0, aBtnSize ); + Link aLink = LINK( this, SfxPasswordDialog, EditModifyHdl ); maPasswordED.SetModifyHdl( aLink ); + maPassword2ED.SetModifyHdl( aLink ); aLink = LINK( this, SfxPasswordDialog, OKHdl ); maOKBtn.SetClickHdl( aLink ); @@ -146,66 +209,46 @@ void SfxPasswordDialog::SetMaxLen( USHORT nLen ) short SfxPasswordDialog::Execute() { - if ( mnExtras < SHOWEXTRAS_ALL ) + maUserFT.Hide(); + maUserED.Hide(); + maConfirmFT.Hide(); + maConfirmED.Hide(); + maPasswordFT.Hide(); + maPassword2Box.Hide(); + maPassword2FT.Hide(); + maPassword2ED.Hide(); + maPassword2FT.Hide(); + maConfirm2FT.Hide(); + maConfirm2ED.Hide(); + + if( mnExtras != SHOWEXTRAS_NONE ) + maPasswordFT.Show(); + if( (mnExtras & SHOWEXTRAS_USER ) ) { - Size a3Size = LogicToPixel( Size( 3, 3 ), MAP_APPFONT ); - Size a6Size = LogicToPixel( Size( 6, 6 ), MAP_APPFONT ); - long nMinHeight = maHelpBtn.GetPosPixel().Y() + - maHelpBtn.GetSizePixel().Height() + a6Size.Height(); - USHORT nRowHided = 1; - - if ( SHOWEXTRAS_NONE == mnExtras ) - { - maUserFT.Hide(); - maUserED.Hide(); - maConfirmFT.Hide(); - maConfirmED.Hide(); - maPasswordFT.Hide(); - - Point aPos = maUserFT.GetPosPixel(); - long nEnd = maUserED.GetPosPixel().X() + maUserED.GetSizePixel().Width(); - maPasswordED.SetPosPixel( aPos ); - Size aSize = maPasswordED.GetSizePixel(); - aSize.Width() = nEnd - aPos.X(); - maPasswordED.SetSizePixel( aSize ); - - nRowHided = 2; - } - else if ( SHOWEXTRAS_USER == mnExtras ) - { - maConfirmFT.Hide(); - maConfirmED.Hide(); - } - else if ( SHOWEXTRAS_CONFIRM == mnExtras ) - { - maUserFT.Hide(); - maUserED.Hide(); - - Point aPwdPos1 = maPasswordFT.GetPosPixel(); - Point aPwdPos2 = maPasswordED.GetPosPixel(); - - Point aPos = maUserFT.GetPosPixel(); - maPasswordFT.SetPosPixel( aPos ); - aPos = maUserED.GetPosPixel(); - maPasswordED.SetPosPixel( aPos ); - - maConfirmFT.SetPosPixel( aPwdPos1 ); - maConfirmED.SetPosPixel( aPwdPos2 ); - } - - Size aBoxSize = maPasswordBox.GetSizePixel(); - aBoxSize.Height() -= ( nRowHided * maUserED.GetSizePixel().Height() ); - aBoxSize.Height() -= ( nRowHided * a3Size.Height() ); - maPasswordBox.SetSizePixel( aBoxSize ); - - long nDlgHeight = maPasswordBox.GetPosPixel().Y() + aBoxSize.Height() + a6Size.Height(); - if ( nDlgHeight < nMinHeight ) - nDlgHeight = nMinHeight; - Size aDlgSize = GetOutputSizePixel(); - aDlgSize.Height() = nDlgHeight; - SetOutputSizePixel( aDlgSize ); + maUserFT.Show(); + maUserED.Show(); + } + if( (mnExtras & SHOWEXTRAS_CONFIRM ) ) + { + maConfirmFT.Show(); + maConfirmED.Show(); + } + if( (mnExtras & SHOWEXTRAS_PASSWORD2) ) + { + maPassword2Box.Show(); + maPassword2FT.Show(); + maPassword2ED.Show(); + } + if( (mnExtras & SHOWEXTRAS_CONFIRM2 ) ) + { + maConfirm2FT.Show(); + maConfirm2ED.Show(); } + boost::shared_ptr<vcl::RowOrColumn> xLayout = + boost::dynamic_pointer_cast<vcl::RowOrColumn>( getLayout() ); + SetSizePixel( xLayout->getOptimalSize( WINDOWSIZE_PREFERRED ) ); + return ModalDialog::Execute(); } diff --git a/sfx2/source/dialog/passwd.hrc b/sfx2/source/dialog/passwd.hrc index 5be0446fd752..5c9b07c7a130 100644 --- a/sfx2/source/dialog/passwd.hrc +++ b/sfx2/source/dialog/passwd.hrc @@ -41,7 +41,10 @@ #define BTN_PASSWD_CANCEL 21 #define BTN_PASSWD_HELP 22 -#define STR_PASSWD_CONFIRM 30 +#define FT_PASSWD_PASSWORD2 25 +#define ED_PASSWD_PASSWORD2 26 +#define FT_PASSWD_CONFIRM2 27 +#define ED_PASSWD_CONFIRM2 28 #endif diff --git a/sfx2/source/dialog/passwd.src b/sfx2/source/dialog/passwd.src index 79cbb382ad36..426fb9986d5a 100644 --- a/sfx2/source/dialog/passwd.src +++ b/sfx2/source/dialog/passwd.src @@ -86,6 +86,32 @@ ModalDialog DLG_PASSWD Size = MAP_APPFONT( 132, 8 ); Text [ en-US ] = "Password" ; }; + FixedText FT_PASSWD_PASSWORD2 + { + Pos = MAP_APPFONT( 12, 30 ); + Size = MAP_APPFONT( 42, 10 ); + Text [ en-US ] = "P~assword"; + }; + Edit ED_PASSWD_PASSWORD2 + { + Border = TRUE; + PassWord = TRUE; + Pos = MAP_APPFONT( 57, 29 ); + Size = MAP_APPFONT( 75, 12 ); + }; + FixedText FT_PASSWD_CONFIRM2 + { + Pos = MAP_APPFONT( 12, 45 ); + Size = MAP_APPFONT( 42, 10 ); + Text [ en-US ] = "Confir~m"; + }; + Edit ED_PASSWD_CONFIRM2 + { + Border = TRUE; + PassWord = TRUE; + Pos = MAP_APPFONT( 57, 44 ); + Size = MAP_APPFONT( 75, 12 ); + }; OKButton BTN_PASSWD_OK { Disable = TRUE; @@ -103,10 +129,6 @@ ModalDialog DLG_PASSWD Pos = MAP_APPFONT( 144, 43 ); Size = MAP_APPFONT( 50, 14 ); }; - String STR_PASSWD_CONFIRM - { - Text [ en-US ] = "Confirm password" ; - }; }; // ********************************************************************** EOF diff --git a/sfx2/source/dialog/versdlg.cxx b/sfx2/source/dialog/versdlg.cxx index 8e440de0757c..a050e07da5ae 100644 --- a/sfx2/source/dialog/versdlg.cxx +++ b/sfx2/source/dialog/versdlg.cxx @@ -329,13 +329,13 @@ void SfxVersionDialog::Open_Impl() SfxStringItem aReferer( SID_REFERER, DEFINE_CONST_UNICODE("private:user") ); SfxStringItem aFile( SID_FILE_NAME, pObjShell->GetMedium()->GetName() ); - ::rtl::OUString aPassString; - if ( GetPasswd_Impl( pObjShell->GetMedium()->GetItemSet(), aPassString ) ) + uno::Sequence< beans::NamedValue > aEncryptionData; + if ( GetEncryptionData_Impl( pObjShell->GetMedium()->GetItemSet(), aEncryptionData ) ) { // there is a password, it should be used during the opening - SfxStringItem aPassItem( SID_PASSWORD, aPassString ); + SfxUnoAnyItem aEncryptionDataItem( SID_ENCRYPTIONDATA, uno::makeAny( aEncryptionData ) ); pViewFrame->GetDispatcher()->Execute( - SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, &aFile, &aItem, &aTarget, &aReferer, &aPassItem, 0L ); + SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, &aFile, &aItem, &aTarget, &aReferer, &aEncryptionDataItem, 0L ); } else pViewFrame->GetDispatcher()->Execute( |