From 2848277180b9cb6dde639001a0f9612af5bd5992 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 13 Feb 2013 23:43:32 +0000 Subject: move macro security dialog to xmlsecurity split out security page and adapt code Change-Id: I51dbd48b2ff4f65f6806fac70bda27ee15d4e176 --- sw/uiconfig/swriter/ui/macrosecurity.ui | 498 ------------------------- xmlsecurity/UI_xmlsec.mk | 2 + xmlsecurity/inc/xmlsecurity/macrosecurity.hxx | 30 +- xmlsecurity/source/dialogs/dialogs.hrc | 21 -- xmlsecurity/source/dialogs/helpids.hrc | 1 - xmlsecurity/source/dialogs/macrosecurity.cxx | 81 ++-- xmlsecurity/source/dialogs/macrosecurity.src | 52 --- xmlsecurity/uiconfig/ui/macrosecuritydialog.ui | 394 +++++++++++++++++++ xmlsecurity/uiconfig/ui/securitylevelpage.ui | 149 ++++++++ 9 files changed, 603 insertions(+), 625 deletions(-) delete mode 100644 sw/uiconfig/swriter/ui/macrosecurity.ui create mode 100644 xmlsecurity/uiconfig/ui/macrosecuritydialog.ui create mode 100644 xmlsecurity/uiconfig/ui/securitylevelpage.ui diff --git a/sw/uiconfig/swriter/ui/macrosecurity.ui b/sw/uiconfig/swriter/ui/macrosecurity.ui deleted file mode 100644 index 9d44ddc851dd..000000000000 --- a/sw/uiconfig/swriter/ui/macrosecurity.ui +++ /dev/null @@ -1,498 +0,0 @@ - - - - - False - 5 - dialog - - - False - vertical - 2 - - - False - end - - - gtk-ok - False - True - True - True - False - True - - - False - True - 0 - - - - - gtk-cancel - False - True - True - True - False - True - - - False - True - 1 - - - - - gtk-help - False - True - True - True - False - True - - - False - True - 2 - - - - - ~Reset - False - True - True - True - False - - - False - True - 3 - - - - - False - True - end - 0 - - - - - True - True - - - True - False - vertical - 12 - - - ~Very high. -Only macros from trusted file locations are allowed to run. All other macros, -regardless whether signed or not,are disabled. - False - True - True - False - False - 0 - True - True - - - False - True - 0 - - - - - H~igh. -Only Signed macros from trusted sources are allowed to run. Unsigned macros -are disabled. - False - True - True - False - False - 0 - True - True - - - False - True - 1 - - - - - ~Medium. -Confirmation required before executing macros from untrusted sources. - False - True - True - False - False - 0 - True - True - - - False - True - 2 - - - - - ~Low(not recommended). -All macros will be executed without confirmation. Use this setting only if you -are certain that all document that will be opened are safe. - False - True - True - False - False - 0 - True - True - - - False - True - 3 - - - - - - - True - False - Security Level - - - - - - False - - - - - True - False - vertical - 6 - - - True - False - 0 - none - - - True - False - 12 - - - True - False - 6 - 6 - 6 - - - True - True - in - - - - - - 0 - 1 - 1 - 1 - - - - - True - False - 12 - end - - - ~View... - False - True - True - True - False - - - False - True - 0 - - - - - gtk-remove - False - True - True - True - False - True - - - False - True - 1 - - - - - 0 - 2 - 1 - 1 - - - - - True - False - - - 150 - True - False - 0 - Issued to - - - 0 - 0 - 1 - 1 - - - - - 150 - True - False - 0 - issued by - - - 1 - 0 - 1 - 1 - - - - - 150 - True - False - 0 - Expiration date - - - 2 - 0 - 1 - 1 - - - - - 0 - 0 - 1 - 1 - - - - - - - - - True - False - Trusted certificates - - - - - False - True - 0 - - - - - True - False - 0 - none - - - True - False - 12 - - - True - False - 6 - 12 - - - True - False - Document macros are always executed if they have been opened from one of the -following locations. - - - 0 - 0 - 1 - 1 - - - - - True - True - in - - - - - - 0 - 1 - 1 - 1 - - - - - True - False - 12 - end - - - gtk-add - False - True - True - True - False - True - - - False - True - 0 - - - - - gtk-remove - False - True - True - True - False - True - - - False - True - 1 - - - - - 0 - 2 - 1 - 1 - - - - - - - - - True - False - Trusted file locations - - - - - False - True - 1 - - - - - 1 - - - - - True - False - Trusted Sources - - - - - - 1 - False - - - - - False - True - 1 - - - - - - ok - cancel - help - reset - - - diff --git a/xmlsecurity/UI_xmlsec.mk b/xmlsecurity/UI_xmlsec.mk index c9c7232e64f4..69f1b2bbceb2 100644 --- a/xmlsecurity/UI_xmlsec.mk +++ b/xmlsecurity/UI_xmlsec.mk @@ -11,7 +11,9 @@ $(eval $(call gb_UI_UI,xmlsec)) $(eval $(call gb_UI_add_uifiles,xmlsec,\ xmlsecurity/uiconfig/ui/digitalsignaturesdialog \ + xmlsecurity/uiconfig/ui/securitylevelpage \ xmlsecurity/uiconfig/ui/selectcertificatedialog \ + xmlsecurity/uiconfig/ui/macrosecuritydialog \ )) # vim: set noet sw=4 ts=4: diff --git a/xmlsecurity/inc/xmlsecurity/macrosecurity.hxx b/xmlsecurity/inc/xmlsecurity/macrosecurity.hxx index 9450ffa425a2..4611f05e50e3 100644 --- a/xmlsecurity/inc/xmlsecurity/macrosecurity.hxx +++ b/xmlsecurity/inc/xmlsecurity/macrosecurity.hxx @@ -89,29 +89,27 @@ class MacroSecurityTP : public TabPage protected: MacroSecurity* mpDlg; public: - MacroSecurityTP( Window* _pParent, const ResId& _rResId, MacroSecurity* _pDlg ); - inline void SetTabDlg( MacroSecurity* pTabDlg ); + MacroSecurityTP(Window* _pParent, const OString& rID, + const OUString& rUIXMLDescription, MacroSecurity* _pDlg); + MacroSecurityTP(Window* _pParent, const ResId& _rResId, MacroSecurity* _pDlg); + + void SetTabDlg(MacroSecurity* pTabDlg) + { + mpDlg = pTabDlg; + } virtual void ClosePage( void ) = 0; }; -inline void MacroSecurityTP::SetTabDlg( MacroSecurity* _pTabDlg ) -{ - mpDlg = _pTabDlg; -} - - class MacroSecurityLevelTP : public MacroSecurityTP { private: - FixedLine maSecLevelFL; - ReadOnlyImage maSecReadonlyFI; - RadioButton maVeryHighRB; - RadioButton maHighRB; - RadioButton maMediumRB; - RadioButton maLowRB; - - sal_uInt16 mnCurLevel; + RadioButton* m_pVeryHighRB; + RadioButton* m_pHighRB; + RadioButton* m_pMediumRB; + RadioButton* m_pLowRB; + + sal_uInt16 mnCurLevel; protected: DECL_LINK(RadioButtonHdl, void *); diff --git a/xmlsecurity/source/dialogs/dialogs.hrc b/xmlsecurity/source/dialogs/dialogs.hrc index ea6097a3a830..cfc4acd489c2 100644 --- a/xmlsecurity/source/dialogs/dialogs.hrc +++ b/xmlsecurity/source/dialogs/dialogs.hrc @@ -175,27 +175,6 @@ #define MS_COL_G (MS_COL_F-RSC_SP_CTRL_X) #define MS_COL_H (MS_COL_G-RSC_CD_PUSHBUTTON_WIDTH) -// --------- tab page security level --------- - -#define FL_SECLEVEL 1 -#define RB_VERYHIGH 2 -#define RB_HIGH 3 -#define RB_MEDIUM 4 -#define RB_LOW 5 -#define FI_SEC_READONLY 6 - -#define RSC_BIG_RADIOBUTTON 40 -#define SL_RB_DIST_Y (RSC_SP_FLGR_SPACE_Y+RSC_BIG_RADIOBUTTON) -#define SL_COL_0 RSC_SP_TBPG_INNERBORDER_LEFT -#define SL_COL_1 (SL_COL_0+RSC_SP_FLGR_SPACE_X) -#define SL_COL_3 (TP_WIDTH-RSC_SP_TBPG_INNERBORDER_RIGHT) -#define SL_COL_2 ((SL_COL_3-SL_COL_1)*100/105) -#define SL_ROW_0 RSC_SP_TBPG_INNERBORDER_TOP -#define SL_ROW_1 (SL_ROW_0+SL_RB_DIST_Y) -#define SL_ROW_2 (SL_ROW_1+SL_RB_DIST_Y) -#define SL_ROW_3 (SL_ROW_2+SL_RB_DIST_Y) -#define SL_ROW_4 (TP_HEIGHT-RSC_SP_TBPG_INNERBORDER_BOTTOM) - // --------- tab page trusted sources --------- #define FL_TRUSTCERT 1 diff --git a/xmlsecurity/source/dialogs/helpids.hrc b/xmlsecurity/source/dialogs/helpids.hrc index 8a3dde570e42..0818b8272ddf 100644 --- a/xmlsecurity/source/dialogs/helpids.hrc +++ b/xmlsecurity/source/dialogs/helpids.hrc @@ -24,7 +24,6 @@ // Help-Ids -------------------------------------------------------------- #define HID_XMLSEC_TP_MACROSEC "XMLSECURITY_HID_XMLSEC_TP_MACROSEC" -#define HID_XMLSEC_TP_SECLEVEL "XMLSECURITY_HID_XMLSEC_TP_SECLEVEL" #define HID_XMLSEC_TP_TRUSTSOURCES "XMLSECURITY_HID_XMLSEC_TP_TRUSTSOURCES" #define HID_XMLSEC_DLG_CERTVIEWER "XMLSECURITY_HID_XMLSEC_DLG_CERTVIEWER" #define HID_XMLSEC_TP_GENERAL "XMLSECURITY_HID_XMLSEC_TP_GENERAL" diff --git a/xmlsecurity/source/dialogs/macrosecurity.cxx b/xmlsecurity/source/dialogs/macrosecurity.cxx index f87160fedf63..53df4453d4d2 100644 --- a/xmlsecurity/source/dialogs/macrosecurity.cxx +++ b/xmlsecurity/source/dialogs/macrosecurity.cxx @@ -91,6 +91,12 @@ MacroSecurity::~MacroSecurity() delete maTabCtrl.GetTabPage( RID_XMLSECTP_SECLEVEL ); } +MacroSecurityTP::MacroSecurityTP(Window* _pParent, const OString& rID, + const OUString& rUIXMLDescription, MacroSecurity* _pDlg) + : TabPage(_pParent, rID, rUIXMLDescription) + , mpDlg(_pDlg) +{ +} MacroSecurityTP::MacroSecurityTP( Window* _pParent, const ResId& _rResId, MacroSecurity* _pDlg ) :TabPage ( _pParent, _rResId ) @@ -98,66 +104,67 @@ MacroSecurityTP::MacroSecurityTP( Window* _pParent, const ResId& _rResId, MacroS { } -MacroSecurityLevelTP::MacroSecurityLevelTP( Window* _pParent, MacroSecurity* _pDlg ) - :MacroSecurityTP ( _pParent, XMLSEC_RES( RID_XMLSECTP_SECLEVEL ), _pDlg ) - ,maSecLevelFL ( this, XMLSEC_RES( FL_SECLEVEL ) ) - ,maSecReadonlyFI ( this, XMLSEC_RES( FI_SEC_READONLY )) - ,maVeryHighRB ( this, XMLSEC_RES( RB_VERYHIGH ) ) - ,maHighRB ( this, XMLSEC_RES( RB_HIGH ) ) - ,maMediumRB ( this, XMLSEC_RES( RB_MEDIUM ) ) - ,maLowRB ( this, XMLSEC_RES( RB_LOW ) ) +MacroSecurityLevelTP::MacroSecurityLevelTP(Window* _pParent, MacroSecurity* _pDlg) + : MacroSecurityTP(_pParent, "SecurityLevelPage", "xmlsec/ui/securitylevelpage.ui", _pDlg) { - FreeResource(); + get(m_pVeryHighRB, "vhigh"); + get(m_pHighRB, "high"); + get(m_pMediumRB, "med"); + get(m_pLowRB, "low"); - maLowRB.SetClickHdl( LINK( this, MacroSecurityLevelTP, RadioButtonHdl ) ); - maMediumRB.SetClickHdl( LINK( this, MacroSecurityLevelTP, RadioButtonHdl ) ); - maHighRB.SetClickHdl( LINK( this, MacroSecurityLevelTP, RadioButtonHdl ) ); - maVeryHighRB.SetClickHdl( LINK( this, MacroSecurityLevelTP, RadioButtonHdl ) ); + m_pLowRB->SetClickHdl( LINK( this, MacroSecurityLevelTP, RadioButtonHdl ) ); + m_pMediumRB->SetClickHdl( LINK( this, MacroSecurityLevelTP, RadioButtonHdl ) ); + m_pHighRB->SetClickHdl( LINK( this, MacroSecurityLevelTP, RadioButtonHdl ) ); + m_pVeryHighRB->SetClickHdl( LINK( this, MacroSecurityLevelTP, RadioButtonHdl ) ); mnCurLevel = (sal_uInt16) mpDlg->maSecOptions.GetMacroSecurityLevel(); sal_Bool bReadonly = mpDlg->maSecOptions.IsReadOnly( SvtSecurityOptions::E_MACRO_SECLEVEL ); RadioButton* pCheck = 0; - switch( mnCurLevel ) + FixedImage* pImage = 0; + switch (mnCurLevel) { - case 3: pCheck = &maVeryHighRB; break; - case 2: pCheck = &maHighRB; break; - case 1: pCheck = &maMediumRB; break; - case 0: pCheck = &maLowRB; break; + case 3: + pCheck = m_pVeryHighRB; + pImage = get("vhighimg"); + break; + case 2: + pCheck = m_pHighRB; + pImage = get("highimg"); + break; + case 1: + pCheck = m_pMediumRB; + pImage = get("medimg"); + break; + case 0: + pCheck = m_pLowRB; + pImage = get("lowimg"); + break; } - if(pCheck) + if (pCheck) pCheck->Check(); else { OSL_FAIL("illegal macro security level"); } - maSecReadonlyFI.Show(bReadonly); - if(bReadonly) + if (bReadonly) { - //move to the selected button - if( pCheck && pCheck != &maVeryHighRB) - { - long nDiff = pCheck->GetPosPixel().Y() - maVeryHighRB.GetPosPixel().Y(); - Point aPos(maSecReadonlyFI.GetPosPixel()); - aPos.Y() += nDiff; - maSecReadonlyFI.SetPosPixel(aPos); - } - maVeryHighRB.Enable(sal_False); - maHighRB.Enable(sal_False); - maMediumRB.Enable(sal_False); - maLowRB.Enable(sal_False); + pImage->Show(true); + m_pVeryHighRB->Enable(false); + m_pHighRB->Enable(false); + m_pMediumRB->Enable(false); + m_pLowRB->Enable(false); } - } IMPL_LINK_NOARG(MacroSecurityLevelTP, RadioButtonHdl) { sal_uInt16 nNewLevel = 0; - if( maVeryHighRB.IsChecked() ) + if( m_pVeryHighRB->IsChecked() ) nNewLevel = 3; - else if( maHighRB.IsChecked() ) + else if( m_pHighRB->IsChecked() ) nNewLevel = 2; - else if( maMediumRB.IsChecked() ) + else if( m_pMediumRB->IsChecked() ) nNewLevel = 1; if ( nNewLevel != mnCurLevel ) diff --git a/xmlsecurity/source/dialogs/macrosecurity.src b/xmlsecurity/source/dialogs/macrosecurity.src index 8d04f80e78b6..a1a6fcdf34c9 100644 --- a/xmlsecurity/source/dialogs/macrosecurity.src +++ b/xmlsecurity/source/dialogs/macrosecurity.src @@ -72,58 +72,6 @@ TabDialog RID_XMLSECTP_MACROSEC }; }; -TabPage RID_XMLSECTP_SECLEVEL -{ - HelpId = HID_XMLSEC_TP_SECLEVEL; - Size = MAP_APPFONT( TP_WIDTH, TP_HEIGHT ); - OutputSize = TRUE; - Hide = TRUE; - SVLook = TRUE; - FixedLine FL_SECLEVEL - { - Pos = MAP_APPFONT( SL_COL_0, SL_ROW_0 ); - Size = MAP_APPFONT( SL_COL_3-SL_COL_0, RSC_CD_FIXEDLINE_HEIGHT ); - Hide = TRUE; - }; - FixedImage FI_SEC_READONLY - { - Pos = MAP_APPFONT( SL_COL_1 - 7, SL_ROW_0 + 4 ); - Size = MAP_APPFONT( 6, 6 ); - }; - RadioButton RB_VERYHIGH - { - HelpID = "xmlsecurity:RadioButton:RID_XMLSECTP_SECLEVEL:RB_VERYHIGH"; - Pos = MAP_APPFONT( SL_COL_1, SL_ROW_0 ); - Size = MAP_APPFONT( SL_COL_2-SL_COL_1, RSC_BIG_RADIOBUTTON ); - WordBreak = TRUE; - Text [ en-US ] = "~Very high.\nOnly macros from trusted file locations are allowed to run. All other macros, regardless whether signed or not, are disabled."; - }; - RadioButton RB_HIGH - { - HelpID = "xmlsecurity:RadioButton:RID_XMLSECTP_SECLEVEL:RB_HIGH"; - Pos = MAP_APPFONT( SL_COL_1, SL_ROW_1 ); - Size = MAP_APPFONT( SL_COL_2-SL_COL_1, RSC_BIG_RADIOBUTTON ); - WordBreak = TRUE; - Text [ en-US ] = "H~igh.\nOnly signed macros from trusted sources are allowed to run. Unsigned macros are disabled."; - }; - RadioButton RB_MEDIUM - { - HelpID = "xmlsecurity:RadioButton:RID_XMLSECTP_SECLEVEL:RB_MEDIUM"; - Pos = MAP_APPFONT( SL_COL_1, SL_ROW_2 ); - Size = MAP_APPFONT( SL_COL_2-SL_COL_1, RSC_BIG_RADIOBUTTON ); - WordBreak = TRUE; - Text [ en-US ] = "~Medium.\nConfirmation required before executing macros from untrusted sources."; - }; - RadioButton RB_LOW - { - HelpID = "xmlsecurity:RadioButton:RID_XMLSECTP_SECLEVEL:RB_LOW"; - Pos = MAP_APPFONT( SL_COL_1, SL_ROW_3 ); - Size = MAP_APPFONT( SL_COL_2-SL_COL_1, SL_ROW_4-SL_ROW_3 ); - WordBreak = TRUE; - Text [ en-US ] = "~Low (not recommended).\nAll macros will be executed without confirmation. Use this setting only if you are certain that all documents that will be opened are safe."; - }; -}; - TabPage RID_XMLSECTP_TRUSTSOURCES { HelpId = HID_XMLSEC_TP_TRUSTSOURCES; diff --git a/xmlsecurity/uiconfig/ui/macrosecuritydialog.ui b/xmlsecurity/uiconfig/ui/macrosecuritydialog.ui new file mode 100644 index 000000000000..7d803d091571 --- /dev/null +++ b/xmlsecurity/uiconfig/ui/macrosecuritydialog.ui @@ -0,0 +1,394 @@ + + + + + False + 5 + Macro Security + dialog + + + False + vertical + 2 + + + False + end + + + gtk-ok + True + True + True + True + + + False + True + 0 + + + + + gtk-cancel + True + True + True + True + + + False + True + 1 + + + + + gtk-help + True + True + True + True + + + False + True + 2 + + + + + ~Reset + True + True + True + + + False + True + 3 + + + + + False + True + end + 0 + + + + + True + True + + + + + + True + False + Security Level + + + False + + + + + True + False + 6 + vertical + 6 + + + True + False + 0 + none + + + True + False + 12 + + + True + False + 6 + 6 + 6 + + + True + True + in + + + + + + 0 + 1 + 1 + 1 + + + + + True + False + 12 + end + + + ~View... + True + True + True + + + False + True + 0 + + + + + gtk-remove + True + True + True + True + + + False + True + 1 + + + + + 0 + 2 + 1 + 1 + + + + + True + False + + + 150 + True + False + 0 + Issued to + + + 0 + 0 + 1 + 1 + + + + + 150 + True + False + 0 + issued by + + + 1 + 0 + 1 + 1 + + + + + 150 + True + False + 0 + Expiration date + + + 2 + 0 + 1 + 1 + + + + + 0 + 0 + 1 + 1 + + + + + + + + + True + False + Trusted certificates + + + + + False + True + 0 + + + + + True + False + 0 + none + + + True + False + 12 + + + True + False + 6 + 12 + + + True + False + Document macros are always executed if they have been opened from one of the +following locations. + + + 0 + 0 + 1 + 1 + + + + + True + True + in + + + + + + 0 + 1 + 1 + 1 + + + + + True + False + 12 + end + + + gtk-add + True + True + True + True + + + False + True + 0 + + + + + gtk-remove + True + True + True + True + + + False + True + 1 + + + + + 0 + 2 + 1 + 1 + + + + + + + + + True + False + Trusted file locations + + + + + False + True + 1 + + + + + 1 + + + + + True + False + Trusted Sources + + + 1 + False + + + + + False + True + 1 + + + + + + ok + cancel + help + reset + + + diff --git a/xmlsecurity/uiconfig/ui/securitylevelpage.ui b/xmlsecurity/uiconfig/ui/securitylevelpage.ui new file mode 100644 index 000000000000..9e004dd5a94f --- /dev/null +++ b/xmlsecurity/uiconfig/ui/securitylevelpage.ui @@ -0,0 +1,149 @@ + + + + + True + False + 6 + 12 + 12 + True + + + _Low (not recommended). +All macros will be executed without confirmation. Use this setting only if you are certain that all documents that will be opened are safe. + True + True + False + True + 0 + True + vhigh:wrap + + + 1 + 3 + 1 + 1 + + + + + _Medium. +Confirmation required before executing macros from untrusted sources. + True + True + False + True + 0 + True + low:wrap + + + 1 + 2 + 1 + 1 + + + + + H_igh. +Only signed macros from trusted sources are allowed to run. Unsigned macros are disabled. + True + True + False + True + 0 + True + True + med:wrap + + + 1 + 1 + 1 + 1 + + + + + _Very high. +Only macros from trusted file locations are allowed to run. All other macros, regardless whether signed or not, are disabled. + True + True + False + True + 0 + True + high:wrap + + + 1 + 0 + 1 + 1 + + + + + False + True + center + center + res/lock.png + + + 0 + 0 + 1 + 1 + + + + + False + True + center + center + res/lock.png + + + 0 + 1 + 1 + 1 + + + + + False + True + center + center + res/lock.png + + + 0 + 2 + 1 + 1 + + + + + False + True + center + center + res/lock.png + + + 0 + 3 + 1 + 1 + + + + -- cgit