diff options
author | Patrick Jaap <patrick.jaap@tu-dresden.de> | 2017-10-13 11:31:28 +0200 |
---|---|---|
committer | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2017-10-15 11:30:30 +0200 |
commit | 52a2a0101f71b21876f17d5419132ffa27f6e35d (patch) | |
tree | 69630fc71938ea16ce549b24907d567fde1a5980 /drawinglayer/source | |
parent | c45256444a533fd2bc41b626562741e774374adb (diff) |
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/43367
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
Diffstat (limited to 'drawinglayer/source')
-rw-r--r-- | drawinglayer/source/tools/emfphelperdata.cxx | 95 |
1 files changed, 52 insertions, 43 deletions
diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index 1dc3d611a046..c39083336046 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -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> @@ -1107,25 +1108,35 @@ 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( + aDstSize.getX(), + aDstSize.getY(), + aDstPoint.getX(), + aDstPoint.getY()); + + if (image.type == 1) // Bitmap { - // create correct transform matrix - basegfx::B2DHomMatrix aTransformMatrix = basegfx::utils::createScaleTranslateB2DHomMatrix( - aDstSize.getX(), - aDstSize.getY(), - aDstPoint.getX(), - aDstPoint.getY()); - - mrTargetHolders.Current().append( - new drawinglayer::primitive2d::BitmapPrimitive2D(aBmp,aTransformMatrix)); + 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)); + } + else + { + SAL_INFO("cppcanvas.emf", "EMF+ warning: empty bitmap"); + } } - else + else if (image.type == 2) // Metafile { - SAL_INFO("cppcanvas.emf", "EMF+ warning: empty bitmap"); + GDIMetaFile aGDI(image.graphic.GetGDIMetaFile()); + aGDI.Clip(aSource); + mrTargetHolders.Current().append( + new drawinglayer::primitive2d::MetafilePrimitive2D(aTransformMatrix,aGDI)); } } else @@ -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; } @@ -1175,35 +1186,33 @@ namespace emfplushelper const OUString emptyString; drawinglayer::attribute::FontAttribute fontAttribute( - font->family, // font family - emptyString, // (no) font style - font->Bold() ? 8u : 1u, // weight: 8 = bold - font->family == "SYMBOL", // symbol - stringFormat->DirectionVertical(), // vertical - font->Italic(), // italic - false, // monospaced - false, // outline = false, no such thing in MS-EMFPLUS - 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 + font->family, // font family + emptyString, // (no) font style + font->Bold() ? 8u : 1u, // weight: 8 = bold + font->family == "SYMBOL", // symbol + stringFormat && stringFormat->DirectionVertical(), // vertical + font->Italic(), // italic + false, // monospaced + false, // outline = false, no such thing in MS-EMFPLUS + stringFormat && stringFormat->DirectionRightToLeft(), // right-to-left + false); // BiDiStrong + + 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 + else { - const EMFPPen* pen = static_cast<EMFPPen*>(maEMFPObjects[brushId & 0xff].get()); - if (pen) - { - 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); |