LO question about ImportGraphic and pExtHeader for EMF/WMF

Julien Nabet serval2412 at yahoo.fr
Wed May 18 08:01:06 UTC 2022

Hello Armin, Bartosz

Taking a look at ImportGraphic methods, I noticed one could be removed 
(see https://gerrit.libreoffice.org/c/core/+/134503).

Then I noticed this method in vcl/source/filter/graphicfilter.cxx:

78  ErrCode GraphicFilter::ImportGraphic( Graphic& rGraphic, 
std::u16string_view rPath, SvStream& rIStream,
1379                                       sal_uInt16 nFormat, 
sal_uInt16* pDeterminedFormat, GraphicFilterImportFlags nImportFlags,
1380                                       const css::uno::Sequence< 
css::beans::PropertyValue >* /*pFilterData*/,
1381                                       WmfExternal const *pExtHeader )


Default value for "pExtHeader" is nullptr in include/vcl/graphicfilter.hxx

     314     ErrCode             ImportGraphic( Graphic& rGraphic, 
std::u16string_view rPath,
     315                                    SvStream& rStream,
     316                                    sal_uInt16 nFormat = 
     317                                    sal_uInt16 * 
pDeterminedFormat = nullptr, GraphicFilterImportFlags nImportFlags = 
     318                                    WmfExternal const 
*pExtHeader = nullptr );


"pExtHeader" has been added in 783269e91e2166357a9fb095e64a1d48e6f0601a 
"emfplus: completed isolation/migration of Emf/Wmf" (in June 2017)

and is only used for "readEMF" and "readWMF" methods which both call 
GraphicFilter::readWMF_EMF (see 

This last one uses pExtHeader here:

1196          if (pExtHeader)
1197          {
1198 aVectorGraphicDataPtr->setWmfExternalHeader(*pExtHeader);
1199          }

But when git grepping ImportGraphic in all LO code, "pExtHeader" was 
never defined and passed to "ImportGraphic" except in 

      44     WmfExternal* pExtHeader = nullptr;
      45     if (rFilter.ImportGraphic(aGraphic, u"", aInStream, 
      46 GraphicFilterImportFlags::NONE, pExtHeader)
      47         != ERRCODE_NONE)
      48         return;


so "setWmfExternalHeader" is never called and all "pExtHeader" parameter 
in each of the quoted methods seems useless.

Did I miss something? If no, can we remove this "pExtHeader" parameter 
and clean the related code or is it some basis to implement in the 
future a feature in EMF/WMF ?



More information about the LibreOffice mailing list