Kaydet (Commit) 6bacfc8d authored tarafından Miklos Vajna's avatar Miklos Vajna

tdf#95707 RTF import: handle device-independent bitmaps

See
<https://msdn.microsoft.com/en-us/library/dd183374%28v=vs.85%29.aspx>
for more info about the header structure that has to be prepended to the
real data to make our BMP import filter happy.

Change-Id: Iabdf4cd169b82ea951d1c1b12432d97d61b7af51
Reviewed-on: https://gerrit.libreoffice.org/24604Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst 79acc3da
This diff is collapsed.
......@@ -2584,6 +2584,12 @@ DECLARE_RTFIMPORT_TEST(testTdf90097, "tdf90097.rtf")
}
#endif
DECLARE_RTFIMPORT_TEST(testTdf95707, "tdf95707.rtf")
{
// Graphic was replaced with a "Read-Error" placeholder.
CPPUNIT_ASSERT(getProperty<OUString>(getShape(1), "GraphicURL") != "vnd.sun.star.GraphicObject:0000000000000000000000000000000000000000");
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -790,6 +790,24 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS
// No destination text? Then we'll get it later.
return;
SvMemoryStream aDIBStream;
if (m_aStates.top().aPicture.eStyle == RTFBmpStyle::DIBITMAP)
{
// Construct a BITMAPFILEHEADER structure before the real data.
SvStream& rBodyStream = *pStream;
aDIBStream.WriteChar('B');
aDIBStream.WriteChar('M');
// The size of the real data.
aDIBStream.WriteUInt32(rBodyStream.Tell());
// Reserved.
aDIBStream.WriteUInt32(0);
// The offset of the real data, i.e. the size of the header, including this number.
aDIBStream.WriteUInt32(14);
rBodyStream.Seek(0);
aDIBStream.WriteStream(rBodyStream);
pStream = &aDIBStream;
}
// Store, and get its URL.
pStream->Seek(0);
uno::Reference<io::XInputStream> xInputStream(new utl::OInputStreamWrapper(pStream));
......@@ -4871,6 +4889,9 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
}
}
break;
case RTF_DIBITMAP:
m_aStates.top().aPicture.eStyle = RTFBmpStyle::DIBITMAP;
break;
default:
{
SAL_INFO("writerfilter", "TODO handle value '" << lcl_RtfToString(nKeyword) << "'");
......
......@@ -73,7 +73,8 @@ enum class RTFBmpStyle
{
NONE,
PNG,
JPEG
JPEG,
DIBITMAP
};
enum class RTFFieldStatus
......
......@@ -330,8 +330,8 @@ RTFError RTFTokenizer::dispatchKeyword(OString& rKeyword, bool bParam, int nPara
return ret;
break;
case CONTROL_VALUE:
// values require a parameter by definition
if (bParam)
// Values require a parameter by definition, but Word doesn't respect this for \dibitmap.
if (bParam || s_m_aRTFControlWords[i].nIndex == RTF_DIBITMAP)
{
ret = m_rImport.dispatchValue(s_m_aRTFControlWords[i].nIndex, nParam);
if (ret != RTFError::OK)
......
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