diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-11-30 08:50:04 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-11-30 15:36:26 +0100 |
commit | ee74bd73856c355f1491e9ff7c3bbbf74a7858bb (patch) | |
tree | 82909c55844f23fd812c5a8477a2c0b78d88e65a /writerperfect | |
parent | 98770243f7f5387aae06e83ed4de0d68e02abb02 (diff) |
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 <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'writerperfect')
-rw-r--r-- | writerperfect/qa/uitest/epubexport/epubexport.py | 26 | ||||
-rw-r--r-- | writerperfect/source/writer/EPUBExportDialog.cxx | 24 | ||||
-rw-r--r-- | writerperfect/source/writer/EPUBExportDialog.hxx | 5 | ||||
-rw-r--r-- | writerperfect/uiconfig/ui/exportepub.ui | 399 |
4 files changed, 364 insertions, 90 deletions
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<Edit> m_pCoverPath; VclPtr<PushButton> m_pCoverButton; 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 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 @@ </packing> </child> <child> - <object class="GtkAlignment" id="alignment1"> + <object class="GtkBox" id="box5"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="top_padding">6</property> - <property name="left_padding">12</property> + <property name="spacing">12</property> <child> - <object class="GtkBox" id="box1"> + <object class="GtkBox" id="box6"> <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="versionft"> + <object class="GtkLabel" id="generalft"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="margin_top">6</property> - <property name="label" translatable="yes" context="exportepub|versionft">Version:</property> + <property name="label" translatable="yes" context="exportepub|generalft">General</property> <property name="use_underline">True</property> <property name="mnemonic_widget">versionlb</property> <property name="xalign">0</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> </object> <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">3</property> + <property name="position">0</property> </packing> </child> <child> - <object class="GtkComboBoxText" id="versionlb"> + <object class="GtkAlignment" id="alignment1"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="active">0</property> - <items> - <item translatable="yes" context="exportepub|epub3">EPUB 3.0</item> - <item translatable="yes" context="exportepub|epub2">EPUB 2.0</item> - </items> + <property name="top_padding">6</property> + <property name="left_padding">12</property> + <child> + <object class="GtkBox" id="box1"> + <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="versionft"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_top">6</property> + <property name="label" translatable="yes" context="exportepub|versionft">Version:</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">3</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="versionlb"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="active">0</property> + <items> + <item translatable="yes" context="exportepub|epub3">EPUB 3.0</item> + <item translatable="yes" context="exportepub|epub2">EPUB 2.0</item> + </items> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">4</property> + </packing> + </child> + </object> + </child> </object> <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">4</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">0</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment2"> - <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="box2"> - <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="splitft"> + <object class="GtkAlignment" id="alignment2"> <property name="visible">True</property> <property name="can_focus">False</property> - <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="xalign">0</property> + <property name="top_padding">6</property> + <property name="left_padding">12</property> + <child> + <object class="GtkBox" id="box2"> + <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="splitft"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <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="xalign">0</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">3</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="splitlb"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="active">0</property> + <items> + <item translatable="yes" context="exportepub|splitpage">Page break</item> + <item translatable="yes" context="exportepub|splitheading">Heading</item> + </items> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">4</property> + </packing> + </child> + </object> + </child> </object> <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">3</property> + <property name="position">2</property> </packing> </child> <child> - <object class="GtkComboBoxText" id="splitlb"> + <object class="GtkAlignment" id="alignment3"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="active">0</property> - <items> - <item translatable="yes" context="exportepub|splitpage">Page break</item> - <item translatable="yes" context="exportepub|splitheading">Heading</item> - </items> + <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">4</property> + <property name="position">3</property> </packing> </child> </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <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"> + <object class="GtkBox" id="box7"> <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"> + <object class="GtkLabel" id="metadataft"> <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="label" translatable="yes" context="exportepub|generalft">Metadata</property> <property name="use_underline">True</property> <property name="mnemonic_widget">versionlb</property> <property name="xalign">0</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> </object> <packing> <property name="expand">False</property> @@ -206,33 +311,142 @@ </packing> </child> <child> - <object class="GtkBox" id="box4"> + <object class="GtkAlignment" id="alignment4"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="spacing">12</property> + <property name="left_padding">12</property> <child> - <object class="GtkEntry" id="coverpath"> + <object class="GtkGrid" id="grid1"> <property name="visible">True</property> - <property name="can_focus">True</property> + <property name="can_focus">False</property> + <property name="row_spacing">12</property> + <property name="column_spacing">12</property> + <child> + <object class="GtkEntry" id="identifier"> + <property name="visible">True</property> + <property name="can_focus">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="identifierft"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <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="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="titleft"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <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="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="title"> + <property name="visible">True</property> + <property name="can_focus">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="authorft"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <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="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="author"> + <property name="visible">True</property> + <property name="can_focus">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="languageft"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <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="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">3</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="language"> + <property name="visible">True</property> + <property name="can_focus">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">3</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="dateft"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <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="xalign">0</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">4</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="date"> + <property name="visible">True</property> + <property name="can_focus">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">4</property> + </packing> + </child> </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> @@ -242,12 +456,17 @@ </packing> </child> </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">3</property> + <property name="position">0</property> </packing> </child> </object> |