Simplify an "ImportGraphic" method by removing useless pExtHeader (WmfExternal)

Change-Id: I2916610e08c3157e0438ec90592fb5b8f921cc24
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134574
Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
Tested-by: Jenkins
This commit is contained in:
Julien Nabet 2022-05-18 21:52:52 +02:00
parent d4ab6a4693
commit 1c25d22bfa
5 changed files with 16 additions and 30 deletions

View file

@ -314,8 +314,7 @@ public:
ErrCode ImportGraphic( Graphic& rGraphic, std::u16string_view rPath,
SvStream& rStream,
sal_uInt16 nFormat = GRFILTER_FORMAT_DONTKNOW,
sal_uInt16 * pDeterminedFormat = nullptr, GraphicFilterImportFlags nImportFlags = GraphicFilterImportFlags::NONE,
WmfExternal const *pExtHeader = nullptr );
sal_uInt16 * pDeterminedFormat = nullptr, GraphicFilterImportFlags nImportFlags = GraphicFilterImportFlags::NONE );
/// Imports multiple graphics.
///
@ -353,10 +352,9 @@ public:
static ErrCode readXBM(SvStream & rStream, Graphic & rGraphic);
static ErrCode readXPM(SvStream & rStream, Graphic & rGraphic);
static ErrCode readWMF_EMF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & rLinkType,
WmfExternal const* pExtHeader, VectorGraphicDataType eType);
static ErrCode readWMF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & rLinkType, WmfExternal const* pExtHeader);
static ErrCode readEMF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & rLinkType, WmfExternal const* pExtHeader);
static ErrCode readWMF_EMF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & rLinkType, VectorGraphicDataType eType);
static ErrCode readWMF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & rLinkType);
static ErrCode readEMF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & rLinkType);
static ErrCode readPDF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & rLinkType);
static ErrCode readTIFF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & rLinkType);

View file

@ -1149,8 +1149,7 @@ ErrCode GraphicFilter::readXPM(SvStream & rStream, Graphic & rGraphic)
return ERRCODE_GRFILTER_FILTERERROR;
}
ErrCode GraphicFilter::readWMF_EMF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & rLinkType,
WmfExternal const *pExtHeader, VectorGraphicDataType eType)
ErrCode GraphicFilter::readWMF_EMF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & rLinkType, VectorGraphicDataType eType)
{
// use new UNO API service, do not directly import but create a
// Graphic that contains the original data and decomposes to
@ -1181,11 +1180,6 @@ ErrCode GraphicFilter::readWMF_EMF(SvStream & rStream, Graphic & rGraphic, GfxLi
auto aVectorGraphicDataPtr = std::make_shared<VectorGraphicData>(aDataContainer, aDataType);
if (pExtHeader)
{
aVectorGraphicDataPtr->setWmfExternalHeader(*pExtHeader);
}
rGraphic = Graphic(aVectorGraphicDataPtr);
rLinkType = GfxLinkType::NativeWmf;
aReturnCode = ERRCODE_NONE;
@ -1194,14 +1188,14 @@ ErrCode GraphicFilter::readWMF_EMF(SvStream & rStream, Graphic & rGraphic, GfxLi
return aReturnCode;
}
ErrCode GraphicFilter::readWMF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & rLinkType, WmfExternal const* pExtHeader)
ErrCode GraphicFilter::readWMF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & rLinkType)
{
return readWMF_EMF(rStream, rGraphic, rLinkType, pExtHeader, VectorGraphicDataType::Wmf);
return readWMF_EMF(rStream, rGraphic, rLinkType,VectorGraphicDataType::Wmf);
}
ErrCode GraphicFilter::readEMF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & rLinkType, WmfExternal const* pExtHeader)
ErrCode GraphicFilter::readEMF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & rLinkType)
{
return readWMF_EMF(rStream, rGraphic, rLinkType, pExtHeader, VectorGraphicDataType::Emf);
return readWMF_EMF(rStream, rGraphic, rLinkType, VectorGraphicDataType::Emf);
}
ErrCode GraphicFilter::readPDF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & rLinkType)
@ -1363,9 +1357,8 @@ ErrCode GraphicFilter::readWEBP(SvStream & rStream, Graphic & rGraphic, GfxLinkT
return ERRCODE_GRFILTER_FILTERERROR;
}
ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, std::u16string_view rPath, SvStream& rIStream,
sal_uInt16 nFormat, sal_uInt16* pDeterminedFormat, GraphicFilterImportFlags nImportFlags,
WmfExternal const *pExtHeader )
ErrCode GraphicFilter::ImportGraphic(Graphic& rGraphic, std::u16string_view rPath, SvStream& rIStream,
sal_uInt16 nFormat, sal_uInt16* pDeterminedFormat, GraphicFilterImportFlags nImportFlags)
{
OUString aFilterName;
sal_uInt64 nStreamBegin;
@ -1458,11 +1451,11 @@ ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, std::u16string_view rPa
}
else if (aFilterName.equalsIgnoreAsciiCase(IMP_WMF))
{
nStatus = readWMF(rIStream, rGraphic, eLinkType, pExtHeader);
nStatus = readWMF(rIStream, rGraphic, eLinkType);
}
else if (aFilterName.equalsIgnoreAsciiCase(IMP_EMF))
{
nStatus = readEMF(rIStream, rGraphic, eLinkType, pExtHeader);
nStatus = readEMF(rIStream, rGraphic, eLinkType);
}
else if (aFilterName.equalsIgnoreAsciiCase(IMP_PDF))
{

View file

@ -32,8 +32,7 @@ Graphic loadFromURL(OUString const& rURL, weld::Window* pParentWin)
ErrCode nError
= rFilter.ImportGraphic(aGraphic, rURL, *pInputStream, GRFILTER_FORMAT_DONTKNOW,
nullptr, GraphicFilterImportFlags::NONE,
/*pExtHeader*/ static_cast<WmfExternal const*>(nullptr));
nullptr, GraphicFilterImportFlags::NONE);
if (nError != ERRCODE_NONE || aGraphic.GetType() == GraphicType::NONE)
return Graphic();
}

