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/svgdocument.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 { SvgDocument(const rtl::OUString & rAbsolutePath)33*ddde725dSArmin Le Grand SvgDocument::SvgDocument(const rtl::OUString& rAbsolutePath) 34*ddde725dSArmin Le Grand : maNodes(), 35*ddde725dSArmin Le Grand maAbsolutePath(rAbsolutePath), 36*ddde725dSArmin Le Grand maIdTokenMapperList(), 37*ddde725dSArmin Le Grand maIdStyleTokenMapperList() 38*ddde725dSArmin Le Grand { 39*ddde725dSArmin Le Grand } 40*ddde725dSArmin Le Grand ~SvgDocument()41*ddde725dSArmin Le Grand SvgDocument::~SvgDocument() 42*ddde725dSArmin Le Grand { 43*ddde725dSArmin Le Grand while(!maNodes.empty()) 44*ddde725dSArmin Le Grand { 45*ddde725dSArmin Le Grand SvgNode* pCandidate = maNodes[maNodes.size() - 1]; 46*ddde725dSArmin Le Grand delete pCandidate; 47*ddde725dSArmin Le Grand maNodes.pop_back(); 48*ddde725dSArmin Le Grand } 49*ddde725dSArmin Le Grand } 50*ddde725dSArmin Le Grand appendNode(SvgNode * pNode)51*ddde725dSArmin Le Grand void SvgDocument::appendNode(SvgNode* pNode) 52*ddde725dSArmin Le Grand { 53*ddde725dSArmin Le Grand OSL_ENSURE(pNode, "OOps, empty node added (!)"); 54*ddde725dSArmin Le Grand maNodes.push_back(pNode); 55*ddde725dSArmin Le Grand } 56*ddde725dSArmin Le Grand addSvgNodeToMapper(const rtl::OUString & rStr,const SvgNode & rNode)57*ddde725dSArmin Le Grand void SvgDocument::addSvgNodeToMapper(const rtl::OUString& rStr, const SvgNode& rNode) 58*ddde725dSArmin Le Grand { 59*ddde725dSArmin Le Grand if(rStr.getLength()) 60*ddde725dSArmin Le Grand { 61*ddde725dSArmin Le Grand maIdTokenMapperList.insert(IdTokenValueType(rStr, &rNode)); 62*ddde725dSArmin Le Grand } 63*ddde725dSArmin Le Grand } 64*ddde725dSArmin Le Grand removeSvgNodeFromMapper(const rtl::OUString & rStr)65*ddde725dSArmin Le Grand void SvgDocument::removeSvgNodeFromMapper(const rtl::OUString& rStr) 66*ddde725dSArmin Le Grand { 67*ddde725dSArmin Le Grand if(rStr.getLength()) 68*ddde725dSArmin Le Grand { 69*ddde725dSArmin Le Grand maIdTokenMapperList.erase(rStr); 70*ddde725dSArmin Le Grand } 71*ddde725dSArmin Le Grand } 72*ddde725dSArmin Le Grand findSvgNodeById(const rtl::OUString & rStr) const73*ddde725dSArmin Le Grand const SvgNode* SvgDocument::findSvgNodeById(const rtl::OUString& rStr) const 74*ddde725dSArmin Le Grand { 75*ddde725dSArmin Le Grand const IdTokenMapper::const_iterator aResult(maIdTokenMapperList.find(rStr)); 76*ddde725dSArmin Le Grand 77*ddde725dSArmin Le Grand if(aResult == maIdTokenMapperList.end()) 78*ddde725dSArmin Le Grand { 79*ddde725dSArmin Le Grand return 0; 80*ddde725dSArmin Le Grand } 81*ddde725dSArmin Le Grand else 82*ddde725dSArmin Le Grand { 83*ddde725dSArmin Le Grand return aResult->second; 84*ddde725dSArmin Le Grand } 85*ddde725dSArmin Le Grand } 86*ddde725dSArmin Le Grand addSvgStyleAttributesToMapper(const rtl::OUString & rStr,const SvgStyleAttributes & rSvgStyleAttributes)87*ddde725dSArmin Le Grand void SvgDocument::addSvgStyleAttributesToMapper(const rtl::OUString& rStr, const SvgStyleAttributes& rSvgStyleAttributes) 88*ddde725dSArmin Le Grand { 89*ddde725dSArmin Le Grand if(rStr.getLength()) 90*ddde725dSArmin Le Grand { 91*ddde725dSArmin Le Grand maIdStyleTokenMapperList.insert(IdStyleTokenValueType(rStr, &rSvgStyleAttributes)); 92*ddde725dSArmin Le Grand } 93*ddde725dSArmin Le Grand } 94*ddde725dSArmin Le Grand removeSvgStyleAttributesFromMapper(const rtl::OUString & rStr)95*ddde725dSArmin Le Grand void SvgDocument::removeSvgStyleAttributesFromMapper(const rtl::OUString& rStr) 96*ddde725dSArmin Le Grand { 97*ddde725dSArmin Le Grand if(rStr.getLength()) 98*ddde725dSArmin Le Grand { 99*ddde725dSArmin Le Grand maIdStyleTokenMapperList.erase(rStr); 100*ddde725dSArmin Le Grand } 101*ddde725dSArmin Le Grand } 102*ddde725dSArmin Le Grand findSvgStyleAttributesById(const rtl::OUString & rStr) const103*ddde725dSArmin Le Grand const SvgStyleAttributes* SvgDocument::findSvgStyleAttributesById(const rtl::OUString& rStr) const 104*ddde725dSArmin Le Grand { 105*ddde725dSArmin Le Grand const IdStyleTokenMapper::const_iterator aResult(maIdStyleTokenMapperList.find(rStr)); 106*ddde725dSArmin Le Grand 107*ddde725dSArmin Le Grand if(aResult == maIdStyleTokenMapperList.end()) 108*ddde725dSArmin Le Grand { 109*ddde725dSArmin Le Grand return 0; 110*ddde725dSArmin Le Grand } 111*ddde725dSArmin Le Grand else 112*ddde725dSArmin Le Grand { 113*ddde725dSArmin Le Grand return aResult->second; 114*ddde725dSArmin Le Grand } 115*ddde725dSArmin Le Grand } 116*ddde725dSArmin Le Grand 117*ddde725dSArmin Le Grand } // end of namespace svgreader 118*ddde725dSArmin Le Grand } // end of namespace svgio 119*ddde725dSArmin Le Grand 120*ddde725dSArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 121*ddde725dSArmin Le Grand // eof 122