diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-03-18 19:57:52 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-03-19 11:15:36 +0100 |
commit | d05ee87bdd779a8d799269af4bb45ae8a4ea3150 (patch) | |
tree | 136f8c6a7fd96180202003aad6294f6a0cbbc1ce /filter | |
parent | b5ca41ab77fb5eba1efed273ce0d551e2e753d34 (diff) |
weld pdf warning dialog
Change-Id: I80b8324dcd575f6b537c4a0be264f0446c0fc32f
Reviewed-on: https://gerrit.libreoffice.org/51516
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'filter')
-rw-r--r-- | filter/inc/bitmaps.hlst | 18 | ||||
-rw-r--r-- | filter/source/pdf/impdialog.cxx | 99 | ||||
-rw-r--r-- | filter/source/pdf/impdialog.hxx | 14 | ||||
-rw-r--r-- | filter/source/pdf/pdfinteract.cxx | 17 | ||||
-rw-r--r-- | filter/source/pdf/pdfinteract.hxx | 16 | ||||
-rw-r--r-- | filter/uiconfig/ui/warnpdfdialog.ui | 60 |
6 files changed, 108 insertions, 116 deletions
diff --git a/filter/inc/bitmaps.hlst b/filter/inc/bitmaps.hlst deleted file mode 100644 index 82e82f76632a..000000000000 --- a/filter/inc/bitmaps.hlst +++ /dev/null @@ -1,18 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#ifndef INCLUDED_FILTER_INC_BITMAPS_HRC -#define INCLUDED_FILTER_INC_BITMAPS_HRC - -#define IMG_WARN "res/ballgreen_7.png" -#define IMG_ERR "res/ballred_7.png" - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx index 68446b6842c7..1b4720673e2c 100644 --- a/filter/source/pdf/impdialog.cxx +++ b/filter/source/pdf/impdialog.cxx @@ -21,7 +21,6 @@ #include "impdialog.hxx" #include <strings.hrc> -#include <bitmaps.hlst> #include <officecfg/Office/Common.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> @@ -1586,103 +1585,55 @@ IMPL_LINK_NOARG(ImpPDFTabLinksPage, ClickRbOpnLnksBrowserHdl, Button*, void) } -ImplErrorDialog::ImplErrorDialog(const std::set< vcl::PDFWriter::ErrorCode >& rErrors) - : MessageDialog(nullptr, "WarnPDFDialog", "filter/ui/warnpdfdialog.ui") +ImplErrorDialog::ImplErrorDialog(weld::Window* pParent, const std::set<vcl::PDFWriter::ErrorCode>& rErrors) + : MessageDialogController(pParent, "filter/ui/warnpdfdialog.ui", "WarnPDFDialog", "grid") + , m_xErrors(m_xBuilder->weld_tree_view("errors")) + , m_xExplanation(m_xBuilder->weld_label("message")) { - get(m_pErrors, "errors"); - get(m_pExplanation, "message"); - - Size aSize(LogicToPixel(Size(100, 75), MapMode(MapUnit::MapAppFont))); - m_pErrors->set_width_request(aSize.Width()); - m_pErrors->set_height_request(aSize.Height()); - m_pExplanation->set_width_request(aSize.Width()); - m_pExplanation->set_height_request(aSize.Height()); - - // load images - Image aWarnImg(BitmapEx(IMG_WARN)); - Image aErrImg(BitmapEx(IMG_ERR)); + int nWidth = m_xErrors->get_approximate_digit_width() * 26; + int nHeight = m_xErrors->get_height_rows(9); + m_xErrors->set_size_request(nWidth, nHeight); + m_xExplanation->set_size_request(nWidth, nHeight); for (auto const& error : rErrors) { switch(error) { case vcl::PDFWriter::Warning_Transparency_Omitted_PDFA: - { - sal_uInt16 nPos = m_pErrors->InsertEntry( PDFFilterResId( STR_WARN_TRANSP_PDFA_SHORT ), - aWarnImg ); - m_pErrors->SetEntryData( nPos, new OUString( PDFFilterResId( STR_WARN_TRANSP_PDFA ) ) ); - } - break; + m_xErrors->append(PDFFilterResId(STR_WARN_TRANSP_PDFA), PDFFilterResId(STR_WARN_TRANSP_PDFA_SHORT), "dialog-warning"); + break; case vcl::PDFWriter::Warning_Transparency_Omitted_PDF13: - { - sal_uInt16 nPos = m_pErrors->InsertEntry( PDFFilterResId( STR_WARN_TRANSP_VERSION_SHORT ), - aWarnImg ); - m_pErrors->SetEntryData( nPos, new OUString( PDFFilterResId( STR_WARN_TRANSP_VERSION ) ) ); - } - break; + m_xErrors->append(PDFFilterResId(STR_WARN_TRANSP_VERSION), PDFFilterResId(STR_WARN_TRANSP_VERSION_SHORT), "dialog-warning"); + break; case vcl::PDFWriter::Warning_FormAction_Omitted_PDFA: - { - sal_uInt16 nPos = m_pErrors->InsertEntry( PDFFilterResId( STR_WARN_FORMACTION_PDFA_SHORT ), - aWarnImg ); - m_pErrors->SetEntryData( nPos, new OUString( PDFFilterResId( STR_WARN_FORMACTION_PDFA ) ) ); - } - break; + m_xErrors->append(PDFFilterResId(STR_WARN_FORMACTION_PDFA), PDFFilterResId(STR_WARN_FORMACTION_PDFA_SHORT), "dialog-warning"); + break; case vcl::PDFWriter::Warning_Transparency_Converted: - { - sal_uInt16 nPos = m_pErrors->InsertEntry( PDFFilterResId( STR_WARN_TRANSP_CONVERTED_SHORT ), - aWarnImg ); - m_pErrors->SetEntryData( nPos, new OUString( PDFFilterResId( STR_WARN_TRANSP_CONVERTED ) ) ); - } - break; + m_xErrors->append(PDFFilterResId(STR_WARN_TRANSP_CONVERTED), PDFFilterResId(STR_WARN_TRANSP_CONVERTED_SHORT), "dialog-warning"); + break; case vcl::PDFWriter::Error_Signature_Failed: - { - sal_uInt16 nPos = m_pErrors->InsertEntry( PDFFilterResId( STR_ERR_SIGNATURE_FAILED ), - aErrImg ); - m_pErrors->SetEntryData( nPos, new OUString( PDFFilterResId( STR_ERR_PDF_EXPORT_ABORTED ) ) ); - } - break; + m_xErrors->append(PDFFilterResId(STR_ERR_PDF_EXPORT_ABORTED), PDFFilterResId(STR_ERR_SIGNATURE_FAILED), "dialog-error"); + break; default: break; } } - if( m_pErrors->GetEntryCount() > 0 ) + if (m_xErrors->n_children() > 0) { - m_pErrors->SelectEntryPos( 0 ); - OUString* pStr = static_cast<OUString*>(m_pErrors->GetEntryData( 0 )); - m_pExplanation->SetText( pStr ? *pStr : OUString() ); + m_xErrors->select(0); + m_xExplanation->set_label(m_xErrors->get_id(0)); } - m_pErrors->SetSelectHdl( LINK( this, ImplErrorDialog, SelectHdl ) ); - - create_message_area(); + m_xErrors->connect_changed(LINK(this, ImplErrorDialog, SelectHdl)); } - -ImplErrorDialog::~ImplErrorDialog() +IMPL_LINK_NOARG(ImplErrorDialog, SelectHdl, weld::TreeView&, void) { - disposeOnce(); + OUString aExplanation = m_xErrors->get_selected_id(); + m_xExplanation->set_label(aExplanation); } - -void ImplErrorDialog::dispose() -{ - // free strings again - for( sal_Int32 n = 0; n < m_pErrors->GetEntryCount(); n++ ) - delete static_cast<OUString*>(m_pErrors->GetEntryData( n )); - m_pErrors.clear(); - m_pExplanation.clear(); - MessageDialog::dispose(); -} - - -IMPL_LINK_NOARG(ImplErrorDialog, SelectHdl, ListBox&, void) -{ - OUString* pStr = static_cast<OUString*>(m_pErrors->GetSelectedEntryData()); - m_pExplanation->SetText( pStr ? *pStr : OUString() ); -} - - /// The digital signatures tab page ImpPDFTabSigningPage::ImpPDFTabSigningPage(vcl::Window* pParent, const SfxItemSet& rCoreSet) : SfxTabPage(pParent, "PdfSignPage","filter/ui/pdfsignpage.ui", &rCoreSet) diff --git a/filter/source/pdf/impdialog.hxx b/filter/source/pdf/impdialog.hxx index cfd33647b1f9..cddb100b8968 100644 --- a/filter/source/pdf/impdialog.hxx +++ b/filter/source/pdf/impdialog.hxx @@ -33,6 +33,7 @@ #include <vcl/group.hxx> #include <vcl/pdfwriter.hxx> #include <vcl/FilterConfigItem.hxx> +#include <vcl/weld.hxx> #include "pdffilter.hxx" @@ -43,19 +44,16 @@ class ImpPDFTabViewerPage; class ImpPDFTabOpnFtrPage; class ImpPDFTabLinksPage; -class ImplErrorDialog : public MessageDialog +class ImplErrorDialog : public weld::MessageDialogController { private: - VclPtr<ListBox> m_pErrors; - VclPtr<FixedText> m_pExplanation; + std::unique_ptr<weld::TreeView> m_xErrors; + std::unique_ptr<weld::Label> m_xExplanation; - DECL_LINK(SelectHdl, ListBox&, void); + DECL_LINK(SelectHdl, weld::TreeView&, void); public: - explicit ImplErrorDialog( const std::set< vcl::PDFWriter::ErrorCode >& ); - virtual ~ImplErrorDialog() override; - - virtual void dispose() override; + explicit ImplErrorDialog(weld::Window* pParent, const std::set<vcl::PDFWriter::ErrorCode>& rErrorCodes); }; diff --git a/filter/source/pdf/pdfinteract.cxx b/filter/source/pdf/pdfinteract.cxx index 8456ecc687ae..19dc5e7546f3 100644 --- a/filter/source/pdf/pdfinteract.cxx +++ b/filter/source/pdf/pdfinteract.cxx @@ -23,24 +23,29 @@ #include <com/sun/star/task/XInteractionRequest.hpp> #include <com/sun/star/task/PDFExportException.hpp> +#include <comphelper/namedvaluecollection.hxx> #include <cppuhelper/supportsservice.hxx> - +#include <toolkit/helper/vclunohelper.hxx> PDFInteractionHandler::PDFInteractionHandler() { } - PDFInteractionHandler::~PDFInteractionHandler() { } - void SAL_CALL PDFInteractionHandler::handle( const Reference< task::XInteractionRequest >& i_xRequest ) { handleInteractionRequest( i_xRequest ); } +void SAL_CALL PDFInteractionHandler::initialize(const css::uno::Sequence<css::uno::Any>& rArguments) +{ + comphelper::NamedValueCollection aProperties(rArguments); + if (aProperties.has("Parent")) + aProperties.get("Parent") >>= m_xParent; +} sal_Bool SAL_CALL PDFInteractionHandler::handleInteractionRequest( const Reference< task::XInteractionRequest >& i_xRequest ) { @@ -54,8 +59,10 @@ sal_Bool SAL_CALL PDFInteractionHandler::handleInteractionRequest( const Referen sal_Int32 nCodes = aExc.ErrorCodes.getLength(); for( sal_Int32 i = 0; i < nCodes; i++ ) aCodes.insert( static_cast<vcl::PDFWriter::ErrorCode>(aExc.ErrorCodes.getConstArray()[i]) ); - ScopedVclPtrInstance< ImplErrorDialog > aDlg( aCodes ); - aDlg->Execute(); + + VclPtr<vcl::Window> xParent(VCLUnoHelper::GetWindow(m_xParent)); + ImplErrorDialog aDlg(xParent ? xParent->GetFrameWeld() : nullptr, aCodes); + aDlg.run(); bHandled = true; } return bHandled; diff --git a/filter/source/pdf/pdfinteract.hxx b/filter/source/pdf/pdfinteract.hxx index 0795558c084e..ccc2339ff448 100644 --- a/filter/source/pdf/pdfinteract.hxx +++ b/filter/source/pdf/pdfinteract.hxx @@ -22,7 +22,9 @@ #include <cppuhelper/implbase.hxx> +#include <com/sun/star/awt/XWindow.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/task/XInteractionHandler2.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> @@ -31,19 +33,25 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; -class PDFInteractionHandler : public cppu::WeakImplHelper < task::XInteractionHandler2, - XServiceInfo > +class PDFInteractionHandler : public cppu::WeakImplHelper<css::lang::XInitialization, + css::task::XInteractionHandler2, + XServiceInfo> { +private: + css::uno::Reference<css::awt::XWindow> m_xParent; protected: // XServiceInfo virtual OUString SAL_CALL getImplementationName() override; virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() override; - // XIniteractionHandler + // XInitialization + virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& rArguments) override; + + // XInteractionHandler virtual void SAL_CALL handle( const Reference< task::XInteractionRequest >& ) override; - // XIniteractionHandler2 + // XInteractionHandler2 virtual sal_Bool SAL_CALL handleInteractionRequest( const Reference< task::XInteractionRequest >& ) override; public: diff --git a/filter/uiconfig/ui/warnpdfdialog.ui b/filter/uiconfig/ui/warnpdfdialog.ui index 2091b5158a97..4c474715f427 100644 --- a/filter/uiconfig/ui/warnpdfdialog.ui +++ b/filter/uiconfig/ui/warnpdfdialog.ui @@ -1,7 +1,17 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.20.2 --> <interface domain="flt"> <requires lib="gtk+" version="3.18"/> + <object class="GtkListStore" id="liststore1"> + <columns> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + <!-- column-name image --> + <column type="gchararray"/> + </columns> + </object> <object class="GtkMessageDialog" id="WarnPDFDialog"> <property name="can_focus">False</property> <property name="border_width">6</property> @@ -33,7 +43,7 @@ </packing> </child> <child> - <object class="GtkGrid" id="grid1"> + <object class="GtkGrid" id="grid"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="hexpand">True</property> @@ -46,11 +56,11 @@ <property name="can_focus">False</property> <property name="hexpand">True</property> <property name="vexpand">True</property> - <property name="xalign">0</property> - <property name="yalign">0</property> <property name="wrap">True</property> <property name="width_chars">30</property> <property name="max_width_chars">30</property> + <property name="xalign">0</property> + <property name="yalign">0</property> </object> <packing> <property name="left_attach">1</property> @@ -58,13 +68,46 @@ </packing> </child> <child> - <object class="GtkTreeView" id="errors:border"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="vexpand">True</property> - <child internal-child="selection"> - <object class="GtkTreeSelection" id="treeview-selection1"/> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="errors"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="vexpand">True</property> + <property name="model">liststore1</property> + <property name="headers_visible">False</property> + <property name="headers_clickable">False</property> + <property name="search_column">0</property> + <property name="show_expanders">False</property> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="treeview-selection1"/> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn1"> + <child> + <object class="GtkCellRendererPixbuf" id="cellrenderertext1"/> + <attributes> + <attribute name="icon-name">2</attribute> + </attributes> + </child> + </object> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn2"> + <child> + <object class="GtkCellRendererText" id="cellrenderertext2"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + </child> + </object> </child> </object> <packing> @@ -81,5 +124,8 @@ </child> </object> </child> + <child> + <placeholder/> + </child> </object> </interface> |