diff options
-rw-r--r-- | writerperfect/qa/uitest/epubexport/epubexport.py | 14 | ||||
-rw-r--r-- | writerperfect/source/writer/EPUBExportDialog.cxx | 23 | ||||
-rw-r--r-- | writerperfect/source/writer/EPUBExportDialog.hxx | 6 | ||||
-rw-r--r-- | writerperfect/source/writer/EPUBExportUIComponent.cxx | 5 | ||||
-rw-r--r-- | writerperfect/source/writer/EPUBExportUIComponent.hxx | 2 | ||||
-rw-r--r-- | writerperfect/uiconfig/ui/exportepub.ui | 89 |
6 files changed, 127 insertions, 12 deletions
diff --git a/writerperfect/qa/uitest/epubexport/epubexport.py b/writerperfect/qa/uitest/epubexport/epubexport.py index 196556b2fb8d..301f090e3362 100644 --- a/writerperfect/qa/uitest/epubexport/epubexport.py +++ b/writerperfect/qa/uitest/epubexport/epubexport.py @@ -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"})) diff --git a/writerperfect/source/writer/EPUBExportDialog.cxx b/writerperfect/source/writer/EPUBExportDialog.cxx index c0e316e1f32a..acc1f9a9182d 100644 --- a/writerperfect/source/writer/EPUBExportDialog.cxx +++ b/writerperfect/source/writer/EPUBExportDialog.cxx @@ -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(); } diff --git a/writerperfect/source/writer/EPUBExportDialog.hxx b/writerperfect/source/writer/EPUBExportDialog.hxx index 4ff67ee6f5e5..1181d096bd03 100644 --- a/writerperfect/source/writer/EPUBExportDialog.hxx +++ b/writerperfect/source/writer/EPUBExportDialog.hxx @@ -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; diff --git a/writerperfect/source/writer/EPUBExportUIComponent.cxx b/writerperfect/source/writer/EPUBExportUIComponent.cxx index b38ebf799859..b6fe80ff3604 100644 --- a/writerperfect/source/writer/EPUBExportUIComponent.cxx +++ b/writerperfect/source/writer/EPUBExportUIComponent.cxx @@ -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; diff --git a/writerperfect/source/writer/EPUBExportUIComponent.hxx b/writerperfect/source/writer/EPUBExportUIComponent.hxx index f20adfd2d997..243e1f8a61fb 100644 --- a/writerperfect/source/writer/EPUBExportUIComponent.hxx +++ b/writerperfect/source/writer/EPUBExportUIComponent.hxx @@ -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 diff --git a/writerperfect/uiconfig/ui/exportepub.ui b/writerperfect/uiconfig/ui/exportepub.ui index bc55aff5eeda..3d7c28af73be 100644 --- a/writerperfect/uiconfig/ui/exportepub.ui +++ b/writerperfect/uiconfig/ui/exportepub.ui @@ -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> |