cppcanvas/source/mtfrenderer/emfplus.cxx | 134 +++++++++++++++++++++++++- cppcanvas/source/mtfrenderer/implrenderer.cxx | 13 ++ vcl/source/filter/wmf/winmtf.cxx | 18 ++- vcl/source/filter/wmf/winmtf.hxx | 2 4 files changed, 158 insertions(+), 9 deletions(-)
New commits: commit dfa0fc194fc2600569374f7282208f77548c27c5 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.com> Date: Sat Jul 19 21:52:09 2014 +0200 emf+: emulate hatch with color blend Conflicts: cppcanvas/source/mtfrenderer/emfplus.cxx Change-Id: I2ac8f790c79c269d4c1fa650e703c3645c567ca4 diff --git a/cppcanvas/source/mtfrenderer/emfplus.cxx b/cppcanvas/source/mtfrenderer/emfplus.cxx index 0c53c59..e6b1ea8 100644 --- a/cppcanvas/source/mtfrenderer/emfplus.cxx +++ b/cppcanvas/source/mtfrenderer/emfplus.cxx @@ -123,6 +123,63 @@ enum EmfPlusCombineMode EmfPlusCombineModeComplement = 0x00000005 }; +enum EmfPlusHatchStyle +{ + HatchStyleHorizontal = 0x00000000, + HatchStyleVertical = 0x00000001, + HatchStyleForwardDiagonal = 0x00000002, + HatchStyleBackwardDiagonal = 0x00000003, + HatchStyleLargeGrid = 0x00000004, + HatchStyleDiagonalCross = 0x00000005, + HatchStyle05Percent = 0x00000006, + HatchStyle10Percent = 0x00000007, + HatchStyle20Percent = 0x00000008, + HatchStyle25Percent = 0x00000009, + HatchStyle30Percent = 0x0000000A, + HatchStyle40Percent = 0x0000000B, + HatchStyle50Percent = 0x0000000C, + HatchStyle60Percent = 0x0000000D, + HatchStyle70Percent = 0x0000000E, + HatchStyle75Percent = 0x0000000F, + HatchStyle80Percent = 0x00000010, + HatchStyle90Percent = 0x00000011, + HatchStyleLightDownwardDiagonal = 0x00000012, + HatchStyleLightUpwardDiagonal = 0x00000013, + HatchStyleDarkDownwardDiagonal = 0x00000014, + HatchStyleDarkUpwardDiagonal = 0x00000015, + HatchStyleWideDownwardDiagonal = 0x00000016, + HatchStyleWideUpwardDiagonal = 0x00000017, + HatchStyleLightVertical = 0x00000018, + HatchStyleLightHorizontal = 0x00000019, + HatchStyleNarrowVertical = 0x0000001A, + HatchStyleNarrowHorizontal = 0x0000001B, + HatchStyleDarkVertical = 0x0000001C, + HatchStyleDarkHorizontal = 0x0000001D, + HatchStyleDashedDownwardDiagonal = 0x0000001E, + HatchStyleDashedUpwardDiagonal = 0x0000001F, + HatchStyleDashedHorizontal = 0x00000020, + HatchStyleDashedVertical = 0x00000021, + HatchStyleSmallConfetti = 0x00000022, + HatchStyleLargeConfetti = 0x00000023, + HatchStyleZigZag = 0x00000024, + HatchStyleWave = 0x00000025, + HatchStyleDiagonalBrick = 0x00000026, + HatchStyleHorizontalBrick = 0x00000027, + HatchStyleWeave = 0x00000028, + HatchStylePlaid = 0x00000029, + HatchStyleDivot = 0x0000002A, + HatchStyleDottedGrid = 0x0000002B, + HatchStyleDottedDiamond = 0x0000002C, + HatchStyleShingle = 0x0000002D, + HatchStyleTrellis = 0x0000002E, + HatchStyleSphere = 0x0000002F, + HatchStyleSmallGrid = 0x00000030, + HatchStyleSmallCheckerBoard = 0x00000031, + HatchStyleLargeCheckerBoard = 0x00000032, + HatchStyleOutlinedDiamond = 0x00000033, + HatchStyleSolidDiamond = 0x00000034 +}; + using namespace ::com::sun::star; using namespace ::basegfx; @@ -362,9 +419,28 @@ namespace cppcanvas sal_Int32 surroundColorsNumber; ::Color* surroundColors; EMFPPath *path; + EmfPlusHatchStyle hatchStyle; public: EMFPBrush () + : type(0) + , additionalFlags(0) + , wrapMode(0) + , areaX(0.0) + , areaY(0.0) + , areaWidth(0.0) + , areaHeight(0.0) + , hasTransformation(false) + , blendPoints(0) + , blendPositions(NULL) + , blendFactors(NULL) + , colorblendPoints(0) + , colorblendPositions(NULL) + , colorblendColors(NULL) + , surroundColorsNumber(0) + , surroundColors(NULL) + , path(NULL) + , hatchStyle(HatchStyleHorizontal) { blendPositions = NULL; colorblendPositions = NULL; @@ -418,7 +494,20 @@ namespace cppcanvas s >> color; solidColor = ::Color (0xff - (color >> 24), (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff); SAL_INFO ("cppcanvas.emf", "EMF+\tsolid color: 0x" << std::hex << color << std::dec); - + break; + } + case 1: + { + sal_uInt32 style; + sal_uInt32 foregroundColor; + sal_uInt32 backgroundColor; + s >> style; + s >> foregroundColor; + s >> backgroundColor; + + hatchStyle = static_cast<EmfPlusHatchStyle>(style); + solidColor = ::Color(0xff - (foregroundColor >> 24), (foregroundColor >> 16) & 0xff, (foregroundColor >> 8) & 0xff, foregroundColor & 0xff); + secondColor = ::Color(0xff - (backgroundColor >> 24), (backgroundColor >> 16) & 0xff, (backgroundColor >> 8) & 0xff, backgroundColor & 0xff); break; } // path gradient @@ -1157,8 +1246,49 @@ namespace cppcanvas rState.isFillColorSet = false; rState.isLineColorSet = false; - if (brush->type == 3 || brush->type == 4) { + if (brush->type == 1) + { + // EMF+ like hatching is currently not supported. These are just color blends which serve as an approximation for some of them + // for the others the hatch "background" color (secondColor in brush) is used. + bool isHatchBlend = true; + double blendFactor = 0.0; + + switch (brush->hatchStyle) + { + case HatchStyle05Percent: blendFactor = 0.05; break; + case HatchStyle10Percent: blendFactor = 0.10; break; + case HatchStyle20Percent: blendFactor = 0.20; break; + case HatchStyle25Percent: blendFactor = 0.25; break; + case HatchStyle30Percent: blendFactor = 0.30; break; + case HatchStyle40Percent: blendFactor = 0.40; break; + case HatchStyle50Percent: blendFactor = 0.50; break; + case HatchStyle60Percent: blendFactor = 0.60; break; + case HatchStyle70Percent: blendFactor = 0.70; break; + case HatchStyle75Percent: blendFactor = 0.75; break; + case HatchStyle80Percent: blendFactor = 0.80; break; + case HatchStyle90Percent: blendFactor = 0.90; break; + default: + isHatchBlend = false; + break; + } + rState.isFillColorSet = true; + rState.isLineColorSet = false; + ::Color fillColor; + if (isHatchBlend) + { + fillColor = brush->solidColor; + fillColor.Merge(brush->secondColor, static_cast<sal_uInt8>(255 * blendFactor)); + } + else + { + fillColor = brush->secondColor; + } + rState.fillColor = ::vcl::unotools::colorToDoubleSequence(fillColor, rCanvas->getUNOCanvas()->getDevice()->getDeviceColorSpace()); + pPolyAction = ActionSharedPtr ( internal::PolyPolyActionFactory::createPolyPolyAction( localPolygon, rParms.mrCanvas, rState ) ); + } + else if (brush->type == 3 || brush->type == 4) + { if (brush->type == 3 && !(brush->additionalFlags & 0x1)) return; // we are unable to parse these brushes yet commit b201eed6051c0cb1f33964b3c6e04f8eae415732 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.com> Date: Fri Jul 18 13:36:59 2014 +0200 bnc#881024 Handle 0 font height just like outdev & drawinglayer Change-Id: I80055e4101873e0ddd408ac1f0ee9c75cc3bf6b3 diff --git a/cppcanvas/source/mtfrenderer/implrenderer.cxx b/cppcanvas/source/mtfrenderer/implrenderer.cxx index a8145bb..b7cbcab 100644 --- a/cppcanvas/source/mtfrenderer/implrenderer.cxx +++ b/cppcanvas/source/mtfrenderer/implrenderer.cxx @@ -809,7 +809,18 @@ namespace cppcanvas // TODO(Q3): This code smells of programming by // coincidence (the next two if statements) - const ::Size rFontSizeLog( rFont.GetSize() ); + + ::Size rFontSizeLog( rFont.GetSize() ); + + if (rFontSizeLog.Height() == 0) + { + // guess 16 pixel (as in VCL) + rFontSizeLog = ::Size(0, 16); + + // convert to target MapUnit if not pixels + rFontSizeLog = OutputDevice::LogicToLogic(rFontSizeLog, MAP_PIXEL, rParms.mrVDev.GetMapMode()); + } + const sal_Int32 nFontWidthLog = rFontSizeLog.Width(); if( nFontWidthLog != 0 ) { commit d040fda43aad75dccd6df0cb514e87f35aafad9e Author: Tomaž Vajngerl <tomaz.vajng...@collabora.com> Date: Fri Jul 18 13:36:13 2014 +0200 bnc#881024 Don't world transform font size in WMF/EMF import Conflicts: vcl/source/filter/wmf/winmtf.cxx Change-Id: Ia865b84ee2b159ff7251ab5a769a2b635dd2a1ea diff --git a/vcl/source/filter/wmf/winmtf.cxx b/vcl/source/filter/wmf/winmtf.cxx index f87336c..a63d25d 100644 --- a/vcl/source/filter/wmf/winmtf.cxx +++ b/vcl/source/filter/wmf/winmtf.cxx @@ -398,14 +398,22 @@ Point WinMtfOutput::ImplMap( const Point& rPt ) return Point(); }; - -Size WinMtfOutput::ImplMap( const Size& rSz ) +Size WinMtfOutput::ImplMap(const Size& rSz, bool bDoWorldTransform) { if ( mnWinExtX && mnWinExtY ) { // #i121382# apply the whole WorldTransform, else a rotation will be misinterpreted - double fWidth = rSz.Width() * maXForm.eM11 + rSz.Height() * maXForm.eM21; - double fHeight = rSz.Width() * maXForm.eM12 + rSz.Height() * maXForm.eM22; + double fWidth, fHeight; + if (bDoWorldTransform) + { + fWidth = rSz.Width() * maXForm.eM11 + rSz.Height() * maXForm.eM21; + fHeight = rSz.Width() * maXForm.eM12 + rSz.Height() * maXForm.eM22; + } + else + { + fWidth = rSz.Width(); + fHeight = rSz.Height(); + } if ( mnGfxMode == GM_COMPATIBLE ) { @@ -469,7 +477,7 @@ void WinMtfOutput::ImplMap( Font& rFont ) { // !!! HACK: we now always set the width to zero because the OS width is interpreted differently; // must later be made portable in SV (KA 1996-02-08) - Size aFontSize = ImplMap ( rFont.GetSize() ); + Size aFontSize = ImplMap (rFont.GetSize(), false); if( aFontSize.Height() < 0 ) aFontSize.Height() *= -1; diff --git a/vcl/source/filter/wmf/winmtf.hxx b/vcl/source/filter/wmf/winmtf.hxx index 7438588..a2f4cfd 100644 --- a/vcl/source/filter/wmf/winmtf.hxx +++ b/vcl/source/filter/wmf/winmtf.hxx @@ -632,7 +632,7 @@ class WinMtfOutput Point ImplMap( const Point& rPt ); Point ImplScale( const Point& rPt ); - Size ImplMap( const Size& rSz ); + Size ImplMap( const Size& rSize, bool bDoWorldTransform = true); Rectangle ImplMap( const Rectangle& rRectangle ); void ImplMap( Font& rFont ); sal_Int32 ImplConvertWidth(const sal_Int32 aWidth);
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits