Kaydet (Commit) 06fa4283 authored tarafından Miklos Vajna's avatar Miklos Vajna

EPUB export: add UI to set a custom cover image

Sets the EPUBCoverImage filter data key at UNO level.

Change-Id: I46eb3c0df1e6c34af0be070c32f9f37666dc718e
Reviewed-on: https://gerrit.libreoffice.org/45485Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst 61282122
......@@ -69,4 +69,18 @@ class EPUBExportTest(UITestCase):
# Make sure that initializing with 2 different versions results in 2 different widget states.
self.assertEqual(2, len(set(positions)))
def testCoverImage(self):
def handleDialog(dialog):
dialog.getChild("coverpath").executeAction("TYPE", mkPropertyValues({"TEXT": "cover.png"}))
dialog.getChild("ok").executeAction("CLICK", tuple())
uiComponent = self.ui_test._xContext.ServiceManager.createInstanceWithContext("com.sun.star.comp.Writer.EPUBExportUIComponent", self.ui_test._xContext)
self.ui_test.execute_blocking_action(action=uiComponent.execute, dialog_handler=handleDialog)
propertyValues = uiComponent.getPropertyValues()
filterData = [i.Value for i in propertyValues if i.Name == "FilterData"][0]
# The EPUBCoverImage key was missing, EPUBExportDialog::OKClickHdl() did not set it.
coverImage = [i.Value for i in filterData if i.Name == "EPUBCoverImage"][0]
self.assertEqual("cover.png", coverImage)
# vim: set shiftwidth=4 softtabstop=4 expandtab:
......@@ -9,6 +9,8 @@
#include "EPUBExportDialog.hxx"
#include <sfx2/opengrf.hxx>
#include "EPUBExportFilter.hxx"
using namespace com::sun::star;
......@@ -90,6 +92,14 @@ EPUBExportDialog::EPUBExportDialog(vcl::Window *pParent, comphelper::SequenceAsH
else
m_pSplit->SelectEntryPos(EPUBExportFilter::GetDefaultSplitMethod());
m_pSplit->SetSelectHdl(LINK(this, EPUBExportDialog, SplitSelectHdl));
get(m_pCoverPath, "coverpath");
get(m_pCoverButton, "coverbutton");
m_pCoverButton->SetClickHdl(LINK(this, EPUBExportDialog, CoverClickHdl));
get(m_pOKButton, "ok");
m_pOKButton->SetClickHdl(LINK(this, EPUBExportDialog, OKClickHdl));
}
IMPL_LINK_NOARG(EPUBExportDialog, VersionSelectHdl, ListBox &, void)
......@@ -104,6 +114,22 @@ IMPL_LINK_NOARG(EPUBExportDialog, SplitSelectHdl, ListBox &, void)
mrFilterData["EPUBSplitMethod"] <<= m_pSplit->GetSelectedEntryPos();
}
IMPL_LINK_NOARG(EPUBExportDialog, CoverClickHdl, Button *, void)
{
SvxOpenGraphicDialog aDlg("Import", this);
aDlg.EnableLink(false);
if (aDlg.Execute() == ERRCODE_NONE)
m_pCoverPath->SetText(aDlg.GetPath());
}
IMPL_LINK_NOARG(EPUBExportDialog, OKClickHdl, Button *, void)
{
if (!m_pCoverPath->GetText().isEmpty())
mrFilterData["EPUBCoverImage"] <<= m_pCoverPath->GetText();
EndDialog(RET_OK);
}
EPUBExportDialog::~EPUBExportDialog()
{
disposeOnce();
......@@ -113,6 +139,9 @@ void EPUBExportDialog::dispose()
{
m_pVersion.clear();
m_pSplit.clear();
m_pCoverPath.clear();
m_pCoverButton.clear();
m_pOKButton.clear();
ModalDialog::dispose();
}
......
......@@ -11,7 +11,9 @@
#define INCLUDED_WRITERPERFECT_SOURCE_WRITER_EPUBEXPORTDIALOG_HXX
#include <comphelper/sequenceashashmap.hxx>
#include <vcl/button.hxx>
#include <vcl/dialog.hxx>
#include <vcl/edit.hxx>
#include <vcl/lstbox.hxx>
namespace writerperfect
......@@ -28,10 +30,15 @@ public:
private:
DECL_LINK(VersionSelectHdl, ListBox &, void);
DECL_LINK(SplitSelectHdl, ListBox &, void);
DECL_LINK(CoverClickHdl, Button *, void);
DECL_LINK(OKClickHdl, Button *, void);
comphelper::SequenceAsHashMap &mrFilterData;
VclPtr<ListBox> m_pVersion;
VclPtr<ListBox> m_pSplit;
VclPtr<Edit> m_pCoverPath;
VclPtr<PushButton> m_pCoverButton;
VclPtr<PushButton> m_pOKButton;
};
} // namespace writerperfect
......
......@@ -177,6 +177,79 @@
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">6</property>
<property name="left_padding">12</property>
<child>
<object class="GtkBox" id="box3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="coverimageft">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">6</property>
<property name="label" translatable="yes" context="exportepub|coverimageft">Custom cover image:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">versionlb</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">12</property>
<child>
<object class="GtkEntry" id="coverpath">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="coverbutton">
<property name="label" translatable="yes" context="exportepub|coverbutton">Browse...</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">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">1</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
</child>
<action-widgets>
......
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