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/svgmarkernode.hxx> 26*ddde725dSArmin Le Grand 27*ddde725dSArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 28*ddde725dSArmin Le Grand 29*ddde725dSArmin Le Grand namespace svgio 30*ddde725dSArmin Le Grand { 31*ddde725dSArmin Le Grand namespace svgreader 32*ddde725dSArmin Le Grand { 33*ddde725dSArmin Le Grand SvgMarkerNode::SvgMarkerNode( 34*ddde725dSArmin Le Grand SvgDocument& rDocument, 35*ddde725dSArmin Le Grand SvgNode* pParent) 36*ddde725dSArmin Le Grand : SvgNode(SVGTokenMarker, rDocument, pParent), 37*ddde725dSArmin Le Grand aPrimitives(), 38*ddde725dSArmin Le Grand maSvgStyleAttributes(*this), 39*ddde725dSArmin Le Grand mpViewBox(0), 40*ddde725dSArmin Le Grand maSvgAspectRatio(), 41*ddde725dSArmin Le Grand maRefX(0), 42*ddde725dSArmin Le Grand maRefY(0), 43*ddde725dSArmin Le Grand maMarkerUnits(strokeWidth), 44*ddde725dSArmin Le Grand maMarkerWidth(3), 45*ddde725dSArmin Le Grand maMarkerHeight(3), 46*ddde725dSArmin Le Grand mfAngle(0.0), 47*ddde725dSArmin Le Grand mbOrientAuto(false) 48*ddde725dSArmin Le Grand { 49*ddde725dSArmin Le Grand } 50*ddde725dSArmin Le Grand 51*ddde725dSArmin Le Grand SvgMarkerNode::~SvgMarkerNode() 52*ddde725dSArmin Le Grand { 53*ddde725dSArmin Le Grand if(mpViewBox) delete mpViewBox; 54*ddde725dSArmin Le Grand } 55*ddde725dSArmin Le Grand 56*ddde725dSArmin Le Grand const SvgStyleAttributes* SvgMarkerNode::getSvgStyleAttributes() const 57*ddde725dSArmin Le Grand { 58*ddde725dSArmin Le Grand static rtl::OUString aClassStr(rtl::OUString::createFromAscii("marker")); 59*ddde725dSArmin Le Grand maSvgStyleAttributes.checkForCssStyle(aClassStr); 60*ddde725dSArmin Le Grand 61*ddde725dSArmin Le Grand return &maSvgStyleAttributes; 62*ddde725dSArmin Le Grand } 63*ddde725dSArmin Le Grand 64*ddde725dSArmin Le Grand void SvgMarkerNode::parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent) 65*ddde725dSArmin Le Grand { 66*ddde725dSArmin Le Grand // call parent 67*ddde725dSArmin Le Grand SvgNode::parseAttribute(rTokenName, aSVGToken, aContent); 68*ddde725dSArmin Le Grand 69*ddde725dSArmin Le Grand // read style attributes 70*ddde725dSArmin Le Grand maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent); 71*ddde725dSArmin Le Grand 72*ddde725dSArmin Le Grand // parse own 73*ddde725dSArmin Le Grand switch(aSVGToken) 74*ddde725dSArmin Le Grand { 75*ddde725dSArmin Le Grand case SVGTokenStyle: 76*ddde725dSArmin Le Grand { 77*ddde725dSArmin Le Grand maSvgStyleAttributes.readStyle(aContent); 78*ddde725dSArmin Le Grand break; 79*ddde725dSArmin Le Grand } 80*ddde725dSArmin Le Grand case SVGTokenViewBox: 81*ddde725dSArmin Le Grand { 82*ddde725dSArmin Le Grand const basegfx::B2DRange aRange(readViewBox(aContent, *this)); 83*ddde725dSArmin Le Grand 84*ddde725dSArmin Le Grand if(!aRange.isEmpty()) 85*ddde725dSArmin Le Grand { 86*ddde725dSArmin Le Grand setViewBox(&aRange); 87*ddde725dSArmin Le Grand } 88*ddde725dSArmin Le Grand break; 89*ddde725dSArmin Le Grand } 90*ddde725dSArmin Le Grand case SVGTokenPreserveAspectRatio: 91*ddde725dSArmin Le Grand { 92*ddde725dSArmin Le Grand setSvgAspectRatio(readSvgAspectRatio(aContent)); 93*ddde725dSArmin Le Grand break; 94*ddde725dSArmin Le Grand } 95*ddde725dSArmin Le Grand case SVGTokenRefX: 96*ddde725dSArmin Le Grand { 97*ddde725dSArmin Le Grand SvgNumber aNum; 98*ddde725dSArmin Le Grand 99*ddde725dSArmin Le Grand if(readSingleNumber(aContent, aNum)) 100*ddde725dSArmin Le Grand { 101*ddde725dSArmin Le Grand setRefX(aNum); 102*ddde725dSArmin Le Grand } 103*ddde725dSArmin Le Grand break; 104*ddde725dSArmin Le Grand } 105*ddde725dSArmin Le Grand case SVGTokenRefY: 106*ddde725dSArmin Le Grand { 107*ddde725dSArmin Le Grand SvgNumber aNum; 108*ddde725dSArmin Le Grand 109*ddde725dSArmin Le Grand if(readSingleNumber(aContent, aNum)) 110*ddde725dSArmin Le Grand { 111*ddde725dSArmin Le Grand setRefY(aNum); 112*ddde725dSArmin Le Grand } 113*ddde725dSArmin Le Grand break; 114*ddde725dSArmin Le Grand } 115*ddde725dSArmin Le Grand case SVGTokenMarkerUnits: 116*ddde725dSArmin Le Grand { 117*ddde725dSArmin Le Grand if(aContent.getLength()) 118*ddde725dSArmin Le Grand { 119*ddde725dSArmin Le Grand static rtl::OUString aStrStrokeWidth(rtl::OUString::createFromAscii("strokeWidth")); 120*ddde725dSArmin Le Grand 121*ddde725dSArmin Le Grand if(aContent.match(aStrStrokeWidth, 0)) 122*ddde725dSArmin Le Grand { 123*ddde725dSArmin Le Grand setMarkerUnits(strokeWidth); 124*ddde725dSArmin Le Grand } 125*ddde725dSArmin Le Grand else if(aContent.match(commonStrings::aStrUserSpaceOnUse, 0)) 126*ddde725dSArmin Le Grand { 127*ddde725dSArmin Le Grand setMarkerUnits(userSpaceOnUse); 128*ddde725dSArmin Le Grand } 129*ddde725dSArmin Le Grand } 130*ddde725dSArmin Le Grand break; 131*ddde725dSArmin Le Grand } 132*ddde725dSArmin Le Grand case SVGTokenMarkerWidth: 133*ddde725dSArmin Le Grand { 134*ddde725dSArmin Le Grand SvgNumber aNum; 135*ddde725dSArmin Le Grand 136*ddde725dSArmin Le Grand if(readSingleNumber(aContent, aNum)) 137*ddde725dSArmin Le Grand { 138*ddde725dSArmin Le Grand if(aNum.isPositive()) 139*ddde725dSArmin Le Grand { 140*ddde725dSArmin Le Grand setMarkerWidth(aNum); 141*ddde725dSArmin Le Grand } 142*ddde725dSArmin Le Grand } 143*ddde725dSArmin Le Grand break; 144*ddde725dSArmin Le Grand } 145*ddde725dSArmin Le Grand case SVGTokenMarkerHeight: 146*ddde725dSArmin Le Grand { 147*ddde725dSArmin Le Grand SvgNumber aNum; 148*ddde725dSArmin Le Grand 149*ddde725dSArmin Le Grand if(readSingleNumber(aContent, aNum)) 150*ddde725dSArmin Le Grand { 151*ddde725dSArmin Le Grand if(aNum.isPositive()) 152*ddde725dSArmin Le Grand { 153*ddde725dSArmin Le Grand setMarkerHeight(aNum); 154*ddde725dSArmin Le Grand } 155*ddde725dSArmin Le Grand } 156*ddde725dSArmin Le Grand break; 157*ddde725dSArmin Le Grand } 158*ddde725dSArmin Le Grand case SVGTokenOrient: 159*ddde725dSArmin Le Grand { 160*ddde725dSArmin Le Grand const sal_Int32 nLen(aContent.getLength()); 161*ddde725dSArmin Le Grand 162*ddde725dSArmin Le Grand if(nLen) 163*ddde725dSArmin Le Grand { 164*ddde725dSArmin Le Grand static rtl::OUString aStrAuto(rtl::OUString::createFromAscii("auto")); 165*ddde725dSArmin Le Grand 166*ddde725dSArmin Le Grand if(aContent.match(aStrAuto, 0)) 167*ddde725dSArmin Le Grand { 168*ddde725dSArmin Le Grand setOrientAuto(true); 169*ddde725dSArmin Le Grand } 170*ddde725dSArmin Le Grand else 171*ddde725dSArmin Le Grand { 172*ddde725dSArmin Le Grand sal_Int32 nPos(0); 173*ddde725dSArmin Le Grand double fAngle(0.0); 174*ddde725dSArmin Le Grand 175*ddde725dSArmin Le Grand if(readAngle(aContent, nPos, fAngle, nLen)) 176*ddde725dSArmin Le Grand { 177*ddde725dSArmin Le Grand setAngle(fAngle); 178*ddde725dSArmin Le Grand } 179*ddde725dSArmin Le Grand } 180*ddde725dSArmin Le Grand } 181*ddde725dSArmin Le Grand break; 182*ddde725dSArmin Le Grand } 183*ddde725dSArmin Le Grand } 184*ddde725dSArmin Le Grand } 185*ddde725dSArmin Le Grand 186*ddde725dSArmin Le Grand const drawinglayer::primitive2d::Primitive2DSequence& SvgMarkerNode::getMarkerPrimitives() const 187*ddde725dSArmin Le Grand { 188*ddde725dSArmin Le Grand if(!aPrimitives.hasElements()) 189*ddde725dSArmin Le Grand { 190*ddde725dSArmin Le Grand decomposeSvgNode(const_cast< SvgMarkerNode* >(this)->aPrimitives, true); 191*ddde725dSArmin Le Grand } 192*ddde725dSArmin Le Grand 193*ddde725dSArmin Le Grand return aPrimitives; 194*ddde725dSArmin Le Grand } 195*ddde725dSArmin Le Grand 196*ddde725dSArmin Le Grand const basegfx::B2DRange* SvgMarkerNode::getCurrentViewPort() const 197*ddde725dSArmin Le Grand { 198*ddde725dSArmin Le Grand if(getViewBox()) 199*ddde725dSArmin Le Grand { 200*ddde725dSArmin Le Grand return getViewBox(); 201*ddde725dSArmin Le Grand } 202*ddde725dSArmin Le Grand else 203*ddde725dSArmin Le Grand { 204*ddde725dSArmin Le Grand return SvgNode::getCurrentViewPort(); 205*ddde725dSArmin Le Grand } 206*ddde725dSArmin Le Grand } 207*ddde725dSArmin Le Grand 208*ddde725dSArmin Le Grand } // end of namespace svgreader 209*ddde725dSArmin Le Grand } // end of namespace svgio 210*ddde725dSArmin Le Grand 211*ddde725dSArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 212*ddde725dSArmin Le Grand // eof 213