From 6178387f7bcc35df9272978ec936f8b53c6da80d Mon Sep 17 00:00:00 2001 From: Rafael Lima Date: Thu, 14 Mar 2024 00:45:43 +0100 Subject: tdf#159985 Warn about the need to reload file after changing macro security level Change-Id: I191fd5d676d6d54fb0ef15652420afdceab2fc78 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164810 Tested-by: Jenkins Reviewed-by: Mike Kaganski Reviewed-by: Heiko Tietze --- xmlsecurity/source/dialogs/macrosecurity.cxx | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'xmlsecurity/source/dialogs') diff --git a/xmlsecurity/source/dialogs/macrosecurity.cxx b/xmlsecurity/source/dialogs/macrosecurity.cxx index ca4df4e64c03..9432220ae5ae 100644 --- a/xmlsecurity/source/dialogs/macrosecurity.cxx +++ b/xmlsecurity/source/dialogs/macrosecurity.cxx @@ -105,6 +105,9 @@ MacroSecurityLevelTP::MacroSecurityLevelTP(weld::Container* pParent, MacroSecuri , m_xHighImg(m_xBuilder->weld_widget("highimg")) , m_xMedImg(m_xBuilder->weld_widget("medimg")) , m_xLowImg(m_xBuilder->weld_widget("lowimg")) + , m_xWarningLb(m_xBuilder->weld_label("warningmsg")) + , m_xWarningImg(m_xBuilder->weld_image("warningimg")) + , m_xWarningBox(m_xBuilder->weld_box("warningbox")) { m_xLowRB->connect_toggled( LINK( this, MacroSecurityLevelTP, RadioButtonHdl ) ); m_xMediumRB->connect_toggled( LINK( this, MacroSecurityLevelTP, RadioButtonHdl ) ); @@ -129,6 +132,7 @@ MacroSecurityLevelTP::MacroSecurityLevelTP(weld::Container* pParent, MacroSecuri } mnCurLevel = static_cast(SvtSecurityOptions::GetMacroSecurityLevel()); + mnInitialLevel = mnCurLevel; bool bReadonly = SvtSecurityOptions::IsReadOnly( SvtSecurityOptions::EOption::MacroSecLevel ); weld::RadioButton* pCheck = nullptr; @@ -166,6 +170,28 @@ MacroSecurityLevelTP::MacroSecurityLevelTP(weld::Container* pParent, MacroSecuri m_xMediumRB->set_sensitive(false); m_xLowRB->set_sensitive(false); } + + SetWarningLabel(""); + // Use same font color as in InfobarType::WARNING + m_xWarningLb->set_font_color(Color(0x70, 0x43, 0x00)); + m_xWarningImg->set_size_request(24, 24); +} + +void MacroSecurityLevelTP::SetWarningLabel(const OUString& sMsg) +{ + m_xWarningLb->set_label(sMsg); + if (!sMsg.isEmpty()) + { + m_xWarningLb->show(); + m_xWarningImg->show(); + m_xWarningBox->set_background(Color(0xFE, 0xEF, 0xB3)); + } + else + { + m_xWarningLb->hide(); + m_xWarningImg->hide(); + m_xWarningBox->set_background(COL_TRANSPARENT); + } } IMPL_LINK_NOARG(MacroSecurityLevelTP, RadioButtonHdl, weld::Toggleable&, void) @@ -183,6 +209,14 @@ IMPL_LINK_NOARG(MacroSecurityLevelTP, RadioButtonHdl, weld::Toggleable&, void) mnCurLevel = nNewLevel; m_pDlg->EnableReset(); } + + // Show warning message if a different security level is chosen + if (nNewLevel != mnInitialLevel) + SetWarningLabel(XsResId(STR_RELOAD_FILE_WARNING)); + else + { + SetWarningLabel(""); + } } void MacroSecurityLevelTP::ClosePage() -- cgit