Kaydet (Commit) d05ee87b authored tarafından Caolán McNamara's avatar Caolán McNamara

weld pdf warning dialog

Change-Id: I80b8324dcd575f6b537c4a0be264f0446c0fc32f
Reviewed-on: https://gerrit.libreoffice.org/51516Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst b5ca41ab
/* -*- 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: */
......@@ -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)
......
......@@ -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);
};
......
......@@ -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;
......
......@@ -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:
......
<?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>
......@@ -201,8 +201,12 @@ protected:
public:
virtual void insert_text(const OUString& rText, int pos) = 0;
virtual void append_text(const OUString& rText) { insert_text(rText, -1); }
virtual void insert(int pos, const OUString& rId, const OUString& rStr) = 0;
virtual void append(const OUString& rId, const OUString& rStr) { insert(-1, rId, rStr); }
virtual void insert(int pos, const OUString& rId, const OUString& rStr, const OUString& rImage)
= 0;
virtual void append(const OUString& rId, const OUString& rStr, const OUString& rImage)
{
insert(-1, rId, rStr, rImage);
}
virtual int n_children() const = 0;
virtual void select(int pos) = 0;
using Container::remove;
......@@ -211,6 +215,7 @@ public:
virtual void set_top_entry(int pos) = 0;
virtual void clear() = 0;
virtual OUString get_selected() const = 0;
OUString get_selected_id() const { return get_id(get_selected_index()); }
virtual int get_selected_index() const = 0;
virtual OUString get(int pos) const = 0;
virtual OUString get_id(int pos) const = 0;
......
......@@ -55,7 +55,6 @@ $(packimages_DIR)/sourceimagelist.ilst : \
$(SRCDIR)/dbaccess/inc/bitmaps.hlst \
$(SRCDIR)/desktop/inc/bitmaps.hlst \
$(SRCDIR)/extensions/inc/bitmaps.hlst \
$(SRCDIR)/filter/inc/bitmaps.hlst \
$(SRCDIR)/formula/inc/bitmaps.hlst \
$(SRCDIR)/fpicker/inc/bitmaps.hlst \
$(SRCDIR)/framework/inc/bitmaps.hlst \
......
......@@ -138,6 +138,9 @@
#define SPINNER_64_12 "vcl/res/spinner-64-12.png"
//end, Throbber::getDefaultImageURLs
#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: */
......@@ -38,6 +38,7 @@
#include <vcl/tabctrl.hxx>
#include <vcl/tabpage.hxx>
#include <vcl/weld.hxx>
#include <bitmaps.hlst>
SalFrame::SalFrame()
: m_pWindow(nullptr)
......@@ -862,10 +863,22 @@ public:
m_xTreeView->InsertEntry(rText, pos);
}
virtual void insert(int pos, const OUString& rId, const OUString& rStr) override
virtual void insert(int pos, const OUString& rId, const OUString& rStr, const OUString& rImage) override
{
m_xTreeView->SetEntryData(m_xTreeView->InsertEntry(rStr, pos == -1 ? COMBOBOX_APPEND : pos),
new OUString(rId));
sal_Int32 nInsertedAt;
if (rImage.isEmpty())
nInsertedAt = m_xTreeView->InsertEntry(rStr, pos == -1 ? COMBOBOX_APPEND : pos);
else
{
assert((rImage == "dialog-warning" || rImage == "dialog-error") && "unknown stock image");
Image aImage;
if (rImage == "dialog-warning")
aImage = Image(BitmapEx(IMG_WARN));
else if (rImage == "dialog-error")
aImage = Image(BitmapEx(IMG_ERR));
nInsertedAt = m_xTreeView->InsertEntry(rStr, aImage, pos == -1 ? COMBOBOX_APPEND : pos);
}
m_xTreeView->SetEntryData(nInsertedAt, new OUString(rId));
}
using SalInstanceContainer::remove;
......
......@@ -2116,15 +2116,28 @@ public:
enable_notify_events();
}
virtual void insert(int pos, const OUString& rId, const OUString& rText) override
virtual void insert(int pos, const OUString& rId, const OUString& rText, const OUString& rImage) override
{
disable_notify_events();
GtkTreeIter iter;
gtk_list_store_insert(m_pListStore, &iter, pos);
gtk_list_store_set(m_pListStore, &iter,
0, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(),
1, OUStringToOString(rId, RTL_TEXTENCODING_UTF8).getStr(),
-1);
if (rImage.isEmpty())
{
gtk_list_store_set(m_pListStore, &iter,
0, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(),
1, OUStringToOString(rId, RTL_TEXTENCODING_UTF8).getStr(),
-1);
}
else
{
assert((rImage == "dialog-warning" || rImage == "dialog-error") && "unknown stock image");
gtk_list_store_set(m_pListStore, &iter,
0, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(),
1, OUStringToOString(rId, RTL_TEXTENCODING_UTF8).getStr(),
2, OUStringToOString(rImage, RTL_TEXTENCODING_UTF8).getStr(),
-1);
}
enable_notify_events();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment