1*ddde725dSArmin Le Grand /************************************************************** 2*ddde725dSArmin Le Grand * 3*ddde725dSArmin Le Grand * Licensed to the Apache Software Foundation (ASF) under one 4*ddde725dSArmin Le Grand * or more contributor license agreements. See the NOTICE file 5*ddde725dSArmin Le Grand * distributed with this work for additional information 6*ddde725dSArmin Le Grand * regarding copyright ownership. The ASF licenses this file 7*ddde725dSArmin Le Grand * to you under the Apache License, Version 2.0 (the 8*ddde725dSArmin Le Grand * "License"); you may not use this file except in compliance 9*ddde725dSArmin Le Grand * with the License. You may obtain a copy of the License at 10*ddde725dSArmin Le Grand * 11*ddde725dSArmin Le Grand * http://www.apache.org/licenses/LICENSE-2.0 12*ddde725dSArmin Le Grand * 13*ddde725dSArmin Le Grand * Unless required by applicable law or agreed to in writing, 14*ddde725dSArmin Le Grand * software distributed under the License is distributed on an 15*ddde725dSArmin Le Grand * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ddde725dSArmin Le Grand * KIND, either express or implied. See the License for the 17*ddde725dSArmin Le Grand * specific language governing permissions and limitations 18*ddde725dSArmin Le Grand * under the License. 19*ddde725dSArmin Le Grand * 20*ddde725dSArmin Le Grand *************************************************************/ 21*ddde725dSArmin Le Grand 22*ddde725dSArmin Le Grand // MARKER(update_precomp.py): autogen include statement, do not remove 23*ddde725dSArmin Le Grand #include "precompiled_svgio.hxx" 24*ddde725dSArmin Le Grand 25*ddde725dSArmin Le Grand #include <svgio/svgreader/svggradientnode.hxx> 26*ddde725dSArmin Le Grand #include <svgio/svgreader/svgdocument.hxx> 27*ddde725dSArmin Le Grand #include <svgio/svgreader/svggradientstopnode.hxx> 28*ddde725dSArmin Le Grand 29*ddde725dSArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 30*ddde725dSArmin Le Grand 31*ddde725dSArmin Le Grand namespace svgio 32*ddde725dSArmin Le Grand { 33*ddde725dSArmin Le Grand namespace svgreader 34*ddde725dSArmin Le Grand { 35*ddde725dSArmin Le Grand void SvgGradientNode::tryToFindLink() 36*ddde725dSArmin Le Grand { 37*ddde725dSArmin Le Grand if(!mpXLink && maXLink.getLength()) 38*ddde725dSArmin Le Grand { 39*ddde725dSArmin Le Grand mpXLink = dynamic_cast< const SvgGradientNode* >(getDocument().findSvgNodeById(maXLink)); 40*ddde725dSArmin Le Grand } 41*ddde725dSArmin Le Grand } 42*ddde725dSArmin Le Grand 43*ddde725dSArmin Le Grand SvgGradientNode::SvgGradientNode( 44*ddde725dSArmin Le Grand SVGToken aType, 45*ddde725dSArmin Le Grand SvgDocument& rDocument, 46*ddde725dSArmin Le Grand SvgNode* pParent) 47*ddde725dSArmin Le Grand : SvgNode(aType, rDocument, pParent), 48*ddde725dSArmin Le Grand maSvgStyleAttributes(*this), 49*ddde725dSArmin Le Grand maX1(), 50*ddde725dSArmin Le Grand maY1(), 51*ddde725dSArmin Le Grand maX2(), 52*ddde725dSArmin Le Grand maY2(), 53*ddde725dSArmin Le Grand maCx(), 54*ddde725dSArmin Le Grand maCy(), 55*ddde725dSArmin Le Grand maR(), 56*ddde725dSArmin Le Grand maFx(), 57*ddde725dSArmin Le Grand maFy(), 58*ddde725dSArmin Le Grand maGradientUnits(objectBoundingBox), 59*ddde725dSArmin Le Grand maSpreadMethod(drawinglayer::primitive2d::Spread_pad), 60*ddde725dSArmin Le Grand mpaGradientTransform(0), 61*ddde725dSArmin Le Grand maXLink(), 62*ddde725dSArmin Le Grand mpXLink(0) 63*ddde725dSArmin Le Grand { 64*ddde725dSArmin Le Grand } 65*ddde725dSArmin Le Grand 66*ddde725dSArmin Le Grand SvgGradientNode::~SvgGradientNode() 67*ddde725dSArmin Le Grand { 68*ddde725dSArmin Le Grand if(mpaGradientTransform) delete mpaGradientTransform; 69*ddde725dSArmin Le Grand // do NOT delete mpXLink, it's only referenced, not owned 70*ddde725dSArmin Le Grand } 71*ddde725dSArmin Le Grand 72*ddde725dSArmin Le Grand const SvgStyleAttributes* SvgGradientNode::getSvgStyleAttributes() const 73*ddde725dSArmin Le Grand { 74*ddde725dSArmin Le Grand return &maSvgStyleAttributes; 75*ddde725dSArmin Le Grand } 76*ddde725dSArmin Le Grand 77*ddde725dSArmin Le Grand void SvgGradientNode::parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent) 78*ddde725dSArmin Le Grand { 79*ddde725dSArmin Le Grand // call parent 80*ddde725dSArmin Le Grand SvgNode::parseAttribute(rTokenName, aSVGToken, aContent); 81*ddde725dSArmin Le Grand 82*ddde725dSArmin Le Grand // read style attributes 83*ddde725dSArmin Le Grand maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent); 84*ddde725dSArmin Le Grand 85*ddde725dSArmin Le Grand // parse own 86*ddde725dSArmin Le Grand switch(aSVGToken) 87*ddde725dSArmin Le Grand { 88*ddde725dSArmin Le Grand case SVGTokenStyle: 89*ddde725dSArmin Le Grand { 90*ddde725dSArmin Le Grand maSvgStyleAttributes.readStyle(aContent); 91*ddde725dSArmin Le Grand break; 92*ddde725dSArmin Le Grand } 93*ddde725dSArmin Le Grand case SVGTokenX1: 94*ddde725dSArmin Le Grand { 95*ddde725dSArmin Le Grand SvgNumber aNum; 96*ddde725dSArmin Le Grand 97*ddde725dSArmin Le Grand if(readSingleNumber(aContent, aNum)) 98*ddde725dSArmin Le Grand { 99*ddde725dSArmin Le Grand setX1(aNum); 100*ddde725dSArmin Le Grand } 101*ddde725dSArmin Le Grand break; 102*ddde725dSArmin Le Grand } 103*ddde725dSArmin Le Grand case SVGTokenY1: 104*ddde725dSArmin Le Grand { 105*ddde725dSArmin Le Grand SvgNumber aNum; 106*ddde725dSArmin Le Grand 107*ddde725dSArmin Le Grand if(readSingleNumber(aContent, aNum)) 108*ddde725dSArmin Le Grand { 109*ddde725dSArmin Le Grand setY1(aNum); 110*ddde725dSArmin Le Grand } 111*ddde725dSArmin Le Grand break; 112*ddde725dSArmin Le Grand } 113*ddde725dSArmin Le Grand case SVGTokenX2: 114*ddde725dSArmin Le Grand { 115*ddde725dSArmin Le Grand SvgNumber aNum; 116*ddde725dSArmin Le Grand 117*ddde725dSArmin Le Grand if(readSingleNumber(aContent, aNum)) 118*ddde725dSArmin Le Grand { 119*ddde725dSArmin Le Grand setX2(aNum); 120*ddde725dSArmin Le Grand } 121*ddde725dSArmin Le Grand break; 122*ddde725dSArmin Le Grand } 123*ddde725dSArmin Le Grand case SVGTokenY2: 124*ddde725dSArmin Le Grand { 125*ddde725dSArmin Le Grand SvgNumber aNum; 126*ddde725dSArmin Le Grand 127*ddde725dSArmin Le Grand if(readSingleNumber(aContent, aNum)) 128*ddde725dSArmin Le Grand { 129*ddde725dSArmin Le Grand setY2(aNum); 130*ddde725dSArmin Le Grand } 131*ddde725dSArmin Le Grand break; 132*ddde725dSArmin Le Grand } 133*ddde725dSArmin Le Grand case SVGTokenCx: 134*ddde725dSArmin Le Grand { 135*ddde725dSArmin Le Grand SvgNumber aNum; 136*ddde725dSArmin Le Grand 137*ddde725dSArmin Le Grand if(readSingleNumber(aContent, aNum)) 138*ddde725dSArmin Le Grand { 139*ddde725dSArmin Le Grand setCx(aNum); 140*ddde725dSArmin Le Grand } 141*ddde725dSArmin Le Grand break; 142*ddde725dSArmin Le Grand } 143*ddde725dSArmin Le Grand case SVGTokenCy: 144*ddde725dSArmin Le Grand { 145*ddde725dSArmin Le Grand SvgNumber aNum; 146*ddde725dSArmin Le Grand 147*ddde725dSArmin Le Grand if(readSingleNumber(aContent, aNum)) 148*ddde725dSArmin Le Grand { 149*ddde725dSArmin Le Grand setCy(aNum); 150*ddde725dSArmin Le Grand } 151*ddde725dSArmin Le Grand break; 152*ddde725dSArmin Le Grand } 153*ddde725dSArmin Le Grand case SVGTokenFx: 154*ddde725dSArmin Le Grand { 155*ddde725dSArmin Le Grand SvgNumber aNum; 156*ddde725dSArmin Le Grand 157*ddde725dSArmin Le Grand if(readSingleNumber(aContent, aNum)) 158*ddde725dSArmin Le Grand { 159*ddde725dSArmin Le Grand setFx(aNum); 160*ddde725dSArmin Le Grand } 161*ddde725dSArmin Le Grand break; 162*ddde725dSArmin Le Grand } 163*ddde725dSArmin Le Grand case SVGTokenFy: 164*ddde725dSArmin Le Grand { 165*ddde725dSArmin Le Grand SvgNumber aNum; 166*ddde725dSArmin Le Grand 167*ddde725dSArmin Le Grand if(readSingleNumber(aContent, aNum)) 168*ddde725dSArmin Le Grand { 169*ddde725dSArmin Le Grand setFy(aNum); 170*ddde725dSArmin Le Grand } 171*ddde725dSArmin Le Grand break; 172*ddde725dSArmin Le Grand } 173*ddde725dSArmin Le Grand case SVGTokenR: 174*ddde725dSArmin Le Grand { 175*ddde725dSArmin Le Grand SvgNumber aNum; 176*ddde725dSArmin Le Grand 177*ddde725dSArmin Le Grand if(readSingleNumber(aContent, aNum)) 178*ddde725dSArmin Le Grand { 179*ddde725dSArmin Le Grand if(aNum.isPositive()) 180*ddde725dSArmin Le Grand { 181*ddde725dSArmin Le Grand setR(aNum); 182*ddde725dSArmin Le Grand } 183*ddde725dSArmin Le Grand } 184*ddde725dSArmin Le Grand break; 185*ddde725dSArmin Le Grand } 186*ddde725dSArmin Le Grand case SVGTokenGradientUnits: 187*ddde725dSArmin Le Grand { 188*ddde725dSArmin Le Grand if(aContent.getLength()) 189*ddde725dSArmin Le Grand { 190*ddde725dSArmin Le Grand if(aContent.match(commonStrings::aStrUserSpaceOnUse, 0)) 191*ddde725dSArmin Le Grand { 192*ddde725dSArmin Le Grand setGradientUnits(userSpaceOnUse); 193*ddde725dSArmin Le Grand } 194*ddde725dSArmin Le Grand else if(aContent.match(commonStrings::aStrObjectBoundingBox, 0)) 195*ddde725dSArmin Le Grand { 196*ddde725dSArmin Le Grand setGradientUnits(objectBoundingBox); 197*ddde725dSArmin Le Grand } 198*ddde725dSArmin Le Grand } 199*ddde725dSArmin Le Grand break; 200*ddde725dSArmin Le Grand } 201*ddde725dSArmin Le Grand case SVGTokenSpreadMethod: 202*ddde725dSArmin Le Grand { 203*ddde725dSArmin Le Grand if(aContent.getLength()) 204*ddde725dSArmin Le Grand { 205*ddde725dSArmin Le Grand static rtl::OUString aStrPad(rtl::OUString::createFromAscii("pad")); 206*ddde725dSArmin Le Grand static rtl::OUString aStrReflect(rtl::OUString::createFromAscii("reflect")); 207*ddde725dSArmin Le Grand static rtl::OUString aStrRepeat(rtl::OUString::createFromAscii("repeat")); 208*ddde725dSArmin Le Grand 209*ddde725dSArmin Le Grand if(aContent.match(aStrPad, 0)) 210*ddde725dSArmin Le Grand { 211*ddde725dSArmin Le Grand setSpreadMethod(drawinglayer::primitive2d::Spread_pad); 212*ddde725dSArmin Le Grand } 213*ddde725dSArmin Le Grand else if(aContent.match(aStrReflect, 0)) 214*ddde725dSArmin Le Grand { 215*ddde725dSArmin Le Grand setSpreadMethod(drawinglayer::primitive2d::Spread_reflect); 216*ddde725dSArmin Le Grand } 217*ddde725dSArmin Le Grand else if(aContent.match(aStrRepeat, 0)) 218*ddde725dSArmin Le Grand { 219*ddde725dSArmin Le Grand setSpreadMethod(drawinglayer::primitive2d::Spread_repeat); 220*ddde725dSArmin Le Grand } 221*ddde725dSArmin Le Grand } 222*ddde725dSArmin Le Grand break; 223*ddde725dSArmin Le Grand } 224*ddde725dSArmin Le Grand case SVGTokenGradientTransform: 225*ddde725dSArmin Le Grand { 226*ddde725dSArmin Le Grand const basegfx::B2DHomMatrix aMatrix(readTransform(aContent, *this)); 227*ddde725dSArmin Le Grand 228*ddde725dSArmin Le Grand if(!aMatrix.isIdentity()) 229*ddde725dSArmin Le Grand { 230*ddde725dSArmin Le Grand setGradientTransform(&aMatrix); 231*ddde725dSArmin Le Grand } 232*ddde725dSArmin Le Grand break; 233*ddde725dSArmin Le Grand } 234*ddde725dSArmin Le Grand case SVGTokenXlinkHref: 235*ddde725dSArmin Le Grand { 236*ddde725dSArmin Le Grand const sal_Int32 nLen(aContent.getLength()); 237*ddde725dSArmin Le Grand 238*ddde725dSArmin Le Grand if(nLen && sal_Unicode('#') == aContent[0]) 239*ddde725dSArmin Le Grand { 240*ddde725dSArmin Le Grand maXLink = aContent.copy(1); 241*ddde725dSArmin Le Grand tryToFindLink(); 242*ddde725dSArmin Le Grand } 243*ddde725dSArmin Le Grand break; 244*ddde725dSArmin Le Grand } 245*ddde725dSArmin Le Grand } 246*ddde725dSArmin Le Grand } 247*ddde725dSArmin Le Grand 248*ddde725dSArmin Le Grand void SvgGradientNode::collectGradientEntries(drawinglayer::primitive2d::SvgGradientEntryVector& aVector) const 249*ddde725dSArmin Le Grand { 250*ddde725dSArmin Le Grand if(getChildren().empty()) 251*ddde725dSArmin Le Grand { 252*ddde725dSArmin Le Grand const_cast< SvgGradientNode* >(this)->tryToFindLink(); 253*ddde725dSArmin Le Grand 254*ddde725dSArmin Le Grand if(mpXLink) 255*ddde725dSArmin Le Grand { 256*ddde725dSArmin Le Grand mpXLink->collectGradientEntries(aVector); 257*ddde725dSArmin Le Grand } 258*ddde725dSArmin Le Grand } 259*ddde725dSArmin Le Grand else 260*ddde725dSArmin Le Grand { 261*ddde725dSArmin Le Grand const sal_uInt32 nCount(getChildren().size()); 262*ddde725dSArmin Le Grand 263*ddde725dSArmin Le Grand for(sal_uInt32 a(0); a < nCount; a++) 264*ddde725dSArmin Le Grand { 265*ddde725dSArmin Le Grand const SvgGradientStopNode* pCandidate = dynamic_cast< const SvgGradientStopNode* >(getChildren()[a]); 266*ddde725dSArmin Le Grand 267*ddde725dSArmin Le Grand if(pCandidate) 268*ddde725dSArmin Le Grand { 269*ddde725dSArmin Le Grand const SvgStyleAttributes* pStyle = pCandidate->getSvgStyleAttributes(); 270*ddde725dSArmin Le Grand 271*ddde725dSArmin Le Grand if(pStyle) 272*ddde725dSArmin Le Grand { 273*ddde725dSArmin Le Grand const SvgNumber aOffset(pCandidate->getOffset()); 274*ddde725dSArmin Le Grand double fOffset(0.0); 275*ddde725dSArmin Le Grand 276*ddde725dSArmin Le Grand if(Unit_percent == aOffset.getUnit()) 277*ddde725dSArmin Le Grand { 278*ddde725dSArmin Le Grand // percent is not relative to distances in ColorStop context, solve locally 279*ddde725dSArmin Le Grand fOffset = aOffset.getNumber() * 0.01; 280*ddde725dSArmin Le Grand } 281*ddde725dSArmin Le Grand else 282*ddde725dSArmin Le Grand { 283*ddde725dSArmin Le Grand fOffset = aOffset.solve(*this); 284*ddde725dSArmin Le Grand } 285*ddde725dSArmin Le Grand 286*ddde725dSArmin Le Grand if(fOffset < 0.0) 287*ddde725dSArmin Le Grand { 288*ddde725dSArmin Le Grand OSL_ENSURE(false, "OOps, SvgGradientStopNode with offset out of range (!)"); 289*ddde725dSArmin Le Grand fOffset = 0.0; 290*ddde725dSArmin Le Grand } 291*ddde725dSArmin Le Grand else if(fOffset > 1.0) 292*ddde725dSArmin Le Grand { 293*ddde725dSArmin Le Grand OSL_ENSURE(false, "OOps, SvgGradientStopNode with offset out of range (!)"); 294*ddde725dSArmin Le Grand fOffset = 1.0; 295*ddde725dSArmin Le Grand } 296*ddde725dSArmin Le Grand 297*ddde725dSArmin Le Grand aVector.push_back( 298*ddde725dSArmin Le Grand drawinglayer::primitive2d::SvgGradientEntry( 299*ddde725dSArmin Le Grand fOffset, 300*ddde725dSArmin Le Grand pStyle->getStopColor(), 301*ddde725dSArmin Le Grand pStyle->getStopOpacity().solve(*this))); 302*ddde725dSArmin Le Grand } 303*ddde725dSArmin Le Grand else 304*ddde725dSArmin Le Grand { 305*ddde725dSArmin Le Grand OSL_ENSURE(false, "OOps, SvgGradientStopNode without Style (!)"); 306*ddde725dSArmin Le Grand } 307*ddde725dSArmin Le Grand } 308*ddde725dSArmin Le Grand } 309*ddde725dSArmin Le Grand } 310*ddde725dSArmin Le Grand } 311*ddde725dSArmin Le Grand 312*ddde725dSArmin Le Grand const SvgNumber SvgGradientNode::getX1() const 313*ddde725dSArmin Le Grand { 314*ddde725dSArmin Le Grand if(maX1.isSet()) 315*ddde725dSArmin Le Grand { 316*ddde725dSArmin Le Grand return maX1; 317*ddde725dSArmin Le Grand } 318*ddde725dSArmin Le Grand 319*ddde725dSArmin Le Grand const_cast< SvgGradientNode* >(this)->tryToFindLink(); 320*ddde725dSArmin Le Grand 321*ddde725dSArmin Le Grand if(mpXLink) 322*ddde725dSArmin Le Grand { 323*ddde725dSArmin Le Grand return mpXLink->getX1(); 324*ddde725dSArmin Le Grand } 325*ddde725dSArmin Le Grand 326*ddde725dSArmin Le Grand // default is 0% 327*ddde725dSArmin Le Grand return SvgNumber(0.0, Unit_percent); 328*ddde725dSArmin Le Grand } 329*ddde725dSArmin Le Grand 330*ddde725dSArmin Le Grand const SvgNumber SvgGradientNode::getY1() const 331*ddde725dSArmin Le Grand { 332*ddde725dSArmin Le Grand if(maY1.isSet()) 333*ddde725dSArmin Le Grand { 334*ddde725dSArmin Le Grand return maY1; 335*ddde725dSArmin Le Grand } 336*ddde725dSArmin Le Grand 337*ddde725dSArmin Le Grand const_cast< SvgGradientNode* >(this)->tryToFindLink(); 338*ddde725dSArmin Le Grand 339*ddde725dSArmin Le Grand if(mpXLink) 340*ddde725dSArmin Le Grand { 341*ddde725dSArmin Le Grand return mpXLink->getY1(); 342*ddde725dSArmin Le Grand } 343*ddde725dSArmin Le Grand 344*ddde725dSArmin Le Grand // default is 0% 345*ddde725dSArmin Le Grand return SvgNumber(0.0, Unit_percent); 346*ddde725dSArmin Le Grand } 347*ddde725dSArmin Le Grand 348*ddde725dSArmin Le Grand const SvgNumber SvgGradientNode::getX2() const 349*ddde725dSArmin Le Grand { 350*ddde725dSArmin Le Grand if(maX2.isSet()) 351*ddde725dSArmin Le Grand { 352*ddde725dSArmin Le Grand return maX2; 353*ddde725dSArmin Le Grand } 354*ddde725dSArmin Le Grand 355*ddde725dSArmin Le Grand const_cast< SvgGradientNode* >(this)->tryToFindLink(); 356*ddde725dSArmin Le Grand 357*ddde725dSArmin Le Grand if(mpXLink) 358*ddde725dSArmin Le Grand { 359*ddde725dSArmin Le Grand return mpXLink->getX2(); 360*ddde725dSArmin Le Grand } 361*ddde725dSArmin Le Grand 362*ddde725dSArmin Le Grand // default is 100% 363*ddde725dSArmin Le Grand return SvgNumber(100.0, Unit_percent); 364*ddde725dSArmin Le Grand } 365*ddde725dSArmin Le Grand 366*ddde725dSArmin Le Grand const SvgNumber SvgGradientNode::getY2() const 367*ddde725dSArmin Le Grand { 368*ddde725dSArmin Le Grand if(maY2.isSet()) 369*ddde725dSArmin Le Grand { 370*ddde725dSArmin Le Grand return maY2; 371*ddde725dSArmin Le Grand } 372*ddde725dSArmin Le Grand 373*ddde725dSArmin Le Grand const_cast< SvgGradientNode* >(this)->tryToFindLink(); 374*ddde725dSArmin Le Grand 375*ddde725dSArmin Le Grand if(mpXLink) 376*ddde725dSArmin Le Grand { 377*ddde725dSArmin Le Grand return mpXLink->getY2(); 378*ddde725dSArmin Le Grand } 379*ddde725dSArmin Le Grand 380*ddde725dSArmin Le Grand // default is 0% 381*ddde725dSArmin Le Grand return SvgNumber(0.0, Unit_percent); 382*ddde725dSArmin Le Grand } 383*ddde725dSArmin Le Grand 384*ddde725dSArmin Le Grand const SvgNumber SvgGradientNode::getCx() const 385*ddde725dSArmin Le Grand { 386*ddde725dSArmin Le Grand if(maCx.isSet()) 387*ddde725dSArmin Le Grand { 388*ddde725dSArmin Le Grand return maCx; 389*ddde725dSArmin Le Grand } 390*ddde725dSArmin Le Grand 391*ddde725dSArmin Le Grand const_cast< SvgGradientNode* >(this)->tryToFindLink(); 392*ddde725dSArmin Le Grand 393*ddde725dSArmin Le Grand if(mpXLink) 394*ddde725dSArmin Le Grand { 395*ddde725dSArmin Le Grand return mpXLink->getCx(); 396*ddde725dSArmin Le Grand } 397*ddde725dSArmin Le Grand 398*ddde725dSArmin Le Grand // default is 50% 399*ddde725dSArmin Le Grand return SvgNumber(50.0, Unit_percent); 400*ddde725dSArmin Le Grand } 401*ddde725dSArmin Le Grand 402*ddde725dSArmin Le Grand const SvgNumber SvgGradientNode::getCy() const 403*ddde725dSArmin Le Grand { 404*ddde725dSArmin Le Grand if(maCy.isSet()) 405*ddde725dSArmin Le Grand { 406*ddde725dSArmin Le Grand return maCy; 407*ddde725dSArmin Le Grand } 408*ddde725dSArmin Le Grand 409*ddde725dSArmin Le Grand const_cast< SvgGradientNode* >(this)->tryToFindLink(); 410*ddde725dSArmin Le Grand 411*ddde725dSArmin Le Grand if(mpXLink) 412*ddde725dSArmin Le Grand { 413*ddde725dSArmin Le Grand return mpXLink->getCy(); 414*ddde725dSArmin Le Grand } 415*ddde725dSArmin Le Grand 416*ddde725dSArmin Le Grand // default is 50% 417*ddde725dSArmin Le Grand return SvgNumber(50.0, Unit_percent); 418*ddde725dSArmin Le Grand } 419*ddde725dSArmin Le Grand 420*ddde725dSArmin Le Grand const SvgNumber SvgGradientNode::getR() const 421*ddde725dSArmin Le Grand { 422*ddde725dSArmin Le Grand if(maR.isSet()) 423*ddde725dSArmin Le Grand { 424*ddde725dSArmin Le Grand return maR; 425*ddde725dSArmin Le Grand } 426*ddde725dSArmin Le Grand 427*ddde725dSArmin Le Grand const_cast< SvgGradientNode* >(this)->tryToFindLink(); 428*ddde725dSArmin Le Grand 429*ddde725dSArmin Le Grand if(mpXLink) 430*ddde725dSArmin Le Grand { 431*ddde725dSArmin Le Grand return mpXLink->getR(); 432*ddde725dSArmin Le Grand } 433*ddde725dSArmin Le Grand 434*ddde725dSArmin Le Grand // default is 50% 435*ddde725dSArmin Le Grand return SvgNumber(50.0, Unit_percent); 436*ddde725dSArmin Le Grand } 437*ddde725dSArmin Le Grand 438*ddde725dSArmin Le Grand const SvgNumber* SvgGradientNode::getFx() const 439*ddde725dSArmin Le Grand { 440*ddde725dSArmin Le Grand if(maFx.isSet()) 441*ddde725dSArmin Le Grand { 442*ddde725dSArmin Le Grand return &maFx; 443*ddde725dSArmin Le Grand } 444*ddde725dSArmin Le Grand 445*ddde725dSArmin Le Grand const_cast< SvgGradientNode* >(this)->tryToFindLink(); 446*ddde725dSArmin Le Grand 447*ddde725dSArmin Le Grand if(mpXLink) 448*ddde725dSArmin Le Grand { 449*ddde725dSArmin Le Grand return mpXLink->getFx(); 450*ddde725dSArmin Le Grand } 451*ddde725dSArmin Le Grand 452*ddde725dSArmin Le Grand return 0; 453*ddde725dSArmin Le Grand } 454*ddde725dSArmin Le Grand 455*ddde725dSArmin Le Grand const SvgNumber* SvgGradientNode::getFy() const 456*ddde725dSArmin Le Grand { 457*ddde725dSArmin Le Grand if(maFy.isSet()) 458*ddde725dSArmin Le Grand { 459*ddde725dSArmin Le Grand return &maFy; 460*ddde725dSArmin Le Grand } 461*ddde725dSArmin Le Grand 462*ddde725dSArmin Le Grand const_cast< SvgGradientNode* >(this)->tryToFindLink(); 463*ddde725dSArmin Le Grand 464*ddde725dSArmin Le Grand if(mpXLink) 465*ddde725dSArmin Le Grand { 466*ddde725dSArmin Le Grand return mpXLink->getFy(); 467*ddde725dSArmin Le Grand } 468*ddde725dSArmin Le Grand 469*ddde725dSArmin Le Grand return 0; 470*ddde725dSArmin Le Grand } 471*ddde725dSArmin Le Grand 472*ddde725dSArmin Le Grand const basegfx::B2DHomMatrix* SvgGradientNode::getGradientTransform() const 473*ddde725dSArmin Le Grand { 474*ddde725dSArmin Le Grand if(mpaGradientTransform) 475*ddde725dSArmin Le Grand { 476*ddde725dSArmin Le Grand return mpaGradientTransform; 477*ddde725dSArmin Le Grand } 478*ddde725dSArmin Le Grand 479*ddde725dSArmin Le Grand const_cast< SvgGradientNode* >(this)->tryToFindLink(); 480*ddde725dSArmin Le Grand 481*ddde725dSArmin Le Grand if(mpXLink) 482*ddde725dSArmin Le Grand { 483*ddde725dSArmin Le Grand return mpXLink->getGradientTransform(); 484*ddde725dSArmin Le Grand } 485*ddde725dSArmin Le Grand 486*ddde725dSArmin Le Grand return 0; 487*ddde725dSArmin Le Grand } 488*ddde725dSArmin Le Grand 489*ddde725dSArmin Le Grand void SvgGradientNode::setGradientTransform(const basegfx::B2DHomMatrix* pMatrix) 490*ddde725dSArmin Le Grand { 491*ddde725dSArmin Le Grand if(mpaGradientTransform) 492*ddde725dSArmin Le Grand { 493*ddde725dSArmin Le Grand delete mpaGradientTransform; 494*ddde725dSArmin Le Grand mpaGradientTransform = 0; 495*ddde725dSArmin Le Grand } 496*ddde725dSArmin Le Grand 497*ddde725dSArmin Le Grand if(pMatrix) 498*ddde725dSArmin Le Grand { 499*ddde725dSArmin Le Grand mpaGradientTransform = new basegfx::B2DHomMatrix(*pMatrix); 500*ddde725dSArmin Le Grand } 501*ddde725dSArmin Le Grand } 502*ddde725dSArmin Le Grand 503*ddde725dSArmin Le Grand } // end of namespace svgreader 504*ddde725dSArmin Le Grand } // end of namespace svgio 505*ddde725dSArmin Le Grand 506*ddde725dSArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 507*ddde725dSArmin Le Grand // eof 508