summaryrefslogtreecommitdiff
path: root/sfx2/source
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2011-04-06 23:17:50 -0400
committerKohei Yoshida <kyoshida@novell.com>2011-04-06 23:17:50 -0400
commit696dccc7134799629ed249f15757000deb533d26 (patch)
tree6d431c644c3b94423591a5cbb88a6afd17620282 /sfx2/source
parente843be296a5d95cbfdc134e729a361bc04d0753f (diff)
Ported document-password-change-sfx2.diff from the build repo.
This allows users to change the current password of a document encrypted with a password.
Diffstat (limited to 'sfx2/source')
-rw-r--r--sfx2/source/dialog/dinfdlg.cxx58
-rwxr-xr-xsfx2/source/dialog/dinfdlg.hrc1
-rw-r--r--sfx2/source/dialog/dinfdlg.src12
3 files changed, 69 insertions, 2 deletions
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index fd095cb7f2..b0e1cab2b4 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -68,6 +68,7 @@
#include <sfx2/frame.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/request.hxx>
+#include <sfx2/passwd.hxx>
#include "helper.hxx"
#include <sfx2/objsh.hxx>
#include <sfx2/docfile.hxx>
@@ -790,6 +791,7 @@ SfxDocumentPage::SfxDocumentPage( Window* pParent, const SfxItemSet& rItemSet )
aBmp1 ( this, SfxResId( BMP_FILE_1 ) ),
aNameED ( this, SfxResId( ED_FILE_NAME ) ),
+ aChangePassBtn ( this, SfxResId( BTN_CHANGE_PASS ) ),
aLine1FL ( this, SfxResId( FL_FILE_1 ) ),
aTypeFT ( this, SfxResId( FT_FILE_TYP ) ),
@@ -832,8 +834,10 @@ SfxDocumentPage::SfxDocumentPage( Window* pParent, const SfxItemSet& rItemSet )
FreeResource();
ImplUpdateSignatures();
+ ImplCheckPasswordState();
aDeleteBtn.SetClickHdl( LINK( this, SfxDocumentPage, DeleteHdl ) );
aSignatureBtn.SetClickHdl( LINK( this, SfxDocumentPage, SignatureHdl ) );
+ aChangePassBtn.SetClickHdl( LINK( this, SfxDocumentPage, ChangePassHdl ) );
// if the button text is too wide, then broaden it
const long nOffset = 12;
@@ -909,6 +913,32 @@ IMPL_LINK( SfxDocumentPage, SignatureHdl, PushButton*, EMPTYARG )
return 0;
}
+IMPL_LINK( SfxDocumentPage, ChangePassHdl, PushButton*, EMPTYARG )
+{
+ SfxObjectShell* pShell = SfxObjectShell::Current();
+ do
+ {
+ if (!pShell)
+ break;
+
+ SfxItemSet* pMedSet = pShell->GetMedium()->GetItemSet();
+ if (!pMedSet)
+ 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) );
+ pShell->SetModified(true);
+ }
+ while (false);
+ return 0;
+}
+
void SfxDocumentPage::ImplUpdateSignatures()
{
SfxObjectShell* pDoc = SfxObjectShell::Current();
@@ -944,6 +974,34 @@ void SfxDocumentPage::ImplUpdateSignatures()
}
}
+void SfxDocumentPage::ImplCheckPasswordState()
+{
+ SfxObjectShell* pShell = SfxObjectShell::Current();
+ do
+ {
+ if (!pShell)
+ break;
+
+ SfxItemSet* pMedSet = pShell->GetMedium()->GetItemSet();
+ 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;
+
+ String aPass = pStrItem->GetValue();
+ aChangePassBtn.Enable();
+ return;
+ }
+ while (false);
+ aChangePassBtn.Disable();
+}
+
//------------------------------------------------------------------------
SfxTabPage* SfxDocumentPage::Create( Window* pParent, const SfxItemSet& rItemSet )
diff --git a/sfx2/source/dialog/dinfdlg.hrc b/sfx2/source/dialog/dinfdlg.hrc
index f710e13534..d700bedee6 100755
--- a/sfx2/source/dialog/dinfdlg.hrc
+++ b/sfx2/source/dialog/dinfdlg.hrc
@@ -133,6 +133,7 @@
#define FT_SIGNED_VAL 77
#define STR_MULTSIGNED 78
#define BTN_SIGNATURE 79
+#define BTN_CHANGE_PASS 80
#define WIN_PROPERTIES 90
#define SB_VERTICAL 91
diff --git a/sfx2/source/dialog/dinfdlg.src b/sfx2/source/dialog/dinfdlg.src
index ccaf6fcf21..64f28f792d 100644
--- a/sfx2/source/dialog/dinfdlg.src
+++ b/sfx2/source/dialog/dinfdlg.src
@@ -126,10 +126,18 @@ TabPage TP_DOCINFODOC
Edit ED_FILE_NAME
{
HelpID = "sfx2:Edit:TP_DOCINFODOC:ED_FILE_NAME";
- Pos = MAP_APPFONT ( 54 , 12 ) ;
- Size = MAP_APPFONT ( 200 , RSC_CD_TEXTBOX_HEIGHT ) ;
+ Pos = MAP_APPFONT ( 36 , 12 ) ;
+ Size = MAP_APPFONT ( 140 , RSC_CD_TEXTBOX_HEIGHT ) ;
Border = TRUE ;
};
+ PushButton BTN_CHANGE_PASS
+ {
+ HelpID = "sfx2:Edit:TP_DOCINFODOC:BTN_CHANGE_PASS";
+ Pos = MAP_APPFONT ( 189 , 11 ) ;
+ Size = MAP_APPFONT ( 65 , RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ Hide = FALSE;
+ Text [ en-US ] = "Change ~Password...";
+ };
FixedLine FL_FILE_1
{
Pos = MAP_APPFONT ( 6 , 31 ) ;