Kaydet (Commit) 6070dec9 authored tarafından Bartosz Kosiorek's avatar Bartosz Kosiorek

tdf#113635 Add support for Clip Intersect and XOR

Change-Id: Iff2bb06a209a6c089fec12b5f888ca4ef7c38c1b
Reviewed-on: https://gerrit.libreoffice.org/44289Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarBartosz Kosiorek <gang65@poczta.onet.pl>
üst f1c790ca
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <drawinglayer/primitive2d/metafileprimitive2d.hxx> #include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
#include <drawinglayer/attribute/fontattribute.hxx> #include <drawinglayer/attribute/fontattribute.hxx>
#include <basegfx/matrix/b2dhommatrixtools.hxx> #include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <basegfx/polygon/b2dpolygonclipper.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx> #include <basegfx/polygon/b2dpolygontools.hxx>
#include <o3tl/make_unique.hxx> #include <o3tl/make_unique.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
...@@ -696,6 +697,63 @@ namespace emfplushelper ...@@ -696,6 +697,63 @@ namespace emfplushelper
{ {
} }
void EmfPlusHelperData::combineClip(int combineMode, ::basegfx::B2DPolyPolygon& polygon)
{
switch (combineMode)
{
case EmfPlusCombineModeReplace:
case EmfPlusCombineModeUnion:
case EmfPlusCombineModeComplement:
{
HandleNewClipRegion(polygon, mrTargetHolders, mrPropertyHolders);
break;
}
case EmfPlusCombineModeXOR:
{
basegfx::B2DPolyPolygon aOriginalPolyPolygon(
mrPropertyHolders.Current().getClipPolyPolygon());
if (!aOriginalPolyPolygon.count())
{
HandleNewClipRegion(polygon, mrTargetHolders, mrPropertyHolders);
}
else
{
aOriginalPolyPolygon.append(polygon);
// use existing tooling from wmfemfhelper
HandleNewClipRegion(aOriginalPolyPolygon, mrTargetHolders, mrPropertyHolders);
}
break;
}
case EmfPlusCombineModeIntersect:
{
const basegfx::B2DPolyPolygon aOriginalPolyPolygon(
mrPropertyHolders.Current().getClipPolyPolygon());
basegfx::B2DPolyPolygon aClippedPolyPolygon;
if (aOriginalPolyPolygon.count())
{
aClippedPolyPolygon = basegfx::utils::clipPolyPolygonOnPolyPolygon(
aOriginalPolyPolygon,
polygon,
true,
false);
}
// use existing tooling from wmfemfhelper
HandleNewClipRegion(aClippedPolyPolygon, mrTargetHolders, mrPropertyHolders);
break;
}
case EmfPlusCombineModeExclude:
{
// Not doing anything is better then including exactly what we wanted to exclude.
break;
}
}
}
void EmfPlusHelperData::processEmfPlusData( void EmfPlusHelperData::processEmfPlusData(
SvMemoryStream& rMS, SvMemoryStream& rMS,
const drawinglayer::geometry::ViewInformation2D& /*rViewInformation*/) const drawinglayer::geometry::ViewInformation2D& /*rViewInformation*/)
...@@ -1451,7 +1509,7 @@ namespace emfplushelper ...@@ -1451,7 +1509,7 @@ namespace emfplushelper
SAL_INFO("drawinglayer", "EMF+ SetClipRect combine mode: " << combineMode); SAL_INFO("drawinglayer", "EMF+ SetClipRect combine mode: " << combineMode);
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
if (combineMode > 1) { if (combineMode > 1) {
SAL_INFO("drawinglayer", "EMF+ TODO combine mode > 1"); SAL_WARN("drawinglayer", "EMF+ \tSetClipRect TODO combine mode > 1");
} }
#endif #endif
...@@ -1470,10 +1528,7 @@ namespace emfplushelper ...@@ -1470,10 +1528,7 @@ namespace emfplushelper
mappedPoint.getX() + mappedSize.getX(), mappedPoint.getX() + mappedSize.getX(),
mappedPoint.getY() + mappedSize.getY())))); mappedPoint.getY() + mappedSize.getY()))));
// use existing tooling from wmfemfhelper combineClip(combineMode, polyPolygon);
HandleNewClipRegion(polyPolygon, mrTargetHolders, mrPropertyHolders);
// polyPolygon.transform(rState.mapModeTransform);
// updateClipping(polyPolygon, rFactoryParms, combineMode == 1);
break; break;
} }
case EmfPlusRecordTypeSetClipPath: case EmfPlusRecordTypeSetClipPath:
...@@ -1486,26 +1541,7 @@ namespace emfplushelper ...@@ -1486,26 +1541,7 @@ namespace emfplushelper
::basegfx::B2DPolyPolygon& clipPoly(path.GetPolygon(*this)); ::basegfx::B2DPolyPolygon& clipPoly(path.GetPolygon(*this));
// clipPoly.transform(rState.mapModeTransform); // clipPoly.transform(rState.mapModeTransform);
switch (combineMode) combineClip(combineMode, clipPoly);
{
case EmfPlusCombineModeReplace:
case EmfPlusCombineModeIntersect:
case EmfPlusCombineModeUnion: // Is this, EmfPlusCombineModeXOR and EmfPlusCombineModeComplement correct?
case EmfPlusCombineModeXOR:
case EmfPlusCombineModeComplement:
{
// use existing tooling from wmfemfhelper
HandleNewClipRegion(clipPoly, mrTargetHolders, mrPropertyHolders);
// updateClipping(clipPoly, rFactoryParms, combineMode == 1);
break;
}
case EmfPlusCombineModeExclude:
{
// Not doing anything is better then including exactly what we wanted to exclude.
break;
}
}
break; break;
} }
case EmfPlusRecordTypeSetClipRegion: case EmfPlusRecordTypeSetClipRegion:
...@@ -1524,7 +1560,7 @@ namespace emfplushelper ...@@ -1524,7 +1560,7 @@ namespace emfplushelper
} }
else else
{ {
SAL_INFO("drawinglayer", "EMF+\tTODO"); SAL_WARN("drawinglayer", "EMF+\tTODO");
} }
break; break;
} }
......
...@@ -242,6 +242,7 @@ namespace emfplushelper ...@@ -242,6 +242,7 @@ namespace emfplushelper
// helper functions // helper functions
::basegfx::BColor EMFPGetBrushColorOrARGBColor(sal_uInt16 flags, sal_uInt32 brushIndexOrColor) const; ::basegfx::BColor EMFPGetBrushColorOrARGBColor(sal_uInt16 flags, sal_uInt32 brushIndexOrColor) const;
void combineClip(int combineMode, ::basegfx::B2DPolyPolygon& polygon);
public: public:
EmfPlusHelperData( EmfPlusHelperData(
......
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