summaryrefslogtreecommitdiff
path: root/sw/source/filter/html
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-03-30 09:24:26 +0300
committerAndras Timar <andras.timar@collabora.com>2023-04-27 23:18:16 +0200
commit4007e70143a277451424c6d56f771fb26a90d665 (patch)
treec1969fe407ccdeb01bf44f8f9a79fd3a6c5ace30 /sw/source/filter/html
parent4658f4233d65007a53aa351f4123ad278a5ac91b (diff)
sw reqif-xhtml export: fix export of transparent TIF
Since commit 22b50f1937de67e4ad9e692d6964aa5b8d33af7a (use libtiff for tiff import, 2022-05-21), transparent TIFs are imported correctly. As the result, reqif export started to output the transparent TIF images as GIFs, because XOutFlags::UseGifIfSensible handles case of transparency, and XOutFlags::UseNativeIfPossible didn't handle TIF. Additionally, the resulting mediatype was reported incorrectly: <reqif-xhtml:object data="[...].gif" type="image/tiff" ... > 1. Handle TIFs in XOutBitmap::WriteGraphic when XOutFlags::UseNativeIfPossible is specified. 2. Return the corrected mediatype from XOutBitmap::WriteGraphic, to inform the caller about the possible change. 3. Remove the XOutFlags::UseGifIfSensible flag when doing the reqif export, to avoid the format change at all. Change-Id: I99f7cfb8d12ef66d372700ec810bd8b269868ffd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149744 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149758 Tested-by: Mike Kaganski <mike.kaganski@collabora.com> (cherry picked from commit a222008d5452c2ace6779b38d06539d085bd3a66) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149755 Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source/filter/html')
-rw-r--r--sw/source/filter/html/htmlflywriter.cxx31
1 files changed, 19 insertions, 12 deletions
diff --git a/sw/source/filter/html/htmlflywriter.cxx b/sw/source/filter/html/htmlflywriter.cxx
index 2cf3c6894ec1..d00fd94e33ee 100644
--- a/sw/source/filter/html/htmlflywriter.cxx
+++ b/sw/source/filter/html/htmlflywriter.cxx
@@ -1967,18 +1967,21 @@ static Writer& OutHTML_FrameFormatGrfNode( Writer& rWrt, const SwFrameFormat& rF
Size aMM100Size = o3tl::convert( rSize.GetSize(),
o3tl::Length::twip, o3tl::Length::mm100 );
- OUString aFilterName("");
+ OUString aFilterName;
- if (rHTMLWrt.mbReqIF && !bWritePNGFallback)
+ if (rHTMLWrt.mbReqIF)
{
- // Writing image without fallback PNG in ReqIF mode: force PNG
- // output.
- // But don't force it when writing the original format and we'll write PNG inside
- // that.
- aFilterName = "PNG";
- nFlags &= ~XOutFlags::UseNativeIfPossible;
+ // In ReqIF mode, do not try to write GIF for other image types
nFlags &= ~XOutFlags::UseGifIfSensible;
- aMimeType = "image/png";
+ if (!bWritePNGFallback)
+ {
+ // Writing image without fallback PNG in ReqIF mode: force PNG
+ // output.
+ // But don't force it when writing the original format and we'll write PNG inside
+ // that.
+ aFilterName = "PNG";
+ nFlags &= ~XOutFlags::UseNativeIfPossible;
+ }
}
const Graphic& rGraphic = pGrfNd->GetGrf();
@@ -1987,6 +1990,8 @@ static Writer& OutHTML_FrameFormatGrfNode( Writer& rWrt, const SwFrameFormat& rF
if (!rGraphic.isAvailable())
const_cast<Graphic&>(rGraphic).makeAvailable();
+ OUString aMimeTypeOverride;
+
if (rHTMLWrt.mbReqIF && bWritePNGFallback)
{
// ReqIF: force native data if possible.
@@ -1998,7 +2003,7 @@ static Writer& OutHTML_FrameFormatGrfNode( Writer& rWrt, const SwFrameFormat& rF
else if (rGraphic.GetGfxLink().IsEMF())
{
aFilterName = "emf";
- aMimeType = "image/x-emf"; // avoid image/x-wmf
+ aMimeTypeOverride = "image/x-emf"; // avoid image/x-wmf
}
else if (pVectorGraphicData && pVectorGraphicData->getType() == VectorGraphicDataType::Wmf)
{
@@ -2007,12 +2012,12 @@ static Writer& OutHTML_FrameFormatGrfNode( Writer& rWrt, const SwFrameFormat& rF
else if (rGraphic.GetGfxLink().GetType() == GfxLinkType::NativeTif)
{
aFilterName = "tif";
- aMimeType = "image/tiff"; // avoid image/x-vclgraphic
+ aMimeTypeOverride = "image/tiff"; // avoid image/x-vclgraphic
}
}
ErrCode nErr = XOutBitmap::WriteGraphic( rGraphic, aGraphicURL,
- aFilterName, nFlags, &aMM100Size );
+ aFilterName, nFlags, &aMM100Size, nullptr, &aMimeType );
if( nErr )
{
rHTMLWrt.m_nWarn = WARN_SWG_POOR_LOAD;
@@ -2021,6 +2026,8 @@ static Writer& OutHTML_FrameFormatGrfNode( Writer& rWrt, const SwFrameFormat& rF
aGraphicURL = URIHelper::SmartRel2Abs(
INetURLObject(rWrt.GetBaseURL()), aGraphicURL,
URIHelper::GetMaybeFileHdl() );
+ if (!aMimeTypeOverride.isEmpty())
+ aMimeType = aMimeTypeOverride;
}
else
{