Kaydet (Commit) 3ed60d22 authored tarafından Miklos Vajna's avatar Miklos Vajna

EPUB export: add UI to test custom media directory

Sets the RVNGMediaDir filter data key at UNO level.

Change-Id: I9919e5ca39c9f4f126d1d67946c8bec99ce0381d
Reviewed-on: https://gerrit.libreoffice.org/45603Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst 7f0641de
......@@ -83,6 +83,20 @@ class EPUBExportTest(UITestCase):
coverImage = [i.Value for i in filterData if i.Name == "RVNGCoverImage"][0]
self.assertEqual("cover.png", coverImage)
def testMediaDir(self):
def handleDialog(dialog):
dialog.getChild("mediadir").executeAction("TYPE", mkPropertyValues({"TEXT": "file:///foo/bar"}))
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 RVNGMediaDir key was missing, EPUBExportDialog::OKClickHdl() did not set it.
mediaDir = [i.Value for i in filterData if i.Name == "RVNGMediaDir"][0]
self.assertEqual("file:///foo/bar", mediaDir)
def testMeta(self):
def handleDialog(dialog):
dialog.getChild("identifier").executeAction("TYPE", mkPropertyValues({"TEXT": "baddcafe-e394-4cd6-9b83-7172794612e5"}))
......
......@@ -9,6 +9,8 @@
#include "EPUBExportDialog.hxx"
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
#include <com/sun/star/ui/dialogs/FolderPicker.hpp>
#include <sfx2/opengrf.hxx>
#include "EPUBExportFilter.hxx"
......@@ -63,8 +65,9 @@ sal_Int32 PositionToVersion(sal_Int32 nPosition)
namespace writerperfect
{
EPUBExportDialog::EPUBExportDialog(vcl::Window *pParent, comphelper::SequenceAsHashMap &rFilterData)
EPUBExportDialog::EPUBExportDialog(vcl::Window *pParent, comphelper::SequenceAsHashMap &rFilterData, const uno::Reference<uno::XComponentContext> &xContext)
: ModalDialog(pParent, "EpubDialog", "writerperfect/ui/exportepub.ui"),
mxContext(xContext),
mrFilterData(rFilterData)
{
get(m_pVersion, "versionlb");
......@@ -98,6 +101,11 @@ EPUBExportDialog::EPUBExportDialog(vcl::Window *pParent, comphelper::SequenceAsH
get(m_pCoverButton, "coverbutton");
m_pCoverButton->SetClickHdl(LINK(this, EPUBExportDialog, CoverClickHdl));
get(m_pMediaDir, "mediadir");
get(m_pMediaButton, "mediabutton");
m_pMediaButton->SetClickHdl(LINK(this, EPUBExportDialog, MediaClickHdl));
get(m_pIdentifier, "identifier");
get(m_pTitle, "title");
get(m_pInitialCreator, "author");
......@@ -128,11 +136,22 @@ IMPL_LINK_NOARG(EPUBExportDialog, CoverClickHdl, Button *, void)
m_pCoverPath->SetText(aDlg.GetPath());
}
IMPL_LINK_NOARG(EPUBExportDialog, MediaClickHdl, Button *, void)
{
uno::Reference<ui::dialogs::XFolderPicker2> xFolderPicker = ui::dialogs::FolderPicker::create(mxContext);
if (xFolderPicker->execute() != ui::dialogs::ExecutableDialogResults::OK)
return;
m_pMediaDir->SetText(xFolderPicker->getDirectory());
}
IMPL_LINK_NOARG(EPUBExportDialog, OKClickHdl, Button *, void)
{
// General
if (!m_pCoverPath->GetText().isEmpty())
mrFilterData["RVNGCoverImage"] <<= m_pCoverPath->GetText();
if (!m_pMediaDir->GetText().isEmpty())
mrFilterData["RVNGMediaDir"] <<= m_pMediaDir->GetText();
// Metadata
if (!m_pIdentifier->GetText().isEmpty())
......@@ -166,6 +185,8 @@ void EPUBExportDialog::dispose()
m_pInitialCreator.clear();
m_pLanguage.clear();
m_pDate.clear();
m_pMediaDir.clear();
m_pMediaButton.clear();
ModalDialog::dispose();
}
......
......@@ -23,7 +23,7 @@ namespace writerperfect
class EPUBExportDialog : public ModalDialog
{
public:
EPUBExportDialog(vcl::Window *pParent, comphelper::SequenceAsHashMap &rFilterData);
EPUBExportDialog(vcl::Window *pParent, comphelper::SequenceAsHashMap &rFilterData, const css::uno::Reference<css::uno::XComponentContext> &xContext);
~EPUBExportDialog() override;
void dispose() override;
......@@ -31,13 +31,17 @@ private:
DECL_LINK(VersionSelectHdl, ListBox &, void);
DECL_LINK(SplitSelectHdl, ListBox &, void);
DECL_LINK(CoverClickHdl, Button *, void);
DECL_LINK(MediaClickHdl, Button *, void);
DECL_LINK(OKClickHdl, Button *, void);
css::uno::Reference<css::uno::XComponentContext> mxContext;
comphelper::SequenceAsHashMap &mrFilterData;
VclPtr<ListBox> m_pVersion;
VclPtr<ListBox> m_pSplit;
VclPtr<Edit> m_pCoverPath;
VclPtr<PushButton> m_pCoverButton;
VclPtr<Edit> m_pMediaDir;
VclPtr<PushButton> m_pMediaButton;
VclPtr<PushButton> m_pOKButton;
VclPtr<Edit> m_pIdentifier;
VclPtr<Edit> m_pTitle;
......
......@@ -23,7 +23,8 @@ using namespace com::sun::star;
namespace writerperfect
{
EPUBExportUIComponent::EPUBExportUIComponent(const uno::Reference<uno::XComponentContext> &/*xContext*/)
EPUBExportUIComponent::EPUBExportUIComponent(const uno::Reference<uno::XComponentContext> &xContext)
: mxContext(xContext)
{
}
......@@ -76,7 +77,7 @@ sal_Int16 EPUBExportUIComponent::execute()
{
SolarMutexGuard aGuard;
ScopedVclPtrInstance<EPUBExportDialog> pDialog(Application::GetDefDialogParent(), maFilterData);
ScopedVclPtrInstance<EPUBExportDialog> pDialog(Application::GetDefDialogParent(), maFilterData, mxContext);
if (pDialog->Execute() == RET_OK)
return ui::dialogs::ExecutableDialogResults::OK;
return ui::dialogs::ExecutableDialogResults::CANCEL;
......
......@@ -52,6 +52,8 @@ private:
comphelper::SequenceAsHashMap maMediaDescriptor;
/// The filter data key.
comphelper::SequenceAsHashMap maFilterData;
/// UNO context.
css::uno::Reference<css::uno::XComponentContext> mxContext;
};
} // namespace writerperfect
......
......@@ -172,7 +172,7 @@
<property name="margin_top">6</property>
<property name="label" translatable="yes" context="exportepub|splitft">Split method:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">versionlb</property>
<property name="mnemonic_widget">splitlb</property>
<property name="xalign">0</property>
</object>
<packing>
......@@ -225,7 +225,7 @@
<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="mnemonic_widget">coverpath</property>
<property name="xalign">0</property>
</object>
<packing>
......@@ -279,6 +279,79 @@
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment4">
<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="box8">
<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="mediadirft">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">6</property>
<property name="label" translatable="yes" context="exportepub|mediadirft">Custom media directory:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">mediadir</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="box9">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">12</property>
<child>
<object class="GtkEntry" id="mediadir">
<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="mediabutton">
<property name="label" translatable="yes" context="exportepub|mediabutton">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">4</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
......@@ -311,7 +384,7 @@
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment4">
<object class="GtkAlignment" id="alignment5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">12</property>
......@@ -338,7 +411,7 @@
<property name="margin_top">6</property>
<property name="label" translatable="yes" context="exportepub|identifierft">Identifier:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">versionlb</property>
<property name="mnemonic_widget">identifier</property>
<property name="xalign">0</property>
</object>
<packing>
......@@ -353,7 +426,7 @@
<property name="margin_top">6</property>
<property name="label" translatable="yes" context="exportepub|titleft">Title:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">versionlb</property>
<property name="mnemonic_widget">title</property>
<property name="xalign">0</property>
</object>
<packing>
......@@ -378,7 +451,7 @@
<property name="margin_top">6</property>
<property name="label" translatable="yes" context="exportepub|authorft">Author:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">versionlb</property>
<property name="mnemonic_widget">author</property>
<property name="xalign">0</property>
</object>
<packing>
......@@ -403,7 +476,7 @@
<property name="margin_top">6</property>
<property name="label" translatable="yes" context="exportepub|languageft">Language:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">versionlb</property>
<property name="mnemonic_widget">language</property>
<property name="xalign">0</property>
</object>
<packing>
......@@ -428,7 +501,7 @@
<property name="margin_top">6</property>
<property name="label" translatable="yes" context="exportepub|dateft">Date:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">versionlb</property>
<property name="mnemonic_widget">date</property>
<property name="xalign">0</property>
</object>
<packing>
......
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