Kaydet (Commit) f8288865 authored tarafından Ashod Nakashian's avatar Ashod Nakashian Kaydeden (comit) Caolán McNamara

oox: don't segfault when failing to open a custom fragment

Change-Id: Ie05d1feea2e930b117b3754c6e0db86bdb85bc61
Reviewed-on: https://gerrit.libreoffice.org/51681Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst f3e8d0fb
......@@ -1118,13 +1118,16 @@ void XmlFilterBase::exportCustomFragments()
addRelation(customFragmentTypes[j], customFragmentTargets[j]);
const OUString aFilename = customFragmentTargets[j];
Reference<XOutputStream> xOutStream = openOutputStream(aFilename);
xOutStream->writeBytes(customFragments[j]);
uno::Reference<XPropertySet> xProps(xOutStream, uno::UNO_QUERY);
if (xProps.is())
if (xOutStream.is())
{
const OUString aType = comphelper::OFOPXMLHelper::GetContentTypeByName(aContentTypes, aFilename);
const OUString aContentType = (aType.getLength() ? aType : OUString("application/octet-stream"));
xProps->setPropertyValue("MediaType", uno::makeAny(aContentType));
xOutStream->writeBytes(customFragments[j]);
uno::Reference<XPropertySet> xProps(xOutStream, uno::UNO_QUERY);
if (xProps.is())
{
const OUString aType = comphelper::OFOPXMLHelper::GetContentTypeByName(aContentTypes, aFilename);
const OUString aContentType = (aType.getLength() ? aType : OUString("application/octet-stream"));
xProps->setPropertyValue("MediaType", uno::makeAny(aContentType));
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment