svgsvgnode.cxx (bdfe698a) | svgsvgnode.cxx (bca0eb5d) |
---|---|
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 --- 159 unchanged lines hidden (view full) --- 168 169 // decompose childs 170 SvgNode::decomposeSvgNode(aSequence, bReferenced); 171 172 if(aSequence.hasElements()) 173 { 174 if(getParent()) 175 { | 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 --- 159 unchanged lines hidden (view full) --- 168 169 // decompose childs 170 SvgNode::decomposeSvgNode(aSequence, bReferenced); 171 172 if(aSequence.hasElements()) 173 { 174 if(getParent()) 175 { |
176 const bool bWidthIsRelative(!getWidth().isSet() || Unit_percent == getWidth().getUnit()); 177 const bool bHeightIsRelative(!getWidth().isSet() || Unit_percent == getWidth().getUnit()); 178 const SvgSvgNode* pParentSvgSvgNode = 0; 179 double fW(0.0); 180 double fH(0.0); 181 182 // #122594# if width/height is not given, it's 100% (see 5.1.2 The �svg� element in SVG1.1 spec). 183 // If it is relative, the question is to what. The previous implementatin assumed relative to the 184 // local ViewBox which is implied by (4.2 Basic data types): 185 // 186 // "Note that the non-property <length> definition also allows a percentage unit identifier. 187 // The meaning of a percentage length value depends on the attribute for which the percentage 188 // length value has been specified. Two common cases are: (a) when a percentage length value 189 // represents a percentage of the viewport width or height (refer to the section that discusses 190 // units in general), and (b) when a percentage length value represents a percentage of the 191 // bounding box width or height on a given object (refer to the section that describes object 192 // bounding box units)." 193 // 194 // This is not closer specified for the SVG element itself as non-outmost element, but comparisons 195 // with common browsers shows that it's mostly interpreted relative to the viewBox of the parent. 196 // Adding code to search the parent SVG element and calculating width/height relative to it's 197 // viewBox width/height (and no longer to the local viewBox). 198 if(bWidthIsRelative || bHeightIsRelative) 199 { 200 for(const SvgNode* pParent = getParent(); pParent && !pParentSvgSvgNode; pParent = pParent->getParent()) 201 { 202 pParentSvgSvgNode = dynamic_cast< const SvgSvgNode* >(pParent); 203 } 204 } 205 206 if(bWidthIsRelative) 207 { 208 fW = getWidth().isSet() ? getWidth().getNumber() * 0.01 : 1.0; 209 210 if(pParentSvgSvgNode) 211 { 212 fW *= pParentSvgSvgNode->getViewBox()->getWidth(); 213 } 214 } 215 else 216 { 217 fW = getWidth().solve(*this, xcoordinate); 218 } 219 220 if(bHeightIsRelative) 221 { 222 fH = getHeight().isSet() ? getHeight().getNumber() * 0.01 : 1.0; 223 224 if(pParentSvgSvgNode) 225 { 226 fH *= pParentSvgSvgNode->getViewBox()->getHeight(); 227 } 228 } 229 else 230 { 231 fH = getHeight().solve(*this, ycoordinate); 232 } 233 |
|
176 if(getViewBox()) 177 { 178 // Svg defines that with no width or no height the viewBox content is empty, 179 // so both need to exist 180 if(!basegfx::fTools::equalZero(getViewBox()->getWidth()) && !basegfx::fTools::equalZero(getViewBox()->getHeight())) 181 { 182 // create target range homing x,y, width and height as given 183 const double fX(getX().isSet() ? getX().solve(*this, xcoordinate) : 0.0); 184 const double fY(getY().isSet() ? getY().solve(*this, ycoordinate) : 0.0); | 234 if(getViewBox()) 235 { 236 // Svg defines that with no width or no height the viewBox content is empty, 237 // so both need to exist 238 if(!basegfx::fTools::equalZero(getViewBox()->getWidth()) && !basegfx::fTools::equalZero(getViewBox()->getHeight())) 239 { 240 // create target range homing x,y, width and height as given 241 const double fX(getX().isSet() ? getX().solve(*this, xcoordinate) : 0.0); 242 const double fY(getY().isSet() ? getY().solve(*this, ycoordinate) : 0.0); |
185 const bool bWidthIsRelative(!getWidth().isSet() || Unit_percent == getWidth().getUnit()); 186 const bool bHeightIsRelative(!getWidth().isSet() || Unit_percent == getWidth().getUnit()); 187 const SvgSvgNode* pParentSvgSvgNode = 0; 188 double fW(0.0); 189 double fH(0.0); 190 191 // #122594# if width/height is not given, it's 100% (see 5.1.2 The �svg� element in SVG1.1 spec). 192 // If it is relative, the question is to what. The previous implementatin assumed relative to the 193 // local ViewBox which is implied by (4.2 Basic data types): 194 // 195 // "Note that the non-property <length> definition also allows a percentage unit identifier. 196 // The meaning of a percentage length value depends on the attribute for which the percentage 197 // length value has been specified. Two common cases are: (a) when a percentage length value 198 // represents a percentage of the viewport width or height (refer to the section that discusses 199 // units in general), and (b) when a percentage length value represents a percentage of the 200 // bounding box width or height on a given object (refer to the section that describes object 201 // bounding box units)." 202 // 203 // This is not closer specified for the SVG element itself as non-outmost element, but comparisons 204 // with common browsers shows that it's mostly interpreted relative to the viewBox of the parent. 205 // Adding code to search the parent SVG element and calculating width/height relative to it's 206 // viewBox width/height (and no longer to the local viewBox). 207 if(bWidthIsRelative || bHeightIsRelative) 208 { 209 for(const SvgNode* pParent = getParent(); pParent && !pParentSvgSvgNode; pParent = pParent->getParent()) 210 { 211 pParentSvgSvgNode = dynamic_cast< const SvgSvgNode* >(pParent); 212 } 213 } 214 215 if(bWidthIsRelative) 216 { 217 fW = getWidth().isSet() ? getWidth().getNumber() * 0.01 : 1.0; 218 219 if(pParentSvgSvgNode) 220 { 221 fW *= pParentSvgSvgNode->getViewBox()->getWidth(); 222 } 223 } 224 else 225 { 226 fW = getWidth().solve(*this, xcoordinate); 227 } 228 229 if(bHeightIsRelative) 230 { 231 fH = getHeight().isSet() ? getHeight().getNumber() * 0.01 : 1.0; 232 233 if(pParentSvgSvgNode) 234 { 235 fH *= pParentSvgSvgNode->getViewBox()->getHeight(); 236 } 237 } 238 else 239 { 240 fH = getHeight().solve(*this, ycoordinate); 241 } 242 | |
243 const basegfx::B2DRange aTarget(fX, fY, fX + fW, fY + fH); 244 245 if(aTarget.equal(*getViewBox())) 246 { 247 // no mapping needed, append 248 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(rTarget, aSequence); 249 } 250 else --- 44 unchanged lines hidden (view full) --- 295 296 drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(rTarget, xTransform); 297 } 298 } 299 } 300 } 301 else 302 { | 243 const basegfx::B2DRange aTarget(fX, fY, fX + fW, fY + fH); 244 245 if(aTarget.equal(*getViewBox())) 246 { 247 // no mapping needed, append 248 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(rTarget, aSequence); 249 } 250 else --- 44 unchanged lines hidden (view full) --- 295 296 drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(rTarget, xTransform); 297 } 298 } 299 } 300 } 301 else 302 { |
303 // check if we have a size 304 const double fW(getWidth().isSet() ? getWidth().solve(*this, xcoordinate) : 0.0); 305 const double fH(getHeight().isSet() ? getHeight().solve(*this, ycoordinate) : 0.0); 306 | |
307 // Svg defines that a negative value is an error and that 0.0 disables rendering 308 if(basegfx::fTools::more(fW, 0.0) && basegfx::fTools::more(fH, 0.0)) 309 { 310 // check if we have a x,y position 311 const double fX(getX().isSet() ? getX().solve(*this, xcoordinate) : 0.0); 312 const double fY(getY().isSet() ? getY().solve(*this, ycoordinate) : 0.0); 313 314 if(!basegfx::fTools::equalZero(fX) || !basegfx::fTools::equalZero(fY)) --- 168 unchanged lines hidden --- | 303 // Svg defines that a negative value is an error and that 0.0 disables rendering 304 if(basegfx::fTools::more(fW, 0.0) && basegfx::fTools::more(fH, 0.0)) 305 { 306 // check if we have a x,y position 307 const double fX(getX().isSet() ? getX().solve(*this, xcoordinate) : 0.0); 308 const double fY(getY().isSet() ? getY().solve(*this, ycoordinate) : 0.0); 309 310 if(!basegfx::fTools::equalZero(fX) || !basegfx::fTools::equalZero(fY)) --- 168 unchanged lines hidden --- |