diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-11-30 16:34:05 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-12-01 09:17:22 +0100 |
commit | 7f0641de763d2fd425c80f630f3ae6bcde778e7a (patch) | |
tree | 441c90c06805f1114de9b190eb748029c1010e77 /writerperfect/source | |
parent | 7dcb4fef3b2383f4dd4d5d5c9ebbe8f19f8f4c8e (diff) |
EPUB export: allow setting custom media dir explicitly
The default is the same <base directory>/<base name>/ as before.
Change-Id: Idb500193a7f6bd901d861e857147832a3ada91d3
Reviewed-on: https://gerrit.libreoffice.org/45602
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'writerperfect/source')
-rw-r--r-- | writerperfect/source/writer/exp/xmlimp.cxx | 44 | ||||
-rw-r--r-- | writerperfect/source/writer/exp/xmlimp.hxx | 1 |
2 files changed, 35 insertions, 10 deletions
diff --git a/writerperfect/source/writer/exp/xmlimp.cxx b/writerperfect/source/writer/exp/xmlimp.cxx index fdbc1d398243..f933487a59b8 100644 --- a/writerperfect/source/writer/exp/xmlimp.cxx +++ b/writerperfect/source/writer/exp/xmlimp.cxx @@ -113,6 +113,37 @@ OUString FindCoverImage(const OUString &rDocumentBaseURL, OUString &rMimeType, c return aRet; } +/// Determines the base directory for cover images, XMP metadata, popup images. +OUString FindMediaDir(const OUString &rDocumentBaseURL, const uno::Sequence<beans::PropertyValue> &rFilterData) +{ + OUString aMediaDir; + + // See if filter data contains a media directory explicitly. + for (sal_Int32 i = 0; i < rFilterData.getLength(); ++i) + { + if (rFilterData[i].Name == "RVNGMediaDir") + { + rFilterData[i].Value >>= aMediaDir; + break; + } + } + + if (!aMediaDir.isEmpty()) + return aMediaDir + "/"; + + // Not set explicitly, try to pick it up from the base directory. + INetURLObject aURL(rDocumentBaseURL); + try + { + aMediaDir = rtl::Uri::convertRelToAbs(rDocumentBaseURL, aURL.GetBase()) + "/"; + } + catch (const rtl::MalformedUriException &rException) + { + SAL_WARN("writerperfect", "FindMediaDir: convertRelToAbs() failed:" << rException.getMessage()); + } + return aMediaDir; +} + /// Picks up XMP metadata from the base directory. void FindXMPMetadata(const uno::Reference<uno::XComponentContext> &xContext, const OUString &rDocumentBaseURL, const uno::Sequence<beans::PropertyValue> &rFilterData, librevenge::RVNGPropertyList &rMetaData) { @@ -256,6 +287,8 @@ XMLImport::XMLImport(const uno::Reference<uno::XComponentContext> &xContext, lib } } + maMediaDir = FindMediaDir(rURL, aFilterData); + OUString aMimeType; OUString aCoverImage = FindCoverImage(rURL, aMimeType, aFilterData); if (!aCoverImage.isEmpty()) @@ -303,16 +336,7 @@ bool XMLImport::FillPopupData(const OUString &rURL, librevenge::RVNGPropertyList if (!bRelative) return false; - OUString aAbs; - INetURLObject aBaseURL(maDocumentBaseURL); - try - { - aAbs = rtl::Uri::convertRelToAbs(maDocumentBaseURL, aBaseURL.GetBase() + "/" + rURL); - } - catch (const rtl::MalformedUriException &rException) - { - SAL_WARN("writerperfect", "XMLImport::FillPopupData: convertRelToAbs() failed:" << rException.getMessage()); - } + OUString aAbs = maMediaDir + rURL; if (aAbs.isEmpty()) return false; diff --git a/writerperfect/source/writer/exp/xmlimp.hxx b/writerperfect/source/writer/exp/xmlimp.hxx index 7b517cbe1325..0777e71953a4 100644 --- a/writerperfect/source/writer/exp/xmlimp.hxx +++ b/writerperfect/source/writer/exp/xmlimp.hxx @@ -58,6 +58,7 @@ class XMLImport : public cppu::WeakImplHelper const css::uno::Reference<css::uno::XComponentContext> &mxContext; css::uno::Reference<css::uri::XUriReferenceFactory> mxUriReferenceFactory; OUString maDocumentBaseURL; + OUString maMediaDir; public: XMLImport(const css::uno::Reference<css::uno::XComponentContext> &xContext, librevenge::RVNGTextInterface &rGenerator, const OUString &rURL, const css::uno::Sequence<css::beans::PropertyValue> &rDescriptor); |