1ddde725dSArmin Le Grand /************************************************************** 2ddde725dSArmin Le Grand * 3ddde725dSArmin Le Grand * Licensed to the Apache Software Foundation (ASF) under one 4ddde725dSArmin Le Grand * or more contributor license agreements. See the NOTICE file 5ddde725dSArmin Le Grand * distributed with this work for additional information 6ddde725dSArmin Le Grand * regarding copyright ownership. The ASF licenses this file 7ddde725dSArmin Le Grand * to you under the Apache License, Version 2.0 (the 8ddde725dSArmin Le Grand * "License"); you may not use this file except in compliance 9ddde725dSArmin Le Grand * with the License. You may obtain a copy of the License at 10ddde725dSArmin Le Grand * 11ddde725dSArmin Le Grand * http://www.apache.org/licenses/LICENSE-2.0 12ddde725dSArmin Le Grand * 13ddde725dSArmin Le Grand * Unless required by applicable law or agreed to in writing, 14ddde725dSArmin Le Grand * software distributed under the License is distributed on an 15ddde725dSArmin Le Grand * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16ddde725dSArmin Le Grand * KIND, either express or implied. See the License for the 17ddde725dSArmin Le Grand * specific language governing permissions and limitations 18ddde725dSArmin Le Grand * under the License. 19ddde725dSArmin Le Grand * 20ddde725dSArmin Le Grand *************************************************************/ 21ddde725dSArmin Le Grand 22ddde725dSArmin Le Grand // MARKER(update_precomp.py): autogen include statement, do not remove 23ddde725dSArmin Le Grand #include "precompiled_svgio.hxx" 24ddde725dSArmin Le Grand 25ddde725dSArmin Le Grand #include <svgio/svgreader/svgmarkernode.hxx> 26ddde725dSArmin Le Grand 27ddde725dSArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 28ddde725dSArmin Le Grand 29ddde725dSArmin Le Grand namespace svgio 30ddde725dSArmin Le Grand { 31ddde725dSArmin Le Grand namespace svgreader 32ddde725dSArmin Le Grand { 33ddde725dSArmin Le Grand SvgMarkerNode::SvgMarkerNode( 34ddde725dSArmin Le Grand SvgDocument& rDocument, 35ddde725dSArmin Le Grand SvgNode* pParent) 36ddde725dSArmin Le Grand : SvgNode(SVGTokenMarker, rDocument, pParent), 37ddde725dSArmin Le Grand aPrimitives(), 38ddde725dSArmin Le Grand maSvgStyleAttributes(*this), 39ddde725dSArmin Le Grand mpViewBox(0), 40ddde725dSArmin Le Grand maSvgAspectRatio(), 41ddde725dSArmin Le Grand maRefX(0), 42ddde725dSArmin Le Grand maRefY(0), 43ddde725dSArmin Le Grand maMarkerUnits(strokeWidth), 44ddde725dSArmin Le Grand maMarkerWidth(3), 45ddde725dSArmin Le Grand maMarkerHeight(3), 46ddde725dSArmin Le Grand mfAngle(0.0), 47ddde725dSArmin Le Grand mbOrientAuto(false) 48ddde725dSArmin Le Grand { 49ddde725dSArmin Le Grand } 50ddde725dSArmin Le Grand 51ddde725dSArmin Le Grand SvgMarkerNode::~SvgMarkerNode() 52ddde725dSArmin Le Grand { 53ddde725dSArmin Le Grand if(mpViewBox) delete mpViewBox; 54ddde725dSArmin Le Grand } 55ddde725dSArmin Le Grand 56ddde725dSArmin Le Grand const SvgStyleAttributes* SvgMarkerNode::getSvgStyleAttributes() const 57ddde725dSArmin Le Grand { 58ddde725dSArmin Le Grand static rtl::OUString aClassStr(rtl::OUString::createFromAscii("marker")); 59ddde725dSArmin Le Grand 6050b37974SArmin Le Grand return checkForCssStyle(aClassStr, maSvgStyleAttributes); 61ddde725dSArmin Le Grand } 62ddde725dSArmin Le Grand 63ddde725dSArmin Le Grand void SvgMarkerNode::parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent) 64ddde725dSArmin Le Grand { 65ddde725dSArmin Le Grand // call parent 66ddde725dSArmin Le Grand SvgNode::parseAttribute(rTokenName, aSVGToken, aContent); 67ddde725dSArmin Le Grand 68ddde725dSArmin Le Grand // read style attributes 69ddde725dSArmin Le Grand maSvgStyleAttributes.parseStyleAttribute(rTokenName, aSVGToken, aContent); 70ddde725dSArmin Le Grand 71ddde725dSArmin Le Grand // parse own 72ddde725dSArmin Le Grand switch(aSVGToken) 73ddde725dSArmin Le Grand { 74ddde725dSArmin Le Grand case SVGTokenStyle: 75ddde725dSArmin Le Grand { 76ddde725dSArmin Le Grand maSvgStyleAttributes.readStyle(aContent); 77ddde725dSArmin Le Grand break; 78ddde725dSArmin Le Grand } 79ddde725dSArmin Le Grand case SVGTokenViewBox: 80ddde725dSArmin Le Grand { 81ddde725dSArmin Le Grand const basegfx::B2DRange aRange(readViewBox(aContent, *this)); 82ddde725dSArmin Le Grand 83ddde725dSArmin Le Grand if(!aRange.isEmpty()) 84ddde725dSArmin Le Grand { 85ddde725dSArmin Le Grand setViewBox(&aRange); 86ddde725dSArmin Le Grand } 87ddde725dSArmin Le Grand break; 88ddde725dSArmin Le Grand } 89ddde725dSArmin Le Grand case SVGTokenPreserveAspectRatio: 90ddde725dSArmin Le Grand { 91ddde725dSArmin Le Grand setSvgAspectRatio(readSvgAspectRatio(aContent)); 92ddde725dSArmin Le Grand break; 93ddde725dSArmin Le Grand } 94ddde725dSArmin Le Grand case SVGTokenRefX: 95ddde725dSArmin Le Grand { 96ddde725dSArmin Le Grand SvgNumber aNum; 97ddde725dSArmin Le Grand 98ddde725dSArmin Le Grand if(readSingleNumber(aContent, aNum)) 99ddde725dSArmin Le Grand { 100ddde725dSArmin Le Grand setRefX(aNum); 101ddde725dSArmin Le Grand } 102ddde725dSArmin Le Grand break; 103ddde725dSArmin Le Grand } 104ddde725dSArmin Le Grand case SVGTokenRefY: 105ddde725dSArmin Le Grand { 106ddde725dSArmin Le Grand SvgNumber aNum; 107ddde725dSArmin Le Grand 108ddde725dSArmin Le Grand if(readSingleNumber(aContent, aNum)) 109ddde725dSArmin Le Grand { 110ddde725dSArmin Le Grand setRefY(aNum); 111ddde725dSArmin Le Grand } 112ddde725dSArmin Le Grand break; 113ddde725dSArmin Le Grand } 114ddde725dSArmin Le Grand case SVGTokenMarkerUnits: 115ddde725dSArmin Le Grand { 116ddde725dSArmin Le Grand if(aContent.getLength()) 117ddde725dSArmin Le Grand { 118ddde725dSArmin Le Grand static rtl::OUString aStrStrokeWidth(rtl::OUString::createFromAscii("strokeWidth")); 119ddde725dSArmin Le Grand 120ddde725dSArmin Le Grand if(aContent.match(aStrStrokeWidth, 0)) 121ddde725dSArmin Le Grand { 122ddde725dSArmin Le Grand setMarkerUnits(strokeWidth); 123ddde725dSArmin Le Grand } 124ddde725dSArmin Le Grand else if(aContent.match(commonStrings::aStrUserSpaceOnUse, 0)) 125ddde725dSArmin Le Grand { 126ddde725dSArmin Le Grand setMarkerUnits(userSpaceOnUse); 127ddde725dSArmin Le Grand } 128ddde725dSArmin Le Grand } 129ddde725dSArmin Le Grand break; 130ddde725dSArmin Le Grand } 131ddde725dSArmin Le Grand case SVGTokenMarkerWidth: 132ddde725dSArmin Le Grand { 133ddde725dSArmin Le Grand SvgNumber aNum; 134ddde725dSArmin Le Grand 135ddde725dSArmin Le Grand if(readSingleNumber(aContent, aNum)) 136ddde725dSArmin Le Grand { 137ddde725dSArmin Le Grand if(aNum.isPositive()) 138ddde725dSArmin Le Grand { 139ddde725dSArmin Le Grand setMarkerWidth(aNum); 140ddde725dSArmin Le Grand } 141ddde725dSArmin Le Grand } 142ddde725dSArmin Le Grand break; 143ddde725dSArmin Le Grand } 144ddde725dSArmin Le Grand case SVGTokenMarkerHeight: 145ddde725dSArmin Le Grand { 146ddde725dSArmin Le Grand SvgNumber aNum; 147ddde725dSArmin Le Grand 148ddde725dSArmin Le Grand if(readSingleNumber(aContent, aNum)) 149ddde725dSArmin Le Grand { 150ddde725dSArmin Le Grand if(aNum.isPositive()) 151ddde725dSArmin Le Grand { 152ddde725dSArmin Le Grand setMarkerHeight(aNum); 153ddde725dSArmin Le Grand } 154ddde725dSArmin Le Grand } 155ddde725dSArmin Le Grand break; 156ddde725dSArmin Le Grand } 157ddde725dSArmin Le Grand case SVGTokenOrient: 158ddde725dSArmin Le Grand { 159ddde725dSArmin Le Grand const sal_Int32 nLen(aContent.getLength()); 160ddde725dSArmin Le Grand 161ddde725dSArmin Le Grand if(nLen) 162ddde725dSArmin Le Grand { 163ddde725dSArmin Le Grand static rtl::OUString aStrAuto(rtl::OUString::createFromAscii("auto")); 164ddde725dSArmin Le Grand 165ddde725dSArmin Le Grand if(aContent.match(aStrAuto, 0)) 166ddde725dSArmin Le Grand { 167ddde725dSArmin Le Grand setOrientAuto(true); 168ddde725dSArmin Le Grand } 169ddde725dSArmin Le Grand else 170ddde725dSArmin Le Grand { 171ddde725dSArmin Le Grand sal_Int32 nPos(0); 172ddde725dSArmin Le Grand double fAngle(0.0); 173ddde725dSArmin Le Grand 174ddde725dSArmin Le Grand if(readAngle(aContent, nPos, fAngle, nLen)) 175ddde725dSArmin Le Grand { 176ddde725dSArmin Le Grand setAngle(fAngle); 177ddde725dSArmin Le Grand } 178ddde725dSArmin Le Grand } 179ddde725dSArmin Le Grand } 180ddde725dSArmin Le Grand break; 181ddde725dSArmin Le Grand } 182e2bf1e9dSArmin Le Grand default: 183e2bf1e9dSArmin Le Grand { 184e2bf1e9dSArmin Le Grand break; 185e2bf1e9dSArmin Le Grand } 186ddde725dSArmin Le Grand } 187ddde725dSArmin Le Grand } 188ddde725dSArmin Le Grand 189ddde725dSArmin Le Grand const drawinglayer::primitive2d::Primitive2DSequence& SvgMarkerNode::getMarkerPrimitives() const 190ddde725dSArmin Le Grand { 191*a275c134SArmin Le Grand if(!aPrimitives.hasElements() && Display_none != getDisplay()) 192ddde725dSArmin Le Grand { 193ddde725dSArmin Le Grand decomposeSvgNode(const_cast< SvgMarkerNode* >(this)->aPrimitives, true); 194ddde725dSArmin Le Grand } 195ddde725dSArmin Le Grand 196ddde725dSArmin Le Grand return aPrimitives; 197ddde725dSArmin Le Grand } 198ddde725dSArmin Le Grand 199ddde725dSArmin Le Grand const basegfx::B2DRange* SvgMarkerNode::getCurrentViewPort() const 200ddde725dSArmin Le Grand { 201ddde725dSArmin Le Grand if(getViewBox()) 202ddde725dSArmin Le Grand { 203ddde725dSArmin Le Grand return getViewBox(); 204ddde725dSArmin Le Grand } 205ddde725dSArmin Le Grand else 206ddde725dSArmin Le Grand { 207ddde725dSArmin Le Grand return SvgNode::getCurrentViewPort(); 208ddde725dSArmin Le Grand } 209ddde725dSArmin Le Grand } 210ddde725dSArmin Le Grand 211ddde725dSArmin Le Grand } // end of namespace svgreader 212ddde725dSArmin Le Grand } // end of namespace svgio 213ddde725dSArmin Le Grand 214ddde725dSArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 215ddde725dSArmin Le Grand // eof 216