office-gobmx/emfio
Stephan Bergmann db3a61cd95 Generally determine Rdb content from gb_*_set_componentfile calls
...instead of by listing the content somewhat redundantly in the Rdb_*.mk
files, to avoid duplication of logic for components that are only built
conditionally (and thus should only be included conditionally in the
corresponding Rdb).  To achieve that, add an "rdb" parameter to
gb_ComponentTarget_ComponentTarget (and to the gb_*_set_componentfile macros
that internally call gb_ComponentTarget_ComponentTarget), which is used to make
the appropriate gb_Rdb_add_component call internally from within
gb_ComponentTarget_ComponentTarget.  (As a special case,
gb_CppunitTest_set_componentfile shall not call gb_Rdb_add_component, as that
has already been done by the corresponding gb_Library_set_componentfile call, so
allow the gb_ComponentTarget_ComponentTarget "rdb" parameter to be empty to
support that special case.)

Most Rdb_*.mk files are thus mostly empty now.  One exception is
i18npool/Rdb_saxparser.mk, which duplicates some of the Rdb_services content as
needed during the build in CustomTarget_i18npool/localedata.

1c9a40299d "gbuild: create services.rdb from built
components" had already tried to do something similar (in addition to other
things) under a new --enable-services-rdb-from-build option.  However, that
approach had four drawbacks that this approach here addresses (and which thus
partly reverts 1c9a40299d):

1  Rdb_services shall not contain the component files of all libraries that are
built.  While that commit filtered out the component files that go into
Rdb_ure/services (ure/Rdb_ure.mk), it failed to filter out the component files
that go into others like Rdb_postgresql-sdbc
(connectivity/Rdb_postgresql-sdbc.mk).

2  The code added by that commit to Makefile.gbuild codified the knowledge that
there is an Rdb_services, which is brittle.

3  The code added by that commit to solenv/gbuild/Rdb.mk codified the knowledge
(for gb_Rdb__URECOMPONENTS) that there is an Rdb_ure/services, which is brittle.

4  Introducing an --enable-services-rdb-from-build option needlessly provided
two different ways how the content of Rdb_services is assembled.

The changes done here would leave --enable-services-rdb-from-build as a
misnomer, as it no longer controls how Rdb_services is assembled.  I thus
renamed it to --enable-customtarget-components, as that is apparently what it
still does now.

Change-Id: Ia5e8df4b640146c77421fcec6daa11a9cd260265
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126577
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-12-10 08:14:24 +01:00
..
inc
qa/cppunit
source ofz: Use-of-uninitialized-value 2021-12-06 20:32:18 +01:00
CppunitTest_emfio_emf.mk
CppunitTest_emfio_wmf.mk
emfio.component
IwyuFilter_emfio.yaml
Library_emfio.mk Generally determine Rdb content from gb_*_set_componentfile calls 2021-12-10 08:14:24 +01:00
Makefile
Module_emfio.mk
README.md

WMF/EMF/EMF+ Reader

Introduction

The emfio module is used to read WMF (Windows Metafile), EMF (Enhanced Metafiles) and also EMF+ (enhanced EMF) files [1], which are binary formats for vector images from Microsoft. These files can contain vector graphics, bitmap components and text.

This folder contains emfio/source/reader which is used for reading the WMF/EMF/EMF+ files, either directly, or inside a document. For embedding Windows Metafiles inside a document, one can use "Insert -> Picture -> From File" to put such a file into the document. It is possible to export the Windows Metafile by using right click and choose "save".

Most of the records of WMF/EMF formats come from the Windows Graphics Device. For Interface (GDI) API and EMF+ they come from the newer Windows GDI+.

More information about rendering Windows Metafiles can be found in the Visual Class Library (VCL) and also in the GDIMetaFile documentation.

An example demo that renders a metafile using vcl be seen by invoking:

./bin/run mtfdemo odk/examples/basic/forms_and_controls/burger.wmf

This opens the burger.wmf file from the ODK examples.

It is also possible to dump metaactions created as the intermediary format before rendering the metafile using:

./bin/run mtfdemo -d odk/examples/basic/forms_and_controls/burger.wmf

If the command is successful, this message will be shown, and metadump.xml will be put in the current folder:

