summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Lohmann <Philipp.Lohmann@Sun.COM>2009-10-23 13:26:54 +0200
committerPhilipp Lohmann <Philipp.Lohmann@Sun.COM>2009-10-23 13:26:54 +0200
commit053cb63bb1f321e63ac4db9a82eae685c6197218 (patch)
treec6d3370d280ad28eda1b3af66aff84fac0d9e02d
parent5074096e42b7b91f50d8e9f1be02e87233d8e60f (diff)
#i90373# allow only ascii characters in PDF passwords
-rw-r--r--sfx2/inc/sfx2/passwd.hxx4
-rw-r--r--sfx2/source/dialog/passwd.cxx28
2 files changed, 29 insertions, 3 deletions
diff --git a/sfx2/inc/sfx2/passwd.hxx b/sfx2/inc/sfx2/passwd.hxx
index bb4e1b8c1561..bfe8debecca1 100644
--- a/sfx2/inc/sfx2/passwd.hxx
+++ b/sfx2/inc/sfx2/passwd.hxx
@@ -68,10 +68,9 @@ private:
USHORT mnMinLen;
USHORT mnExtras;
-//#if 0 // _SOLAR__PRIVATE
+ bool mbAsciiOnly;
DECL_DLLPRIVATE_LINK( EditModifyHdl, Edit* );
DECL_DLLPRIVATE_LINK( OKHdl, OKButton* );
-//#endif
public:
SfxPasswordDialog( Window* pParent, const String* pGroupText = NULL );
@@ -84,6 +83,7 @@ public:
void SetMaxLen( USHORT Len );
void SetEditHelpId( ULONG nId ) { maPasswordED.SetHelpId( nId ); }
void ShowExtras( USHORT nExtras ) { mnExtras = nExtras; }
+ void AllowAsciiOnly( bool i_bAsciiOnly = true ) { mbAsciiOnly = i_bAsciiOnly; }
virtual short Execute();
};
diff --git a/sfx2/source/dialog/passwd.cxx b/sfx2/source/dialog/passwd.cxx
index cbe47d39b704..981657d476fa 100644
--- a/sfx2/source/dialog/passwd.cxx
+++ b/sfx2/source/dialog/passwd.cxx
@@ -43,10 +43,35 @@
#include "dialog.hrc"
#include "passwd.hrc"
+#include "vcl/sound.hxx"
+
// -----------------------------------------------------------------------
IMPL_LINK_INLINE_START( SfxPasswordDialog, EditModifyHdl, Edit *, EMPTYARG )
{
+ if( mbAsciiOnly )
+ {
+ rtl::OUString aTest( maPasswordED.GetText() );
+ const sal_Unicode* pTest = aTest.getStr();
+ sal_Int32 nLen = aTest.getLength();
+ rtl::OUStringBuffer aFilter( nLen );
+ bool bReset = false;
+ for( sal_Int32 i = 0; i < nLen; i++ )
+ {
+ if( *pTest > 0x007f )
+ bReset = true;
+ else
+ aFilter.append( *pTest );
+ pTest++;
+ }
+ if( bReset )
+ {
+ Sound::Beep( SOUND_ERROR );
+ maPasswordED.SetSelection( Selection( 0, nLen ) );
+ maPasswordED.ReplaceSelected( aFilter.makeStringAndClear() );
+ }
+
+ }
maOKBtn.Enable( maPasswordED.GetText().Len() >= mnMinLen );
return 0;
}
@@ -88,7 +113,8 @@ SfxPasswordDialog::SfxPasswordDialog( Window* pParent, const String* pGroupText
maConfirmStr ( SfxResId( STR_PASSWD_CONFIRM ) ),
mnMinLen ( 5 ),
- mnExtras ( 0 )
+ mnExtras ( 0 ),
+ mbAsciiOnly ( false )
{
FreeResource();