xref: /aoo41x/main/svgio/source/svgreader/svgnode.cxx (revision 50b37974)
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/svgnode.hxx>
26ddde725dSArmin Le Grand #include <basegfx/polygon/b2dpolypolygontools.hxx>
27ddde725dSArmin Le Grand #include <svgio/svgreader/svgdocument.hxx>
28ddde725dSArmin Le Grand #include <svgio/svgreader/svgnode.hxx>
29ddde725dSArmin Le Grand #include <svgio/svgreader/svgstyleattributes.hxx>
30025b0597SArmin Le Grand #include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx>
31172c67b2SArmin Le Grand #include <tools/urlobj.hxx>
32ddde725dSArmin Le Grand 
33ddde725dSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
34ddde725dSArmin Le Grand 
35ddde725dSArmin Le Grand namespace svgio
36ddde725dSArmin Le Grand {
37ddde725dSArmin Le Grand     namespace svgreader
38ddde725dSArmin Le Grand     {
39ddde725dSArmin Le Grand         const SvgStyleAttributes* SvgNode::getSvgStyleAttributes() const
40ddde725dSArmin Le Grand         {
41ddde725dSArmin Le Grand             return 0;
42ddde725dSArmin Le Grand         }
43ddde725dSArmin Le Grand 
44*50b37974SArmin Le Grand         const SvgStyleAttributes* SvgNode::checkForCssStyle(const rtl::OUString& rClassStr, const SvgStyleAttributes& rOriginal) const
45*50b37974SArmin Le Grand         {
46*50b37974SArmin Le Grand             const SvgDocument& rDocument = getDocument();
47*50b37974SArmin Le Grand 
48*50b37974SArmin Le Grand             if(rDocument.hasSvgStyleAttributesById())
49*50b37974SArmin Le Grand             {
50*50b37974SArmin Le Grand                 if(getClass())
51*50b37974SArmin Le Grand                 {
52*50b37974SArmin Le Grand                     // find all referenced CSS styles, a list of entries is allowed
53*50b37974SArmin Le Grand                     const rtl::OUString* pClassList = getClass();
54*50b37974SArmin Le Grand                     const sal_Int32 nLen(pClassList->getLength());
55*50b37974SArmin Le Grand                     sal_Int32 nPos(0);
56*50b37974SArmin Le Grand                     const SvgStyleAttributes* pNew = 0;
57*50b37974SArmin Le Grand 
58*50b37974SArmin Le Grand                     skip_char(*pClassList, sal_Unicode(' '), nPos, nLen);
59*50b37974SArmin Le Grand 
60*50b37974SArmin Le Grand                     while(nPos < nLen)
61*50b37974SArmin Le Grand                     {
62*50b37974SArmin Le Grand                         rtl::OUStringBuffer aTokenValue;
63*50b37974SArmin Le Grand 
64*50b37974SArmin Le Grand                         copyToLimiter(*pClassList, sal_Unicode(' '), nPos, aTokenValue, nLen);
65*50b37974SArmin Le Grand                         skip_char(*pClassList, sal_Unicode(' '), nPos, nLen);
66*50b37974SArmin Le Grand 
67*50b37974SArmin Le Grand                         rtl::OUString aId(rtl::OUString::createFromAscii("."));
68*50b37974SArmin Le Grand                         const rtl::OUString aOUTokenValue(aTokenValue.makeStringAndClear());
69*50b37974SArmin Le Grand 
70*50b37974SArmin Le Grand                         // look for CSS style common to token
71*50b37974SArmin Le Grand                         aId = aId + aOUTokenValue;
72*50b37974SArmin Le Grand                         pNew = rDocument.findSvgStyleAttributesById(aId);
73*50b37974SArmin Le Grand 
74*50b37974SArmin Le Grand                         if(!pNew && rClassStr.getLength())
75*50b37974SArmin Le Grand                         {
76*50b37974SArmin Le Grand                             // look for CSS style common to class.token
77*50b37974SArmin Le Grand                             aId = rClassStr + aId;
78*50b37974SArmin Le Grand 
79*50b37974SArmin Le Grand                             pNew = rDocument.findSvgStyleAttributesById(aId);
80*50b37974SArmin Le Grand                         }
81*50b37974SArmin Le Grand 
82*50b37974SArmin Le Grand                         if(pNew)
83*50b37974SArmin Le Grand                         {
84*50b37974SArmin Le Grand                             const_cast< SvgNode* >(this)->maCssStyleVector.push_back(pNew);
85*50b37974SArmin Le Grand                         }
86*50b37974SArmin Le Grand                     }
87*50b37974SArmin Le Grand                 }
88*50b37974SArmin Le Grand 
89*50b37974SArmin Le Grand                 if(maCssStyleVector.empty() && getId())
90*50b37974SArmin Le Grand                 {
91*50b37974SArmin Le Grand                     // if none found, search for CSS style equal to Id
92*50b37974SArmin Le Grand                     const SvgStyleAttributes* pNew = rDocument.findSvgStyleAttributesById(*getId());
93*50b37974SArmin Le Grand 
94*50b37974SArmin Le Grand                     if(pNew)
95*50b37974SArmin Le Grand                     {
96*50b37974SArmin Le Grand                         const_cast< SvgNode* >(this)->maCssStyleVector.push_back(pNew);
97*50b37974SArmin Le Grand                     }
98*50b37974SArmin Le Grand                 }
99*50b37974SArmin Le Grand 
100*50b37974SArmin Le Grand                 if(maCssStyleVector.empty() && rClassStr.getLength())
101*50b37974SArmin Le Grand                 {
102*50b37974SArmin Le Grand                     // if none found, search for CSS style equal to class type
103*50b37974SArmin Le Grand                     const SvgStyleAttributes* pNew = rDocument.findSvgStyleAttributesById(rClassStr);
104*50b37974SArmin Le Grand 
105*50b37974SArmin Le Grand                     if(pNew)
106*50b37974SArmin Le Grand                     {
107*50b37974SArmin Le Grand                         const_cast< SvgNode* >(this)->maCssStyleVector.push_back(pNew);
108*50b37974SArmin Le Grand                     }
109*50b37974SArmin Le Grand                 }
110*50b37974SArmin Le Grand             }
111*50b37974SArmin Le Grand 
112*50b37974SArmin Le Grand             if(maCssStyleVector.empty())
113*50b37974SArmin Le Grand             {
114*50b37974SArmin Le Grand                 return &rOriginal;
115*50b37974SArmin Le Grand             }
116*50b37974SArmin Le Grand             else
117*50b37974SArmin Le Grand             {
118*50b37974SArmin Le Grand                 // set CssStyleParent at maCssStyleVector members to hang them in front of
119*50b37974SArmin Le Grand                 // the existing style
120*50b37974SArmin Le Grand                 SvgStyleAttributes* pCurrent = const_cast< SvgStyleAttributes* >(&rOriginal);
121*50b37974SArmin Le Grand 
122*50b37974SArmin Le Grand                 for(sal_uInt32 a(0); a < maCssStyleVector.size(); a++)
123*50b37974SArmin Le Grand                 {
124*50b37974SArmin Le Grand                     SvgStyleAttributes* pCandidate = const_cast< SvgStyleAttributes* >(maCssStyleVector[maCssStyleVector.size() - a - 1]);
125*50b37974SArmin Le Grand 
126*50b37974SArmin Le Grand                     pCandidate->setCssStyleParent(pCurrent);
127*50b37974SArmin Le Grand                     pCurrent = pCandidate;
128*50b37974SArmin Le Grand                 }
129*50b37974SArmin Le Grand 
130*50b37974SArmin Le Grand                 return pCurrent;
131*50b37974SArmin Le Grand             }
132*50b37974SArmin Le Grand         }
133*50b37974SArmin Le Grand 
134ddde725dSArmin Le Grand         SvgNode::SvgNode(
135ddde725dSArmin Le Grand             SVGToken aType,
136ddde725dSArmin Le Grand             SvgDocument& rDocument,
137ddde725dSArmin Le Grand             SvgNode* pParent)
138ddde725dSArmin Le Grand         :   maType(aType),
139ddde725dSArmin Le Grand             mrDocument(rDocument),
140ddde725dSArmin Le Grand             mpParent(pParent),
141ddde725dSArmin Le Grand             mpAlternativeParent(0),
142ddde725dSArmin Le Grand             maChildren(),
143ddde725dSArmin Le Grand             mpId(0),
144ddde725dSArmin Le Grand             mpClass(0),
145*50b37974SArmin Le Grand             maXmlSpace(XmlSpace_notset),
146*50b37974SArmin Le Grand             maCssStyleVector()
147ddde725dSArmin Le Grand         {
148ddde725dSArmin Le Grand             OSL_ENSURE(SVGTokenUnknown != maType, "SvgNode with unknown type created (!)");
149ddde725dSArmin Le Grand 
150ddde725dSArmin Le Grand             if(pParent)
151ddde725dSArmin Le Grand             {
152ddde725dSArmin Le Grand                 pParent->maChildren.push_back(this);
153ddde725dSArmin Le Grand             }
154ddde725dSArmin Le Grand             else
155ddde725dSArmin Le Grand             {
156ddde725dSArmin Le Grand #ifdef DBG_UTIL
157ddde725dSArmin Le Grand                 if(SVGTokenSvg != getType())
158ddde725dSArmin Le Grand                 {
159ddde725dSArmin Le Grand                     OSL_ENSURE(false, "No parent for this node (!)");
160ddde725dSArmin Le Grand                 }
161ddde725dSArmin Le Grand #endif
162ddde725dSArmin Le Grand             }
163ddde725dSArmin Le Grand         }
164ddde725dSArmin Le Grand 
165ddde725dSArmin Le Grand         SvgNode::~SvgNode()
166ddde725dSArmin Le Grand         {
167ddde725dSArmin Le Grand             while(maChildren.size())
168ddde725dSArmin Le Grand             {
169ddde725dSArmin Le Grand                 delete maChildren[maChildren.size() - 1];
170ddde725dSArmin Le Grand                 maChildren.pop_back();
171ddde725dSArmin Le Grand             }
172ddde725dSArmin Le Grand 
173ddde725dSArmin Le Grand             if(mpId) delete mpId;
174ddde725dSArmin Le Grand             if(mpClass) delete mpClass;
175ddde725dSArmin Le Grand         }
176ddde725dSArmin Le Grand 
177ddde725dSArmin Le Grand         void SvgNode::parseAttributes(const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttribs)
178ddde725dSArmin Le Grand         {
179ddde725dSArmin Le Grand             const sal_uInt32 nAttributes(xAttribs->getLength());
180ddde725dSArmin Le Grand 
181ddde725dSArmin Le Grand             for(sal_uInt32 a(0); a < nAttributes; a++)
182ddde725dSArmin Le Grand             {
183ddde725dSArmin Le Grand                 const ::rtl::OUString aTokenName(xAttribs->getNameByIndex(a));
184ddde725dSArmin Le Grand 
185ddde725dSArmin Le Grand                 parseAttribute(aTokenName, StrToSVGToken(aTokenName), xAttribs->getValueByIndex(a));
186ddde725dSArmin Le Grand             }
187ddde725dSArmin Le Grand         }
188ddde725dSArmin Le Grand 
189e2bf1e9dSArmin Le Grand         void SvgNode::parseAttribute(const rtl::OUString& /*rTokenName*/, SVGToken aSVGToken, const rtl::OUString& aContent)
190ddde725dSArmin Le Grand         {
191ddde725dSArmin Le Grand             switch(aSVGToken)
192ddde725dSArmin Le Grand             {
193ddde725dSArmin Le Grand                 case SVGTokenId:
194ddde725dSArmin Le Grand                 {
195ddde725dSArmin Le Grand                     if(aContent.getLength())
196ddde725dSArmin Le Grand                     {
197ddde725dSArmin Le Grand                         setId(&aContent);
198ddde725dSArmin Le Grand                     }
199ddde725dSArmin Le Grand                     break;
200ddde725dSArmin Le Grand                 }
201ddde725dSArmin Le Grand                 case SVGTokenClass:
202ddde725dSArmin Le Grand                 {
203ddde725dSArmin Le Grand                     if(aContent.getLength())
204ddde725dSArmin Le Grand                     {
205ddde725dSArmin Le Grand                         setClass(&aContent);
206ddde725dSArmin Le Grand                     }
207ddde725dSArmin Le Grand                     break;
208ddde725dSArmin Le Grand                 }
209ddde725dSArmin Le Grand                 case SVGTokenXmlSpace:
210ddde725dSArmin Le Grand                 {
211ddde725dSArmin Le Grand                     if(aContent.getLength())
212ddde725dSArmin Le Grand                     {
213ddde725dSArmin Le Grand                         static rtl::OUString aStrDefault(rtl::OUString::createFromAscii("default"));
214ddde725dSArmin Le Grand                         static rtl::OUString aStrPreserve(rtl::OUString::createFromAscii("preserve"));
215ddde725dSArmin Le Grand 
216ddde725dSArmin Le Grand                         if(aContent.match(aStrDefault))
217ddde725dSArmin Le Grand                         {
218ddde725dSArmin Le Grand                             setXmlSpace(XmlSpace_default);
219ddde725dSArmin Le Grand                         }
220ddde725dSArmin Le Grand                         else if(aContent.match(aStrPreserve))
221ddde725dSArmin Le Grand                         {
222ddde725dSArmin Le Grand                             setXmlSpace(XmlSpace_preserve);
223ddde725dSArmin Le Grand                         }
224ddde725dSArmin Le Grand                     }
225ddde725dSArmin Le Grand                     break;
226ddde725dSArmin Le Grand                 }
227e2bf1e9dSArmin Le Grand                 default:
228e2bf1e9dSArmin Le Grand                 {
229e2bf1e9dSArmin Le Grand                     break;
230e2bf1e9dSArmin Le Grand                 }
231ddde725dSArmin Le Grand             }
232ddde725dSArmin Le Grand         }
233ddde725dSArmin Le Grand 
234ddde725dSArmin Le Grand         void SvgNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DSequence& rTarget, bool bReferenced) const
235ddde725dSArmin Le Grand         {
236ddde725dSArmin Le Grand             if(!bReferenced)
237ddde725dSArmin Le Grand             {
238ddde725dSArmin Le Grand                 if(SVGTokenDefs == getType() ||
239ddde725dSArmin Le Grand                     SVGTokenSymbol == getType() ||
240ddde725dSArmin Le Grand                     SVGTokenClipPathNode == getType() ||
241ddde725dSArmin Le Grand                     SVGTokenMask == getType() ||
242ddde725dSArmin Le Grand                     SVGTokenMarker == getType() ||
243ddde725dSArmin Le Grand                     SVGTokenPattern == getType())
244ddde725dSArmin Le Grand                 {
245ddde725dSArmin Le Grand                     // do not decompose defs or symbol nodes (these hold only style-like
246ddde725dSArmin Le Grand                     // objects which may be used by referencing them) except when doing
247ddde725dSArmin Le Grand                     // so controlled referenced
248ddde725dSArmin Le Grand 
249ddde725dSArmin Le Grand                     // also do not decompose ClipPaths and Masks. These should be embedded
250ddde725dSArmin Le Grand                     // in a defs node (which gets not decomposed by itself), but you never
251ddde725dSArmin Le Grand                     // know
252ddde725dSArmin Le Grand 
253ddde725dSArmin Le Grand                     // also not directly used are Markers and Patterns, only indirecty used
254ddde725dSArmin Le Grand                     // by reference
255ddde725dSArmin Le Grand                     return;
256ddde725dSArmin Le Grand                 }
257ddde725dSArmin Le Grand             }
258ddde725dSArmin Le Grand 
259ddde725dSArmin Le Grand             const SvgNodeVector& rChildren = getChildren();
260ddde725dSArmin Le Grand 
261ddde725dSArmin Le Grand             if(!rChildren.empty())
262ddde725dSArmin Le Grand             {
263ddde725dSArmin Le Grand                 const sal_uInt32 nCount(rChildren.size());
264ddde725dSArmin Le Grand 
265ddde725dSArmin Le Grand                 for(sal_uInt32 a(0); a < nCount; a++)
266ddde725dSArmin Le Grand                 {
267ddde725dSArmin Le Grand                     SvgNode* pCandidate = rChildren[a];
268ddde725dSArmin Le Grand 
269ddde725dSArmin Le Grand                     if(pCandidate)
270ddde725dSArmin Le Grand                     {
271ddde725dSArmin Le Grand                         drawinglayer::primitive2d::Primitive2DSequence aNewTarget;
272ddde725dSArmin Le Grand 
273ddde725dSArmin Le Grand                         pCandidate->decomposeSvgNode(aNewTarget, bReferenced);
274ddde725dSArmin Le Grand 
275ddde725dSArmin Le Grand                         if(aNewTarget.hasElements())
276ddde725dSArmin Le Grand                         {
277ddde725dSArmin Le Grand                             drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(rTarget, aNewTarget);
278ddde725dSArmin Le Grand                         }
279ddde725dSArmin Le Grand                     }
280ddde725dSArmin Le Grand                     else
281ddde725dSArmin Le Grand                     {
282ddde725dSArmin Le Grand                         OSL_ENSURE(false, "Null-Pointer in child node list (!)");
283ddde725dSArmin Le Grand                     }
284ddde725dSArmin Le Grand                 }
285025b0597SArmin Le Grand 
286025b0597SArmin Le Grand                 if(rTarget.hasElements())
287025b0597SArmin Le Grand                 {
288025b0597SArmin Le Grand                     const SvgStyleAttributes* pStyles = getSvgStyleAttributes();
289025b0597SArmin Le Grand 
290025b0597SArmin Le Grand                     if(pStyles)
291025b0597SArmin Le Grand                     {
292025b0597SArmin Le Grand                         // check if we have Title or Desc
293025b0597SArmin Le Grand                         const rtl::OUString& rTitle = pStyles->getTitle();
294025b0597SArmin Le Grand                         const rtl::OUString& rDesc = pStyles->getDesc();
295025b0597SArmin Le Grand 
296025b0597SArmin Le Grand                         if(rTitle.getLength() || rDesc.getLength())
297025b0597SArmin Le Grand                         {
298025b0597SArmin Le Grand                             // default object name is empty
299025b0597SArmin Le Grand                             rtl::OUString aObjectName;
300025b0597SArmin Le Grand 
301025b0597SArmin Le Grand                             // use path as object name when outmost element
302025b0597SArmin Le Grand                             if(SVGTokenSvg == getType())
303025b0597SArmin Le Grand                             {
304025b0597SArmin Le Grand                                 aObjectName = getDocument().getAbsolutePath();
305172c67b2SArmin Le Grand 
306172c67b2SArmin Le Grand                                 if(aObjectName.getLength())
307172c67b2SArmin Le Grand                                 {
308172c67b2SArmin Le Grand                             		INetURLObject aURL(aObjectName);
309172c67b2SArmin Le Grand 
310172c67b2SArmin Le Grand                                     aObjectName = aURL.getName(
311172c67b2SArmin Le Grand                                         INetURLObject::LAST_SEGMENT,
312172c67b2SArmin Le Grand                                         true,
313172c67b2SArmin Le Grand                                         INetURLObject::DECODE_WITH_CHARSET);
314172c67b2SArmin Le Grand                                 }
315025b0597SArmin Le Grand                             }
316025b0597SArmin Le Grand 
317025b0597SArmin Le Grand                             // pack in ObjectInfoPrimitive2D group
318025b0597SArmin Le Grand                             const drawinglayer::primitive2d::Primitive2DReference xRef(
319025b0597SArmin Le Grand                                 new drawinglayer::primitive2d::ObjectInfoPrimitive2D(
320025b0597SArmin Le Grand                                     rTarget,
321025b0597SArmin Le Grand                                     aObjectName,
322025b0597SArmin Le Grand                                     rTitle,
323025b0597SArmin Le Grand                                     rDesc));
324025b0597SArmin Le Grand 
325025b0597SArmin Le Grand                             rTarget = drawinglayer::primitive2d::Primitive2DSequence(&xRef, 1);
326025b0597SArmin Le Grand                         }
327025b0597SArmin Le Grand                     }
328025b0597SArmin Le Grand                 }
329ddde725dSArmin Le Grand             }
330ddde725dSArmin Le Grand         }
331ddde725dSArmin Le Grand 
332ddde725dSArmin Le Grand         const basegfx::B2DRange* SvgNode::getCurrentViewPort() const
333ddde725dSArmin Le Grand         {
334ddde725dSArmin Le Grand             if(getParent())
335ddde725dSArmin Le Grand             {
336ddde725dSArmin Le Grand                 return getParent()->getCurrentViewPort();
337ddde725dSArmin Le Grand             }
338ddde725dSArmin Le Grand             else
339ddde725dSArmin Le Grand             {
340ddde725dSArmin Le Grand                 return 0;
341ddde725dSArmin Le Grand             }
342ddde725dSArmin Le Grand         }
343ddde725dSArmin Le Grand 
344ddde725dSArmin Le Grand         double SvgNode::getCurrentFontSize() const
345ddde725dSArmin Le Grand         {
346ddde725dSArmin Le Grand             if(getSvgStyleAttributes())
347ddde725dSArmin Le Grand             {
348ddde725dSArmin Le Grand                 return getSvgStyleAttributes()->getFontSize().solve(*this, xcoordinate);
349ddde725dSArmin Le Grand             }
350ddde725dSArmin Le Grand             else if(getParent())
351ddde725dSArmin Le Grand             {
352ddde725dSArmin Le Grand                 return getParent()->getCurrentFontSize();
353ddde725dSArmin Le Grand             }
354ddde725dSArmin Le Grand             else
355ddde725dSArmin Le Grand             {
356ddde725dSArmin Le Grand                 return 0.0;
357ddde725dSArmin Le Grand             }
358ddde725dSArmin Le Grand         }
359ddde725dSArmin Le Grand 
360ddde725dSArmin Le Grand         double SvgNode::getCurrentXHeight() const
361ddde725dSArmin Le Grand         {
362ddde725dSArmin Le Grand             if(getSvgStyleAttributes())
363ddde725dSArmin Le Grand             {
364ddde725dSArmin Le Grand                 // for XHeight, use FontSize currently
365ddde725dSArmin Le Grand                 return getSvgStyleAttributes()->getFontSize().solve(*this, ycoordinate);
366ddde725dSArmin Le Grand             }
367ddde725dSArmin Le Grand             else if(getParent())
368ddde725dSArmin Le Grand             {
369ddde725dSArmin Le Grand                 return getParent()->getCurrentXHeight();
370ddde725dSArmin Le Grand             }
371ddde725dSArmin Le Grand             else
372ddde725dSArmin Le Grand             {
373ddde725dSArmin Le Grand                 return 0.0;
374ddde725dSArmin Le Grand             }
375ddde725dSArmin Le Grand         }
376ddde725dSArmin Le Grand 
377ddde725dSArmin Le Grand         void SvgNode::setId(const rtl::OUString* pfId)
378ddde725dSArmin Le Grand         {
379ddde725dSArmin Le Grand             if(mpId)
380ddde725dSArmin Le Grand             {
381ddde725dSArmin Le Grand                 mrDocument.removeSvgNodeFromMapper(*mpId);
382ddde725dSArmin Le Grand                 delete mpId;
383ddde725dSArmin Le Grand                 mpId = 0;
384ddde725dSArmin Le Grand             }
385ddde725dSArmin Le Grand 
386ddde725dSArmin Le Grand             if(pfId)
387ddde725dSArmin Le Grand             {
388ddde725dSArmin Le Grand                 mpId = new rtl::OUString(*pfId);
389ddde725dSArmin Le Grand                 mrDocument.addSvgNodeToMapper(*mpId, *this);
390ddde725dSArmin Le Grand             }
391ddde725dSArmin Le Grand         }
392ddde725dSArmin Le Grand 
393ddde725dSArmin Le Grand         void SvgNode::setClass(const rtl::OUString* pfClass)
394ddde725dSArmin Le Grand         {
395ddde725dSArmin Le Grand             if(mpClass)
396ddde725dSArmin Le Grand             {
397ddde725dSArmin Le Grand                 mrDocument.removeSvgNodeFromMapper(*mpClass);
398ddde725dSArmin Le Grand                 delete mpClass;
399ddde725dSArmin Le Grand                 mpClass = 0;
400ddde725dSArmin Le Grand             }
401ddde725dSArmin Le Grand 
402ddde725dSArmin Le Grand             if(pfClass)
403ddde725dSArmin Le Grand             {
404ddde725dSArmin Le Grand                 mpClass = new rtl::OUString(*pfClass);
405ddde725dSArmin Le Grand                 mrDocument.addSvgNodeToMapper(*mpClass, *this);
406ddde725dSArmin Le Grand             }
407ddde725dSArmin Le Grand         }
408ddde725dSArmin Le Grand 
409ddde725dSArmin Le Grand         XmlSpace SvgNode::getXmlSpace() const
410ddde725dSArmin Le Grand         {
411ddde725dSArmin Le Grand             if(maXmlSpace != XmlSpace_notset)
412ddde725dSArmin Le Grand             {
413ddde725dSArmin Le Grand                 return maXmlSpace;
414ddde725dSArmin Le Grand             }
415ddde725dSArmin Le Grand 
416ddde725dSArmin Le Grand             if(getParent())
417ddde725dSArmin Le Grand             {
418ddde725dSArmin Le Grand                 return getParent()->getXmlSpace();
419ddde725dSArmin Le Grand             }
420ddde725dSArmin Le Grand 
421ddde725dSArmin Le Grand             // default is XmlSpace_default
422ddde725dSArmin Le Grand             return XmlSpace_default;
423ddde725dSArmin Le Grand         }
424ddde725dSArmin Le Grand 
425ddde725dSArmin Le Grand     } // end of namespace svgreader
426ddde725dSArmin Le Grand } // end of namespace svgio
427ddde725dSArmin Le Grand 
428ddde725dSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
429ddde725dSArmin Le Grand // eof
430