From e49aa9303f047d7610b2b8334404db120d7bc8db Mon Sep 17 00:00:00 2001 From: Bartosz Kosiorek Date: Mon, 6 Nov 2017 23:44:34 +0100 Subject: tdf#77229 tdf#113635 EMF+ Add support for Clip Union, Exclude and Complement Union: Replaces the existing region with the union of the existing and new regions. Exclude: Replaces the existing region with the part of itself that is not in the new region. Complement: Replaces the existing region with the part of the new region that is not in the existing region. Change-Id: Iabbe0ddfa082a332e94dd85b6444b234d1bdee35 Reviewed-on: https://gerrit.libreoffice.org/44380 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek --- drawinglayer/source/tools/emfphelperdata.cxx | 65 ++++++++++++++++------------ 1 file changed, 37 insertions(+), 28 deletions(-) (limited to 'drawinglayer/source') diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index ebce2fbbd411..77f5d8f0c912 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -702,30 +703,10 @@ namespace emfplushelper 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( @@ -734,7 +715,6 @@ namespace emfplushelper basegfx::B2DPolyPolygon aClippedPolyPolygon; if (aOriginalPolyPolygon.count()) { - aClippedPolyPolygon = basegfx::utils::clipPolyPolygonOnPolyPolygon( aOriginalPolyPolygon, polygon, @@ -742,13 +722,47 @@ namespace emfplushelper false); } - // use existing tooling from wmfemfhelper HandleNewClipRegion(aClippedPolyPolygon, mrTargetHolders, mrPropertyHolders); break; } + case EmfPlusCombineModeUnion: + { + basegfx::B2DPolyPolygon aOriginalPolyPolygon( + mrPropertyHolders.Current().getClipPolyPolygon()); + + aOriginalPolyPolygon = ::basegfx::utils::solvePolygonOperationOr(aOriginalPolyPolygon, polygon); + HandleNewClipRegion(aOriginalPolyPolygon, mrTargetHolders, mrPropertyHolders); + + break; + } + case EmfPlusCombineModeXOR: + { + basegfx::B2DPolyPolygon aOriginalPolyPolygon( + mrPropertyHolders.Current().getClipPolyPolygon()); + + aOriginalPolyPolygon = ::basegfx::utils::solvePolygonOperationXor(aOriginalPolyPolygon, polygon); + HandleNewClipRegion(aOriginalPolyPolygon, mrTargetHolders, mrPropertyHolders); + + break; + } case EmfPlusCombineModeExclude: { - // Not doing anything is better then including exactly what we wanted to exclude. + // Replaces the existing region with the part of itself that is not in the new region. + basegfx::B2DPolyPolygon aOriginalPolyPolygon( + mrPropertyHolders.Current().getClipPolyPolygon()); + + aOriginalPolyPolygon = ::basegfx::utils::solvePolygonOperationDiff(aOriginalPolyPolygon, polygon); + HandleNewClipRegion(aOriginalPolyPolygon, mrTargetHolders, mrPropertyHolders); + break; + } + case EmfPlusCombineModeComplement: + { + // Replaces the existing region with the part of the new region that is not in the existing region. + basegfx::B2DPolyPolygon aOriginalPolyPolygon( + mrPropertyHolders.Current().getClipPolyPolygon()); + + aOriginalPolyPolygon = ::basegfx::utils::solvePolygonOperationDiff(polygon, aOriginalPolyPolygon); + HandleNewClipRegion(aOriginalPolyPolygon, mrTargetHolders, mrPropertyHolders); break; } } @@ -1507,11 +1521,6 @@ namespace emfplushelper int combineMode = (flags >> 8) & 0xf; SAL_INFO("drawinglayer", "EMF+ SetClipRect combine mode: " << combineMode); -#if OSL_DEBUG_LEVEL > 1 - if (combineMode > 1) { - SAL_WARN("drawinglayer", "EMF+ \tSetClipRect TODO combine mode > 1"); - } -#endif float dx, dy, dw, dh; ReadRectangle(rMS, dx, dy, dw, dh); -- cgit