diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-01-18 18:04:45 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-01-19 09:13:06 +0100 |
commit | 9bca3cc18655d02f3c111d692b26339a6e3669d4 (patch) | |
tree | a87c3a08a2a559af8125c5d74ceffa8f2af0ff67 /writerperfect | |
parent | 9035ee7c90ed5ff78864145fd92241491033c074 (diff) |
EPUB export UI: show title from the doc model
It was a bit confusing that the doc model had a title set, it was
written to the EPUB file but the UI did not show it.
Change-Id: Ife408e0dabd3fe48e8acc1f09be0c86f78ed4b80
Reviewed-on: https://gerrit.libreoffice.org/48150
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'writerperfect')
5 files changed, 28 insertions, 6 deletions
diff --git a/writerperfect/source/writer/EPUBExportDialog.cxx b/writerperfect/source/writer/EPUBExportDialog.cxx index 2add78c6389f..09ab58499a26 100644 --- a/writerperfect/source/writer/EPUBExportDialog.cxx +++ b/writerperfect/source/writer/EPUBExportDialog.cxx @@ -13,6 +13,7 @@ #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> #include <com/sun/star/ui/dialogs/FolderPicker.hpp> +#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <comphelper/sequenceashashmap.hxx> #include <sfx2/opengrf.hxx> @@ -68,10 +69,11 @@ sal_Int32 PositionToVersion(sal_Int32 nPosition) namespace writerperfect { -EPUBExportDialog::EPUBExportDialog(vcl::Window *pParent, comphelper::SequenceAsHashMap &rFilterData, uno::Reference<uno::XComponentContext> xContext) +EPUBExportDialog::EPUBExportDialog(vcl::Window *pParent, comphelper::SequenceAsHashMap &rFilterData, uno::Reference<uno::XComponentContext> xContext, const css::uno::Reference<css::lang::XComponent> &xDocument) : ModalDialog(pParent, "EpubDialog", "writerperfect/ui/exportepub.ui"), mxContext(std::move(xContext)), - mrFilterData(rFilterData) + mrFilterData(rFilterData), + mxSourceDocument(xDocument) { get(m_pVersion, "versionlb"); assert(PositionToVersion(m_pVersion->GetSelectedEntryPos()) == EPUBExportFilter::GetDefaultVersion()); @@ -124,7 +126,15 @@ EPUBExportDialog::EPUBExportDialog(vcl::Window *pParent, comphelper::SequenceAsH m_pMediaButton->SetClickHdl(LINK(this, EPUBExportDialog, MediaClickHdl)); get(m_pIdentifier, "identifier"); + get(m_pTitle, "title"); + uno::Reference<document::XDocumentPropertiesSupplier> xDPS(mxSourceDocument, uno::UNO_QUERY); + uno::Reference<document::XDocumentProperties> xDP; + if (xDPS.is()) + xDP = xDPS->getDocumentProperties(); + if (xDP.is()) + m_pTitle->SetText(xDP->getTitle()); + get(m_pInitialCreator, "author"); get(m_pLanguage, "language"); get(m_pDate, "date"); diff --git a/writerperfect/source/writer/EPUBExportDialog.hxx b/writerperfect/source/writer/EPUBExportDialog.hxx index 8180e4a24366..7d7f016b1a18 100644 --- a/writerperfect/source/writer/EPUBExportDialog.hxx +++ b/writerperfect/source/writer/EPUBExportDialog.hxx @@ -27,7 +27,7 @@ namespace writerperfect class EPUBExportDialog : public ModalDialog { public: - EPUBExportDialog(vcl::Window *pParent, comphelper::SequenceAsHashMap &rFilterData, css::uno::Reference<css::uno::XComponentContext> xContext); + EPUBExportDialog(vcl::Window *pParent, comphelper::SequenceAsHashMap &rFilterData, css::uno::Reference<css::uno::XComponentContext> xContext, const css::uno::Reference<css::lang::XComponent> &xDocument); ~EPUBExportDialog() override; void dispose() override; @@ -41,6 +41,7 @@ private: 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; diff --git a/writerperfect/source/writer/EPUBExportUIComponent.cxx b/writerperfect/source/writer/EPUBExportUIComponent.cxx index 66d8506fa771..4df8ea4a1946 100644 --- a/writerperfect/source/writer/EPUBExportUIComponent.cxx +++ b/writerperfect/source/writer/EPUBExportUIComponent.cxx @@ -76,12 +76,17 @@ sal_Int16 EPUBExportUIComponent::execute() { SolarMutexGuard aGuard; - ScopedVclPtrInstance<EPUBExportDialog> pDialog(Application::GetDefDialogParent(), maFilterData, mxContext); + ScopedVclPtrInstance<EPUBExportDialog> pDialog(Application::GetDefDialogParent(), maFilterData, mxContext, mxSourceDocument); if (pDialog->Execute() == RET_OK) return ui::dialogs::ExecutableDialogResults::OK; return ui::dialogs::ExecutableDialogResults::CANCEL; } +void SAL_CALL EPUBExportUIComponent::setSourceDocument(const css::uno::Reference<css::lang::XComponent> &xDocument) +{ + mxSourceDocument = xDocument; +} + extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface *com_sun_star_comp_Writer_EPUBExportUIComponent_get_implementation(uno::XComponentContext *pCtx, uno::Sequence<uno::Any> const &/*rSeq*/) { return cppu::acquire(new EPUBExportUIComponent(pCtx)); diff --git a/writerperfect/source/writer/EPUBExportUIComponent.hxx b/writerperfect/source/writer/EPUBExportUIComponent.hxx index 3ef6d7cc1b2f..865571dde97b 100644 --- a/writerperfect/source/writer/EPUBExportUIComponent.hxx +++ b/writerperfect/source/writer/EPUBExportUIComponent.hxx @@ -14,6 +14,7 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> #include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/document/XExporter.hpp> #include <comphelper/sequenceashashmap.hxx> #include <cppuhelper/implbase.hxx> @@ -26,7 +27,8 @@ class EPUBExportUIComponent : public cppu::WeakImplHelper < css::beans::XPropertyAccess, css::lang::XServiceInfo, - css::ui::dialogs::XExecutableDialog + css::ui::dialogs::XExecutableDialog, + css::document::XExporter > { public: @@ -45,6 +47,9 @@ public: void SAL_CALL setTitle(const OUString &rTitle) override; sal_Int16 SAL_CALL execute() override; + // XExporter + void SAL_CALL setSourceDocument(const css::uno::Reference<css::lang::XComponent> &xDocument) override; + private: /// The full set of property values. comphelper::SequenceAsHashMap maMediaDescriptor; @@ -52,6 +57,7 @@ private: comphelper::SequenceAsHashMap maFilterData; /// UNO context. css::uno::Reference<css::uno::XComponentContext> mxContext; + css::uno::Reference<css::lang::XComponent> mxSourceDocument; }; } // namespace writerperfect diff --git a/writerperfect/source/writer/exp/xmlimp.cxx b/writerperfect/source/writer/exp/xmlimp.cxx index f001bd667e5a..ef681119d4cf 100644 --- a/writerperfect/source/writer/exp/xmlimp.cxx +++ b/writerperfect/source/writer/exp/xmlimp.cxx @@ -370,7 +370,7 @@ const librevenge::RVNGPropertyList &XMLImport::GetMetaData() namespace { /// Finds out if a file URL exists. -bool FileURLExists(const OUString& rURL) +bool FileURLExists(const OUString &rURL) { SvFileStream aStream(rURL, StreamMode::READ); return aStream.IsOpen(); |