[Libreoffice-commits] core.git: emfio/inc emfio/source vcl/source
LuboÅ¡ LuÅák (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jun 11 22:00:23 UTC 2021
emfio/inc/wmfreader.hxx | 5 +++++
emfio/source/emfuno/xemfparser.cxx | 5 ++++-
emfio/source/reader/emfreader.cxx | 2 +-
emfio/source/reader/wmfreader.cxx | 1 +
vcl/source/filter/wmf/wmf.cxx | 10 ++++++----
5 files changed, 17 insertions(+), 6 deletions(-)
New commits:
commit b342a445cd8b115e76d261860088b012b74c0b0e
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Fri Jun 11 15:48:32 2021 +0200
Commit: Luboš Luňák <l.lunak at collabora.com>
CommitDate: Fri Jun 11 23:59:32 2021 +0200
drop EMF+ also when converting WMF, not just EMF
A WMF may have EMF with EMF+ actions embedded. When we read that,
we drop drawing non-EMF+ actions if we use EMF+. But EMF+ actions
are stored as MetaCommentAction in the metafile, and WMF writer
(unlike EMF) writer simply ignores comments. So when writing WMF,
make sure to read non-EMF actions so that something is written.
This is an extension of 295626a0bd39540544b774094a63df23e5376839.
Change-Id: I37355f694fe656b661abe54274ea203934e68151
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117062
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak at collabora.com>
diff --git a/emfio/inc/wmfreader.hxx b/emfio/inc/wmfreader.hxx
index 279f3e4caeee..a7dff2b94d85 100644
--- a/emfio/inc/wmfreader.hxx
+++ b/emfio/inc/wmfreader.hxx
@@ -51,6 +51,8 @@ namespace emfio
// eventually handed over external header
const WmfExternal* mpExternalHeader;
+ bool mbEnableEMFPlus = true;
+
// reads header of the WMF-Datei
bool ReadHeader();
@@ -68,6 +70,9 @@ namespace emfio
// read WMF file from stream and fill the GDIMetaFile
void ReadWMF();
+
+ // Allows disabling EMF+ if EMF is embedded in this WMF.
+ void SetEnableEMFPlus(bool bEnableEMFPlus) { mbEnableEMFPlus = bEnableEMFPlus; }
};
}
diff --git a/emfio/source/emfuno/xemfparser.cxx b/emfio/source/emfuno/xemfparser.cxx
index 7788802c4e1c..e5d27056332d 100644
--- a/emfio/source/emfuno/xemfparser.cxx
+++ b/emfio/source/emfuno/xemfparser.cxx
@@ -130,7 +130,10 @@ namespace emfio::emfreader
}
else
{
- emfio::WmfReader(*pStream, aMtf, bExternalHeaderUsed ? &aExternalHeader : nullptr).ReadWMF();
+ emfio::WmfReader aReader(*pStream, aMtf, bExternalHeaderUsed ? &aExternalHeader : nullptr);
+ if (!bEnableEMFPlus)
+ aReader.SetEnableEMFPlus(bEnableEMFPlus);
+ aReader.ReadWMF();
// Need to check for ErrCode at stream to not lose former work.
// This may contain important information and will behave the
diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx
index 04f591a7eb9a..4ad77dd3fb32 100644
--- a/emfio/source/reader/emfreader.cxx
+++ b/emfio/source/reader/emfreader.cxx
@@ -817,7 +817,7 @@ namespace emfio
bEnableEMFPlus = mbEnableEMFPlus;
}
- SAL_INFO("emfio", "EMF_PLUS_DISABLE is " << (bEnableEMFPlus ? "enabled" : "disabled"));
+ SAL_INFO("emfio", "EMF+ reading is " << (bEnableEMFPlus ? "enabled" : "disabled"));
while (bStatus && mnRecordCount-- && mpInputStream->good() && !mbReadOtherGraphicFormat)
{
diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx
index 93908503d9bf..9ddb674b7c05 100644
--- a/emfio/source/reader/wmfreader.cxx
+++ b/emfio/source/reader/wmfreader.cxx
@@ -1596,6 +1596,7 @@ namespace emfio
GDIMetaFile aMeta;
mpEMFStream->Seek( 0 );
std::unique_ptr<EmfReader> pEMFReader(std::make_unique<EmfReader>( *mpEMFStream, aMeta ));
+ pEMFReader->SetEnableEMFPlus(mbEnableEMFPlus);
bEMFAvailable = pEMFReader->ReadEnhWMF();
pEMFReader.reset(); // destroy first!!!
diff --git a/vcl/source/filter/wmf/wmf.cxx b/vcl/source/filter/wmf/wmf.cxx
index ccff80c20339..ee1ce77e4185 100644
--- a/vcl/source/filter/wmf/wmf.cxx
+++ b/vcl/source/filter/wmf/wmf.cxx
@@ -88,13 +88,15 @@ bool ConvertGraphicToWMF(const Graphic& rGraphic, SvStream& rTargetStream,
FilterConfigItem const* pConfigItem, bool bPlaceable)
{
GfxLink aLink = rGraphic.GetGfxLink();
- if (aLink.IsEMF() && aLink.GetData() && aLink.GetDataSize())
+ if (aLink.GetType() == GfxLinkType::NativeWmf && aLink.GetData() && aLink.GetDataSize())
{
- // This may be an EMF+ file, converting that to WMF is better done by re-parsing EMF+ as EMF
- // and converting that to WMF.
+ // This may be an EMF+ file or WMF file with EMF+ embedded. In EmfReader::ReadEnhWMF()
+ // we normally drop non-EMF commands when reading EMF+, so converting that to WMF
+ // is better done by re-parsing with EMF+ disabled.
auto & rDataContainer = aLink.getDataContainer();
auto aVectorGraphicData
- = std::make_shared<VectorGraphicData>(rDataContainer, VectorGraphicDataType::Emf);
+ = std::make_shared<VectorGraphicData>(rDataContainer,
+ aLink.IsEMF() ? VectorGraphicDataType::Emf : VectorGraphicDataType::Wmf);
aVectorGraphicData->setEnableEMFPlus(false);
Graphic aGraphic(aVectorGraphicData);
bool bRet = ConvertGDIMetaFileToWMF(aGraphic.GetGDIMetaFile(), rTargetStream, pConfigItem,
More information about the Libreoffice-commits
mailing list