Kaydet (Commit) 52a2a010 authored tarafından Patrick Jaap's avatar Patrick Jaap Kaydeden (comit) Bartosz Kosiorek

tdf#31814 Fix for EMF+ DrawString and DrawImage

DrawString:
The value 'fontAttribute' is optional and may be null,
results in missing characters.

DrawImage:
The case of 'metafile' was missing and leads to
low resolution rendering.

Change-Id: I81566d884975fda832f4a5af6663c837f355c383
Reviewed-on: https://gerrit.libreoffice.org/43367Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarBartosz Kosiorek <gang65@poczta.onet.pl>
üst c4525644
......@@ -32,6 +32,7 @@
#include <drawinglayer/primitive2d/svggradientprimitive2d.hxx>
#include <drawinglayer/primitive2d/textprimitive2d.hxx>
#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
#include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
#include <drawinglayer/attribute/fontattribute.hxx>
#include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx>
......@@ -1106,12 +1107,6 @@ namespace emfplushelper
}
if (bValid)
{
BitmapEx aBmp(image.graphic.GetBitmapEx());
aBmp.Crop(aSource);
Size aSize(aBmp.GetSizePixel());
SAL_INFO("cppcanvas.emf", "EMF+ bitmap size: " << aSize.Width() << "x" << aSize.Height());
if (aSize.Width() > 0 && aSize.Height() > 0)
{
// create correct transform matrix
basegfx::B2DHomMatrix aTransformMatrix = basegfx::utils::createScaleTranslateB2DHomMatrix(
......@@ -1120,6 +1115,14 @@ namespace emfplushelper
aDstPoint.getX(),
aDstPoint.getY());
if (image.type == 1) // Bitmap
{
BitmapEx aBmp(image.graphic.GetBitmapEx());
aBmp.Crop(aSource);
Size aSize(aBmp.GetSizePixel());
SAL_INFO("cppcanvas.emf", "EMF+ bitmap size: " << aSize.Width() << "x" << aSize.Height());
if (aSize.Width() > 0 && aSize.Height() > 0)
{
mrTargetHolders.Current().append(
new drawinglayer::primitive2d::BitmapPrimitive2D(aBmp,aTransformMatrix));
}
......@@ -1128,6 +1131,14 @@ namespace emfplushelper
SAL_INFO("cppcanvas.emf", "EMF+ warning: empty bitmap");
}
}
else if (image.type == 2) // Metafile
{
GDIMetaFile aGDI(image.graphic.GetGDIMetaFile());
aGDI.Clip(aSource);
mrTargetHolders.Current().append(
new drawinglayer::primitive2d::MetafilePrimitive2D(aTransformMatrix,aGDI));
}
}
else
{
SAL_WARN("cppcanvas.emf", "EMF+ DrawImage(Points) TODO (fixme)");
......@@ -1158,11 +1169,11 @@ namespace emfplushelper
// parse the string
OUString text = read_uInt16s_ToOUString(rMS, stringLength);
SAL_INFO("cppcanvas.emf", "EMF+ DrawString string: " << text);
// get the stringFormat from the Object table
// get the stringFormat from the Object table ( this is OPTIONAL and may be nullptr )
EMFPStringFormat *stringFormat = static_cast< EMFPStringFormat* >(maEMFPObjects[formatId & 0xff].get());
// get the font from the flags
EMFPFont *font = static_cast< EMFPFont* >( maEMFPObjects[flags & 0xff].get() );
if (!stringFormat || !font)
if (!font)
{
break;
}
......@@ -1179,31 +1190,29 @@ namespace emfplushelper
emptyString, // (no) font style
font->Bold() ? 8u : 1u, // weight: 8 = bold
font->family == "SYMBOL", // symbol
stringFormat->DirectionVertical(), // vertical
stringFormat && stringFormat->DirectionVertical(), // vertical
font->Italic(), // italic
false, // monospaced
false, // outline = false, no such thing in MS-EMFPLUS
stringFormat->DirectionRightToLeft(), // right-to-left
stringFormat && stringFormat->DirectionRightToLeft(), // right-to-left
false); // BiDiStrong
LanguageTag aLanguageTag(static_cast< LanguageType >(stringFormat->language));
css::lang::Locale locale = aLanguageTag.getLocale();
basegfx::B2DHomMatrix transformMatrix = basegfx::utils::createScaleTranslateB2DHomMatrix(MapSize(font->emSize,font->emSize),Map(lx,ly+font->emSize));
basegfx::BColor color;
if (flags & 0x8000) // we use a color
css::lang::Locale locale;
if (stringFormat)
{
color = Color(0xff - (brushId >> 24), (brushId >> 16) & 0xff, (brushId >> 8) & 0xff, brushId & 0xff).getBColor();
LanguageTag aLanguageTag(static_cast< LanguageType >(stringFormat->language));
locale = aLanguageTag.getLocale();
}
else // we use a pen
{
const EMFPPen* pen = static_cast<EMFPPen*>(maEMFPObjects[brushId & 0xff].get());
if (pen)
else
{
color = pen->GetColor().getBColor();
}
// use system default
locale = Application::GetSettings().GetLanguageTag().getLocale();
}
basegfx::B2DHomMatrix transformMatrix = basegfx::utils::createScaleTranslateB2DHomMatrix(MapSize(font->emSize,font->emSize),Map(lx,ly+font->emSize));
basegfx::BColor color = EMFPGetBrushColorOrARGBColor(flags,brushId);
mrPropertyHolders.Current().setTextColor(color);
mrPropertyHolders.Current().setTextColorActive(true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment