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

EPUB export: add UI to set custom metadata

The motivation here is that when it comes to date or author, the typical
metata for the Writer document won't match the metadata of the book the
file represents, so allowing a custom override as part of EPUB export
makes sense.

Change-Id: I19aaed83ae0e69bc0dfa3084e1c9dc9cc534328f
Reviewed-on: https://gerrit.libreoffice.org/45553Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst 98770243
...@@ -83,4 +83,30 @@ class EPUBExportTest(UITestCase): ...@@ -83,4 +83,30 @@ class EPUBExportTest(UITestCase):
coverImage = [i.Value for i in filterData if i.Name == "RVNGCoverImage"][0] coverImage = [i.Value for i in filterData if i.Name == "RVNGCoverImage"][0]
self.assertEqual("cover.png", coverImage) self.assertEqual("cover.png", coverImage)
def testMeta(self):
def handleDialog(dialog):
dialog.getChild("identifier").executeAction("TYPE", mkPropertyValues({"TEXT": "baddcafe-e394-4cd6-9b83-7172794612e5"}))
dialog.getChild("title").executeAction("TYPE", mkPropertyValues({"TEXT": "unknown title from ui"}))
dialog.getChild("author").executeAction("TYPE", mkPropertyValues({"TEXT": "unknown author from ui"}))
dialog.getChild("language").executeAction("TYPE", mkPropertyValues({"TEXT": "sk"}))
dialog.getChild("date").executeAction("TYPE", mkPropertyValues({"TEXT": "2013-11-20T17:16:07Z"}))
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]
# These keys were missing, EPUBExportDialog::OKClickHdl() did not set them.
identifier = [i.Value for i in filterData if i.Name == "RVNGIdentifier"][0]
self.assertEqual("baddcafe-e394-4cd6-9b83-7172794612e5", identifier)
title = [i.Value for i in filterData if i.Name == "RVNGTitle"][0]
self.assertEqual("unknown title from ui", title)
initialCreator = [i.Value for i in filterData if i.Name == "RVNGInitialCreator"][0]
self.assertEqual("unknown author from ui", initialCreator)
language = [i.Value for i in filterData if i.Name == "RVNGLanguage"][0]
self.assertEqual("sk", language)
date = [i.Value for i in filterData if i.Name == "RVNGDate"][0]
self.assertEqual("2013-11-20T17:16:07Z", date)
# vim: set shiftwidth=4 softtabstop=4 expandtab: # vim: set shiftwidth=4 softtabstop=4 expandtab:
...@@ -98,6 +98,12 @@ EPUBExportDialog::EPUBExportDialog(vcl::Window *pParent, comphelper::SequenceAsH ...@@ -98,6 +98,12 @@ EPUBExportDialog::EPUBExportDialog(vcl::Window *pParent, comphelper::SequenceAsH
get(m_pCoverButton, "coverbutton"); get(m_pCoverButton, "coverbutton");
m_pCoverButton->SetClickHdl(LINK(this, EPUBExportDialog, CoverClickHdl)); m_pCoverButton->SetClickHdl(LINK(this, EPUBExportDialog, CoverClickHdl));
get(m_pIdentifier, "identifier");
get(m_pTitle, "title");
get(m_pInitialCreator, "author");
get(m_pLanguage, "language");
get(m_pDate, "date");
get(m_pOKButton, "ok"); get(m_pOKButton, "ok");
m_pOKButton->SetClickHdl(LINK(this, EPUBExportDialog, OKClickHdl)); m_pOKButton->SetClickHdl(LINK(this, EPUBExportDialog, OKClickHdl));
} }
...@@ -124,9 +130,22 @@ IMPL_LINK_NOARG(EPUBExportDialog, CoverClickHdl, Button *, void) ...@@ -124,9 +130,22 @@ IMPL_LINK_NOARG(EPUBExportDialog, CoverClickHdl, Button *, void)
IMPL_LINK_NOARG(EPUBExportDialog, OKClickHdl, Button *, void) IMPL_LINK_NOARG(EPUBExportDialog, OKClickHdl, Button *, void)
{ {
// General
if (!m_pCoverPath->GetText().isEmpty()) if (!m_pCoverPath->GetText().isEmpty())
mrFilterData["RVNGCoverImage"] <<= m_pCoverPath->GetText(); mrFilterData["RVNGCoverImage"] <<= m_pCoverPath->GetText();
// Metadata
if (!m_pIdentifier->GetText().isEmpty())
mrFilterData["RVNGIdentifier"] <<= m_pIdentifier->GetText();
if (!m_pTitle->GetText().isEmpty())
mrFilterData["RVNGTitle"] <<= m_pTitle->GetText();
if (!m_pInitialCreator->GetText().isEmpty())
mrFilterData["RVNGInitialCreator"] <<= m_pInitialCreator->GetText();
if (!m_pLanguage->GetText().isEmpty())
mrFilterData["RVNGLanguage"] <<= m_pLanguage->GetText();
if (!m_pDate->GetText().isEmpty())
mrFilterData["RVNGDate"] <<= m_pDate->GetText();
EndDialog(RET_OK); EndDialog(RET_OK);
} }
...@@ -142,6 +161,11 @@ void EPUBExportDialog::dispose() ...@@ -142,6 +161,11 @@ void EPUBExportDialog::dispose()
m_pCoverPath.clear(); m_pCoverPath.clear();
m_pCoverButton.clear(); m_pCoverButton.clear();
m_pOKButton.clear(); m_pOKButton.clear();
m_pIdentifier.clear();
m_pTitle.clear();
m_pInitialCreator.clear();
m_pLanguage.clear();
m_pDate.clear();
ModalDialog::dispose(); ModalDialog::dispose();
} }
......
...@@ -39,6 +39,11 @@ private: ...@@ -39,6 +39,11 @@ private:
VclPtr<Edit> m_pCoverPath; VclPtr<Edit> m_pCoverPath;
VclPtr<PushButton> m_pCoverButton; VclPtr<PushButton> m_pCoverButton;
VclPtr<PushButton> m_pOKButton; VclPtr<PushButton> m_pOKButton;
VclPtr<Edit> m_pIdentifier;
VclPtr<Edit> m_pTitle;
VclPtr<Edit> m_pInitialCreator;
VclPtr<Edit> m_pLanguage;
VclPtr<Edit> m_pDate;
}; };
} // namespace writerperfect } // namespace writerperfect
......
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