Kaydet (Commit) f7c8774b authored tarafından Vasily Melenchuk's avatar Vasily Melenchuk Kaydeden (comit) Thorsten Behrens

tdf#39960 fix saving of GIF images into RTF

Currently in case of RTF export LO converts all unknown graphic into WMF. And some images due to zero prefSize
produce invalid WMF of zero dimensions.

As a workaround for current case we do not convert GIF images to WMF, PNG format looks better here. The code can
be extended to provide suitable converters for other formats.

Change-Id: I0c98111a4496250874aa4f664dd2f70134c1bdd1
Reviewed-on: https://gerrit.libreoffice.org/19581Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
üst 70a50e83
...@@ -3837,6 +3837,9 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrameFormat* pFlyFrameFormat ...@@ -3837,6 +3837,9 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrameFormat* pFlyFrameFormat
if (rGraphic.GetType()==GRAPHIC_NONE) if (rGraphic.GetType()==GRAPHIC_NONE)
return; return;
ConvertDataFormat pConvertDestinationFormat = ConvertDataFormat::WMF;
const sal_Char* pConvertDestinationBLIPType = OOO_STRING_SVTOOLS_RTF_WMETAFILE;
GfxLink aGraphicLink; GfxLink aGraphicLink;
const sal_Char* pBLIPType = 0; const sal_Char* pBLIPType = 0;
if (rGraphic.IsLink()) if (rGraphic.IsLink())
...@@ -3869,6 +3872,11 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrameFormat* pFlyFrameFormat ...@@ -3869,6 +3872,11 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrameFormat* pFlyFrameFormat
pBLIPType = pBLIPType =
IsEMF(pGraphicAry, nSize) ? OOO_STRING_SVTOOLS_RTF_EMFBLIP : OOO_STRING_SVTOOLS_RTF_WMETAFILE; IsEMF(pGraphicAry, nSize) ? OOO_STRING_SVTOOLS_RTF_EMFBLIP : OOO_STRING_SVTOOLS_RTF_WMETAFILE;
break; break;
case GFX_LINK_TYPE_NATIVE_GIF:
// GIF is not supported by RTF, but we override default conversion to WMF, PNG seems fits better here.
pConvertDestinationFormat = ConvertDataFormat::PNG;
pConvertDestinationBLIPType = OOO_STRING_SVTOOLS_RTF_PNGBLIP;
break;
default: default:
break; break;
} }
...@@ -3977,9 +3985,9 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrameFormat* pFlyFrameFormat ...@@ -3977,9 +3985,9 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrameFormat* pFlyFrameFormat
else else
{ {
aStream.Seek(0); aStream.Seek(0);
if (GraphicConverter::Export(aStream, rGraphic, ConvertDataFormat::WMF) != ERRCODE_NONE) if (GraphicConverter::Export(aStream, rGraphic, pConvertDestinationFormat) != ERRCODE_NONE)
SAL_WARN("sw.rtf", "failed to export the graphic"); SAL_WARN("sw.rtf", "failed to export the graphic");
pBLIPType = OOO_STRING_SVTOOLS_RTF_WMETAFILE; pBLIPType = pConvertDestinationBLIPType;
aStream.Seek(STREAM_SEEK_TO_END); aStream.Seek(STREAM_SEEK_TO_END);
nSize = aStream.Tell(); nSize = aStream.Tell();
pGraphicAry = static_cast<sal_uInt8 const*>(aStream.GetData()); pGraphicAry = static_cast<sal_uInt8 const*>(aStream.GetData());
......
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