From ee74bd73856c355f1491e9ff7c3bbbf74a7858bb Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 30 Nov 2017 08:50:04 +0100 Subject: 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/45553 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- writerperfect/qa/uitest/epubexport/epubexport.py | 26 ++ writerperfect/source/writer/EPUBExportDialog.cxx | 24 ++ writerperfect/source/writer/EPUBExportDialog.hxx | 5 + writerperfect/uiconfig/ui/exportepub.ui | 399 ++++++++++++++++++----- 4 files changed, 364 insertions(+), 90 deletions(-) (limited to 'writerperfect') diff --git a/writerperfect/qa/uitest/epubexport/epubexport.py b/writerperfect/qa/uitest/epubexport/epubexport.py index 8db15c5bf891..196556b2fb8d 100644 --- a/writerperfect/qa/uitest/epubexport/epubexport.py +++ b/writerperfect/qa/uitest/epubexport/epubexport.py @@ -83,4 +83,30 @@ class EPUBExportTest(UITestCase): coverImage = [i.Value for i in filterData if i.Name == "RVNGCoverImage"][0] 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: diff --git a/writerperfect/source/writer/EPUBExportDialog.cxx b/writerperfect/source/writer/EPUBExportDialog.cxx index da42954a5d02..c0e316e1f32a 100644 --- a/writerperfect/source/writer/EPUBExportDialog.cxx +++ b/writerperfect/source/writer/EPUBExportDialog.cxx @@ -98,6 +98,12 @@ EPUBExportDialog::EPUBExportDialog(vcl::Window *pParent, comphelper::SequenceAsH get(m_pCoverButton, "coverbutton"); 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"); m_pOKButton->SetClickHdl(LINK(this, EPUBExportDialog, OKClickHdl)); } @@ -124,9 +130,22 @@ IMPL_LINK_NOARG(EPUBExportDialog, CoverClickHdl, Button *, void) IMPL_LINK_NOARG(EPUBExportDialog, OKClickHdl, Button *, void) { + // General if (!m_pCoverPath->GetText().isEmpty()) 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); } @@ -142,6 +161,11 @@ void EPUBExportDialog::dispose() m_pCoverPath.clear(); m_pCoverButton.clear(); m_pOKButton.clear(); + m_pIdentifier.clear(); + m_pTitle.clear(); + m_pInitialCreator.clear(); + m_pLanguage.clear(); + m_pDate.clear(); ModalDialog::dispose(); } diff --git a/writerperfect/source/writer/EPUBExportDialog.hxx b/writerperfect/source/writer/EPUBExportDialog.hxx index e211ca3340c7..4ff67ee6f5e5 100644 --- a/writerperfect/source/writer/EPUBExportDialog.hxx +++ b/writerperfect/source/writer/EPUBExportDialog.hxx @@ -39,6 +39,11 @@ private: VclPtr m_pCoverPath; VclPtr m_pCoverButton; VclPtr m_pOKButton; + VclPtr m_pIdentifier; + VclPtr m_pTitle; + VclPtr m_pInitialCreator; + VclPtr m_pLanguage; + VclPtr m_pDate; }; } // namespace writerperfect diff --git a/writerperfect/uiconfig/ui/exportepub.ui b/writerperfect/uiconfig/ui/exportepub.ui index e77f806adfcf..bc55aff5eeda 100644 --- a/writerperfect/uiconfig/ui/exportepub.ui +++ b/writerperfect/uiconfig/ui/exportepub.ui @@ -72,132 +72,237 @@ - + True False - 6 - 12 + 12 - + True False vertical - 6 - + True False 6 - Version: + General True versionlb 0 + + + False True - 3 + 0 - + True False - 0 - - EPUB 3.0 - EPUB 2.0 - + 6 + 12 + + + True + False + vertical + 6 + + + True + False + 6 + Version: + True + versionlb + 0 + + + False + True + 3 + + + + + True + False + 0 + + EPUB 3.0 + EPUB 2.0 + + + + False + True + 4 + + + + False True - 4 + 1 - - - - - False - True - 0 - - - - - True - False - 6 - 12 - - - True - False - vertical - 6 - + True False - 6 - Split method: - True - versionlb - 0 + 6 + 12 + + + True + False + vertical + 6 + + + True + False + 6 + Split method: + True + versionlb + 0 + + + False + True + 3 + + + + + True + False + 0 + + Page break + Heading + + + + False + True + 4 + + + + False True - 3 + 2 - + True False - 0 - - Page break - Heading - + 6 + 12 + + + True + False + vertical + 6 + + + True + False + 6 + Custom cover image: + True + versionlb + 0 + + + False + True + 0 + + + + + True + False + 12 + + + True + True + + + True + True + 0 + + + + + Browse... + True + True + True + + + False + True + 1 + + + + + False + True + 1 + + + + False True - 4 + 3 + + False + True + 0 + - - - False - True - 1 - - - - - True - False - 6 - 12 - + True False vertical - 6 - + True False 6 - Custom cover image: + Metadata True versionlb 0 + + + False @@ -206,33 +311,142 @@ - + True False - 12 + 12 - + True - True + False + 12 + 12 + + + True + True + + + 1 + 0 + + + + + True + False + 6 + Identifier: + True + versionlb + 0 + + + 0 + 0 + + + + + True + False + 6 + Title: + True + versionlb + 0 + + + 0 + 1 + + + + + True + True + + + 1 + 1 + + + + + True + False + 6 + Author: + True + versionlb + 0 + + + 0 + 2 + + + + + True + True + + + 1 + 2 + + + + + True + False + 6 + Language: + True + versionlb + 0 + + + 0 + 3 + + + + + True + True + + + 1 + 3 + + + + + True + False + 6 + Date: + True + versionlb + 0 + + + 0 + 4 + + + + + True + True + + + 1 + 4 + + - - True - True - 0 - - - - - Browse... - True - True - True - - - False - True - 1 - @@ -242,12 +456,17 @@ + + False + True + 1 + False True - 3 + 0 -- cgit v1.2.3