svgclippathnode.cxx (3aaca8a3) | svgclippathnode.cxx (db3fbf26) |
---|---|
1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 10 unchanged lines hidden (view full) --- 19 * 20 *************************************************************/ 21 22// MARKER(update_precomp.py): autogen include statement, do not remove 23#include "precompiled_svgio.hxx" 24 25#include <svgio/svgreader/svgclippathnode.hxx> 26#include <drawinglayer/primitive2d/transformprimitive2d.hxx> | 1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 10 unchanged lines hidden (view full) --- 19 * 20 *************************************************************/ 21 22// MARKER(update_precomp.py): autogen include statement, do not remove 23#include "precompiled_svgio.hxx" 24 25#include <svgio/svgreader/svgclippathnode.hxx> 26#include <drawinglayer/primitive2d/transformprimitive2d.hxx> |
27#include <drawinglayer/primitive2d/transparenceprimitive2d.hxx> | 27#include <drawinglayer/primitive2d/maskprimitive2d.hxx> |
28#include <basegfx/matrix/b2dhommatrixtools.hxx> 29#include <drawinglayer/geometry/viewinformation2d.hxx> | 28#include <basegfx/matrix/b2dhommatrixtools.hxx> 29#include <drawinglayer/geometry/viewinformation2d.hxx> |
30#include <drawinglayer/processor2d/contourextractor2d.hxx> 31#include <basegfx/polygon/b2dpolypolygoncutter.hxx> |
|
30 31////////////////////////////////////////////////////////////////////////////// 32 33namespace svgio 34{ 35 namespace svgreader 36 { 37 SvgClipPathNode::SvgClipPathNode( --- 90 unchanged lines hidden (view full) --- 128 } 129 } 130 } 131 132 void SvgClipPathNode::apply(drawinglayer::primitive2d::Primitive2DSequence& rContent) const 133 { 134 if(rContent.hasElements()) 135 { | 32 33////////////////////////////////////////////////////////////////////////////// 34 35namespace svgio 36{ 37 namespace svgreader 38 { 39 SvgClipPathNode::SvgClipPathNode( --- 90 unchanged lines hidden (view full) --- 130 } 131 } 132 } 133 134 void SvgClipPathNode::apply(drawinglayer::primitive2d::Primitive2DSequence& rContent) const 135 { 136 if(rContent.hasElements()) 137 { |
138 const drawinglayer::geometry::ViewInformation2D aViewInformation2D; |
|
136 drawinglayer::primitive2d::Primitive2DSequence aClipTarget; | 139 drawinglayer::primitive2d::Primitive2DSequence aClipTarget; |
140 basegfx::B2DPolyPolygon aClipPolyPolygon; |
|
137 138 // get clipPath definition as primitives 139 decomposeSvgNode(aClipTarget, true); 140 141 if(aClipTarget.hasElements()) 142 { | 141 142 // get clipPath definition as primitives 143 decomposeSvgNode(aClipTarget, true); 144 145 if(aClipTarget.hasElements()) 146 { |
147 // extract filled plygons as base for a mask PolyPolygon 148 drawinglayer::processor2d::ContourExtractor2D aExtractor(aViewInformation2D, true); 149 150 aExtractor.process(aClipTarget); 151 152 const basegfx::B2DPolyPolygonVector& rResult(aExtractor.getExtractedContour()); 153 const sal_uInt32 nSize(rResult.size()); 154 155 if(nSize > 1) 156 { 157 // merge to single clipPolyPolygon 158 aClipPolyPolygon = basegfx::tools::mergeToSinglePolyPolygon(rResult); 159 } 160 else 161 { 162 aClipPolyPolygon = rResult[0]; 163 } 164 } 165 166 if(aClipPolyPolygon.count()) 167 { |
|
143 if(objectBoundingBox == getClipPathUnits()) 144 { | 168 if(objectBoundingBox == getClipPathUnits()) 169 { |
145 // clip is object-relative, embed in content transformation | 170 // clip is object-relative, transform using content transformation |
146 const basegfx::B2DRange aContentRange( 147 drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence( 148 rContent, | 171 const basegfx::B2DRange aContentRange( 172 drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence( 173 rContent, |
149 drawinglayer::geometry::ViewInformation2D())); | 174 aViewInformation2D)); |
150 | 175 |
151 const drawinglayer::primitive2d::Primitive2DReference xTransform( 152 new drawinglayer::primitive2d::TransformPrimitive2D( 153 basegfx::tools::createScaleTranslateB2DHomMatrix( 154 aContentRange.getRange(), 155 aContentRange.getMinimum()), 156 aClipTarget)); 157 158 aClipTarget = drawinglayer::primitive2d::Primitive2DSequence(&xTransform, 1); | 176 aClipPolyPolygon.transform( 177 basegfx::tools::createScaleTranslateB2DHomMatrix( 178 aContentRange.getRange(), 179 aContentRange.getMinimum())); |
159 } 160 | 180 } 181 |
161 // redefine target. Use TransparencePrimitive2D with created clip | 182 // redefine target. Use MaskPrimitive2D with created clip |
162 // geometry. Using the automatically set mbIsClipPathContent at 163 // SvgStyleAttributes the clip definition is without fill, stroke, | 183 // geometry. Using the automatically set mbIsClipPathContent at 184 // SvgStyleAttributes the clip definition is without fill, stroke, |
164 // and strokeWidth and forced to black, thus being 100% opaque | 185 // and strokeWidth and forced to black |
165 const drawinglayer::primitive2d::Primitive2DReference xEmbedTransparence( | 186 const drawinglayer::primitive2d::Primitive2DReference xEmbedTransparence( |
166 new drawinglayer::primitive2d::TransparencePrimitive2D( 167 rContent, 168 aClipTarget)); | 187 new drawinglayer::primitive2d::MaskPrimitive2D( 188 aClipPolyPolygon, 189 rContent)); |
169 170 rContent = drawinglayer::primitive2d::Primitive2DSequence(&xEmbedTransparence, 1); 171 } 172 else 173 { 174 // An empty clipping path will completely clip away the element that had 175 // the �clip-path� property applied. (Svg spec) 176 rContent.realloc(0); 177 } 178 } 179 } 180 181 } // end of namespace svgreader 182} // end of namespace svgio 183 184////////////////////////////////////////////////////////////////////////////// 185// eof | 190 191 rContent = drawinglayer::primitive2d::Primitive2DSequence(&xEmbedTransparence, 1); 192 } 193 else 194 { 195 // An empty clipping path will completely clip away the element that had 196 // the �clip-path� property applied. (Svg spec) 197 rContent.realloc(0); 198 } 199 } 200 } 201 202 } // end of namespace svgreader 203} // end of namespace svgio 204 205////////////////////////////////////////////////////////////////////////////// 206// eof |