diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-04-18 11:49:10 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-04-18 21:39:14 +0200 |
commit | 158cd800d607898b1d2fe9bf4514900802ca1d90 (patch) | |
tree | 2cf7b77b4e322cb4250391e9428b34deea3e0076 /writerperfect/source | |
parent | dc7f9a1f79a94107d6113ee6569dbcbf15cf3071 (diff) |
weld EPUBExportDialog and add parent
Change-Id: Iec4fa3afb1e90ec36f792ea65b8c57b11cff98b3
Reviewed-on: https://gerrit.libreoffice.org/53094
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'writerperfect/source')
-rw-r--r-- | writerperfect/source/writer/EPUBExportDialog.cxx | 153 | ||||
-rw-r--r-- | writerperfect/source/writer/EPUBExportDialog.hxx | 57 | ||||
-rw-r--r-- | writerperfect/source/writer/EPUBExportUIComponent.cxx | 13 | ||||
-rw-r--r-- | writerperfect/source/writer/EPUBExportUIComponent.hxx | 7 |
4 files changed, 110 insertions, 120 deletions
diff --git a/writerperfect/source/writer/EPUBExportDialog.cxx b/writerperfect/source/writer/EPUBExportDialog.cxx index c01bc32ec111..bf1f4a0e4cfd 100644 --- a/writerperfect/source/writer/EPUBExportDialog.cxx +++ b/writerperfect/source/writer/EPUBExportDialog.cxx @@ -70,25 +70,37 @@ sal_Int32 PositionToVersion(sal_Int32 nPosition) namespace writerperfect { -EPUBExportDialog::EPUBExportDialog(vcl::Window *pParent, comphelper::SequenceAsHashMap &rFilterData, uno::Reference<uno::XComponentContext> xContext, css::uno::Reference<css::lang::XComponent> xDocument) - : ModalDialog(pParent, "EpubDialog", "writerperfect/ui/exportepub.ui"), - mxContext(std::move(xContext)), - mrFilterData(rFilterData), - mxSourceDocument(std::move(xDocument)) +EPUBExportDialog::EPUBExportDialog(weld::Window *pParent, comphelper::SequenceAsHashMap &rFilterData, uno::Reference<uno::XComponentContext> xContext, css::uno::Reference<css::lang::XComponent> xDocument) + : GenericDialogController(pParent, "writerperfect/ui/exportepub.ui", "EpubDialog") + , m_xContext(std::move(xContext)) + , m_rFilterData(rFilterData) + , m_xSourceDocument(std::move(xDocument)) + , m_xVersion(m_xBuilder->weld_combo_box_text("versionlb")) + , m_xSplit(m_xBuilder->weld_combo_box_text("splitlb")) + , m_xLayout(m_xBuilder->weld_combo_box_text("layoutlb")) + , m_xCoverPath(m_xBuilder->weld_entry("coverpath")) + , m_xCoverButton(m_xBuilder->weld_button("coverbutton")) + , m_xMediaDir(m_xBuilder->weld_entry("mediadir")) + , m_xMediaButton(m_xBuilder->weld_button("mediabutton")) + , m_xOKButton(m_xBuilder->weld_button("ok")) + , m_xIdentifier(m_xBuilder->weld_entry("identifier")) + , m_xTitle(m_xBuilder->weld_entry("title")) + , m_xInitialCreator(m_xBuilder->weld_entry("author")) + , m_xLanguage(m_xBuilder->weld_entry("language")) + , m_xDate(m_xBuilder->weld_entry("date")) + { - get(m_pVersion, "versionlb"); - assert(PositionToVersion(m_pVersion->GetSelectedEntryPos()) == EPUBExportFilter::GetDefaultVersion()); + assert(PositionToVersion(m_xVersion->get_active()) == EPUBExportFilter::GetDefaultVersion()); auto it = rFilterData.find("EPUBVersion"); if (it != rFilterData.end()) { sal_Int32 nVersion = 0; if (it->second >>= nVersion) - m_pVersion->SelectEntryPos(VersionToPosition(nVersion)); + m_xVersion->set_active(VersionToPosition(nVersion)); } - m_pVersion->SetSelectHdl(LINK(this, EPUBExportDialog, VersionSelectHdl)); + m_xVersion->connect_changed(LINK(this, EPUBExportDialog, VersionSelectHdl)); - get(m_pSplit, "splitlb"); it = rFilterData.find("EPUBSplitMethod"); if (it != rFilterData.end()) { @@ -96,13 +108,12 @@ EPUBExportDialog::EPUBExportDialog(vcl::Window *pParent, comphelper::SequenceAsH if (it->second >>= nSplitMethod) // No conversion, 1:1 mapping between libepubgen::EPUBSplitMethod // and entry positions. - m_pSplit->SelectEntryPos(nSplitMethod); + m_xSplit->set_active(nSplitMethod); } else - m_pSplit->SelectEntryPos(EPUBExportFilter::GetDefaultSplitMethod()); - m_pSplit->SetSelectHdl(LINK(this, EPUBExportDialog, SplitSelectHdl)); + m_xSplit->set_active(EPUBExportFilter::GetDefaultSplitMethod()); + m_xSplit->connect_changed(LINK(this, EPUBExportDialog, SplitSelectHdl)); - get(m_pLayout, "layoutlb"); it = rFilterData.find("EPUBLayoutMethod"); if (it != rFilterData.end()) { @@ -110,137 +121,105 @@ EPUBExportDialog::EPUBExportDialog(vcl::Window *pParent, comphelper::SequenceAsH if (it->second >>= nLayoutMethod) // No conversion, 1:1 mapping between libepubgen::EPUBLayoutMethod // and entry positions. - m_pLayout->SelectEntryPos(nLayoutMethod); + m_xLayout->set_active(nLayoutMethod); } else - m_pLayout->SelectEntryPos(EPUBExportFilter::GetDefaultLayoutMethod()); - m_pLayout->SetSelectHdl(LINK(this, EPUBExportDialog, LayoutSelectHdl)); - - get(m_pCoverPath, "coverpath"); - - get(m_pCoverButton, "coverbutton"); - m_pCoverButton->SetClickHdl(LINK(this, EPUBExportDialog, CoverClickHdl)); - - get(m_pMediaDir, "mediadir"); + m_xLayout->set_active(EPUBExportFilter::GetDefaultLayoutMethod()); + m_xLayout->connect_changed(LINK(this, EPUBExportDialog, LayoutSelectHdl)); - get(m_pMediaButton, "mediabutton"); - m_pMediaButton->SetClickHdl(LINK(this, EPUBExportDialog, MediaClickHdl)); + m_xCoverButton->connect_clicked(LINK(this, EPUBExportDialog, CoverClickHdl)); - get(m_pIdentifier, "identifier"); + m_xMediaButton->connect_clicked(LINK(this, EPUBExportDialog, MediaClickHdl)); - get(m_pTitle, "title"); - uno::Reference<document::XDocumentPropertiesSupplier> xDPS(mxSourceDocument, uno::UNO_QUERY); + uno::Reference<document::XDocumentPropertiesSupplier> xDPS(m_xSourceDocument, uno::UNO_QUERY); uno::Reference<document::XDocumentProperties> xDP; if (xDPS.is()) xDP = xDPS->getDocumentProperties(); if (xDP.is()) - m_pTitle->SetText(xDP->getTitle()); + m_xTitle->set_text(xDP->getTitle()); - get(m_pInitialCreator, "author"); if (xDP.is()) - m_pInitialCreator->SetText(xDP->getAuthor()); + m_xInitialCreator->set_text(xDP->getAuthor()); - get(m_pLanguage, "language"); if (xDP.is()) { OUString aLanguage(LanguageTag::convertToBcp47(xDP->getLanguage(), false)); - m_pLanguage->SetText(aLanguage); + m_xLanguage->set_text(aLanguage); } - get(m_pDate, "date"); if (xDP.is()) { OUStringBuffer aBuffer; util::DateTime aDate(xDP->getModificationDate()); sax::Converter::convertDateTime(aBuffer, aDate, nullptr, true); - m_pDate->SetText(aBuffer.makeStringAndClear()); + m_xDate->set_text(aBuffer.makeStringAndClear()); } - get(m_pOKButton, "ok"); - m_pOKButton->SetClickHdl(LINK(this, EPUBExportDialog, OKClickHdl)); + m_xOKButton->connect_clicked(LINK(this, EPUBExportDialog, OKClickHdl)); } -IMPL_LINK_NOARG(EPUBExportDialog, VersionSelectHdl, ListBox &, void) +IMPL_LINK_NOARG(EPUBExportDialog, VersionSelectHdl, weld::ComboBoxText &, void) { - mrFilterData["EPUBVersion"] <<= PositionToVersion(m_pVersion->GetSelectedEntryPos()); + m_rFilterData["EPUBVersion"] <<= PositionToVersion(m_xVersion->get_active()); } -IMPL_LINK_NOARG(EPUBExportDialog, SplitSelectHdl, ListBox &, void) +IMPL_LINK_NOARG(EPUBExportDialog, SplitSelectHdl, weld::ComboBoxText &, void) { // No conversion, 1:1 mapping between entry positions and // libepubgen::EPUBSplitMethod. - mrFilterData["EPUBSplitMethod"] <<= m_pSplit->GetSelectedEntryPos(); + m_rFilterData["EPUBSplitMethod"] <<= static_cast<sal_Int32>(m_xSplit->get_active()); } -IMPL_LINK_NOARG(EPUBExportDialog, LayoutSelectHdl, ListBox &, void) +IMPL_LINK_NOARG(EPUBExportDialog, LayoutSelectHdl, weld::ComboBoxText &, void) { // No conversion, 1:1 mapping between entry positions and // libepubgen::EPUBLayoutMethod. - mrFilterData["EPUBLayoutMethod"] <<= m_pLayout->GetSelectedEntryPos(); - m_pSplit->Enable(m_pLayout->GetSelectedEntryPos() != libepubgen::EPUB_LAYOUT_METHOD_FIXED); + m_rFilterData["EPUBLayoutMethod"] <<= static_cast<sal_Int32>(m_xLayout->get_active()); + m_xSplit->set_sensitive(m_xLayout->get_active() != libepubgen::EPUB_LAYOUT_METHOD_FIXED); } -IMPL_LINK_NOARG(EPUBExportDialog, CoverClickHdl, Button *, void) +IMPL_LINK_NOARG(EPUBExportDialog, CoverClickHdl, weld::Button &, void) { - SvxOpenGraphicDialog aDlg("Import", GetFrameWeld()); + SvxOpenGraphicDialog aDlg("Import", m_xDialog.get()); aDlg.EnableLink(false); if (aDlg.Execute() == ERRCODE_NONE) - m_pCoverPath->SetText(aDlg.GetPath()); + m_xCoverPath->set_text(aDlg.GetPath()); } -IMPL_LINK_NOARG(EPUBExportDialog, MediaClickHdl, Button *, void) +IMPL_LINK_NOARG(EPUBExportDialog, MediaClickHdl, weld::Button &, void) { - uno::Reference<ui::dialogs::XFolderPicker2> xFolderPicker = ui::dialogs::FolderPicker::create(mxContext); + uno::Reference<ui::dialogs::XFolderPicker2> xFolderPicker = ui::dialogs::FolderPicker::create(m_xContext); if (xFolderPicker->execute() != ui::dialogs::ExecutableDialogResults::OK) return; - m_pMediaDir->SetText(xFolderPicker->getDirectory()); + m_xMediaDir->set_text(xFolderPicker->getDirectory()); } -IMPL_LINK_NOARG(EPUBExportDialog, OKClickHdl, Button *, void) +IMPL_LINK_NOARG(EPUBExportDialog, OKClickHdl, weld::Button &, void) { // General - if (!m_pCoverPath->GetText().isEmpty()) - mrFilterData["RVNGCoverImage"] <<= m_pCoverPath->GetText(); - if (!m_pMediaDir->GetText().isEmpty()) - mrFilterData["RVNGMediaDir"] <<= m_pMediaDir->GetText(); + if (!m_xCoverPath->get_text().isEmpty()) + m_rFilterData["RVNGCoverImage"] <<= m_xCoverPath->get_text(); + if (!m_xMediaDir->get_text().isEmpty()) + m_rFilterData["RVNGMediaDir"] <<= m_xMediaDir->get_text(); // 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); + if (!m_xIdentifier->get_text().isEmpty()) + m_rFilterData["RVNGIdentifier"] <<= m_xIdentifier->get_text(); + if (!m_xTitle->get_text().isEmpty()) + m_rFilterData["RVNGTitle"] <<= m_xTitle->get_text(); + if (!m_xInitialCreator->get_text().isEmpty()) + m_rFilterData["RVNGInitialCreator"] <<= m_xInitialCreator->get_text(); + if (!m_xLanguage->get_text().isEmpty()) + m_rFilterData["RVNGLanguage"] <<= m_xLanguage->get_text(); + if (!m_xDate->get_text().isEmpty()) + m_rFilterData["RVNGDate"] <<= m_xDate->get_text(); + + m_xDialog->response(RET_OK); } EPUBExportDialog::~EPUBExportDialog() { - disposeOnce(); -} - -void EPUBExportDialog::dispose() -{ - m_pVersion.clear(); - m_pSplit.clear(); - m_pCoverPath.clear(); - m_pCoverButton.clear(); - m_pOKButton.clear(); - m_pIdentifier.clear(); - m_pTitle.clear(); - m_pInitialCreator.clear(); - m_pLanguage.clear(); - m_pDate.clear(); - m_pMediaDir.clear(); - m_pMediaButton.clear(); - m_pLayout.clear(); - ModalDialog::dispose(); } } // namespace writerperfect diff --git a/writerperfect/source/writer/EPUBExportDialog.hxx b/writerperfect/source/writer/EPUBExportDialog.hxx index ab90c48ee04c..51326c1ae1f6 100644 --- a/writerperfect/source/writer/EPUBExportDialog.hxx +++ b/writerperfect/source/writer/EPUBExportDialog.hxx @@ -10,10 +10,7 @@ #ifndef INCLUDED_WRITERPERFECT_SOURCE_WRITER_EPUBEXPORTDIALOG_HXX #define INCLUDED_WRITERPERFECT_SOURCE_WRITER_EPUBEXPORTDIALOG_HXX -#include <vcl/button.hxx> -#include <vcl/dialog.hxx> -#include <vcl/edit.hxx> -#include <vcl/lstbox.hxx> +#include <vcl/weld.hxx> namespace comphelper { @@ -24,37 +21,37 @@ namespace writerperfect { /// EPUB export options dialog. -class EPUBExportDialog : public ModalDialog +class EPUBExportDialog : public weld::GenericDialogController { public: - EPUBExportDialog(vcl::Window *pParent, comphelper::SequenceAsHashMap &rFilterData, css::uno::Reference<css::uno::XComponentContext> xContext, css::uno::Reference<css::lang::XComponent> xDocument); + EPUBExportDialog(weld::Window *pParent, comphelper::SequenceAsHashMap &rFilterData, css::uno::Reference<css::uno::XComponentContext> xContext, css::uno::Reference<css::lang::XComponent> xDocument); ~EPUBExportDialog() override; - void dispose() override; private: - DECL_LINK(VersionSelectHdl, ListBox &, void); - DECL_LINK(SplitSelectHdl, ListBox &, void); - DECL_LINK(LayoutSelectHdl, 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; - css::uno::Reference<css::lang::XComponent> mxSourceDocument; - VclPtr<ListBox> m_pVersion; - VclPtr<ListBox> m_pSplit; - VclPtr<ListBox> m_pLayout; - 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; - VclPtr<Edit> m_pInitialCreator; - VclPtr<Edit> m_pLanguage; - VclPtr<Edit> m_pDate; + DECL_LINK(VersionSelectHdl, weld::ComboBoxText &, void); + DECL_LINK(SplitSelectHdl, weld::ComboBoxText &, void); + DECL_LINK(LayoutSelectHdl, weld::ComboBoxText &, void); + DECL_LINK(CoverClickHdl, weld::Button &, void); + DECL_LINK(MediaClickHdl, weld::Button &, void); + DECL_LINK(OKClickHdl, weld::Button &, void); + + css::uno::Reference<css::uno::XComponentContext> m_xContext; + comphelper::SequenceAsHashMap &m_rFilterData; + css::uno::Reference<css::lang::XComponent> m_xSourceDocument; + + std::unique_ptr<weld::ComboBoxText> m_xVersion; + std::unique_ptr<weld::ComboBoxText> m_xSplit; + std::unique_ptr<weld::ComboBoxText> m_xLayout; + std::unique_ptr<weld::Entry> m_xCoverPath; + std::unique_ptr<weld::Button> m_xCoverButton; + std::unique_ptr<weld::Entry> m_xMediaDir; + std::unique_ptr<weld::Button> m_xMediaButton; + std::unique_ptr<weld::Button> m_xOKButton; + std::unique_ptr<weld::Entry> m_xIdentifier; + std::unique_ptr<weld::Entry> m_xTitle; + std::unique_ptr<weld::Entry> m_xInitialCreator; + std::unique_ptr<weld::Entry> m_xLanguage; + std::unique_ptr<weld::Entry> m_xDate; }; } // namespace writerperfect diff --git a/writerperfect/source/writer/EPUBExportUIComponent.cxx b/writerperfect/source/writer/EPUBExportUIComponent.cxx index 4df8ea4a1946..abf533f7f19a 100644 --- a/writerperfect/source/writer/EPUBExportUIComponent.cxx +++ b/writerperfect/source/writer/EPUBExportUIComponent.cxx @@ -10,7 +10,7 @@ #include "EPUBExportUIComponent.hxx" #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> - +#include <comphelper/namedvaluecollection.hxx> #include <cppuhelper/supportsservice.hxx> #include <vcl/svapp.hxx> #include <vcl/vclptr.hxx> @@ -72,12 +72,19 @@ void EPUBExportUIComponent::setTitle(const OUString &/*rTitle*/) { } +void SAL_CALL EPUBExportUIComponent::initialize(const uno::Sequence<uno::Any>& rArguments) +{ + ::comphelper::NamedValueCollection aProperties(rArguments); + if (aProperties.has("ParentWindow")) + aProperties.get("ParentWindow") >>= mxDialogParent; +} + sal_Int16 EPUBExportUIComponent::execute() { SolarMutexGuard aGuard; - ScopedVclPtrInstance<EPUBExportDialog> pDialog(Application::GetDefDialogParent(), maFilterData, mxContext, mxSourceDocument); - if (pDialog->Execute() == RET_OK) + EPUBExportDialog aDialog(Application::GetFrameWeld(mxDialogParent), maFilterData, mxContext, mxSourceDocument); + if (aDialog.run() == 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 865571dde97b..f2288a91ad76 100644 --- a/writerperfect/source/writer/EPUBExportUIComponent.hxx +++ b/writerperfect/source/writer/EPUBExportUIComponent.hxx @@ -10,8 +10,10 @@ #ifndef INCLUDED_WRITERPERFECT_SOURCE_WRITER_EPUBEXPORTUICOMPONENT_HXX #define INCLUDED_WRITERPERFECT_SOURCE_WRITER_EPUBEXPORTUICOMPONENT_HXX +#include <com/sun/star/awt/XWindow.hpp> #include <com/sun/star/beans/XPropertyAccess.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/document/XExporter.hpp> @@ -26,6 +28,7 @@ namespace writerperfect class EPUBExportUIComponent : public cppu::WeakImplHelper < css::beans::XPropertyAccess, + css::lang::XInitialization, css::lang::XServiceInfo, css::ui::dialogs::XExecutableDialog, css::document::XExporter @@ -50,6 +53,9 @@ public: // XExporter void SAL_CALL setSourceDocument(const css::uno::Reference<css::lang::XComponent> &xDocument) override; + // XInitialization + void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& rArguments) override; + private: /// The full set of property values. comphelper::SequenceAsHashMap maMediaDescriptor; @@ -58,6 +64,7 @@ private: /// UNO context. css::uno::Reference<css::uno::XComponentContext> mxContext; css::uno::Reference<css::lang::XComponent> mxSourceDocument; + css::uno::Reference<css::awt::XWindow> mxDialogParent; }; } // namespace writerperfect |