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 4450b37974SArmin Le Grand const SvgStyleAttributes* SvgNode::checkForCssStyle(const rtl::OUString& rClassStr, const SvgStyleAttributes& rOriginal) const 4550b37974SArmin Le Grand { 460906e779SArmin Le Grand if(maCssStyleVector.empty()) // #120435# Evaluate for CSS styles only once, this cannot change 4750b37974SArmin Le Grand { 480906e779SArmin Le Grand const SvgDocument& rDocument = getDocument(); 490906e779SArmin Le Grand 500906e779SArmin Le Grand if(rDocument.hasSvgStyleAttributesById()) 5150b37974SArmin Le Grand { 520906e779SArmin Le Grand if(getClass()) 530906e779SArmin Le Grand { 540906e779SArmin Le Grand // find all referenced CSS styles, a list of entries is allowed 550906e779SArmin Le Grand const rtl::OUString* pClassList = getClass(); 560906e779SArmin Le Grand const sal_Int32 nLen(pClassList->getLength()); 570906e779SArmin Le Grand sal_Int32 nPos(0); 580906e779SArmin Le Grand const SvgStyleAttributes* pNew = 0; 5950b37974SArmin Le Grand 600906e779SArmin Le Grand skip_char(*pClassList, sal_Unicode(' '), nPos, nLen); 6150b37974SArmin Le Grand 620906e779SArmin Le Grand while(nPos < nLen) 630906e779SArmin Le Grand { 640906e779SArmin Le Grand rtl::OUStringBuffer aTokenValue; 6550b37974SArmin Le Grand 660906e779SArmin Le Grand copyToLimiter(*pClassList, sal_Unicode(' '), nPos, aTokenValue, nLen); 670906e779SArmin Le Grand skip_char(*pClassList, sal_Unicode(' '), nPos, nLen); 6850b37974SArmin Le Grand 690906e779SArmin Le Grand rtl::OUString aId(rtl::OUString::createFromAscii(".")); 700906e779SArmin Le Grand const rtl::OUString aOUTokenValue(aTokenValue.makeStringAndClear()); 7150b37974SArmin Le Grand 720906e779SArmin Le Grand // look for CSS style common to token 730906e779SArmin Le Grand aId = aId + aOUTokenValue; 740906e779SArmin Le Grand pNew = rDocument.findSvgStyleAttributesById(aId); 7550b37974SArmin Le Grand 760906e779SArmin Le Grand if(!pNew && rClassStr.getLength()) 770906e779SArmin Le Grand { 780906e779SArmin Le Grand // look for CSS style common to class.token 790906e779SArmin Le Grand aId = rClassStr + aId; 8050b37974SArmin Le Grand 810906e779SArmin Le Grand pNew = rDocument.findSvgStyleAttributesById(aId); 820906e779SArmin Le Grand } 8350b37974SArmin Le Grand 840906e779SArmin Le Grand if(pNew) 850906e779SArmin Le Grand { 860906e779SArmin Le Grand const_cast< SvgNode* >(this)->maCssStyleVector.push_back(pNew); 870906e779SArmin Le Grand } 880906e779SArmin Le Grand } 890906e779SArmin Le Grand } 900906e779SArmin Le Grand 910906e779SArmin Le Grand if(maCssStyleVector.empty() && getId()) 920906e779SArmin Le Grand { 930906e779SArmin Le Grand // if none found, search for CSS style equal to Id 940906e779SArmin Le Grand const SvgStyleAttributes* pNew = rDocument.findSvgStyleAttributesById(*getId()); 950906e779SArmin Le Grand 9650b37974SArmin Le Grand if(pNew) 9750b37974SArmin Le Grand { 9850b37974SArmin Le Grand const_cast< SvgNode* >(this)->maCssStyleVector.push_back(pNew); 9950b37974SArmin Le Grand } 10050b37974SArmin Le Grand } 10150b37974SArmin Le Grand 1020906e779SArmin Le Grand if(maCssStyleVector.empty() && rClassStr.getLength()) 10350b37974SArmin Le Grand { 1040906e779SArmin Le Grand // if none found, search for CSS style equal to class type 1050906e779SArmin Le Grand const SvgStyleAttributes* pNew = rDocument.findSvgStyleAttributesById(rClassStr); 10650b37974SArmin Le Grand 1070906e779SArmin Le Grand if(pNew) 1080906e779SArmin Le Grand { 1090906e779SArmin Le Grand const_cast< SvgNode* >(this)->maCssStyleVector.push_back(pNew); 1100906e779SArmin Le Grand } 11150b37974SArmin Le Grand } 11250b37974SArmin Le Grand } 11350b37974SArmin Le Grand } 11450b37974SArmin Le Grand 11550b37974SArmin Le Grand if(maCssStyleVector.empty()) 11650b37974SArmin Le Grand { 11750b37974SArmin Le Grand return &rOriginal; 11850b37974SArmin Le Grand } 11950b37974SArmin Le Grand else 12050b37974SArmin Le Grand { 12150b37974SArmin Le Grand // set CssStyleParent at maCssStyleVector members to hang them in front of 1220906e779SArmin Le Grand // the existing style. Build a style chain, reset parent of original for security. 1230906e779SArmin Le Grand // Repeated style requests should only be issued from sub-Text nodes and I'm not 1240906e779SArmin Le Grand // sure if in-between text nodes may build other chains (should not happen). But 1250906e779SArmin Le Grand // it's only a re-chaining with pointers (cheap), so allow to do it every time. 12650b37974SArmin Le Grand SvgStyleAttributes* pCurrent = const_cast< SvgStyleAttributes* >(&rOriginal); 1270906e779SArmin Le Grand pCurrent->setCssStyleParent(0); 12850b37974SArmin Le Grand 12950b37974SArmin Le Grand for(sal_uInt32 a(0); a < maCssStyleVector.size(); a++) 13050b37974SArmin Le Grand { 13150b37974SArmin Le Grand SvgStyleAttributes* pCandidate = const_cast< SvgStyleAttributes* >(maCssStyleVector[maCssStyleVector.size() - a - 1]); 13250b37974SArmin Le Grand 13350b37974SArmin Le Grand pCandidate->setCssStyleParent(pCurrent); 13450b37974SArmin Le Grand pCurrent = pCandidate; 13550b37974SArmin Le Grand } 13650b37974SArmin Le Grand 13750b37974SArmin Le Grand return pCurrent; 13850b37974SArmin Le Grand } 13950b37974SArmin Le Grand } 14050b37974SArmin Le Grand 141ddde725dSArmin Le Grand SvgNode::SvgNode( 142ddde725dSArmin Le Grand SVGToken aType, 143ddde725dSArmin Le Grand SvgDocument& rDocument, 144ddde725dSArmin Le Grand SvgNode* pParent) 145ddde725dSArmin Le Grand : maType(aType), 146ddde725dSArmin Le Grand mrDocument(rDocument), 147ddde725dSArmin Le Grand mpParent(pParent), 148ddde725dSArmin Le Grand mpAlternativeParent(0), 149ddde725dSArmin Le Grand maChildren(), 150ddde725dSArmin Le Grand mpId(0), 151ddde725dSArmin Le Grand mpClass(0), 15250b37974SArmin Le Grand maXmlSpace(XmlSpace_notset), 153*a275c134SArmin Le Grand maDisplay(Display_inline), 15450b37974SArmin Le Grand maCssStyleVector() 155ddde725dSArmin Le Grand { 156ddde725dSArmin Le Grand OSL_ENSURE(SVGTokenUnknown != maType, "SvgNode with unknown type created (!)"); 157ddde725dSArmin Le Grand 158ddde725dSArmin Le Grand if(pParent) 159ddde725dSArmin Le Grand { 160ddde725dSArmin Le Grand pParent->maChildren.push_back(this); 161ddde725dSArmin Le Grand } 162ddde725dSArmin Le Grand else 163ddde725dSArmin Le Grand { 164ddde725dSArmin Le Grand #ifdef DBG_UTIL 165ddde725dSArmin Le Grand if(SVGTokenSvg != getType()) 166ddde725dSArmin Le Grand { 167ddde725dSArmin Le Grand OSL_ENSURE(false, "No parent for this node (!)"); 168ddde725dSArmin Le Grand } 169ddde725dSArmin Le Grand #endif 170ddde725dSArmin Le Grand } 171ddde725dSArmin Le Grand } 172ddde725dSArmin Le Grand 173ddde725dSArmin Le Grand SvgNode::~SvgNode() 174ddde725dSArmin Le Grand { 175ddde725dSArmin Le Grand while(maChildren.size()) 176ddde725dSArmin Le Grand { 177ddde725dSArmin Le Grand delete maChildren[maChildren.size() - 1]; 178ddde725dSArmin Le Grand maChildren.pop_back(); 179ddde725dSArmin Le Grand } 180ddde725dSArmin Le Grand 181ddde725dSArmin Le Grand if(mpId) delete mpId; 182ddde725dSArmin Le Grand if(mpClass) delete mpClass; 183ddde725dSArmin Le Grand } 184ddde725dSArmin Le Grand 185ddde725dSArmin Le Grand void SvgNode::parseAttributes(const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttribs) 186ddde725dSArmin Le Grand { 187ddde725dSArmin Le Grand const sal_uInt32 nAttributes(xAttribs->getLength()); 188ddde725dSArmin Le Grand 189ddde725dSArmin Le Grand for(sal_uInt32 a(0); a < nAttributes; a++) 190ddde725dSArmin Le Grand { 191ddde725dSArmin Le Grand const ::rtl::OUString aTokenName(xAttribs->getNameByIndex(a)); 192ddde725dSArmin Le Grand 193ddde725dSArmin Le Grand parseAttribute(aTokenName, StrToSVGToken(aTokenName), xAttribs->getValueByIndex(a)); 194ddde725dSArmin Le Grand } 195ddde725dSArmin Le Grand } 196ddde725dSArmin Le Grand 197e2bf1e9dSArmin Le Grand void SvgNode::parseAttribute(const rtl::OUString& /*rTokenName*/, SVGToken aSVGToken, const rtl::OUString& aContent) 198ddde725dSArmin Le Grand { 199ddde725dSArmin Le Grand switch(aSVGToken) 200ddde725dSArmin Le Grand { 201ddde725dSArmin Le Grand case SVGTokenId: 202ddde725dSArmin Le Grand { 203ddde725dSArmin Le Grand if(aContent.getLength()) 204ddde725dSArmin Le Grand { 205ddde725dSArmin Le Grand setId(&aContent); 206ddde725dSArmin Le Grand } 207ddde725dSArmin Le Grand break; 208ddde725dSArmin Le Grand } 209ddde725dSArmin Le Grand case SVGTokenClass: 210ddde725dSArmin Le Grand { 211ddde725dSArmin Le Grand if(aContent.getLength()) 212ddde725dSArmin Le Grand { 213ddde725dSArmin Le Grand setClass(&aContent); 214ddde725dSArmin Le Grand } 215ddde725dSArmin Le Grand break; 216ddde725dSArmin Le Grand } 217ddde725dSArmin Le Grand case SVGTokenXmlSpace: 218ddde725dSArmin Le Grand { 219ddde725dSArmin Le Grand if(aContent.getLength()) 220ddde725dSArmin Le Grand { 221ddde725dSArmin Le Grand static rtl::OUString aStrDefault(rtl::OUString::createFromAscii("default")); 222ddde725dSArmin Le Grand static rtl::OUString aStrPreserve(rtl::OUString::createFromAscii("preserve")); 223ddde725dSArmin Le Grand 224ddde725dSArmin Le Grand if(aContent.match(aStrDefault)) 225ddde725dSArmin Le Grand { 226ddde725dSArmin Le Grand setXmlSpace(XmlSpace_default); 227ddde725dSArmin Le Grand } 228ddde725dSArmin Le Grand else if(aContent.match(aStrPreserve)) 229ddde725dSArmin Le Grand { 230ddde725dSArmin Le Grand setXmlSpace(XmlSpace_preserve); 231ddde725dSArmin Le Grand } 232ddde725dSArmin Le Grand } 233ddde725dSArmin Le Grand break; 234ddde725dSArmin Le Grand } 235*a275c134SArmin Le Grand case SVGTokenDisplay: 236*a275c134SArmin Le Grand { 237*a275c134SArmin Le Grand if(aContent.getLength()) 238*a275c134SArmin Le Grand { 239*a275c134SArmin Le Grand static rtl::OUString aStrInline(rtl::OUString::createFromAscii("inline")); 240*a275c134SArmin Le Grand static rtl::OUString aStrBlock(rtl::OUString::createFromAscii("block")); 241*a275c134SArmin Le Grand static rtl::OUString aStrList_item(rtl::OUString::createFromAscii("list-item")); 242*a275c134SArmin Le Grand static rtl::OUString aStrRun_in(rtl::OUString::createFromAscii("run-in")); 243*a275c134SArmin Le Grand static rtl::OUString aStrCompact(rtl::OUString::createFromAscii("compact")); 244*a275c134SArmin Le Grand static rtl::OUString aStrMarker(rtl::OUString::createFromAscii("marker")); 245*a275c134SArmin Le Grand static rtl::OUString aStrTable(rtl::OUString::createFromAscii("table")); 246*a275c134SArmin Le Grand static rtl::OUString aStrInline_table(rtl::OUString::createFromAscii("inline-table")); 247*a275c134SArmin Le Grand static rtl::OUString aStrTable_row_group(rtl::OUString::createFromAscii("table-row-group")); 248*a275c134SArmin Le Grand static rtl::OUString aStrTable_header_group(rtl::OUString::createFromAscii("table-header-group")); 249*a275c134SArmin Le Grand static rtl::OUString aStrTable_footer_group(rtl::OUString::createFromAscii("table-footer-group")); 250*a275c134SArmin Le Grand static rtl::OUString aStrTable_row(rtl::OUString::createFromAscii("table-row")); 251*a275c134SArmin Le Grand static rtl::OUString aStrTable_column_group(rtl::OUString::createFromAscii("table-column-group")); 252*a275c134SArmin Le Grand static rtl::OUString aStrTable_column(rtl::OUString::createFromAscii("table-column")); 253*a275c134SArmin Le Grand static rtl::OUString aStrTable_cell(rtl::OUString::createFromAscii("table-cell")); 254*a275c134SArmin Le Grand static rtl::OUString aStrTable_caption(rtl::OUString::createFromAscii("table-caption")); 255*a275c134SArmin Le Grand static rtl::OUString aStrNone(rtl::OUString::createFromAscii("none")); 256*a275c134SArmin Le Grand static rtl::OUString aStrInherit(rtl::OUString::createFromAscii("inherit")); 257*a275c134SArmin Le Grand 258*a275c134SArmin Le Grand if(aContent.match(aStrInline)) 259*a275c134SArmin Le Grand { 260*a275c134SArmin Le Grand setDisplay(Display_inline); 261*a275c134SArmin Le Grand } 262*a275c134SArmin Le Grand else if(aContent.match(aStrNone)) 263*a275c134SArmin Le Grand { 264*a275c134SArmin Le Grand setDisplay(Display_none); 265*a275c134SArmin Le Grand } 266*a275c134SArmin Le Grand else if(aContent.match(aStrInherit)) 267*a275c134SArmin Le Grand { 268*a275c134SArmin Le Grand setDisplay(Display_inherit); 269*a275c134SArmin Le Grand } 270*a275c134SArmin Le Grand else if(aContent.match(aStrBlock)) 271*a275c134SArmin Le Grand { 272*a275c134SArmin Le Grand setDisplay(Display_block); 273*a275c134SArmin Le Grand } 274*a275c134SArmin Le Grand else if(aContent.match(aStrList_item)) 275*a275c134SArmin Le Grand { 276*a275c134SArmin Le Grand setDisplay(Display_list_item); 277*a275c134SArmin Le Grand } 278*a275c134SArmin Le Grand else if(aContent.match(aStrRun_in)) 279*a275c134SArmin Le Grand { 280*a275c134SArmin Le Grand setDisplay(Display_run_in); 281*a275c134SArmin Le Grand } 282*a275c134SArmin Le Grand else if(aContent.match(aStrCompact)) 283*a275c134SArmin Le Grand { 284*a275c134SArmin Le Grand setDisplay(Display_compact); 285*a275c134SArmin Le Grand } 286*a275c134SArmin Le Grand else if(aContent.match(aStrMarker)) 287*a275c134SArmin Le Grand { 288*a275c134SArmin Le Grand setDisplay(Display_marker); 289*a275c134SArmin Le Grand } 290*a275c134SArmin Le Grand else if(aContent.match(aStrTable)) 291*a275c134SArmin Le Grand { 292*a275c134SArmin Le Grand setDisplay(Display_table); 293*a275c134SArmin Le Grand } 294*a275c134SArmin Le Grand else if(aContent.match(aStrInline_table)) 295*a275c134SArmin Le Grand { 296*a275c134SArmin Le Grand setDisplay(Display_inline_table); 297*a275c134SArmin Le Grand } 298*a275c134SArmin Le Grand else if(aContent.match(aStrTable_row_group)) 299*a275c134SArmin Le Grand { 300*a275c134SArmin Le Grand setDisplay(Display_table_row_group); 301*a275c134SArmin Le Grand } 302*a275c134SArmin Le Grand else if(aContent.match(aStrTable_header_group)) 303*a275c134SArmin Le Grand { 304*a275c134SArmin Le Grand setDisplay(Display_table_header_group); 305*a275c134SArmin Le Grand } 306*a275c134SArmin Le Grand else if(aContent.match(aStrTable_footer_group)) 307*a275c134SArmin Le Grand { 308*a275c134SArmin Le Grand setDisplay(Display_table_footer_group); 309*a275c134SArmin Le Grand } 310*a275c134SArmin Le Grand else if(aContent.match(aStrTable_row)) 311*a275c134SArmin Le Grand { 312*a275c134SArmin Le Grand setDisplay(Display_table_row); 313*a275c134SArmin Le Grand } 314*a275c134SArmin Le Grand else if(aContent.match(aStrTable_column_group)) 315*a275c134SArmin Le Grand { 316*a275c134SArmin Le Grand setDisplay(Display_table_column_group); 317*a275c134SArmin Le Grand } 318*a275c134SArmin Le Grand else if(aContent.match(aStrTable_column)) 319*a275c134SArmin Le Grand { 320*a275c134SArmin Le Grand setDisplay(Display_table_column); 321*a275c134SArmin Le Grand } 322*a275c134SArmin Le Grand else if(aContent.match(aStrTable_cell)) 323*a275c134SArmin Le Grand { 324*a275c134SArmin Le Grand setDisplay(Display_table_cell); 325*a275c134SArmin Le Grand } 326*a275c134SArmin Le Grand else if(aContent.match(aStrTable_caption)) 327*a275c134SArmin Le Grand { 328*a275c134SArmin Le Grand setDisplay(Display_table_caption); 329*a275c134SArmin Le Grand } 330*a275c134SArmin Le Grand } 331*a275c134SArmin Le Grand break; 332*a275c134SArmin Le Grand } 333e2bf1e9dSArmin Le Grand default: 334e2bf1e9dSArmin Le Grand { 335e2bf1e9dSArmin Le Grand break; 336e2bf1e9dSArmin Le Grand } 337ddde725dSArmin Le Grand } 338ddde725dSArmin Le Grand } 339ddde725dSArmin Le Grand 340ddde725dSArmin Le Grand void SvgNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DSequence& rTarget, bool bReferenced) const 341ddde725dSArmin Le Grand { 342*a275c134SArmin Le Grand if(Display_none == getDisplay()) 343*a275c134SArmin Le Grand { 344*a275c134SArmin Le Grand return; 345*a275c134SArmin Le Grand } 346*a275c134SArmin Le Grand 347ddde725dSArmin Le Grand if(!bReferenced) 348ddde725dSArmin Le Grand { 349ddde725dSArmin Le Grand if(SVGTokenDefs == getType() || 350ddde725dSArmin Le Grand SVGTokenSymbol == getType() || 351ddde725dSArmin Le Grand SVGTokenClipPathNode == getType() || 352ddde725dSArmin Le Grand SVGTokenMask == getType() || 353ddde725dSArmin Le Grand SVGTokenMarker == getType() || 354ddde725dSArmin Le Grand SVGTokenPattern == getType()) 355ddde725dSArmin Le Grand { 356ddde725dSArmin Le Grand // do not decompose defs or symbol nodes (these hold only style-like 357ddde725dSArmin Le Grand // objects which may be used by referencing them) except when doing 358ddde725dSArmin Le Grand // so controlled referenced 359ddde725dSArmin Le Grand 360ddde725dSArmin Le Grand // also do not decompose ClipPaths and Masks. These should be embedded 361ddde725dSArmin Le Grand // in a defs node (which gets not decomposed by itself), but you never 362ddde725dSArmin Le Grand // know 363ddde725dSArmin Le Grand 364ddde725dSArmin Le Grand // also not directly used are Markers and Patterns, only indirecty used 365ddde725dSArmin Le Grand // by reference 366*a275c134SArmin Le Grand 367*a275c134SArmin Le Grand // #121656# also do not decompose nodes which have display="none" set 368*a275c134SArmin Le Grand // as property 369ddde725dSArmin Le Grand return; 370ddde725dSArmin Le Grand } 371ddde725dSArmin Le Grand } 372ddde725dSArmin Le Grand 373ddde725dSArmin Le Grand const SvgNodeVector& rChildren = getChildren(); 374ddde725dSArmin Le Grand 375ddde725dSArmin Le Grand if(!rChildren.empty()) 376ddde725dSArmin Le Grand { 377ddde725dSArmin Le Grand const sal_uInt32 nCount(rChildren.size()); 378ddde725dSArmin Le Grand 379ddde725dSArmin Le Grand for(sal_uInt32 a(0); a < nCount; a++) 380ddde725dSArmin Le Grand { 381ddde725dSArmin Le Grand SvgNode* pCandidate = rChildren[a]; 382ddde725dSArmin Le Grand 383*a275c134SArmin Le Grand if(pCandidate && Display_none != pCandidate->getDisplay()) 384ddde725dSArmin Le Grand { 385ddde725dSArmin Le Grand drawinglayer::primitive2d::Primitive2DSequence aNewTarget; 386ddde725dSArmin Le Grand 387ddde725dSArmin Le Grand pCandidate->decomposeSvgNode(aNewTarget, bReferenced); 388ddde725dSArmin Le Grand 389ddde725dSArmin Le Grand if(aNewTarget.hasElements()) 390ddde725dSArmin Le Grand { 391ddde725dSArmin Le Grand drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(rTarget, aNewTarget); 392ddde725dSArmin Le Grand } 393ddde725dSArmin Le Grand } 394ddde725dSArmin Le Grand else 395ddde725dSArmin Le Grand { 396ddde725dSArmin Le Grand OSL_ENSURE(false, "Null-Pointer in child node list (!)"); 397ddde725dSArmin Le Grand } 398ddde725dSArmin Le Grand } 399025b0597SArmin Le Grand 400025b0597SArmin Le Grand if(rTarget.hasElements()) 401025b0597SArmin Le Grand { 402025b0597SArmin Le Grand const SvgStyleAttributes* pStyles = getSvgStyleAttributes(); 403025b0597SArmin Le Grand 404025b0597SArmin Le Grand if(pStyles) 405025b0597SArmin Le Grand { 406025b0597SArmin Le Grand // check if we have Title or Desc 407025b0597SArmin Le Grand const rtl::OUString& rTitle = pStyles->getTitle(); 408025b0597SArmin Le Grand const rtl::OUString& rDesc = pStyles->getDesc(); 409025b0597SArmin Le Grand 410025b0597SArmin Le Grand if(rTitle.getLength() || rDesc.getLength()) 411025b0597SArmin Le Grand { 412025b0597SArmin Le Grand // default object name is empty 413025b0597SArmin Le Grand rtl::OUString aObjectName; 414025b0597SArmin Le Grand 415025b0597SArmin Le Grand // use path as object name when outmost element 416025b0597SArmin Le Grand if(SVGTokenSvg == getType()) 417025b0597SArmin Le Grand { 418025b0597SArmin Le Grand aObjectName = getDocument().getAbsolutePath(); 419172c67b2SArmin Le Grand 420172c67b2SArmin Le Grand if(aObjectName.getLength()) 421172c67b2SArmin Le Grand { 422172c67b2SArmin Le Grand INetURLObject aURL(aObjectName); 423172c67b2SArmin Le Grand 424172c67b2SArmin Le Grand aObjectName = aURL.getName( 425172c67b2SArmin Le Grand INetURLObject::LAST_SEGMENT, 426172c67b2SArmin Le Grand true, 427172c67b2SArmin Le Grand INetURLObject::DECODE_WITH_CHARSET); 428172c67b2SArmin Le Grand } 429025b0597SArmin Le Grand } 430025b0597SArmin Le Grand 431025b0597SArmin Le Grand // pack in ObjectInfoPrimitive2D group 432025b0597SArmin Le Grand const drawinglayer::primitive2d::Primitive2DReference xRef( 433025b0597SArmin Le Grand new drawinglayer::primitive2d::ObjectInfoPrimitive2D( 434025b0597SArmin Le Grand rTarget, 435025b0597SArmin Le Grand aObjectName, 436025b0597SArmin Le Grand rTitle, 437025b0597SArmin Le Grand rDesc)); 438025b0597SArmin Le Grand 439025b0597SArmin Le Grand rTarget = drawinglayer::primitive2d::Primitive2DSequence(&xRef, 1); 440025b0597SArmin Le Grand } 441025b0597SArmin Le Grand } 442025b0597SArmin Le Grand } 443ddde725dSArmin Le Grand } 444ddde725dSArmin Le Grand } 445ddde725dSArmin Le Grand 446ddde725dSArmin Le Grand const basegfx::B2DRange* SvgNode::getCurrentViewPort() const 447ddde725dSArmin Le Grand { 448ddde725dSArmin Le Grand if(getParent()) 449ddde725dSArmin Le Grand { 450ddde725dSArmin Le Grand return getParent()->getCurrentViewPort(); 451ddde725dSArmin Le Grand } 452ddde725dSArmin Le Grand else 453ddde725dSArmin Le Grand { 454ddde725dSArmin Le Grand return 0; 455ddde725dSArmin Le Grand } 456ddde725dSArmin Le Grand } 457ddde725dSArmin Le Grand 458ddde725dSArmin Le Grand double SvgNode::getCurrentFontSize() const 459ddde725dSArmin Le Grand { 460ddde725dSArmin Le Grand if(getSvgStyleAttributes()) 461ddde725dSArmin Le Grand { 462ddde725dSArmin Le Grand return getSvgStyleAttributes()->getFontSize().solve(*this, xcoordinate); 463ddde725dSArmin Le Grand } 464ddde725dSArmin Le Grand else if(getParent()) 465ddde725dSArmin Le Grand { 466ddde725dSArmin Le Grand return getParent()->getCurrentFontSize(); 467ddde725dSArmin Le Grand } 468ddde725dSArmin Le Grand else 469ddde725dSArmin Le Grand { 470ddde725dSArmin Le Grand return 0.0; 471ddde725dSArmin Le Grand } 472ddde725dSArmin Le Grand } 473ddde725dSArmin Le Grand 474ddde725dSArmin Le Grand double SvgNode::getCurrentXHeight() const 475ddde725dSArmin Le Grand { 476ddde725dSArmin Le Grand if(getSvgStyleAttributes()) 477ddde725dSArmin Le Grand { 478ddde725dSArmin Le Grand // for XHeight, use FontSize currently 479ddde725dSArmin Le Grand return getSvgStyleAttributes()->getFontSize().solve(*this, ycoordinate); 480ddde725dSArmin Le Grand } 481ddde725dSArmin Le Grand else if(getParent()) 482ddde725dSArmin Le Grand { 483ddde725dSArmin Le Grand return getParent()->getCurrentXHeight(); 484ddde725dSArmin Le Grand } 485ddde725dSArmin Le Grand else 486ddde725dSArmin Le Grand { 487ddde725dSArmin Le Grand return 0.0; 488ddde725dSArmin Le Grand } 489ddde725dSArmin Le Grand } 490ddde725dSArmin Le Grand 491ddde725dSArmin Le Grand void SvgNode::setId(const rtl::OUString* pfId) 492ddde725dSArmin Le Grand { 493ddde725dSArmin Le Grand if(mpId) 494ddde725dSArmin Le Grand { 495ddde725dSArmin Le Grand mrDocument.removeSvgNodeFromMapper(*mpId); 496ddde725dSArmin Le Grand delete mpId; 497ddde725dSArmin Le Grand mpId = 0; 498ddde725dSArmin Le Grand } 499ddde725dSArmin Le Grand 500ddde725dSArmin Le Grand if(pfId) 501ddde725dSArmin Le Grand { 502ddde725dSArmin Le Grand mpId = new rtl::OUString(*pfId); 503ddde725dSArmin Le Grand mrDocument.addSvgNodeToMapper(*mpId, *this); 504ddde725dSArmin Le Grand } 505ddde725dSArmin Le Grand } 506ddde725dSArmin Le Grand 507ddde725dSArmin Le Grand void SvgNode::setClass(const rtl::OUString* pfClass) 508ddde725dSArmin Le Grand { 509ddde725dSArmin Le Grand if(mpClass) 510ddde725dSArmin Le Grand { 511ddde725dSArmin Le Grand mrDocument.removeSvgNodeFromMapper(*mpClass); 512ddde725dSArmin Le Grand delete mpClass; 513ddde725dSArmin Le Grand mpClass = 0; 514ddde725dSArmin Le Grand } 515ddde725dSArmin Le Grand 516ddde725dSArmin Le Grand if(pfClass) 517ddde725dSArmin Le Grand { 518ddde725dSArmin Le Grand mpClass = new rtl::OUString(*pfClass); 519ddde725dSArmin Le Grand mrDocument.addSvgNodeToMapper(*mpClass, *this); 520ddde725dSArmin Le Grand } 521ddde725dSArmin Le Grand } 522ddde725dSArmin Le Grand 523ddde725dSArmin Le Grand XmlSpace SvgNode::getXmlSpace() const 524ddde725dSArmin Le Grand { 525ddde725dSArmin Le Grand if(maXmlSpace != XmlSpace_notset) 526ddde725dSArmin Le Grand { 527ddde725dSArmin Le Grand return maXmlSpace; 528ddde725dSArmin Le Grand } 529ddde725dSArmin Le Grand 530ddde725dSArmin Le Grand if(getParent()) 531ddde725dSArmin Le Grand { 532ddde725dSArmin Le Grand return getParent()->getXmlSpace(); 533ddde725dSArmin Le Grand } 534ddde725dSArmin Le Grand 535ddde725dSArmin Le Grand // default is XmlSpace_default 536ddde725dSArmin Le Grand return XmlSpace_default; 537ddde725dSArmin Le Grand } 538ddde725dSArmin Le Grand 539ddde725dSArmin Le Grand } // end of namespace svgreader 540ddde725dSArmin Le Grand } // end of namespace svgio 541ddde725dSArmin Le Grand 542ddde725dSArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 543ddde725dSArmin Le Grand // eof 544