View file

@ -401,10 +401,8 @@ uno::Reference< ::graphic::XGraphic > SAL_CALL GraphicProvider::queryGraphic( co
aExtHeader.xExt = nExtWidth;
aExtHeader.yExt = nExtHeight;
aExtHeader.mapMode = nExtMapMode;
WmfExternal *pExtHeader = nullptr;
if ( nExtMapMode > 0 )
{
pExtHeader = &aExtHeader;
bLazyRead = false;
}
@ -416,8 +414,7 @@ uno::Reference< ::graphic::XGraphic > SAL_CALL GraphicProvider::queryGraphic( co
aVCLGraphic = aGraphic;
}
if (aVCLGraphic.IsNone())
error = rFilter.ImportGraphic(aVCLGraphic, aPath, *pIStm, GRFILTER_FORMAT_DONTKNOW,
nullptr, GraphicFilterImportFlags::NONE, pExtHeader);
error = rFilter.ImportGraphic(aVCLGraphic, aPath, *pIStm, GRFILTER_FORMAT_DONTKNOW, nullptr, GraphicFilterImportFlags::NONE);
if( (error == ERRCODE_NONE ) &&
( aVCLGraphic.GetType() != GraphicType::NONE ) )

View file

@ -41,9 +41,8 @@ void generatePreview(std::string_view rPdfPath, std::string_view rPngPath)
OUString aInURL;
osl::FileBase::getFileURLFromSystemPath(OUString::fromUtf8(rPdfPath), aInURL);
SvFileStream aInStream(aInURL, StreamMode::READ);
WmfExternal* pExtHeader = nullptr;
if (rFilter.ImportGraphic(aGraphic, u"", aInStream, GRFILTER_FORMAT_DONTKNOW, nullptr,
GraphicFilterImportFlags::NONE, pExtHeader)
GraphicFilterImportFlags::NONE)
!= ERRCODE_NONE)
return;