diff --git a/xmlsecurity/inc/xmlsecurity/digitalsignaturesdialog.hxx b/xmlsecurity/inc/xmlsecurity/digitalsignaturesdialog.hxx index 85b2d87d4f2e..3396413c768a 100644 --- a/xmlsecurity/inc/xmlsecurity/digitalsignaturesdialog.hxx +++ b/xmlsecurity/inc/xmlsecurity/digitalsignaturesdialog.hxx @@ -2,9 +2,9 @@ * * $RCSfile: digitalsignaturesdialog.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: mt $ $Date: 2004-07-14 11:05:44 $ + * last change: $Author: gt $ $Date: 2004-07-27 07:56:35 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -65,6 +65,7 @@ #include #include #include +#include #include #include @@ -93,6 +94,7 @@ class HeaderBar; class DigitalSignaturesDialog : public ModalDialog { private: + enum SigState { S_NONE, S_VALID, S_BROKEN }; XMLSignatureHelper maSignatureHelper; @@ -109,6 +111,10 @@ private: FixedText maHintBasicFT; FixedText maHintPackageFT; SvxSimpleTable maSignaturesLB; + FixedImage maSigsValidImg; + FixedInfo maSigsValidFI; + FixedImage maSigsInvalidImg; + FixedInfo maSigsInvalidFI; PushButton maViewBtn; PushButton maAddBtn; @@ -130,6 +136,7 @@ private: void ImplFillSignaturesBox(); void ImplShowSignaturesDetails(); + void SetState( SigState _eState ); public: DigitalSignaturesDialog( Window* pParent, cssu::Reference< css::lang::XMultiServiceFactory >& rxMSF, DocumentSignatureMode eMode, sal_Bool bReadOnly ); ~DigitalSignaturesDialog(); diff --git a/xmlsecurity/source/dialogs/certificateviewer.cxx b/xmlsecurity/source/dialogs/certificateviewer.cxx index a219db984c72..a90cb8cecf9c 100644 --- a/xmlsecurity/source/dialogs/certificateviewer.cxx +++ b/xmlsecurity/source/dialogs/certificateviewer.cxx @@ -2,9 +2,9 @@ * * $RCSfile: certificateviewer.cxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: mt $ $Date: 2004-07-26 07:29:31 $ + * last change: $Author: gt $ $Date: 2004-07-27 07:57:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -87,51 +87,17 @@ using namespace ::com::sun::star::uno; namespace { void ShrinkToFit( FixedImage& _rImage ); - long ShrinkToFitWidth( Control& _rCtrl, long _nOffs = 0 ); // return = new width void AdjustPosAndSize( Control& _rCtrl, Point& _rStartIn_EndOut, long _nXOffset = 0 ); - void AlignAfterImage( const FixedImage& _rImage, Control& _rCtrl, long _nXOffset = 0 ); - void AlignAfterImage( const FixedImage& _rImage, FixedInfo& _rFI, long _nXOffset = 0 ); void ShrinkToFit( FixedImage& _rImg ) { _rImg.SetSizePixel( _rImg.GetImage().GetSizePixel() ); } - long ShrinkToFitWidth( Control& _rCtrl, long _nOffs ) - { - long nWidth = _rCtrl.GetTextWidth( _rCtrl.GetText() ); - Size aSize( _rCtrl.GetSizePixel() ); - nWidth += _nOffs; - aSize.Width() = nWidth; - _rCtrl.SetSizePixel( aSize ); - return nWidth; - } - void AdjustPosAndSize( Control& _rCtrl, Point& _rStartIn_EndOut, long _nOffs ) { _rCtrl.SetPosPixel( _rStartIn_EndOut ); - _rStartIn_EndOut.X() += ShrinkToFitWidth( _rCtrl, _nOffs ); - } - - void AlignAfterImage( const FixedImage& _rImage, Control& _rCtrl, long _nXOffset ) - { - Point aPos( _rImage.GetPosPixel() ); - Size aSize( _rImage.GetSizePixel() ); - long n = aPos.X(); - n += aSize.Width(); - n += _nXOffset; - aPos.X() = n; - n = aPos.Y(); - n += aSize.Height() / 2; // y-position is in the middle of the image - n -= _rCtrl.GetSizePixel().Height() / 2; // center Control - aPos.Y() = n; - _rCtrl.SetPosPixel( aPos ); - } - - void AlignAfterImage( const FixedImage& _rImage, FixedInfo& _rFI, long _nXOffset ) - { - AlignAfterImage( _rImage, static_cast< Control& >( _rFI ), _nXOffset ); - ShrinkToFitWidth( _rFI ); + _rStartIn_EndOut.X() += XmlSec::ShrinkToFitWidth( _rCtrl, _nOffs ); } }; @@ -243,8 +209,8 @@ CertificateViewerGeneralTP::CertificateViewerGeneralTP( Window* _pParent, Certif // adjust position of fixed text depending on image sizes ShrinkToFit( maCertImg ); ShrinkToFit( maKeyImg ); - AlignAfterImage( maCertImg, maCertInfoFI, 12 ); - AlignAfterImage( maKeyImg, maHintCorrespPrivKeyFI, 12 ); + XmlSec::AlignAfterImage( maCertImg, maCertInfoFI, 12 ); + XmlSec::AlignAfterImage( maKeyImg, maHintCorrespPrivKeyFI, 12 ); // Check if we have the private key... long nCertificateCharacters = _pDlg->mxSecurityEnvironment->getCertificateCharacters( xCert ); diff --git a/xmlsecurity/source/dialogs/dialogs.hrc b/xmlsecurity/source/dialogs/dialogs.hrc index 9ff2d80e5e7f..a66b3f5b5b80 100644 --- a/xmlsecurity/source/dialogs/dialogs.hrc +++ b/xmlsecurity/source/dialogs/dialogs.hrc @@ -2,9 +2,9 @@ * * $RCSfile: dialogs.hrc,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: mt $ $Date: 2004-07-22 09:43:23 $ + * last change: $Author: gt $ $Date: 2004-07-27 07:57:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -120,6 +120,11 @@ #define FT_HINT_DOC 4 #define FT_HINT_BASIC 5 #define FT_HINT_PACK 6 +#define IMG_STATE_VALID 7 +#define FI_STATE_VALID 8 +#define IMG_STATE_BROKEN 9 +#define FI_STATE_BROKEN 10 + //#define DS_WIDTH DLGS_WIDTH //#define DS_HEIGHT DLGS_HEIGHT @@ -150,7 +155,8 @@ #define DS_ROW_5 DLGS_BOTTOM_FL_Y(DS_HEIGHT) #define DS_ROW_4 DLGS_BOTTOM_LAST_CTRL_L(DS_HEIGHT) #define DS_ROW_3 (DS_ROW_4-RSC_CD_PUSHBUTTON_HEIGHT) -#define DS_ROW_2 (DS_ROW_3-RSC_SP_CTRL_Y) +#define DS_ROW_2A (DS_ROW_3-RSC_CD_FIXEDTEXT_HEIGHT-RSC_SP_CTRL_Y) +#define DS_ROW_2 (DS_ROW_2A-RSC_SP_CTRL_GROUP_Y) #define DS_LB_WIDTH (DS_COL_7-DS_COL_0) diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx index fdf24f98cbcd..62f8e7fc6f0b 100644 --- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx +++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx @@ -2,9 +2,9 @@ * * $RCSfile: digitalsignaturesdialog.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: mt $ $Date: 2004-07-26 15:53:17 $ + * last change: $Author: gt $ $Date: 2004-07-27 07:57:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -99,6 +99,17 @@ using namespace ::com::sun::star::security; using namespace ::com::sun::star; using namespace ::com::sun::star; +void DigitalSignaturesDialog::SetState( SigState _eState ) +{ + bool bShowValid = _eState == S_VALID; + bool bShowInvalid = _eState == S_BROKEN; + + maSigsValidImg.Show( bShowValid ); + maSigsValidFI.Show( bShowValid ); + maSigsInvalidImg.Show( bShowInvalid ); + maSigsInvalidFI.Show( bShowInvalid ); +} + DigitalSignaturesDialog::DigitalSignaturesDialog( Window* pParent, uno::Reference< lang::XMultiServiceFactory >& rxMSF, DocumentSignatureMode eMode, sal_Bool bReadOnly ) :ModalDialog ( pParent, XMLSEC_RES( RID_XMLSECDLG_DIGSIG ) ) ,maSignatureHelper ( rxMSF ) @@ -107,6 +118,10 @@ DigitalSignaturesDialog::DigitalSignaturesDialog( Window* pParent, uno::Referenc ,maHintBasicFT ( this, ResId( FT_HINT_BASIC ) ) ,maHintPackageFT ( this, ResId( FT_HINT_PACK ) ) ,maSignaturesLB ( this, ResId( LB_SIGNATURES ) ) + ,maSigsValidImg ( this, ResId( IMG_STATE_VALID ) ) + ,maSigsValidFI ( this, ResId( FI_STATE_VALID ) ) + ,maSigsInvalidImg ( this, ResId( IMG_STATE_BROKEN ) ) + ,maSigsInvalidFI ( this, ResId( FI_STATE_BROKEN ) ) ,maViewBtn ( this, ResId( BTN_VIEWCERT ) ) ,maAddBtn ( this, ResId( BTN_ADDCERT ) ) ,maRemoveBtn ( this, ResId( BTN_REMOVECERT ) ) @@ -115,11 +130,14 @@ DigitalSignaturesDialog::DigitalSignaturesDialog( Window* pParent, uno::Referenc ,maCancelBtn ( this, ResId( BTN_CANCEL ) ) ,maHelpBtn ( this, ResId( BTN_HELP ) ) { - static long nTabs[] = { 3, 0, 32*DS_LB_WIDTH/100, 64*DS_LB_WIDTH/100 }; + static long nTabs[] = { 4, 0, 8*DS_LB_WIDTH/100, 36*DS_LB_WIDTH/100, 74*DS_LB_WIDTH/100 }; maSignaturesLB.SetTabs( &nTabs[ 0 ] ); maSignaturesLB.InsertHeaderEntry( String( ResId( STR_HEADERBAR ) ) ); FreeResource(); + + SetState( S_NONE ); // first hide state image & info + mbVerifySignatures = true; mbSignaturesChanged = false; @@ -142,6 +160,10 @@ DigitalSignaturesDialog::DigitalSignaturesDialog( Window* pParent, uno::Referenc case SignatureModeMacros: maHintBasicFT.Show(); break; case SignatureModePackage: maHintPackageFT.Show(); break; } + + // adjust fixed text to images + XmlSec::AlignAndFitImageAndControl( maSigsValidImg, maSigsValidFI, 5 ); + XmlSec::AlignAndFitImageAndControl( maSigsInvalidImg, maSigsInvalidFI, 5 ); } DigitalSignaturesDialog::~DigitalSignaturesDialog() @@ -358,7 +380,10 @@ void DigitalSignaturesDialog::ImplFillSignaturesBox() uno::Reference< ::com::sun::star::security::XCertificate > xCert; String aCN_Id( String::CreateFromAscii( "CN" ) ); + String aNullStr; int nInfos = aCurrentSignatureInformations.size(); + int nValidCnt = 0; + bool bValid; for( int n = 0; n < nInfos; ++n ) { const SignatureInformation& rInfo = aCurrentSignatureInformations[n]; @@ -377,7 +402,6 @@ void DigitalSignaturesDialog::ImplFillSignaturesBox() { aSubject = XmlSec::GetContentPart( xCert->getSubjectName(), aCN_Id ); aIssuer = XmlSec::GetContentPart( rInfo.ouX509IssuerName, aCN_Id ); -// aDateTimeStr = XmlSec::GetDateString( xCert->getNotAfter() ); aDateTimeStr = XmlSec::GetDateTimeString( rInfo.ouDate, rInfo.ouTime ); } else @@ -386,13 +410,24 @@ void DigitalSignaturesDialog::ImplFillSignaturesBox() aSubject = String::CreateFromAscii( "ERROR getting certificate!" ); #endif } - SvLBoxEntry* pEntry = maSignaturesLB.InsertEntry( aSubject ); - maSignaturesLB.SetEntryText( aIssuer, pEntry, 1 ); - maSignaturesLB.SetEntryText( aDateTimeStr, pEntry, 2 ); + + bValid = true; + if( bValid ) + ++nValidCnt; + + Image aImg( bValid? maSigsValidImg.GetImage() : maSigsInvalidImg.GetImage() ); + SvLBoxEntry* pEntry = maSignaturesLB.InsertEntry( aNullStr, aImg, aImg ); + maSignaturesLB.SetEntryText( aSubject, pEntry, 1 ); + maSignaturesLB.SetEntryText( aIssuer, pEntry, 2 ); + maSignaturesLB.SetEntryText( aDateTimeStr, pEntry, 3 ); pEntry->SetUserData( ( void* ) n ); // missuse user data as index } -// maViewBtn.Disable(); + bValid = ( nValidCnt == nInfos ); + maSigsInvalidImg.SetImage( bValid? maSigsValidImg.GetImage() : maSigsInvalidImg.GetImage() ); + + SetState( bValid? S_VALID : S_BROKEN ); + SignatureHighlightHdl( NULL ); } diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.src b/xmlsecurity/source/dialogs/digitalsignaturesdialog.src index 8ea04dc9e2fd..991c25e8cab5 100644 --- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.src +++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.src @@ -2,9 +2,9 @@ * * $RCSfile: digitalsignaturesdialog.src,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ + * last change: $Author: gt $ $Date: 2004-07-27 07:57:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,8 +70,7 @@ ModalDialog RID_XMLSECDLG_DIGSIG Moveable = TRUE; SVLook = TRUE; -// Text = "Digital Signatures"; - Text = "Digital Signatures"; + Text = "Digitale Signaturen"; Text [ en-US ] = "Digital Signatures"; FixedText FT_HINT_DOC @@ -98,7 +97,6 @@ ModalDialog RID_XMLSECDLG_DIGSIG Text = "The following have signed this package"; Text [ en-US ] = "The following have signed this package"; }; -// ListBox LB_SIGNATURES Control LB_SIGNATURES { Pos = MAP_APPFONT( DS_COL_0, DS_ROW_1 ); @@ -108,31 +106,64 @@ ModalDialog RID_XMLSECDLG_DIGSIG }; String STR_HEADERBAR { - Text = "Signer\tDigital ID Issued by\tDate"; - Text [ en-US ] = "Signer\tDigital ID Issued by\tDate"; + Text = "\tSigner\tDigital ID Issued by\tDate"; + Text [ en-US ] = "\tSigner\tDigital ID Issued by\tDate"; + }; + FixedImage IMG_STATE_VALID + { + Pos = MAP_APPFONT( DS_COL_0, DS_ROW_2A ); + Size = MAP_APPFONT( IMG1_WIDTH, IMG1_HEIGHT ); + Fixed = Image + { + ImageBitmap = Bitmap { File = "signet_11x16.png"; }; + MaskColor = STD_MASKCOLOR; + }; + }; + FixedText FI_STATE_VALID + { + Pos = MAP_APPFONT( DS_COL_0, DS_ROW_2A ); + Size = MAP_APPFONT( DS_COL_7-DS_COL_0, RSC_CD_FIXEDTEXT_HEIGHT ); + Hide = TRUE; + Text = "Die Signaturen in diesem Dokument sind gültig."; + Text [ en-US ] = "The signatures in this document are valid"; + }; + FixedImage IMG_STATE_BROKEN + { + Pos = MAP_APPFONT( DS_COL_0, DS_ROW_2A ); + Size = MAP_APPFONT( IMG1_WIDTH, IMG1_HEIGHT ); + Fixed = Image + { + ImageBitmap = Bitmap { File = "caution_11x16.png"; }; + MaskColor = STD_MASKCOLOR; + }; + }; + FixedText FI_STATE_BROKEN + { + Pos = MAP_APPFONT( DS_COL_0, DS_ROW_2A ); + Size = MAP_APPFONT( DS_COL_7-DS_COL_0, RSC_CD_FIXEDTEXT_HEIGHT ); + Hide = TRUE; + Text = "Die Signaturen in diesem Dokument sind ungültig."; + Text [ en-US ] = "The signatures in this document are invalid"; }; PushButton BTN_VIEWCERT { Pos = MAP_APPFONT( DS_COL_1, DS_ROW_3 ); Size = MAP_APPFONT( DS_COL_2-DS_COL_1, RSC_CD_PUSHBUTTON_HEIGHT ); -// Text = "Zertifikat anzeigen..."; - Text = "View Certificate..."; + Text = "Zertifikat anzeigen..."; Text [ en-US ] = "View Certificate..."; }; PushButton BTN_ADDCERT { Pos = MAP_APPFONT( DS_COL_3, DS_ROW_3 ); Size = MAP_APPFONT( DS_COL_4-DS_COL_3, RSC_CD_PUSHBUTTON_HEIGHT ); -// Text = "Hinzufügen..."; - Text = "Add..."; + Text = "Hinzufügen..."; Text [ en-US ] = "Add..."; }; PushButton BTN_REMOVECERT { Pos = MAP_APPFONT( DS_COL_5, DS_ROW_3 ); Size = MAP_APPFONT( DS_COL_6-DS_COL_5, RSC_CD_PUSHBUTTON_HEIGHT ); -// Text = "Entfernen"; - Text = "Remove"; + Text = "Entfernen"; Text [ en-US ] = "Remove"; }; FixedLine FL_BOTTOM_SEP diff --git a/xmlsecurity/source/dialogs/resourcemanager.cxx b/xmlsecurity/source/dialogs/resourcemanager.cxx index 9f45de4543fa..f6f1dc0d52e9 100644 --- a/xmlsecurity/source/dialogs/resourcemanager.cxx +++ b/xmlsecurity/source/dialogs/resourcemanager.cxx @@ -2,9 +2,9 @@ * * $RCSfile: resourcemanager.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: mt $ $Date: 2004-07-26 07:29:31 $ + * last change: $Author: gt $ $Date: 2004-07-27 07:57:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,6 +62,8 @@ #include "resourcemanager.hxx" #include +#include +#include #include @@ -251,6 +253,43 @@ namespace XmlSec return aStr; } + + long ShrinkToFitWidth( Control& _rCtrl, long _nOffs ) + { + long nWidth = _rCtrl.GetTextWidth( _rCtrl.GetText() ); + Size aSize( _rCtrl.GetSizePixel() ); + nWidth += _nOffs; + aSize.Width() = nWidth; + _rCtrl.SetSizePixel( aSize ); + return nWidth; + } + + void AlignAfterImage( const FixedImage& _rImage, Control& _rCtrl, long _nXOffset ) + { + Point aPos( _rImage.GetPosPixel() ); + Size aSize( _rImage.GetSizePixel() ); + long n = aPos.X(); + n += aSize.Width(); + n += _nXOffset; + aPos.X() = n; + n = aPos.Y(); + n += aSize.Height() / 2; // y-position is in the middle of the image + n -= _rCtrl.GetSizePixel().Height() / 2; // center Control + aPos.Y() = n; + _rCtrl.SetPosPixel( aPos ); + } + + void AlignAfterImage( const FixedImage& _rImage, FixedInfo& _rFI, long _nXOffset ) + { + AlignAfterImage( _rImage, static_cast< Control& >( _rFI ), _nXOffset ); + ShrinkToFitWidth( _rFI ); + } + + void AlignAndFitImageAndControl( FixedImage& _rImage, FixedInfo& _rFI, long _nXOffset ) + { + _rImage.SetSizePixel( _rImage.GetImage().GetSizePixel() ); + AlignAfterImage( _rImage, _rFI, _nXOffset ); + } } diff --git a/xmlsecurity/source/dialogs/resourcemanager.hxx b/xmlsecurity/source/dialogs/resourcemanager.hxx index 892f9977c81d..81eff9199a84 100644 --- a/xmlsecurity/source/dialogs/resourcemanager.hxx +++ b/xmlsecurity/source/dialogs/resourcemanager.hxx @@ -2,9 +2,9 @@ * * $RCSfile: resourcemanager.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: gt $ $Date: 2004-07-15 06:20:09 $ + * last change: $Author: gt $ $Date: 2004-07-27 07:57:11 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -78,6 +78,10 @@ #include #endif +class FixedImage; +class FixedInfo; +class Control; + namespace XmlSec { ResMgr* GetResMgr( void ); @@ -94,6 +98,11 @@ namespace XmlSec String GetContentPart( const String& _rRawString, const String& _rPartId ); String GetHexString( const ::com::sun::star::uno::Sequence< sal_Int8 >& _rSeq, const char* _pSep = ":", UINT16 _nLineBreak = 0xFFFF ); + + long ShrinkToFitWidth( Control& _rCtrl, long _nOffs = 0 ); // return = new width + void AlignAfterImage( const FixedImage& _rImage, Control& _rCtrl, long _nXOffset = 0 ); + void AlignAfterImage( const FixedImage& _rImage, FixedInfo& _rFI, long _nXOffset = 0 ); + void AlignAndFitImageAndControl( FixedImage& _rImage, FixedInfo& _rFI, long _nXOffset = 0 ); } #define XMLSEC_RES(id) ResId(id,XmlSec::GetResMgr())