"Dumped metaactions as metadump.xml"

The demo code structure is described in GDIMetaFile documentation.

[1] Windows Meta File, Wikipedia

EMF+ Specifics

Handling EMF+ is to some extent different from handling WMF/EMF. More information can be found in the VCL documentation.

How does it work?

emfio module takes a byte array and turns it into a drawinglayer primitive container. The rendering is done via drawinglayer primitives. For more information, you should refer to VCL documentation.

Limitations

Not all the WMF/EMF/EMF+ records are supported by this module. Unsupported records are marked as "not implemented", and a warning message will printed if they are actually read within a file. You can file a bug report for implementing these records.

Currently, these records are not implemented (specified in wmfreader.cxx):

W_META_SETRELABS W_META_SETPOLYFILLMODE W_META_SETSTRETCHBLTMODE
W_META_SETTEXTCHAREXTRA W_META_SETTEXTJUSTIFICATION W_META_FLOODFILL
W_META_FILLREGION W_META_FRAMEREGION W_META_INVERTREGION
W_META_PAINTREGION W_META_DRAWTEXT W_META_SETMAPPERFLAGS
W_META_SETDIBTODEV W_META_REALIZEPALETTE W_META_ANIMATEPALETTE
W_META_SETPALENTRIES W_META_RESIZEPALETTE W_META_EXTFLOODFILL
W_META_RESETDC W_META_STARTDOC W_META_STARTPAGE W_META_ENDPAGE
W_META_ABORTDOC W_META_ENDDOC

And these records are not implemented (specified in emfreader.cxx):

EMR_MASKBLT EMR_PLGBLT EMR_SETDIBITSTODEVICE EMR_FRAMERGN
EMR_INVERTRGN EMR_FLATTENPATH EMR_WIDENPATH EMR_POLYDRAW
EMR_SETARCDIRECTION EMR_SETPALETTEENTRIES EMR_RESIZEPALETTE
EMR_EXTFLOODFILL EMR_ANGLEARC EMR_SETCOLORADJUSTMENT EMR_POLYDRAW16
EMR_CREATECOLORSPACE EMR_SETCOLORSPACE EMR_DELETECOLORSPACE
EMR_GLSRECORD EMR_GLSBOUNDEDRECORD EMR_PIXELFORMAT EMR_DRAWESCAPE
EMR_EXTESCAPE EMR_STARTDOC EMR_SMALLTEXTOUT EMR_FORCEUFIMAPPING
EMR_NAMEDESCAPE EMR_COLORCORRECTPALETTE EMR_SETICMPROFILEA
EMR_SETICMPROFILEW EMR_TRANSPARENTBLT EMR_TRANSPARENTDIB
EMR_GRADIENTFILL EMR_SETLINKEDUFIS EMR_SETMAPPERFLAGS EMR_SETICMMODE
EMR_CREATEMONOBRUSH EMR_SETBRUSHORGEX EMR_SETMETARGN EMR_SETMITERLIMIT
EMR_EXCLUDECLIPRECT EMR_REALIZEPALETTE EMR_SELECTPALETTE
EMR_CREATEPALETTE EMR_ALPHADIBBLEND EMR_SETTEXTJUSTIFICATION

Due to the difference on the fonts available on various platforms, the outcome of text rendering can be different on Linux, Windows, macOS and elsewhere.

Known Bugs

Known remaining bugs for this module is gathered here:

Dependencies

The direct dependency for emfio is drawinglayer. The complete list of dependencies including the indirect dependencies is as below:

basegfx drawinglayer cppu cppuhelper sal comphelper tl salhelper vcl svt utl

Tools

Several tools are available for inspecting WMF/EMF/EMF+ files, which are binary formats. Some of them are:

  • mso-dumper: Reads and dumps various binary formats from Microsoft including WMF/EMF/EMF+. The output is in a custom XML format. emf-dump.py and wmf-dump.py are usable.
  • RE-lab (Formerly OLEToy): Reads, dumps and modifies several binary formats from Microsoft including WMF/EMF/EMF+, and also other companies.
  • EMF+ diagnostics reporting tool

References

Documentation for WMF/EMF/EMF+ formats are available on Microsoft website: