diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2008-05-14 09:21:30 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2008-05-14 09:21:30 +0000 |
commit | 5479c9506dd5b265931838279ed14841e170411f (patch) | |
tree | 1c3918a8e865a68f420bf5f7670fcd4f179a99f5 /xmlsecurity | |
parent | e6df13b5ada650fef0c1bb21e311f5351c1a3757 (diff) |
INTEGRATION: CWS jl93 (1.30.8); FILE MERGED
2008/05/07 08:06:33 jl 1.30.8.5: #i86651# removed an error message
2008/05/05 13:13:29 jl 1.30.8.4: RESYNC: (1.30-1.32); FILE MERGED
2008/04/21 15:00:54 jl 1.30.8.3: #i86651# new error messages when adding or removing a signature
2008/03/28 09:32:14 jl 1.30.8.2: #i86651#
2008/03/20 11:49:20 jl 1.30.8.1: #i86651# disable add and remove buttons when an old ODF document is used
Diffstat (limited to 'xmlsecurity')
-rw-r--r-- | xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx | 79 |
1 files changed, 76 insertions, 3 deletions
diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx index 7269a62ebdb2..389469167200 100644 --- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx +++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: digitalsignaturesdialog.cxx,v $ - * $Revision: 1.32 $ + * $Revision: 1.33 $ * * This file is part of OpenOffice.org. * @@ -56,6 +56,8 @@ #include "resourcemanager.hxx" #include <vcl/msgbox.hxx> // Until encrypted docs work... +#include <unotools/configitem.hxx> + using namespace ::com::sun::star::security; namespace css = ::com::sun::star; @@ -66,6 +68,40 @@ namespace css = ::com::sun::star; #endif using namespace ::com::sun::star; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; +namespace +{ + class SaveODFItem: public utl::ConfigItem + { + sal_Int16 m_nODF; + public: + SaveODFItem(); + //See group ODF in Common.xcs + bool isLessODF1_2() + { + return m_nODF < 3; + } + }; + + SaveODFItem::SaveODFItem(): utl::ConfigItem(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "Office.Common/Save"))), m_nODF(0) + { + OUString sDef(RTL_CONSTASCII_USTRINGPARAM("ODF/DefaultVersion")); + Sequence< css::uno::Any > aValues = GetProperties( Sequence<OUString>(&sDef,1) ); + if ( aValues.getLength() == 1) + { + sal_Int16 nTmp; + if ( aValues[0] >>= nTmp ) + m_nODF = nTmp; + else + DBG_ASSERT(0, "SaveODFItem::SaveODFItem(): Wrong Type!" ); + } + else + DBG_ASSERT(0, "No ODF/DefaultVersion"); + } + +} sal_Bool HandleStreamAsXML_Impl( const uno::Reference < embed::XStorage >& rxStore, const rtl::OUString& rURI ) { @@ -103,7 +139,10 @@ sal_Bool HandleStreamAsXML_Impl( const uno::Reference < embed::XStorage >& rxSto return bResult; } -DigitalSignaturesDialog::DigitalSignaturesDialog( Window* pParent, uno::Reference< lang::XMultiServiceFactory >& rxMSF, DocumentSignatureMode eMode, sal_Bool bReadOnly ) +DigitalSignaturesDialog::DigitalSignaturesDialog( + Window* pParent, + uno::Reference< lang::XMultiServiceFactory >& rxMSF, DocumentSignatureMode eMode, + sal_Bool bReadOnly) :ModalDialog ( pParent, XMLSEC_RES( RID_XMLSECDLG_DIGSIG ) ) ,maSignatureHelper ( rxMSF ) ,meSignatureMode ( eMode ) @@ -154,7 +193,7 @@ DigitalSignaturesDialog::DigitalSignaturesDialog( Window* pParent, uno::Referenc maViewBtn.Disable(); maAddBtn.SetClickHdl( LINK( this, DigitalSignaturesDialog, AddButtonHdl ) ); - if ( bReadOnly ) + if ( bReadOnly ) maAddBtn.Disable(); maRemoveBtn.SetClickHdl( LINK( this, DigitalSignaturesDialog, RemoveButtonHdl ) ); @@ -202,6 +241,36 @@ void DigitalSignaturesDialog::SetSignatureStream( const cssu::Reference < css::i mxSignatureStream = rxStream; } + +bool DigitalSignaturesDialog::canAdd() +{ + bool ret = false; + OSL_ASSERT(mxStore.is()); + bool bDoc1_1 = DocumentSignatureHelper::isODFPre_1_2(mxStore); + SaveODFItem item; + bool bSave1_1 = item.isLessODF1_2(); + + // see specification + //cvs: specs/www/appwide/security/Electronic_Signatures_and_Security.sxw + //Paragraph 'Behavior with regard to ODF 1.2' + if (!bSave1_1 && bDoc1_1 + || bSave1_1 && bDoc1_1) + { + //#4 + ErrorBox err(NULL, XMLSEC_RES(RID_XMLSECDLG_OLD_ODF_FORMAT)); + err.Execute(); + } + else + ret = true; + + return ret; +} + +bool DigitalSignaturesDialog::canRemove() +{ + return canAdd(); +} + short DigitalSignaturesDialog::Execute() { // Verify Signatures and add certificates to ListBox... @@ -240,6 +309,8 @@ IMPL_LINK( DigitalSignaturesDialog, ViewButtonHdl, Button*, EMPTYARG ) IMPL_LINK( DigitalSignaturesDialog, AddButtonHdl, Button*, EMPTYARG ) { + if( ! canAdd()) + return 0; try { uno::Reference<com::sun::star::xml::crypto::XSecurityEnvironment> xSecEnv = maSignatureHelper.GetSecurityEnvironment(); @@ -341,6 +412,8 @@ IMPL_LINK( DigitalSignaturesDialog, AddButtonHdl, Button*, EMPTYARG ) IMPL_LINK( DigitalSignaturesDialog, RemoveButtonHdl, Button*, EMPTYARG ) { + if (!canRemove()) + return 0; if( maSignaturesLB.FirstSelected() ) { try |