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

sw XHTML export: fix missing type attribute for fallback image

This was working in OutHTML_FrameFormatGrfNode(), but not in
OutHTML_FrameFormatOLENodeGrf().

Change-Id: I4f8e280713cad2a00cad5da65a09afc5a36d40d0
Reviewed-on: https://gerrit.libreoffice.org/51571Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst 67a023ef
...@@ -406,6 +406,18 @@ DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testReqIfOleImg, "reqif-ole-img.xhtml") ...@@ -406,6 +406,18 @@ DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testReqIfOleImg, "reqif-ole-img.xhtml")
// Check alternate text (it was empty, for export the 'alt' attribute was used). // Check alternate text (it was empty, for export the 'alt' attribute was used).
CPPUNIT_ASSERT_EQUAL(OUString("OLE Object"), getProperty<OUString>(xObject, "Title").trim()); CPPUNIT_ASSERT_EQUAL(OUString("OLE Object"), getProperty<OUString>(xObject, "Title").trim());
if (!mbExported)
return;
// "type" attribute was missing for the inner <object> element.
SvStream* pStream = maTempFile.GetStream(StreamMode::READ);
CPPUNIT_ASSERT(pStream);
pStream->Seek(STREAM_SEEK_TO_END);
sal_uInt64 nLength = pStream->Tell();
pStream->Seek(0);
OString aStream(read_uInt8s_ToOString(*pStream, nLength));
CPPUNIT_ASSERT(aStream.indexOf("type=\"image/png\"") != -1);
} }
DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testReqIfPngImg, "reqif-png-img.xhtml") DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testReqIfPngImg, "reqif-png-img.xhtml")
......
...@@ -1448,16 +1448,26 @@ Writer& OutHTML_FrameFormatOLENodeGrf( Writer& rWrt, const SwFrameFormat& rFrame ...@@ -1448,16 +1448,26 @@ Writer& OutHTML_FrameFormatOLENodeGrf( Writer& rWrt, const SwFrameFormat& rFrame
} }
OUString aGraphicURL; OUString aGraphicURL;
OUString aMimeType;
if(!rHTMLWrt.mbEmbedImages) if(!rHTMLWrt.mbEmbedImages)
{ {
const OUString* pTempFileName = rHTMLWrt.GetOrigFileName(); const OUString* pTempFileName = rHTMLWrt.GetOrigFileName();
if(pTempFileName) if(pTempFileName)
aGraphicURL = *pTempFileName; aGraphicURL = *pTempFileName;
OUString aFilterName("JPG");
XOutFlags nFlags = XOutFlags::UseGifIfPossible | XOutFlags::UseNativeIfPossible;
if (bObjectOpened)
{
aFilterName = "PNG";
nFlags = XOutFlags::NONE;
aMimeType = "image/png";
}
ErrCode nErr = XOutBitmap::WriteGraphic( aGraphic, aGraphicURL, ErrCode nErr = XOutBitmap::WriteGraphic( aGraphic, aGraphicURL,
"JPG", aFilterName,
(XOutFlags::UseGifIfPossible | nFlags );
XOutFlags::UseNativeIfPossible) );
if( nErr ) // error, don't write anything if( nErr ) // error, don't write anything
{ {
rHTMLWrt.m_nWarn = WARN_SWG_POOR_LOAD; rHTMLWrt.m_nWarn = WARN_SWG_POOR_LOAD;
...@@ -1474,7 +1484,7 @@ Writer& OutHTML_FrameFormatOLENodeGrf( Writer& rWrt, const SwFrameFormat& rFrame ...@@ -1474,7 +1484,7 @@ Writer& OutHTML_FrameFormatOLENodeGrf( Writer& rWrt, const SwFrameFormat& rFrame
nFlags |= HtmlFrmOpts::Replacement; nFlags |= HtmlFrmOpts::Replacement;
OutHTML_Image( rWrt, rFrameFormat, aGraphicURL, aGraphic, OutHTML_Image( rWrt, rFrameFormat, aGraphicURL, aGraphic,
pOLENd->GetTitle(), pOLENd->GetTwipSize(), pOLENd->GetTitle(), pOLENd->GetTwipSize(),
nFlags, "ole" ); nFlags, "ole", nullptr, aMimeType );
if (bObjectOpened) if (bObjectOpened)
// Close native data. // Close native data.
......
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