diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-03-20 09:39:24 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-03-20 15:28:36 +0100 |
commit | 44bf46c1bb9ba884e2ed2042ef995f198460cc28 (patch) | |
tree | f1edb1fdf82f5f77d8ee27f9b8d2ca28958293f3 /uui | |
parent | 2333786aa0eaf70c45c80e546239fb3565b1b4e7 (diff) |
weld MacroWarning
Change-Id: I9ec8ce9b0d5bb973f75606d850fb5961a85865cd
Reviewed-on: https://gerrit.libreoffice.org/51630
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'uui')
-rw-r--r-- | uui/inc/pch/precompiled_uui.hxx | 1 | ||||
-rw-r--r-- | uui/source/iahndl.cxx | 12 | ||||
-rw-r--r-- | uui/source/secmacrowarnings.cxx | 126 | ||||
-rw-r--r-- | uui/source/secmacrowarnings.hxx | 36 | ||||
-rw-r--r-- | uui/uiconfig/ui/macrowarnmedium.ui | 195 |
5 files changed, 118 insertions, 252 deletions
diff --git a/uui/inc/pch/precompiled_uui.hxx b/uui/inc/pch/precompiled_uui.hxx index e233152d4011..ca2e75cbe217 100644 --- a/uui/inc/pch/precompiled_uui.hxx +++ b/uui/inc/pch/precompiled_uui.hxx @@ -55,7 +55,6 @@ #include <vcl/dllapi.h> #include <vcl/errcode.hxx> #include <vcl/layout.hxx> -#include <vcl/msgbox.hxx> #include <vcl/svapp.hxx> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> diff --git a/uui/source/iahndl.cxx b/uui/source/iahndl.cxx index 439c223d5e52..60f281e1d4c5 100644 --- a/uui/source/iahndl.cxx +++ b/uui/source/iahndl.cxx @@ -1173,20 +1173,20 @@ UUIInteractionHelper::handleMacroConfirmRequest( bool bApprove = false; bool bShowSignatures = aSignInfo.getLength() > 0; - ScopedVclPtrInstance<MacroWarning> aWarning( - getParentProperty(), bShowSignatures ); + vcl::Window* pWin = getParentProperty(); + MacroWarning aWarning(pWin ? pWin->GetFrameWeld() : nullptr, bShowSignatures); - aWarning->SetDocumentURL( aDocumentURL ); + aWarning.SetDocumentURL(aDocumentURL); if ( aSignInfo.getLength() > 1 ) { - aWarning->SetStorage( xZipStorage, aDocumentVersion, aSignInfo ); + aWarning.SetStorage(xZipStorage, aDocumentVersion, aSignInfo); } else if ( aSignInfo.getLength() == 1 ) { - aWarning->SetCertificate( aSignInfo[ 0 ].Signer ); + aWarning.SetCertificate(aSignInfo[0].Signer); } - bApprove = aWarning->Execute() == RET_OK; + bApprove = aWarning.run() == RET_OK; if ( bApprove && xApprove.is() ) xApprove->select(); diff --git a/uui/source/secmacrowarnings.cxx b/uui/source/secmacrowarnings.cxx index 6c2ae03f53d6..9363db6a0265 100644 --- a/uui/source/secmacrowarnings.cxx +++ b/uui/source/secmacrowarnings.cxx @@ -23,10 +23,9 @@ #include <comphelper/sequence.hxx> #include <comphelper/documentconstants.hxx> #include <comphelper/processfactory.hxx> +#include <osl/file.h> #include <sal/macros.h> - -#include <vcl/fixed.hxx> -#include <vcl/msgbox.hxx> +#include <unotools/resmgr.hxx> #include <com/sun/star/security/NoPasswordException.hpp> using namespace ::com::sun::star::security; @@ -62,58 +61,37 @@ namespace } } - -MacroWarning::MacroWarning( vcl::Window* _pParent, bool _bWithSignatures ) - :ModalDialog ( _pParent, "MacroWarnMedium", "uui/ui/macrowarnmedium.ui" ) - ,mpInfos ( nullptr ) - ,mbSignedMode ( true ) - ,mbShowSignatures ( _bWithSignatures ) - ,mnActSecLevel ( 0 ) +MacroWarning::MacroWarning(weld::Window* pParent, bool _bWithSignatures) + : MessageDialogController(pParent, "uui/ui/macrowarnmedium.ui", "MacroWarnMedium", "grid") + , mxGrid(m_xBuilder->weld_widget("grid")) + , mxSignsFI(m_xBuilder->weld_label("signsLabel")) + , mxViewSignsBtn(m_xBuilder->weld_button("viewSignsButton")) + , mxAlwaysTrustCB(m_xBuilder->weld_check_button("alwaysTrustCheckbutton")) + , mxEnableBtn(m_xBuilder->weld_button("ok")) + , mxDisableBtn(m_xBuilder->weld_button("cancel")) + , mpInfos ( nullptr ) + , mbSignedMode ( true ) + , mbShowSignatures ( _bWithSignatures ) + , mnActSecLevel ( 0 ) { - get(mpSymbolImg, "symbolImage"); - get(mpDocNameFI, "docNameLabel"); - get(mpDescr1FI, "descr1Label"); - get(mpDescr1aFI, "descr1aLabel"); - get(mpSignsFI, "signsLabel"); - get(mpViewSignsBtn, "viewSignsButton"); - get(mpDescr2FI, "descr2Label"); - get(mpAlwaysTrustCB, "alwaysTrustCheckbutton"); - get(mpEnableBtn, "ok"); - get(mpDisableBtn, "cancel"); + m_xDialog->set_title(Translate::GetReadStringHook()(m_xDialog->get_title())); InitControls(); - mpDisableBtn->SetClickHdl( LINK( this, MacroWarning, DisableBtnHdl ) ); - mpEnableBtn->SetClickHdl( LINK( this, MacroWarning, EnableBtnHdl ) ); - mpDisableBtn->GrabFocus(); // Default button, but focus is on view button -} - -MacroWarning::~MacroWarning() -{ - disposeOnce(); -} - -void MacroWarning::dispose() -{ - mpSymbolImg.clear(); - mpDocNameFI.clear(); - mpDescr1aFI.clear(); - mpDescr1FI.clear(); - mpSignsFI.clear(); - mpViewSignsBtn.clear(); - mpDescr2FI.clear(); - mpAlwaysTrustCB.clear(); - mpEnableBtn.clear(); - mpDisableBtn.clear(); - ModalDialog::dispose(); + mxEnableBtn->connect_clicked(LINK(this, MacroWarning, EnableBtnHdl)); + mxDisableBtn->grab_focus(); // Default button, but focus is on view button } void MacroWarning::SetDocumentURL( const OUString& rDocURL ) { - mpDocNameFI->SetText( rDocURL ); + OUString aAbbreviatedPath; + osl_abbreviateSystemPath(rDocURL.pData, &aAbbreviatedPath.pData, 50, nullptr); + fprintf(stderr, "in %s, out %s\n", OUStringToOString(rDocURL, RTL_TEXTENCODING_UTF8).getStr(), + OUStringToOString(aAbbreviatedPath, RTL_TEXTENCODING_UTF8).getStr()); + m_xDialog->set_primary_text(aAbbreviatedPath); } -IMPL_LINK_NOARG(MacroWarning, ViewSignsBtnHdl, Button*, void) +IMPL_LINK_NOARG(MacroWarning, ViewSignsBtnHdl, weld::Button&, void) { DBG_ASSERT( mxCert.is(), "*MacroWarning::ViewSignsBtnHdl(): no certificate set!" ); @@ -128,9 +106,9 @@ IMPL_LINK_NOARG(MacroWarning, ViewSignsBtnHdl, Button*, void) } } -IMPL_LINK_NOARG(MacroWarning, EnableBtnHdl, Button*, void) +IMPL_LINK_NOARG(MacroWarning, EnableBtnHdl, weld::Button&, void) { - if( mbSignedMode && mpAlwaysTrustCB->IsChecked() ) + if (mbSignedMode && mxAlwaysTrustCB->get_active()) { // insert path into trusted path list uno::Reference< security::XDocumentDigitalSignatures > xD( security::DocumentDigitalSignatures::createWithVersion(comphelper::getProcessComponentContext(), maODFVersion)); @@ -145,56 +123,32 @@ IMPL_LINK_NOARG(MacroWarning, EnableBtnHdl, Button*, void) xD->addAuthorToTrustedSources( (*mpInfos)[ i ].Signer ); } } - - EndDialog( RET_OK ); -} - -IMPL_LINK_NOARG(MacroWarning, DisableBtnHdl, Button*, void) -{ - EndDialog(); + m_xDialog->response(RET_OK); } -IMPL_LINK_NOARG(MacroWarning, AlwaysTrustCheckHdl, Button*, void) +IMPL_LINK_NOARG(MacroWarning, AlwaysTrustCheckHdl, weld::Button&, void) { - bool bEnable = ( mnActSecLevel < 2 || mpAlwaysTrustCB->IsChecked() ); - mpEnableBtn->Enable( bEnable ); - mpDisableBtn->Enable( !mpAlwaysTrustCB->IsChecked() ); + const bool bEnable = (mnActSecLevel < 2 || mxAlwaysTrustCB->get_active()); + mxEnableBtn->set_sensitive(bEnable); + mxDisableBtn->set_sensitive(!mxAlwaysTrustCB->get_active()); } void MacroWarning::InitControls() { - // set warning image - Image aImg(GetStandardWarningBoxImage()); - mpSymbolImg->SetImage( aImg ); - mpSymbolImg->SetSizePixel( aImg.GetSizePixel() ); - // set bold font and path ellipsis for docname fixedtext - vcl::Font aTmpFont = mpDocNameFI->GetControlFont(); - aTmpFont.SetWeight( WEIGHT_BOLD ); - mpDocNameFI->SetControlFont( aTmpFont ); - WinBits nStyle = mpDocNameFI->GetStyle(); - nStyle |= WB_PATHELLIPSIS; - mpDocNameFI->SetStyle( nStyle ); // show signature controls? - if( mbShowSignatures ) + if (mbShowSignatures) { - mpViewSignsBtn->SetClickHdl( LINK( this, MacroWarning, ViewSignsBtnHdl ) ); - mpViewSignsBtn->Disable(); // default - mpAlwaysTrustCB->SetClickHdl( LINK( this, MacroWarning, AlwaysTrustCheckHdl ) ); + mxViewSignsBtn->connect_clicked(LINK(this, MacroWarning, ViewSignsBtnHdl)); + mxViewSignsBtn->set_sensitive(false); // default + mxAlwaysTrustCB->connect_clicked(LINK(this, MacroWarning, AlwaysTrustCheckHdl)); mnActSecLevel = SvtSecurityOptions().GetMacroSecurityLevel(); if ( mnActSecLevel >= 2 ) - mpEnableBtn->Disable(); + mxEnableBtn->set_sensitive(false); } else { - mpDescr1FI->Hide(); - mpDescr1aFI->Show(); - mpSignsFI->Hide(); - mpViewSignsBtn->Hide(); - mpAlwaysTrustCB->Hide(); - - // move hint up to position of signer list - mpDescr2FI->SetPosPixel( mpSignsFI->GetPosPixel() ); + mxGrid->hide(); } } @@ -218,8 +172,8 @@ void MacroWarning::SetStorage( const css::uno::Reference < css::embed::XStorage s += GetContentPart( rInfos[ i ].Signer->getSubjectName(), aCN_Id ); } - mpSignsFI->SetText( s ); - mpViewSignsBtn->Enable(); + mxSignsFI->set_label(s); + mxViewSignsBtn->set_sensitive(true); } } @@ -229,8 +183,8 @@ void MacroWarning::SetCertificate( const css::uno::Reference< css::security::XCe if( mxCert.is() ) { OUString s = GetContentPart( mxCert->getSubjectName(), "CN" ); - mpSignsFI->SetText( s ); - mpViewSignsBtn->Enable(); + mxSignsFI->set_label(s); + mxViewSignsBtn->set_sensitive(true); } } diff --git a/uui/source/secmacrowarnings.hxx b/uui/source/secmacrowarnings.hxx index 8a34d90ffd9c..fbaf55751f5e 100644 --- a/uui/source/secmacrowarnings.hxx +++ b/uui/source/secmacrowarnings.hxx @@ -20,11 +20,9 @@ #ifndef INCLUDED_UUI_SOURCE_SECMACROWARNINGS_HXX #define INCLUDED_UUI_SOURCE_SECMACROWARNINGS_HXX -#include <vcl/dialog.hxx> -#include <unotools/securityoptions.hxx> -#include <vcl/button.hxx> -#include <vcl/fixed.hxx> #include <com/sun/star/uno/Sequence.hxx> +#include <unotools/securityoptions.hxx> +#include <vcl/weld.hxx> namespace com { namespace sun { @@ -33,41 +31,33 @@ namespace security { class XCertificate; } }}} -class MacroWarning : public ModalDialog +class MacroWarning : public weld::MessageDialogController { private: + std::unique_ptr<weld::Widget> mxGrid; + std::unique_ptr<weld::Label> mxSignsFI; + std::unique_ptr<weld::Button> mxViewSignsBtn; + std::unique_ptr<weld::CheckButton> mxAlwaysTrustCB; + std::unique_ptr<weld::Button> mxEnableBtn; + std::unique_ptr<weld::Button> mxDisableBtn; css::uno::Reference< css::security::XCertificate > mxCert; css::uno::Reference< css::embed::XStorage > mxStore; OUString maODFVersion; const css::uno::Sequence< css::security::DocumentSignatureInformation >* mpInfos; - VclPtr<FixedImage> mpSymbolImg; - VclPtr<FixedText> mpDocNameFI; - VclPtr<FixedText> mpDescr1FI; - VclPtr<FixedText> mpDescr1aFI; - VclPtr<FixedText> mpSignsFI; - VclPtr<PushButton> mpViewSignsBtn; - VclPtr<FixedText> mpDescr2FI; - VclPtr<CheckBox> mpAlwaysTrustCB; - VclPtr<PushButton> mpEnableBtn; - VclPtr<PushButton> mpDisableBtn; - const bool mbSignedMode; // mode of dialog (signed / unsigned macros) const bool mbShowSignatures; sal_Int32 mnActSecLevel; - DECL_LINK( ViewSignsBtnHdl, Button*, void ); - DECL_LINK( EnableBtnHdl, Button*, void ); - DECL_LINK( DisableBtnHdl, Button*, void ); - DECL_LINK( AlwaysTrustCheckHdl, Button*, void ); + DECL_LINK(ViewSignsBtnHdl, weld::Button&, void); + DECL_LINK(EnableBtnHdl, weld::Button&, void); + DECL_LINK(AlwaysTrustCheckHdl, weld::Button&, void); void InitControls(); public: - MacroWarning( vcl::Window* pParent, bool _bShowSignatures ); - virtual ~MacroWarning() override; - virtual void dispose() override; + MacroWarning(weld::Window* pParent, bool _bShowSignatures); void SetDocumentURL( const OUString& rDocURL ); diff --git a/uui/uiconfig/ui/macrowarnmedium.ui b/uui/uiconfig/ui/macrowarnmedium.ui index a6b6e89b9a46..c4dddb522235 100644 --- a/uui/uiconfig/ui/macrowarnmedium.ui +++ b/uui/uiconfig/ui/macrowarnmedium.ui @@ -1,30 +1,35 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.20.2 --> <!-- interface-requires gtk+ 3.0 --> <interface domain="uui"> <requires lib="gtk+" version="3.18"/> - <object class="GtkDialog" id="MacroWarnMedium"> + <object class="GtkMessageDialog" id="MacroWarnMedium"> <property name="can_focus">False</property> - <property name="border_width">6</property> <property name="title" translatable="yes" context="macrowarnmedium|MacroWarnMedium">%PRODUCTNAME - Security Warning</property> - <property name="resizable">False</property> + <property name="modal">True</property> + <property name="default_width">0</property> + <property name="default_height">0</property> <property name="type_hint">dialog</property> + <property name="message_type">warning</property> + <property name="secondary_text" translatable="yes" context="macrowarnmedium|descr2Label">The document contains document macros. + +Macros may contain viruses. Disabling macros for a document is always safe. If you disable macros you may lose functionality provided by the document macros.</property> <child internal-child="vbox"> - <object class="GtkBox" id="dialog-vbox1"> + <object class="GtkBox"> <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> <property name="orientation">vertical</property> - <property name="spacing">12</property> + <property name="spacing">2</property> <child internal-child="action_area"> - <object class="GtkButtonBox" id="dialog-action_area1"> + <object class="GtkButtonBox"> <property name="can_focus">False</property> - <property name="layout_style">end</property> + <property name="homogeneous">True</property> <child> - <object class="GtkButton" id="ok"> - <property name="label" translatable="yes" context="macrowarnmedium|ok">_Enable Macros</property> + <object class="GtkButton" id="cancel"> + <property name="label" translatable="yes" context="macrowarnmedium|cancel">_Disable Macros</property> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="can_default">True</property> + <property name="has_default">True</property> <property name="receives_default">True</property> <property name="use_underline">True</property> </object> @@ -35,12 +40,10 @@ </packing> </child> <child> - <object class="GtkButton" id="cancel"> - <property name="label" translatable="yes" context="macrowarnmedium|cancel">_Disable Macros</property> + <object class="GtkButton" id="ok"> + <property name="label" translatable="yes" context="macrowarnmedium|ok">_Enable Macros</property> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="has_default">True</property> <property name="receives_default">True</property> <property name="use_underline">True</property> </object> @@ -63,54 +66,57 @@ <property name="fill">True</property> <property name="position">2</property> <property name="secondary">True</property> - <property name="non_homogeneous">True</property> </packing> </child> </object> <packing> <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">end</property> + <property name="fill">False</property> <property name="position">0</property> </packing> </child> <child> - <object class="GtkBox" id="box1"> + <object class="GtkGrid" id="grid"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="spacing">12</property> + <property name="row_spacing">6</property> <child> - <object class="GtkImage" id="symbolImage"> + <object class="GtkLabel" id="descr1Label"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="valign">start</property> - <property name="stock">gtk-missing-image</property> + <property name="halign">start</property> + <property name="hexpand">True</property> + <property name="label" translatable="yes" context="macrowarnmedium|descr1Label">The document contains document macros signed by:</property> </object> <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="alwaysTrustCheckbutton"> + <property name="label" translatable="yes" context="macrowarnmedium|alwaysTrustCheckbutton">_Always trust macros from this source</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> </packing> </child> <child> - <object class="GtkBox" id="box2"> + <object class="GtkBox"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="border_width">6</property> - <property name="orientation">vertical</property> - <property name="spacing">6</property> + <property name="spacing">12</property> <child> - <object class="GtkLabel" id="docNameLabel"> + <object class="GtkLabel" id="signsLabel"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="halign">start</property> - <property name="hexpand">True</property> - <property name="xalign">0</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> </object> <packing> <property name="expand">False</property> @@ -119,126 +125,43 @@ </packing> </child> <child> - <object class="GtkLabel" id="descr1Label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="halign">start</property> - <property name="hexpand">True</property> - <property name="label" translatable="yes" context="macrowarnmedium|descr1Label">The document contains document macros signed by:</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="descr1aLabel"> - <property name="visible">False</property> - <property name="can_focus">False</property> - <property name="halign">start</property> - <property name="hexpand">True</property> - <property name="label" translatable="yes" context="macrowarnmedium|descr1aLabel">The document contains document macros.</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkBox" id="box3"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="spacing">12</property> - <child> - <object class="GtkLabel" id="signsLabel"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkButton" id="viewSignsButton"> - <property name="label" translatable="yes" context="macrowarnmedium|viewSignsButton">_View Signatures…</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="halign">end</property> - <property name="valign">start</property> - <property name="hexpand">True</property> - <property name="use_underline">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">2</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="descr2Label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="yalign">0</property> - <property name="label" translatable="yes" context="macrowarnmedium|descr2Label">Macros may contain viruses. Disabling macros for a document is always safe. If you disable macros you may lose functionality provided by the document macros.</property> - <property name="wrap">True</property> - <property name="max_width_chars">62</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">3</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="alwaysTrustCheckbutton"> - <property name="label" translatable="yes" context="macrowarnmedium|alwaysTrustCheckbutton">_Always trust macros from this source</property> + <object class="GtkButton" id="viewSignsButton"> + <property name="label" translatable="yes" context="macrowarnmedium|viewSignsButton">_View Signatures…</property> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="receives_default">False</property> + <property name="receives_default">True</property> + <property name="halign">end</property> + <property name="valign">start</property> + <property name="hexpand">True</property> <property name="use_underline">True</property> - <property name="xalign">0</property> - <property name="draw_indicator">True</property> </object> <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">4</property> + <property name="position">1</property> </packing> </child> </object> <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> + <property name="left_attach">0</property> + <property name="top_attach">1</property> </packing> </child> </object> <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">1</property> + <property name="position">2</property> </packing> </child> </object> </child> <action-widgets> - <action-widget response="-5">ok</action-widget> <action-widget response="-6">cancel</action-widget> <action-widget response="-11">help</action-widget> </action-widgets> + <child> + <placeholder/> + </child> </object> </interface> |