drawinglayer/source/tools/emfphelperdata.cxx:451:83: runtime error: negation of -2147483648 cannot be represented in type 'sal_Int32' (aka 'int'); cast to an unsigned type to negate this value to itself
#0 0x7b71c0dc8ec7 in emfplushelper::EmfPlusHelperData::mappingChanged() drawinglayer/source/tools/emfphelperdata.cxx:451:83
#1 0x7b71c0de6a2d in emfplushelper::EmfPlusHelperData::EmfPlusHelperData(SvMemoryStream&, wmfemfhelper::TargetHolders&, wmfemfhelper::PropertyHolders&) drawinglayer/source/tools/emfphelperdata.cxx:1503:9
#2 0x7b71c0dc0059 in emfplushelper::EmfPlusHelper::EmfPlusHelper(SvMemoryStream&, wmfemfhelper::TargetHolders&, wmfemfhelper::PropertyHolders&) drawinglayer/source/tools/emfplushelper.cxx:29:17
#3 0x7b71c0f31dc6 in wmfemfhelper::implInterpretMetafile(GDIMetaFile const&, wmfemfhelper::TargetHolders&, wmfemfhelper::PropertyHolders&, drawinglayer::geometry::ViewInformation2D const&) drawinglayer/source/tools/wmfemfhelper.cxx:2923:37
#4 0x7b71c0f19d51 in wmfemfhelper::interpretMetafile(GDIMetaFile const&, drawinglayer::geometry::ViewInformation2D const&) drawinglayer/source/tools/wmfemfhelper.cxx:2993:9
#5 0x7b71c0a70d93 in drawinglayer::primitive2d::MetafilePrimitive2D::create2DDecomposition(drawinglayer::geometry::ViewInformation2D const&) const drawinglayer/source/primitive2d/metafileprimitive2d.cxx:42:42
#6 0x7f71deb27e4f in drawinglayer::primitive2d::BufferedDecompositionPrimitive2D::get2DDecomposition(drawinglayer::primitive2d::Primitive2DDecompositionVisitor&, drawinglayer::geometry::ViewInformation2D const&) const drawinglayer/source/primitive2d/BufferedDecompositionPrimitive2D.cxx:90:41
#7 0x7b71c0a727d5 in TestImportWMF drawinglayer/source/primitive2d/metafileprimitive2d.cxx:149:16
so negate the frame offsets as doubles
Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: I2cf478245f30f4573bfa5ccb2c6dcbe5c603e38b
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/11528
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
Reviewed-by: Noel Grandin <noel.grandin@collabora.com>
(cherry picked from commit f6f1f208a87c2a725e5c20c6a7453fa5679eca76)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210540
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Drawing API
Drawing API that can specify what to draw via a kind of display list.
Example of the DrawingLayer use is eg. in svx/source/xoutdev/xtabhtch.cxx:121.
A stripped down version with extended comments:
// Create a hatch primitive (here a rectangle that will be filled with
// the appropriate hatching, but has no border).
// This will not draw it yet; it's so far only constructed to add it to a
// display list later.
const drawinglayer::primitive2d::Primitive2DReference aHatchPrimitive(
new drawinglayer::primitive2d::PolyPolygonHatchPrimitive2D(...));
// Create a rectangle around the hatch, to give it a border.
const drawinglayer::primitive2d::Primitive2DReference aBlackRectanglePrimitive(
new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(...));
// Here we want to render to a virtual device (to later obtain the bitmap
// out of that), so prepare it.
VirtualDevice aVirtualDevice;
// Create processor and draw primitives, to get it ready for rendering.
std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D(
drawinglayer::processor2d::createPixelProcessor2DFromOutputDevice(...));
// Fill-in the display list.
drawinglayer::primitive2d::Primitive2DSequence aSequence(2);
aSequence[0] = aHatchPrimitive;
aSequence[1] = aBlackRectanglePrimitive;
// Render it to the virtual device.
pProcessor2D->process(aSequence);
pProcessor2D.reset();
// Obtain the bitmap that was rendered from the virtual device, to reuse
// it in the widget.
aRetval = aVirtualDevice.GetBitmap(Point(0, 0), aVirtualDevice.GetOutputSizePixel());
DrawingLayer Glossary
Primitives - classes that represent what should be drawn. It holds the data what to draw, but does not contain any kind of the rendering. Some of the primitives are 'Basic primitives', that are primitives that cannot be decomposed. The rest of the primitives can be decomposed to the basic primitives.
Decomposition - a way how to break down the more complicated primitives into
the basic primitives, and represent them via them; this logically makes the
plain Primitive2DSequence display list a hierarchy.
Eg. PolygonMarkerPrimitive2D can be decomposed to 2 hairlines
PolyPolygonHairlinePrimitive2D's, each with different color.
Processor - a class that goes through the hierarchy of the Primitives, and
renders it some way. Various processors, like VclPixelProcessor2D (renders to
the screen), VclMetafileProcessor2D (renders to the VCL metafile, eg. for
printing), etc.
How to Implement a New Primitive ("Something New to Draw")
-
Create an ancestor of
BasePrimitive2D(or of its ancestor if it fits the purpose better)-
Assign it an ID [in
drawinglayer_primitivetypes2d.hxx] -
Implement its decomposition [
virtual Primitive2DSequence create2DDecomposition(...)]
-
-
Extend the (various) processor(s) If you need more than relying on just the decomposition
Where is DrawingLayer Used
-
SdrObject(s) (rectangles, Circles, predefined shapes etc.) -
Selections
-
Various smaller cases to 'just draw something'
- Draw to a virtual device, and use the resulting bitmap (like the example above)
-
Custom widgets (like the Header / Footer indicator button)
Dumping DrawingLayer Primitives as XML
For debugging purposes, it is possible to dump the drawinglayer primitives as an xml file. The drawinglayer xml dump can show possible problems with the rendering.
For example, in emfio/qa/cppunit/emf/EmfImportTest.cxx, one can write:
Primitive2DSequence aSequence = parseEmf(u"emfio/qa/cppunit/wmf/data/stockobject.emf");
drawinglayer::Primitive2dXmlDump dumper;
Primitive2DContainer aContainer(aSequence);
dumper.dump(aContainer, "/tmp/drawinglayer.xml");
Then, after invoking make CppunitTest_emfio_emf, /tmp/drawinglayer.xml will
be the dump of the drawinglayer primitives used to draw the emf file in
LibreOffice. The top level tag will be .