diff options
Diffstat (limited to 'drawinglayer/source/tools/wmfemfhelper.cxx')
-rw-r--r-- | drawinglayer/source/tools/wmfemfhelper.cxx | 213 |
1 files changed, 75 insertions, 138 deletions
diff --git a/drawinglayer/source/tools/wmfemfhelper.cxx b/drawinglayer/source/tools/wmfemfhelper.cxx index 7f07e472bef8..13634c9ad1a5 100644 --- a/drawinglayer/source/tools/wmfemfhelper.cxx +++ b/drawinglayer/source/tools/wmfemfhelper.cxx @@ -23,6 +23,7 @@ #include <vcl/metaact.hxx> #include <drawinglayer/primitive2d/transformprimitive2d.hxx> #include <basegfx/matrix/b2dhommatrixtools.hxx> +#include <basegfx/utils/gradienttools.hxx> #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx> #include <drawinglayer/primitive2d/PolygonStrokePrimitive2D.hxx> #include <drawinglayer/primitive2d/PolygonHairlinePrimitive2D.hxx> @@ -76,7 +77,7 @@ namespace drawinglayer::primitive2d { protected: /// local decomposition. - virtual void create2DDecomposition(Primitive2DContainer& rContainer, + virtual Primitive2DReference create2DDecomposition( const geometry::ViewInformation2D& rViewInformation) const override; public: @@ -91,14 +92,14 @@ namespace drawinglayer::primitive2d } - void NonOverlappingFillGradientPrimitive2D::create2DDecomposition( - Primitive2DContainer& rContainer, + Primitive2DReference NonOverlappingFillGradientPrimitive2D::create2DDecomposition( const geometry::ViewInformation2D& /*rViewInformation*/) const { if (!getFillGradient().isDefault()) { - createFill(rContainer, false); + return createFill(false); } + return nullptr; } } // end of namespace @@ -333,15 +334,7 @@ namespace wmfemfhelper drawinglayer::primitive2d::Primitive2DContainer TargetHolder::getPrimitive2DSequence(const PropertyHolder& rPropertyHolder) { - const sal_uInt32 nCount(aTargets.size()); - drawinglayer::primitive2d::Primitive2DContainer xRetval(nCount); - - for (sal_uInt32 a(0); a < nCount; a++) - { - xRetval[a] = aTargets[a].get(); - } - // Since we have released them from the list - aTargets.clear(); + drawinglayer::primitive2d::Primitive2DContainer xRetval = std::move(aTargets); if (!xRetval.empty() && rPropertyHolder.getClipPolyPolygonActive()) { @@ -349,12 +342,11 @@ namespace wmfemfhelper if (rClipPolyPolygon.count()) { - drawinglayer::primitive2d::Primitive2DReference xMask( - new drawinglayer::primitive2d::MaskPrimitive2D( - rClipPolyPolygon, - std::move(xRetval))); - - xRetval = drawinglayer::primitive2d::Primitive2DContainer{ xMask }; + xRetval = drawinglayer::primitive2d::Primitive2DContainer{ + new drawinglayer::primitive2d::MaskPrimitive2D( + rClipPolyPolygon, + std::move(xRetval)) + }; } } @@ -477,7 +469,7 @@ namespace wmfemfhelper aLinePolygon.transform(rProperties.getTransformation()); rTarget.append( new drawinglayer::primitive2d::PolygonHairlinePrimitive2D( - aLinePolygon, + std::move(aLinePolygon), rProperties.getLineColor())); } } @@ -494,7 +486,7 @@ namespace wmfemfhelper aFillPolyPolygon.transform(rProperties.getTransformation()); rTarget.append( new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D( - aFillPolyPolygon, + std::move(aFillPolyPolygon), rProperties.getFillColor())); } } @@ -516,7 +508,7 @@ namespace wmfemfhelper { basegfx::B2DPolygon aLinePolygon(rLinePolygon); aLinePolygon.transform(rProperties.getTransformation()); - const drawinglayer::attribute::LineAttribute aLineAttribute( + drawinglayer::attribute::LineAttribute aLineAttribute( rProperties.getLineColor(), bWidthUsed ? rLineInfo.GetWidth() : 0.0, rLineInfo.GetLineJoin(), @@ -524,39 +516,23 @@ namespace wmfemfhelper if(bDashDotUsed) { - std::vector< double > fDotDashArray; - const double fDashLen(rLineInfo.GetDashLen()); - const double fDotLen(rLineInfo.GetDotLen()); - const double fDistance(rLineInfo.GetDistance()); - - for(sal_uInt16 a(0); a < rLineInfo.GetDashCount(); a++) - { - fDotDashArray.push_back(fDashLen); - fDotDashArray.push_back(fDistance); - } - - for(sal_uInt16 b(0); b < rLineInfo.GetDotCount(); b++) - { - fDotDashArray.push_back(fDotLen); - fDotDashArray.push_back(fDistance); - } - + std::vector< double > fDotDashArray = rLineInfo.GetDotDashArray(); const double fAccumulated(std::accumulate(fDotDashArray.begin(), fDotDashArray.end(), 0.0)); - const drawinglayer::attribute::StrokeAttribute aStrokeAttribute( + drawinglayer::attribute::StrokeAttribute aStrokeAttribute( std::move(fDotDashArray), fAccumulated); rTarget.append( new drawinglayer::primitive2d::PolygonStrokePrimitive2D( - aLinePolygon, - aLineAttribute, - aStrokeAttribute)); + std::move(aLinePolygon), + std::move(aLineAttribute), + std::move(aStrokeAttribute))); } else { rTarget.append( new drawinglayer::primitive2d::PolygonStrokePrimitive2D( - aLinePolygon, + std::move(aLinePolygon), aLineAttribute)); } } @@ -649,7 +625,7 @@ namespace wmfemfhelper rTarget.append( new drawinglayer::primitive2d::BitmapPrimitive2D( - VCLUnoHelper::CreateVCLXBitmap(rBitmapEx), + rBitmapEx, aObjectTransform)); } @@ -664,8 +640,8 @@ namespace wmfemfhelper aWhite, rMaskColor }; - Bitmap aMask(rBitmap.CreateMask(aWhite)); - Bitmap aSolid(rBitmap.GetSizePixel(), vcl::PixelFormat::N1_BPP, &aBiLevelPalette); + AlphaMask aMask(rBitmap.CreateAlphaMask(aWhite)); + Bitmap aSolid(rBitmap.GetSizePixel(), vcl::PixelFormat::N8_BPP, &aBiLevelPalette); aSolid.Erase(rMaskColor); @@ -697,50 +673,13 @@ namespace wmfemfhelper aEnd = interpolate(aBlack, aEnd, static_cast<double>(nEndIntens) * 0.01); } - drawinglayer::attribute::GradientStyle aGradientStyle(drawinglayer::attribute::GradientStyle::Rect); - - switch(rGradient.GetStyle()) - { - case GradientStyle::Linear : - { - aGradientStyle = drawinglayer::attribute::GradientStyle::Linear; - break; - } - case GradientStyle::Axial : - { - aGradientStyle = drawinglayer::attribute::GradientStyle::Axial; - break; - } - case GradientStyle::Radial : - { - aGradientStyle = drawinglayer::attribute::GradientStyle::Radial; - break; - } - case GradientStyle::Elliptical : - { - aGradientStyle = drawinglayer::attribute::GradientStyle::Elliptical; - break; - } - case GradientStyle::Square : - { - aGradientStyle = drawinglayer::attribute::GradientStyle::Square; - break; - } - default : // GradientStyle::Rect - { - aGradientStyle = drawinglayer::attribute::GradientStyle::Rect; - break; - } - } - return drawinglayer::attribute::FillGradientAttribute( - aGradientStyle, + rGradient.GetStyle(), static_cast<double>(rGradient.GetBorder()) * 0.01, static_cast<double>(rGradient.GetOfsX()) * 0.01, static_cast<double>(rGradient.GetOfsY()) * 0.01, toRadians(rGradient.GetAngle()), - aStart, - aEnd, + basegfx::BColorStops(aStart, aEnd), rGradient.GetSteps()); } @@ -940,12 +879,13 @@ namespace wmfemfhelper const Gradient& rGradient, PropertyHolder const & rPropertyHolder) { - const drawinglayer::attribute::FillGradientAttribute aAttribute(createFillGradientAttribute(rGradient)); + drawinglayer::attribute::FillGradientAttribute aAttribute(createFillGradientAttribute(rGradient)); + basegfx::BColor aSingleColor; - if(aAttribute.getStartColor() == aAttribute.getEndColor()) + if (aAttribute.getColorStops().isSingleColor(aSingleColor)) { // not really a gradient. Create filled rectangle - return CreateColorWallpaper(rRange, aAttribute.getStartColor(), rPropertyHolder); + return CreateColorWallpaper(rRange, aSingleColor, rPropertyHolder); } else { @@ -953,7 +893,7 @@ namespace wmfemfhelper rtl::Reference<drawinglayer::primitive2d::BasePrimitive2D> pRetval( new drawinglayer::primitive2d::FillGradientPrimitive2D( rRange, - aAttribute)); + std::move(aAttribute))); if(!rPropertyHolder.getTransformation().isIdentity()) { @@ -1100,6 +1040,7 @@ namespace wmfemfhelper sal_uInt16 nTextStart, sal_uInt16 nTextLength, std::vector< double >&& rDXArray, + std::vector< sal_Bool >&& rKashidaArray, TargetHolder& rTarget, PropertyHolder const & rProperty) { @@ -1125,7 +1066,7 @@ namespace wmfemfhelper // prepare FontColor and Locale const basegfx::BColor aFontColor(rProperty.getTextColor()); const Color aFillColor(rFont.GetFillColor()); - const css::lang::Locale aLocale(LanguageTag(rProperty.getLanguageType()).getLocale()); + css::lang::Locale aLocale(LanguageTag(rProperty.getLanguageType()).getLocale()); const bool bWordLineMode(rFont.IsWordLineMode()); const bool bDecoratedIsNeeded( @@ -1184,6 +1125,7 @@ namespace wmfemfhelper nTextStart, nTextLength, std::move(rDXArray), + std::move(rKashidaArray), aFontAttribute, aLocale, aFontColor, @@ -1212,8 +1154,9 @@ namespace wmfemfhelper nTextStart, nTextLength, std::vector(rDXArray), - aFontAttribute, - aLocale, + std::vector(rKashidaArray), + std::move(aFontAttribute), + std::move(aLocale), aFontColor); } } @@ -1315,7 +1258,7 @@ namespace wmfemfhelper if(!(bUnderlineUsed || bStrikeoutUsed || bOverlineUsed)) return; - std::vector< drawinglayer::primitive2d::BasePrimitive2D* > aTargetVector; + drawinglayer::primitive2d::Primitive2DContainer aTargets; basegfx::B2DVector aAlignmentOffset(0.0, 0.0); drawinglayer::attribute::FontAttribute aFontAttribute; basegfx::B2DHomMatrix aTextTransform; @@ -1337,7 +1280,7 @@ namespace wmfemfhelper if(bOverlineUsed) { // create primitive geometry for overline - aTargetVector.push_back( + aTargets.push_back( new drawinglayer::primitive2d::TextLinePrimitive2D( aTextTransform, fLineWidth, @@ -1350,7 +1293,7 @@ namespace wmfemfhelper if(bUnderlineUsed) { // create primitive geometry for underline - aTargetVector.push_back( + aTargets.push_back( new drawinglayer::primitive2d::TextLinePrimitive2D( aTextTransform, fLineWidth, @@ -1369,22 +1312,22 @@ namespace wmfemfhelper // strikeout with character const sal_Unicode aStrikeoutChar( drawinglayer::primitive2d::TEXT_STRIKEOUT_SLASH == aTextStrikeout ? '/' : 'X'); - const css::lang::Locale aLocale(LanguageTag( + css::lang::Locale aLocale(LanguageTag( rProperty.getLanguageType()).getLocale()); - aTargetVector.push_back( + aTargets.push_back( new drawinglayer::primitive2d::TextCharacterStrikeoutPrimitive2D( aTextTransform, fLineWidth, rProperty.getTextColor(), aStrikeoutChar, - aFontAttribute, - aLocale)); + std::move(aFontAttribute), + std::move(aLocale))); } else { // strikeout with geometry - aTargetVector.push_back( + aTargets.push_back( new drawinglayer::primitive2d::TextGeometryStrikeoutPrimitive2D( aTextTransform, fLineWidth, @@ -1395,31 +1338,21 @@ namespace wmfemfhelper } } - if(aTargetVector.empty()) + if(aTargets.empty()) return; // add created text primitive to target if(rProperty.getTransformation().isIdentity()) { - for(drawinglayer::primitive2d::BasePrimitive2D* a : aTargetVector) - { - rTarget.append(a); - } + rTarget.append(std::move(aTargets)); } else { // when a transformation is set, embed to it - drawinglayer::primitive2d::Primitive2DContainer xTargets(aTargetVector.size()); - - for(size_t a(0); a < aTargetVector.size(); a++) - { - xTargets[a] = drawinglayer::primitive2d::Primitive2DReference(aTargetVector[a]); - } - rTarget.append( new drawinglayer::primitive2d::TransformPrimitive2D( rProperty.getTransformation(), - std::move(xTargets))); + std::move(aTargets))); } } @@ -1564,7 +1497,6 @@ namespace wmfemfhelper } else { - aLineInfo.SetLineJoin(basegfx::B2DLineJoin::NONE); // It were lines; force to NONE createLinePrimitive(aLinePolygon, aLineInfo, rTargetHolders.Current(), rPropertyHolders.Current()); aLinePolygon.clear(); aLineInfo = pA->GetLineInfo(); @@ -1579,16 +1511,14 @@ namespace wmfemfhelper aLinePolygon.append(aEnd); } - nAction++; if(nAction < nCount) pAction = rMetaFile.GetAction(nAction); + nAction++; + if (nAction < nCount) + pAction = rMetaFile.GetAction(nAction); } nAction--; - - if(aLinePolygon.count()) - { - aLineInfo.SetLineJoin(basegfx::B2DLineJoin::NONE); // It were lines; force to NONE + if (aLinePolygon.count()) createLinePrimitive(aLinePolygon, aLineInfo, rTargetHolders.Current(), rPropertyHolders.Current()); - } } break; @@ -1806,6 +1736,7 @@ namespace wmfemfhelper nTextIndex, nTextLength, std::move(aDXArray), + {}, rTargetHolders.Current(), rPropertyHolders.Current()); } @@ -1829,7 +1760,8 @@ namespace wmfemfhelper { // prepare DXArray (if used) std::vector< double > aDXArray; - const std::vector<sal_Int32> & rDXArray = pA->GetDXArray(); + const KernArray& rDXArray = pA->GetDXArray(); + std::vector< sal_Bool > aKashidaArray = pA->GetKashidaArray(); if(!rDXArray.empty()) { @@ -1847,6 +1779,7 @@ namespace wmfemfhelper nTextIndex, nTextLength, std::move(aDXArray), + std::move(aKashidaArray), rTargetHolders.Current(), rPropertyHolders.Current()); } @@ -1910,6 +1843,7 @@ namespace wmfemfhelper nTextIndex, nTextLength, std::move(aTextArray), + {}, rTargetHolders.Current(), rPropertyHolders.Current()); } @@ -2115,10 +2049,11 @@ namespace wmfemfhelper if(!aRange.isEmpty()) { const Gradient& rGradient = pA->GetGradient(); - const drawinglayer::attribute::FillGradientAttribute aAttribute(createFillGradientAttribute(rGradient)); + drawinglayer::attribute::FillGradientAttribute aAttribute(createFillGradientAttribute(rGradient)); basegfx::B2DPolyPolygon aOutline(basegfx::utils::createPolygonFromRect(aRange)); + basegfx::BColor aSingleColor; - if(aAttribute.getStartColor() == aAttribute.getEndColor()) + if (aAttribute.getColorStops().isSingleColor(aSingleColor)) { // not really a gradient. Create filled rectangle createFillPrimitive( @@ -2147,7 +2082,7 @@ namespace wmfemfhelper xGradient[0] = drawinglayer::primitive2d::Primitive2DReference( new drawinglayer::primitive2d::FillGradientPrimitive2D( aRange, - aAttribute)); + std::move(aAttribute))); } // #i112300# clip against polygon representing the rectangle from @@ -2156,7 +2091,7 @@ namespace wmfemfhelper aOutline.transform(rPropertyHolders.Current().getTransformation()); rTargetHolders.Current().append( new drawinglayer::primitive2d::MaskPrimitive2D( - aOutline, + std::move(aOutline), std::move(xGradient))); } } @@ -2173,7 +2108,7 @@ namespace wmfemfhelper if(aOutline.count()) { const Hatch& rHatch = pA->GetHatch(); - const drawinglayer::attribute::FillHatchAttribute aAttribute(createFillHatchAttribute(rHatch)); + drawinglayer::attribute::FillHatchAttribute aAttribute(createFillHatchAttribute(rHatch)); aOutline.transform(rPropertyHolders.Current().getTransformation()); @@ -2182,11 +2117,11 @@ namespace wmfemfhelper new drawinglayer::primitive2d::FillHatchPrimitive2D( aObjectRange, basegfx::BColor(), - aAttribute)); + std::move(aAttribute))); rTargetHolders.Current().append( new drawinglayer::primitive2d::MaskPrimitive2D( - aOutline, + std::move(aOutline), drawinglayer::primitive2d::Primitive2DContainer { aFillHatch })); } @@ -2826,15 +2761,16 @@ namespace wmfemfhelper // check if gradient is a real gradient const Gradient& rGradient = pA->GetGradient(); - const drawinglayer::attribute::FillGradientAttribute aAttribute(createFillGradientAttribute(rGradient)); + drawinglayer::attribute::FillGradientAttribute aAttribute(createFillGradientAttribute(rGradient)); + basegfx::BColor aSingleColor; - if(aAttribute.getStartColor() == aAttribute.getEndColor()) + if (aAttribute.getColorStops().isSingleColor(aSingleColor)) { // not really a gradient; create UnifiedTransparencePrimitive2D rTargetHolders.Current().append( new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D( std::move(xSubContent), - aAttribute.getStartColor().luminance())); + aSingleColor.luminance())); } else { @@ -2846,7 +2782,7 @@ namespace wmfemfhelper const drawinglayer::primitive2d::Primitive2DReference xTransparence( new drawinglayer::primitive2d::FillGradientPrimitive2D( aRange, - aAttribute)); + std::move(aAttribute))); // create transparence primitive rTargetHolders.Current().append( @@ -2946,15 +2882,16 @@ namespace wmfemfhelper // get and check if gradient is a real gradient const Gradient& rGradient = pMetaGradientExAction->GetGradient(); - const drawinglayer::attribute::FillGradientAttribute aAttribute(createFillGradientAttribute(rGradient)); + drawinglayer::attribute::FillGradientAttribute aAttribute(createFillGradientAttribute(rGradient)); + basegfx::BColor aSingleColor; - if(aAttribute.getStartColor() == aAttribute.getEndColor()) + if (aAttribute.getColorStops().isSingleColor(aSingleColor)) { // not really a gradient rTargetHolders.Current().append( new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D( - aPolyPolygon, - aAttribute.getStartColor())); + std::move(aPolyPolygon), + aSingleColor)); } else { @@ -2962,7 +2899,7 @@ namespace wmfemfhelper rTargetHolders.Current().append( new drawinglayer::primitive2d::PolyPolygonGradientPrimitive2D( aPolyPolygon, - aAttribute)); + std::move(aAttribute))); } } } |