30 #include <osl/diagnose.h>
37 bool handleGeometricContent(
54 if(aResult == rSource)
64 for(
auto const& rB2DPolygon : aResult)
67 new MetaPolyLineAction(
74 new MetaPolyPolygonAction(
84 bool handleGradientContent(
101 if(aResult == rSource)
110 new MetaGradientExAction(
120 bool handleBitmapContent(
134 rPoint.X(), rPoint.Y(),
135 rPoint.X() + rSize.
Width(), rPoint.Y() + rSize.
Height());
143 if(!aClipOfBitmap.count())
152 const double fBitmapArea(
153 aLogicBitmapRange.getWidth() * aLogicBitmapRange.getWidth() +
154 aLogicBitmapRange.getHeight() * aLogicBitmapRange.getHeight());
155 const double fFactor(fClipArea / fBitmapArea);
169 aVDev->SetOutputSizePixel(aSizePixel);
170 aVDev->EnableMapMode(
false);
171 aVDev->SetFillColor( COL_WHITE);
172 aVDev->SetLineColor();
182 aVDev->SetBackground(
Wallpaper(COL_BLACK));
190 aTransform.
translate(-aLogicBitmapRange.getMinX(), -aLogicBitmapRange.getMinY());
192 static_cast< double >(aSizePixel.Width()) / aLogicBitmapRange.getWidth(),
193 static_cast< double >(aSizePixel.Height()) / aLogicBitmapRange.getHeight());
194 aPixelPoly.transform(aTransform);
205 aSizePixel.Width(), aSizePixel.Height())));
206 aInvertPixelPoly.
append(aPixelPoly);
209 aVDev->DrawPolyPolygon(aInvertPixelPoly);
241 "XPATHSTROKE_SEQ_BEGIN",
243 static_cast< const sal_uInt8* >(aMemStm.
GetData()),
254 "XPATHFILL_SEQ_BEGIN",
256 static_cast< const sal_uInt8* >(aMemStm.
GetData()),
274 bool bChanged(
false);
275 std::vector< basegfx::B2DPolyPolygon > aClips;
276 std::vector< PushFlags > aPushFlags;
277 std::vector< MapMode > aMapModes;
280 aClips.emplace_back();
283 aMapModes.emplace_back();
299 const MetaClipRegionAction* pA =
static_cast< const MetaClipRegionAction*
>(pAction);
306 aClips.back() = aNewClip;
318 const MetaISectRectClipRegionAction* pA =
static_cast< const MetaISectRectClipRegionAction*
>(pAction);
321 if(!rRect.
IsEmpty() && !aClips.empty() && aClips.back().count())
336 const MetaISectRegionClipRegionAction* pA =
static_cast< const MetaISectRegionClipRegionAction*
>(pAction);
339 if(!rRegion.
IsEmpty() && !aClips.empty() && aClips.back().count())
354 const MetaMoveClipRegionAction* pA =
static_cast< const MetaMoveClipRegionAction*
>(pAction);
358 if((aHorMove || aVerMove) && !aClips.empty() && aClips.back().count())
360 aClips.back().transform(
370 const MetaPushAction* pA =
static_cast< const MetaPushAction*
>(pAction);
373 aPushFlags.push_back(nFlags);
377 aClips.push_back(aClips.back());
382 aMapModes.push_back(aMapModes.back());
390 if(!aPushFlags.empty())
392 const PushFlags nFlags(aPushFlags.back());
393 aPushFlags.pop_back();
397 if(aClips.size() > 1)
403 OSL_ENSURE(
false,
"Wrong POP() in ClipRegions (!)");
409 if(aMapModes.size() > 1)
411 aMapModes.pop_back();
415 OSL_ENSURE(
false,
"Wrong POP() in MapModes (!)");
421 OSL_ENSURE(
false,
"Invalid pop() without push() (!)");
429 const MetaMapModeAction* pA =
static_cast< const MetaMapModeAction*
>(pAction);
431 aMapModes.back() = pA->GetMapMode();
445 if(!aClips.empty() && aClips.back().count())
454 const MetaPixelAction* pA =
static_cast< const MetaPixelAction*
>(pAction);
455 const Point& rPoint = pA->GetPoint();
494 bDone = handleGeometricContent(
514 bDone = handleGeometricContent(
527 const MetaRoundRectAction* pA =
static_cast< const MetaRoundRectAction*
>(pAction);
536 const sal_uInt32 nHor(pA->GetHorzRound());
537 const sal_uInt32 nVer(pA->GetVertRound());
543 double fRadiusX((nHor * 2.0) / (aRange.getWidth() > 0.0 ? aRange.getWidth() : 1.0));
544 double fRadiusY((nVer * 2.0) / (aRange.getHeight() > 0.0 ? aRange.getHeight() : 1.0));
545 fRadiusX = std::clamp(fRadiusX, 0.0, 1.0);
546 fRadiusY = std::clamp(fRadiusY, 0.0, 1.0);
555 bDone = handleGeometricContent(
566 const MetaEllipseAction* pA =
static_cast< const MetaEllipseAction*
>(pAction);
577 bDone = handleGeometricContent(
592 const MetaArcAction* pA =
static_cast< const MetaArcAction*
>(pAction);
607 bDone = handleGeometricContent(
618 const MetaPieAction* pA =
static_cast< const MetaPieAction*
>(pAction);
633 bDone = handleGeometricContent(
644 const MetaChordAction* pA =
static_cast< const MetaChordAction*
>(pAction);
659 bDone = handleGeometricContent(
670 const MetaPolyLineAction* pA =
static_cast< const MetaPolyLineAction*
>(pAction);
672 bDone = handleGeometricContent(
682 const MetaPolygonAction* pA =
static_cast< const MetaPolygonAction*
>(pAction);
684 bDone = handleGeometricContent(
694 const MetaPolyPolygonAction* pA =
static_cast< const MetaPolyPolygonAction*
>(pAction);
697 bDone = handleGeometricContent(
726 bDone = handleBitmapContent(
753 bDone = handleBitmapContent(
766 bDone = handleBitmapContent(
779 bDone = handleBitmapContent(
790 const MetaBmpExScalePartAction* pA =
static_cast< const MetaBmpExScalePartAction*
>(pAction);
791 const BitmapEx& rBitmapEx = pA->GetBitmapEx();
800 BitmapEx aCroppedBitmapEx(rBitmapEx);
803 if(aCropRectangle.IsEmpty())
810 aCroppedBitmapEx.
Crop(aCropRectangle);
811 bDone = handleBitmapContent(
824 const MetaBmpScalePartAction* pA =
static_cast< const MetaBmpScalePartAction*
>(pAction);
825 const Bitmap& rBitmap = pA->GetBitmap();
834 Bitmap aCroppedBitmap(rBitmap);
837 if(aCropRectangle.IsEmpty())
844 aCroppedBitmap.
Crop(aCropRectangle);
845 bDone = handleBitmapContent(
863 if(rComment.equalsIgnoreAsciiCase(
"XGRAD_SEQ_BEGIN"))
871 else if(rComment.equalsIgnoreAsciiCase(
"XPATHFILL_SEQ_BEGIN"))
895 if(aResult != aSource)
899 addSvtGraphicFill(aFilling, aTarget);
907 addSvtGraphicFill(aFilling, aTarget);
912 else if(rComment.equalsIgnoreAsciiCase(
"XPATHSTROKE_SEQ_BEGIN"))
936 if(aResult.count() > 1 || aResult.getB2DPolygon(0) != aSource)
939 for(
auto const& rB2DPolygon : aResult)
942 addSvtGraphicStroke(aStroke, aTarget);
952 addSvtGraphicStroke(aStroke, aTarget);
974 bDone = handleGradientContent(
988 const MetaGradientExAction* pA =
static_cast< const MetaGradientExAction*
>(pAction);
991 bDone = handleGradientContent(
1042 aTarget.
AddAction(const_cast< MetaAction* >(pAction));
1082 MetafileAccessor::~MetafileAccessor()
B2DPoint getCenter() const
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
double getArea(const B2DPolygon &rCandidate)
const MapMode & GetPrefMapMode() const
Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
Bitmap const & GetBitmap() const
Encapsulates geometry and associated attributes of a graphical 'pen stroke'.
B2DPolyPolygon clipPolyPolygonOnPolyPolygon(const B2DPolyPolygon &rCandidate, const B2DPolyPolygon &rClip, bool bInside, bool bStroke)
virtual sal_uInt64 TellEnd() override
const Size & GetPrefSize() const
static OutputDevice * GetDefaultDevice()
Get the default "device" (in this case the default window).
bool Crop(const tools::Rectangle &rRectPixel)
Crop the bitmap.
const Size & GetPrefSize() const
B2IRange fround(const B2DRange &rRange)
void setPath(const tools::PolyPolygon &rPath)
Set path to fill.
const MapMode & GetPrefMapMode() const
B2DPolygon createPolygonFromRect(const B2DRectangle &rRect, double fRadiusX, double fRadiusY)
tools::Long Width() const
void scale(double fX, double fY)
void SetPrefSize(const Size &rSize)
void getPath(tools::Polygon &) const
Query path to stroke.
MapUnit GetMapUnit() const
bool IsTransparent() const
Bitmap GetBitmap(Color aTransparentReplaceColor) const
Point PixelToLogic(const Point &rDevicePt) const
void append(const B2DPolygon &rPolygon, sal_uInt32 nCount=1)
AlphaMask GetAlpha() const
B2DPolyPolygon clipPolygonOnPolyPolygon(const B2DPolygon &rCandidate, const B2DPolyPolygon &rClip, bool bInside, bool bStroke)
bool isInside(const B2DPolygon &rCandidate, const B2DPoint &rPoint, bool bWithBorder)
tools::Long Height() const
void translate(double fX, double fY)
void setPath(const tools::Polygon &)
Set path to stroke.
basegfx::B2DPolyPolygon GetAsB2DPolyPolygon() const
Encapsulates geometry and associated attributes of a filled area.
B2DPolyPolygon clipPolyPolygonOnRange(const B2DPolyPolygon &rCandidate, const B2DRange &rRange, bool bInside, bool bStroke)
void getPath(tools::PolyPolygon &) const
Query path to fill.
B2DHomMatrix createTranslateB2DHomMatrix(double fTranslateX, double fTranslateY)
const Size & GetSizePixel() const
bool Crop(const tools::Rectangle &rRectPixel)
Crop the bitmap.
B2DPolygon createPolygonFromEllipse(const B2DPoint &rCenter, double fRadiusX, double fRadiusY, sal_uInt32 nStartQuadrant=0)