diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-03-30 09:24:26 +0300 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2023-04-03 16:20:08 +0200 |
commit | 7a7cf430c851ae1a685e9808ee27b2ff3f09fccb (patch) | |
tree | 5758b142a2f62c729cf765d5a60f6bbc7f5c3b65 /svx | |
parent | dacdb5a424601e9ee33f57cceb79f3835530654f (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 'svx')
-rw-r--r-- | svx/source/xoutdev/_xoutbmp.cxx | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx index 7241fedfe043..a67b2b4da277 100644 --- a/svx/source/xoutdev/_xoutbmp.cxx +++ b/svx/source/xoutdev/_xoutbmp.cxx @@ -30,10 +30,13 @@ #include <vcl/cvtgrf.hxx> #include <memory> +#include <com/sun/star/beans/XPropertySet.hpp> + constexpr OUStringLiteral FORMAT_BMP = u"bmp"; constexpr OUStringLiteral FORMAT_GIF = u"gif"; constexpr OUStringLiteral FORMAT_JPG = u"jpg"; constexpr OUStringLiteral FORMAT_PNG = u"png"; +constexpr OUStringLiteral FORMAT_TIF = u"tif"; constexpr OUStringLiteral FORMAT_WEBP = u"webp"; using namespace com::sun::star; @@ -104,7 +107,8 @@ Graphic XOutBitmap::MirrorGraphic( const Graphic& rGraphic, const BmpMirrorFlags ErrCode XOutBitmap::WriteGraphic( const Graphic& rGraphic, OUString& rFileName, const OUString& rFilterName, const XOutFlags nFlags, const Size* pMtfSize_100TH_MM, - const css::uno::Sequence< css::beans::PropertyValue >* pFilterData ) + const css::uno::Sequence< css::beans::PropertyValue >* pFilterData, + OUString* pMediaType ) { if( rGraphic.GetType() == GraphicType::NONE ) return ERRCODE_NONE; @@ -183,6 +187,7 @@ ErrCode XOutBitmap::WriteGraphic( const Graphic& rGraphic, OUString& rFileName, case GfxLinkType::NativeJpg: aExt = FORMAT_JPG; break; case GfxLinkType::NativePng: aExt = FORMAT_PNG; break; + case GfxLinkType::NativeTif: aExt = FORMAT_TIF; break; case GfxLinkType::NativeWebp: aExt = FORMAT_WEBP; break; default: @@ -197,6 +202,9 @@ ErrCode XOutBitmap::WriteGraphic( const Graphic& rGraphic, OUString& rFileName, if( !(nFlags & XOutFlags::DontAddExtension) ) aURL.setExtension( aExt ); rFileName = aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ); + if (pMediaType) + if (uno::Reference<beans::XPropertySet> xGraphic{ rGraphic.GetXGraphic(), uno::UNO_QUERY }) + xGraphic->getPropertyValue("MimeType") >>= *pMediaType; SfxMedium aMedium(aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE), StreamMode::WRITE | StreamMode::SHARE_DENYNONE | StreamMode::TRUNC); SvStream* pOStm = aMedium.GetOutStream(); @@ -308,6 +316,8 @@ ErrCode XOutBitmap::WriteGraphic( const Graphic& rGraphic, OUString& rFileName, if( !(nFlags & XOutFlags::DontAddExtension) ) aURL.setExtension( aExt ); rFileName = aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ); + if (pMediaType) + *pMediaType = rFilter.GetExportFormatMediaType(nFilter); nErr = ExportGraphic( aGraphic, aURL, rFilter, nFilter, pFilterData ); } } |