diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-01-18 11:49:45 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-01-19 09:07:45 +0100 |
commit | 5c4d5021000584ac541e4d0323586c4ff926173f (patch) | |
tree | 7116ade1f81d473579374e8d023576dbea47b086 /writerperfect/source/writer/exp/xmlimp.cxx | |
parent | cc2ee044d9fc34d112842ca6e4150567238c7e4f (diff) |
EPUB export: fix validation error on invalid relative links
It's valid to have a relative link that points nowhere in ODF, but the
same is not true for EPUB.
Change-Id: I7884032e277a0c53d0c513cea70dd2ee29ccd85c
Diffstat (limited to 'writerperfect/source/writer/exp/xmlimp.cxx')
-rw-r--r-- | writerperfect/source/writer/exp/xmlimp.cxx | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/writerperfect/source/writer/exp/xmlimp.cxx b/writerperfect/source/writer/exp/xmlimp.cxx index 811e604a3801..f600840be1d7 100644 --- a/writerperfect/source/writer/exp/xmlimp.cxx +++ b/writerperfect/source/writer/exp/xmlimp.cxx @@ -367,7 +367,7 @@ const librevenge::RVNGPropertyList &XMLImport::GetMetaData() return maMetaData; } -bool XMLImport::FillPopupData(const OUString &rURL, librevenge::RVNGPropertyList &rPropList) +PopupState XMLImport::FillPopupData(const OUString &rURL, librevenge::RVNGPropertyList &rPropList) { uno::Reference<uri::XUriReference> xUriRef; try @@ -378,32 +378,33 @@ bool XMLImport::FillPopupData(const OUString &rURL, librevenge::RVNGPropertyList { SAL_WARN("writerperfect", "XMLImport::FillPopupData: XUriReference::parse() failed:" << rException.Message); } - bool bRelative = false; + bool bAbsolute = true; if (xUriRef.is()) - bRelative = !xUriRef->isAbsolute(); - if (!bRelative) - return false; + bAbsolute = xUriRef->isAbsolute(); + if (bAbsolute) + return PopupState::NotConsumed; OUString aAbs = maMediaDir + rURL; if (aAbs.isEmpty()) - return false; + return PopupState::NotConsumed; SvFileStream aStream(aAbs, StreamMode::READ); - if (aStream.IsOpen()) - { - librevenge::RVNGBinaryData aBinaryData; - SvMemoryStream aMemoryStream; - aMemoryStream.WriteStream(aStream); - aBinaryData.append(static_cast<const unsigned char *>(aMemoryStream.GetBuffer()), aMemoryStream.GetSize()); - rPropList.insert("office:binary-data", aBinaryData); + if (!aStream.IsOpen()) + // Relative link, but points to non-existing file: don't emit that to + // librevenge, since it will be invalid anyway. + return PopupState::Ignore; - INetURLObject aAbsURL(aAbs); - OUString aMimeType = GetMimeType(aAbsURL.GetExtension()); - rPropList.insert("librevenge:mime-type", aMimeType.toUtf8().getStr()); - return true; - } + librevenge::RVNGBinaryData aBinaryData; + SvMemoryStream aMemoryStream; + aMemoryStream.WriteStream(aStream); + aBinaryData.append(static_cast<const unsigned char *>(aMemoryStream.GetBuffer()), aMemoryStream.GetSize()); + rPropList.insert("office:binary-data", aBinaryData); + + INetURLObject aAbsURL(aAbs); + OUString aMimeType = GetMimeType(aAbsURL.GetExtension()); + rPropList.insert("librevenge:mime-type", aMimeType.toUtf8().getStr()); - return false; + return PopupState::Consumed; } const std::vector<std::pair<uno::Sequence<sal_Int8>, Size>> &XMLImport::GetPageMetafiles() const |