diff options
author | Balazs Varga <balazs.varga.extern@allotropia.de> | 2023-10-10 21:55:42 +0200 |
---|---|---|
committer | Balazs Varga <balazs.varga.extern@allotropia.de> | 2023-10-16 23:18:56 +0200 |
commit | 1f440348eb0892fd2c9597806d87b5fe9d60d49a (patch) | |
tree | e927316990059bcbcfe69d4670d8139015b45c63 /sfx2 | |
parent | 2247b00230e479e63ab996d4e1694b1d74aeba81 (diff) |
tdf#157482 UI: Turn Security Warnings popup windows into infobars
In case of all the 4 security warnings we will have a new infobar warning
dialog message with an infobar button which can open the security windows
option settings and we can set which security issues should warn us, and also
which security infos we want to remove. (etc after saving)
TODO: If the directly the file dialog window pop up the Infobar message will only
update after closing the file dialog window. That should be fixed later.
Change-Id: Idf0f728fd40089d3691f8f044d3718a4e0d99cad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157797
Tested-by: Jenkins
Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/appserv.cxx | 8 | ||||
-rw-r--r-- | sfx2/source/appl/appuno.cxx | 7 | ||||
-rw-r--r-- | sfx2/source/dialog/infobar.cxx | 8 | ||||
-rw-r--r-- | sfx2/source/doc/objserv.cxx | 69 | ||||
-rw-r--r-- | sfx2/source/doc/objstor.cxx | 29 | ||||
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 40 | ||||
-rw-r--r-- | sfx2/source/view/viewprn.cxx | 3 | ||||
-rw-r--r-- | sfx2/source/view/viewsh.cxx | 10 |
8 files changed, 103 insertions, 71 deletions
diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index 493361fabc0f..5b0ef2ca491f 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -1440,10 +1440,16 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) const SfxStringItem* pURLItem = rReq.GetArg<SfxStringItem>(SID_OPTIONS_PAGEURL); if ( pURLItem ) sPageURL = pURLItem->GetValue(); + + sal_uInt16 nPageID = 0; + const SfxUInt16Item* pIDItem = rReq.GetArg<SfxUInt16Item>(SID_OPTIONS_PAGEID); + if (pIDItem) + nPageID = pIDItem->GetValue(); + Reference <XFrame> xFrame(GetRequestFrame(rReq)); SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); VclPtr<VclAbstractDialog> pDlg = - pFact->CreateFrameDialog(rReq.GetFrameWeld(), xFrame, rReq.GetSlot(), sPageURL ); + pFact->CreateFrameDialog(rReq.GetFrameWeld(), xFrame, rReq.GetSlot(), nPageID, sPageURL); short nRet = pDlg->Execute(); pDlg.disposeAndClear(); SfxViewFrame* pView = SfxViewFrame::GetFirst(); diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index e4443b7f46fc..7290ec77eb78 100644 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -887,12 +887,15 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert if ( "OptionsTreeDialog" == pSlot->pUnoName ) { auto pProp = std::find_if(rArgs.begin(), rArgs.end(), - [](const PropertyValue& rProp) { return rProp.Name == "OptionsPageURL"; }); + [](const PropertyValue& rProp) { return rProp.Name == "OptionsPageURL" || rProp.Name == "OptionsPageID"; }); if (pProp != rArgs.end()) { OUString sURL; - if ( pProp->Value >>= sURL ) + sal_uInt16 nPageID; + if ( pProp->Name == "OptionsPageURL" && (pProp->Value >>= sURL) ) rSet.Put( SfxStringItem( SID_OPTIONS_PAGEURL, sURL ) ); + else if ( pProp->Name == "OptionsPageID" && (pProp->Value >>= nPageID) ) + rSet.Put( SfxUInt16Item( SID_OPTIONS_PAGEID, nPageID ) ); } } } diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx index 2ab8704c1da4..ca848813f09e 100644 --- a/sfx2/source/dialog/infobar.cxx +++ b/sfx2/source/dialog/infobar.cxx @@ -15,6 +15,7 @@ #include <drawinglayer/processor2d/processor2dtools.hxx> #include <memory> #include <officecfg/Office/UI/Infobar.hxx> +#include <officecfg/Office/Common.hxx> #include <sfx2/bindings.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/infobar.hxx> @@ -438,6 +439,13 @@ bool SfxInfoBarContainerWindow::isInfobarEnabled(std::u16string_view sId) return officecfg::Office::UI::Infobar::Enabled::HiddenTrackChanges::get(); if (sId == u"macro") return officecfg::Office::UI::Infobar::Enabled::MacrosDisabled::get(); + if (sId == u"securitywarn") + { + return officecfg::Office::Common::Security::Scripting::WarnSaveOrSendDoc::get() + || officecfg::Office::Common::Security::Scripting::WarnSignDoc::get() + || officecfg::Office::Common::Security::Scripting::WarnPrintDoc::get() + || officecfg::Office::Common::Security::Scripting::WarnCreatePDF::get(); + } return true; } diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index fb62f3768163..023780d4db50 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -535,49 +535,48 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) if( SID_SIGNATURE == nId || SID_MACRO_SIGNATURE == nId ) { - if ( QueryHiddenInformation( HiddenWarningFact::WhenSigning, nullptr ) == RET_YES ) + QueryHiddenInformation(HiddenWarningFact::WhenSigning); + + if (SID_SIGNATURE == nId) { - if (SID_SIGNATURE == nId) + uno::Reference<security::XCertificate> xCertificate = GetSignPDFCertificate(); + if (xCertificate.is()) { - uno::Reference<security::XCertificate> xCertificate = GetSignPDFCertificate(); - if (xCertificate.is()) - { - bHaveWeSigned |= SignDocumentContentUsingCertificate(xCertificate); + bHaveWeSigned |= SignDocumentContentUsingCertificate(xCertificate); - // Reload to show how the PDF actually looks like after signing. This also - // changes "finish signing" on the infobar back to "sign document" as a side - // effect. - SfxViewFrame* pFrame = GetFrame(); - if (pFrame) + // Reload to show how the PDF actually looks like after signing. This also + // changes "finish signing" on the infobar back to "sign document" as a side + // effect. + SfxViewFrame* pFrame = GetFrame(); + if (pFrame) + { + // Store current page before reload. + SfxAllItemSet aSet(SfxGetpApp()->GetPool()); + uno::Reference<drawing::XDrawView> xController( + GetBaseModel()->getCurrentController(), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPage(xController->getCurrentPage(), + uno::UNO_QUERY); + sal_Int32 nPage{}; + xPage->getPropertyValue("Number") >>= nPage; + if (nPage > 0) { - // Store current page before reload. - SfxAllItemSet aSet(SfxGetpApp()->GetPool()); - uno::Reference<drawing::XDrawView> xController( - GetBaseModel()->getCurrentController(), uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xPage(xController->getCurrentPage(), - uno::UNO_QUERY); - sal_Int32 nPage{}; - xPage->getPropertyValue("Number") >>= nPage; - if (nPage > 0) - { - // nPage is 1-based. - aSet.Put(SfxInt32Item(SID_PAGE_NUMBER, nPage - 1)); - } - SfxRequest aReq(SID_RELOAD, SfxCallMode::SLOT, aSet); - pFrame->ExecReload_Impl(aReq); + // nPage is 1-based. + aSet.Put(SfxInt32Item(SID_PAGE_NUMBER, nPage - 1)); } - } - else - { - bHaveWeSigned |= SignDocumentContent(pDialogParent); + SfxRequest aReq(SID_RELOAD, SfxCallMode::SLOT, aSet); + pFrame->ExecReload_Impl(aReq); } } else { - bHaveWeSigned |= SignScriptingContent(pDialogParent); + bHaveWeSigned |= SignDocumentContent(pDialogParent); } } + else + { + bHaveWeSigned |= SignScriptingContent(pDialogParent); + } if ( bHaveWeSigned && HasValidSignatures() ) { @@ -1057,13 +1056,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) if (bIsAsync && SfxViewShell::Current()) SfxViewShell::Current()->SetStoringHelper(xHelper); - if ( QueryHiddenInformation( bIsPDFExport ? HiddenWarningFact::WhenCreatingPDF : HiddenWarningFact::WhenSaving, nullptr ) != RET_YES ) - { - // the user has decided not to store the document - throw task::ErrorCodeIOException( - "SfxObjectShell::ExecFile_Impl: ERRCODE_IO_ABORT", - uno::Reference< uno::XInterface >(), sal_uInt32(ERRCODE_IO_ABORT)); - } + QueryHiddenInformation(bIsPDFExport ? HiddenWarningFact::WhenCreatingPDF : HiddenWarningFact::WhenSaving); const SfxBoolItem *pItem = nId != SID_DIRECTEXPORTDOCASPDF ? nullptr : dynamic_cast<const SfxBoolItem*>( GetSlotState(SID_MAIL_PREPAREEXPORT) ); diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 8a1978681f99..b17b67a851a4 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -110,6 +110,7 @@ #include <sfx2/dispatch.hxx> #include <sfx2/sfxuno.hxx> #include <sfx2/event.hxx> +#include <sfx2/infobar.hxx> #include <fltoptint.hxx> #include <sfx2/viewfrm.hxx> #include "graphhelp.hxx" @@ -3081,35 +3082,29 @@ HiddenInformation SfxObjectShell::GetHiddenInformationState( HiddenInformation n return nState; } -sal_Int16 SfxObjectShell::QueryHiddenInformation(HiddenWarningFact eFact, weld::Window* pParent) +void SfxObjectShell::QueryHiddenInformation(HiddenWarningFact eFact) { - sal_Int16 nRet = RET_YES; - TranslateId pResId; SvtSecurityOptions::EOption eOption = SvtSecurityOptions::EOption(); switch ( eFact ) { case HiddenWarningFact::WhenSaving : { - pResId = STR_HIDDENINFO_CONTINUE_SAVING; eOption = SvtSecurityOptions::EOption::DocWarnSaveOrSend; break; } case HiddenWarningFact::WhenPrinting : { - pResId = STR_HIDDENINFO_CONTINUE_PRINTING; eOption = SvtSecurityOptions::EOption::DocWarnPrint; break; } case HiddenWarningFact::WhenSigning : { - pResId = STR_HIDDENINFO_CONTINUE_SIGNING; eOption = SvtSecurityOptions::EOption::DocWarnSigning; break; } case HiddenWarningFact::WhenCreatingPDF : { - pResId = STR_HIDDENINFO_CONTINUE_CREATEPDF; eOption = SvtSecurityOptions::EOption::DocWarnCreatePdf; break; } @@ -3119,40 +3114,30 @@ sal_Int16 SfxObjectShell::QueryHiddenInformation(HiddenWarningFact eFact, weld:: if ( SvtSecurityOptions::IsOptionSet( eOption ) ) { - OUString sMessage( SfxResId(STR_HIDDENINFO_CONTAINS) ); + OUString sMessage; HiddenInformation nWantedStates = HiddenInformation::RECORDEDCHANGES | HiddenInformation::NOTES; if ( eFact != HiddenWarningFact::WhenPrinting ) nWantedStates |= HiddenInformation::DOCUMENTVERSIONS; HiddenInformation nStates = GetHiddenInformationState( nWantedStates ); - bool bWarning = false; if ( nStates & HiddenInformation::RECORDEDCHANGES ) { sMessage += SfxResId(STR_HIDDENINFO_RECORDCHANGES) + "\n"; - bWarning = true; } if ( nStates & HiddenInformation::NOTES ) { sMessage += SfxResId(STR_HIDDENINFO_NOTES) + "\n"; - bWarning = true; } if ( nStates & HiddenInformation::DOCUMENTVERSIONS ) { sMessage += SfxResId(STR_HIDDENINFO_DOCVERSIONS) + "\n"; - bWarning = true; } - if ( bWarning ) - { - sMessage += "\n" + SfxResId(pResId); - std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(pParent, - VclMessageType::Warning, VclButtonsType::YesNo, sMessage)); - xWarn->set_default_response(RET_NO); - nRet = xWarn->run(); - } - } + SfxViewFrame* pFrame = SfxViewFrame::GetFirst(this); + if (pFrame) + pFrame->HandleSecurityInfobar(!sMessage.isEmpty() ? sMessage.trim().replaceAll("\n", ", ") : sMessage); - return nRet; + } } bool SfxObjectShell::IsSecurityOptOpenReadOnly() const diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index b15689e87b9d..d447c8396971 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -27,6 +27,7 @@ #include <sfx2/viewfrm.hxx> #include <sfx2/classificationhelper.hxx> #include <sfx2/notebookbar/SfxNotebookBar.hxx> +#include <sfx2/pageids.hxx> #include <com/sun/star/document/MacroExecMode.hpp> #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/frame/DispatchRecorder.hpp> @@ -1306,6 +1307,38 @@ void SfxViewFrame::AppendReadOnlyInfobar() } } +void SfxViewFrame::HandleSecurityInfobar(const OUString& sSecondaryMessage) +{ + if (!HasInfoBarWithID(u"securitywarn")) + { + // new info bar + if (!sSecondaryMessage.isEmpty()) + { + auto pInfoBar = AppendInfoBar("securitywarn", SfxResId(STR_HIDDENINFO_CONTAINS).replaceAll("\n\n", " "), + sSecondaryMessage, InfobarType::WARNING); + if (!pInfoBar) + return; + + weld::Button& rGetInvolvedButton = pInfoBar->addButton(); + rGetInvolvedButton.set_label(SfxResId(STR_SECURITY_OPTIONS)); + rGetInvolvedButton.connect_clicked(LINK(this, SfxViewFrame, SecurityButtonHandler)); + } + } + else + { + // info bar exists already + if (sSecondaryMessage.isEmpty()) + { + RemoveInfoBar(u"securitywarn"); + } + else + { + UpdateInfoBar(u"securitywarn", SfxResId(STR_HIDDENINFO_CONTAINS).replaceAll("\n\n", " "), + sSecondaryMessage, InfobarType::WARNING); + } + } +} + void SfxViewFrame::AppendContainsMacrosInfobar() { SfxObjectShell_Impl* pObjImpl = m_xObjSh->Get_Impl(); @@ -1808,6 +1841,13 @@ IMPL_LINK_NOARG(SfxViewFrame, MacroButtonHandler, weld::Button&, void) { &aTabItem, &aCurrentDocItem }, { &aDocFrame }); } +IMPL_LINK_NOARG(SfxViewFrame, SecurityButtonHandler, weld::Button&, void) +{ + SfxUInt16Item aPageID(SID_OPTIONS_PAGEID, sal_uInt16(RID_SVXPAGE_INET_SECURITY)); + GetDispatcher()->ExecuteList(SID_OPTIONS_TREEDIALOG, SfxCallMode::SYNCHRON, { &aPageID }); + RemoveInfoBar(u"securitywarn"); +} + IMPL_LINK_NOARG(SfxViewFrame, EventButtonHandler, weld::Button&, void) { SfxUnoFrameItem aDocFrame(SID_FILLFRAME, GetFrame().GetFrameInterface()); diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index 5ada786ba108..19fddbffdfa0 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -677,8 +677,7 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) return; } - if ( !bSilent && pDoc->QueryHiddenInformation( HiddenWarningFact::WhenPrinting, nullptr ) != RET_YES ) - return; + pDoc->QueryHiddenInformation(HiddenWarningFact::WhenPrinting); // should we print only the selection or the whole document const SfxBoolItem* pSelectItem = rReq.GetArg<SfxBoolItem>(SID_SELECTION); diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 6b36430d7d4c..5e437b45269a 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -1598,11 +1598,9 @@ void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq ) case SID_MAIL_SENDDOCASFORMAT: { SfxObjectShell* pDoc = GetObjectShell(); - if ( pDoc && pDoc->QueryHiddenInformation( - HiddenWarningFact::WhenSaving, GetViewFrame().GetFrameWeld() ) != RET_YES ) + if (!pDoc) break; - - + pDoc->QueryHiddenInformation(HiddenWarningFact::WhenSaving); SfxMailModel aModel; OUString aDocType; @@ -1658,9 +1656,9 @@ void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq ) { SfxBluetoothModel aModel; SfxObjectShell* pDoc = GetObjectShell(); - if ( pDoc && pDoc->QueryHiddenInformation( - HiddenWarningFact::WhenSaving, GetViewFrame().GetFrameWeld() ) != RET_YES ) + if (!pDoc) break; + pDoc->QueryHiddenInformation(HiddenWarningFact::WhenSaving); uno::Reference < frame::XFrame > xFrame( rFrame.GetFrame().GetFrameInterface() ); SfxMailModel::SendMailResult eResult = aModel.SaveAndSend( xFrame ); if( eResult == SfxMailModel::SEND_MAIL_ERROR ) |