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), 153a275c134SArmin 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 197*01e92ad6SArmin Le Grand Display getDisplayFromContent(const rtl::OUString& aContent) 198*01e92ad6SArmin Le Grand { 199*01e92ad6SArmin Le Grand if(aContent.getLength()) 200*01e92ad6SArmin Le Grand { 201*01e92ad6SArmin Le Grand static rtl::OUString aStrInline(rtl::OUString::createFromAscii("inline")); 202*01e92ad6SArmin Le Grand static rtl::OUString aStrBlock(rtl::OUString::createFromAscii("block")); 203*01e92ad6SArmin Le Grand static rtl::OUString aStrList_item(rtl::OUString::createFromAscii("list-item")); 204*01e92ad6SArmin Le Grand static rtl::OUString aStrRun_in(rtl::OUString::createFromAscii("run-in")); 205*01e92ad6SArmin Le Grand static rtl::OUString aStrCompact(rtl::OUString::createFromAscii("compact")); 206*01e92ad6SArmin Le Grand static rtl::OUString aStrMarker(rtl::OUString::createFromAscii("marker")); 207*01e92ad6SArmin Le Grand static rtl::OUString aStrTable(rtl::OUString::createFromAscii("table")); 208*01e92ad6SArmin Le Grand static rtl::OUString aStrInline_table(rtl::OUString::createFromAscii("inline-table")); 209*01e92ad6SArmin Le Grand static rtl::OUString aStrTable_row_group(rtl::OUString::createFromAscii("table-row-group")); 210*01e92ad6SArmin Le Grand static rtl::OUString aStrTable_header_group(rtl::OUString::createFromAscii("table-header-group")); 211*01e92ad6SArmin Le Grand static rtl::OUString aStrTable_footer_group(rtl::OUString::createFromAscii("table-footer-group")); 212*01e92ad6SArmin Le Grand static rtl::OUString aStrTable_row(rtl::OUString::createFromAscii("table-row")); 213*01e92ad6SArmin Le Grand static rtl::OUString aStrTable_column_group(rtl::OUString::createFromAscii("table-column-group")); 214*01e92ad6SArmin Le Grand static rtl::OUString aStrTable_column(rtl::OUString::createFromAscii("table-column")); 215*01e92ad6SArmin Le Grand static rtl::OUString aStrTable_cell(rtl::OUString::createFromAscii("table-cell")); 216*01e92ad6SArmin Le Grand static rtl::OUString aStrTable_caption(rtl::OUString::createFromAscii("table-caption")); 217*01e92ad6SArmin Le Grand static rtl::OUString aStrNone(rtl::OUString::createFromAscii("none")); 218*01e92ad6SArmin Le Grand static rtl::OUString aStrInherit(rtl::OUString::createFromAscii("inherit")); 219*01e92ad6SArmin Le Grand 220*01e92ad6SArmin Le Grand if(aContent.match(aStrInline)) 221*01e92ad6SArmin Le Grand { 222*01e92ad6SArmin Le Grand return Display_inline; 223*01e92ad6SArmin Le Grand } 224*01e92ad6SArmin Le Grand else if(aContent.match(aStrNone)) 225*01e92ad6SArmin Le Grand { 226*01e92ad6SArmin Le Grand return Display_none; 227*01e92ad6SArmin Le Grand } 228*01e92ad6SArmin Le Grand else if(aContent.match(aStrInherit)) 229*01e92ad6SArmin Le Grand { 230*01e92ad6SArmin Le Grand return Display_inherit; 231*01e92ad6SArmin Le Grand } 232*01e92ad6SArmin Le Grand else if(aContent.match(aStrBlock)) 233*01e92ad6SArmin Le Grand { 234*01e92ad6SArmin Le Grand return Display_block; 235*01e92ad6SArmin Le Grand } 236*01e92ad6SArmin Le Grand else if(aContent.match(aStrList_item)) 237*01e92ad6SArmin Le Grand { 238*01e92ad6SArmin Le Grand return Display_list_item; 239*01e92ad6SArmin Le Grand } 240*01e92ad6SArmin Le Grand else if(aContent.match(aStrRun_in)) 241*01e92ad6SArmin Le Grand { 242*01e92ad6SArmin Le Grand return Display_run_in; 243*01e92ad6SArmin Le Grand } 244*01e92ad6SArmin Le Grand else if(aContent.match(aStrCompact)) 245*01e92ad6SArmin Le Grand { 246*01e92ad6SArmin Le Grand return Display_compact; 247*01e92ad6SArmin Le Grand } 248*01e92ad6SArmin Le Grand else if(aContent.match(aStrMarker)) 249*01e92ad6SArmin Le Grand { 250*01e92ad6SArmin Le Grand return Display_marker; 251*01e92ad6SArmin Le Grand } 252*01e92ad6SArmin Le Grand else if(aContent.match(aStrTable)) 253*01e92ad6SArmin Le Grand { 254*01e92ad6SArmin Le Grand return Display_table; 255*01e92ad6SArmin Le Grand } 256*01e92ad6SArmin Le Grand else if(aContent.match(aStrInline_table)) 257*01e92ad6SArmin Le Grand { 258*01e92ad6SArmin Le Grand return Display_inline_table; 259*01e92ad6SArmin Le Grand } 260*01e92ad6SArmin Le Grand else if(aContent.match(aStrTable_row_group)) 261*01e92ad6SArmin Le Grand { 262*01e92ad6SArmin Le Grand return Display_table_row_group; 263*01e92ad6SArmin Le Grand } 264*01e92ad6SArmin Le Grand else if(aContent.match(aStrTable_header_group)) 265*01e92ad6SArmin Le Grand { 266*01e92ad6SArmin Le Grand return Display_table_header_group; 267*01e92ad6SArmin Le Grand } 268*01e92ad6SArmin Le Grand else if(aContent.match(aStrTable_footer_group)) 269*01e92ad6SArmin Le Grand { 270*01e92ad6SArmin Le Grand return Display_table_footer_group; 271*01e92ad6SArmin Le Grand } 272*01e92ad6SArmin Le Grand else if(aContent.match(aStrTable_row)) 273*01e92ad6SArmin Le Grand { 274*01e92ad6SArmin Le Grand return Display_table_row; 275*01e92ad6SArmin Le Grand } 276*01e92ad6SArmin Le Grand else if(aContent.match(aStrTable_column_group)) 277*01e92ad6SArmin Le Grand { 278*01e92ad6SArmin Le Grand return Display_table_column_group; 279*01e92ad6SArmin Le Grand } 280*01e92ad6SArmin Le Grand else if(aContent.match(aStrTable_column)) 281*01e92ad6SArmin Le Grand { 282*01e92ad6SArmin Le Grand return Display_table_column; 283*01e92ad6SArmin Le Grand } 284*01e92ad6SArmin Le Grand else if(aContent.match(aStrTable_cell)) 285*01e92ad6SArmin Le Grand { 286*01e92ad6SArmin Le Grand return Display_table_cell; 287*01e92ad6SArmin Le Grand } 288*01e92ad6SArmin Le Grand else if(aContent.match(aStrTable_caption)) 289*01e92ad6SArmin Le Grand { 290*01e92ad6SArmin Le Grand return Display_table_caption; 291*01e92ad6SArmin Le Grand } 292*01e92ad6SArmin Le Grand } 293*01e92ad6SArmin Le Grand 294*01e92ad6SArmin Le Grand // return the default 295*01e92ad6SArmin Le Grand return Display_inline; 296*01e92ad6SArmin Le Grand } 297*01e92ad6SArmin Le Grand 298e2bf1e9dSArmin Le Grand void SvgNode::parseAttribute(const rtl::OUString& /*rTokenName*/, SVGToken aSVGToken, const rtl::OUString& aContent) 299ddde725dSArmin Le Grand { 300ddde725dSArmin Le Grand switch(aSVGToken) 301ddde725dSArmin Le Grand { 302ddde725dSArmin Le Grand case SVGTokenId: 303ddde725dSArmin Le Grand { 304ddde725dSArmin Le Grand if(aContent.getLength()) 305ddde725dSArmin Le Grand { 306ddde725dSArmin Le Grand setId(&aContent); 307ddde725dSArmin Le Grand } 308ddde725dSArmin Le Grand break; 309ddde725dSArmin Le Grand } 310ddde725dSArmin Le Grand case SVGTokenClass: 311ddde725dSArmin Le Grand { 312ddde725dSArmin Le Grand if(aContent.getLength()) 313ddde725dSArmin Le Grand { 314ddde725dSArmin Le Grand setClass(&aContent); 315ddde725dSArmin Le Grand } 316ddde725dSArmin Le Grand break; 317ddde725dSArmin Le Grand } 318ddde725dSArmin Le Grand case SVGTokenXmlSpace: 319ddde725dSArmin Le Grand { 320ddde725dSArmin Le Grand if(aContent.getLength()) 321ddde725dSArmin Le Grand { 322ddde725dSArmin Le Grand static rtl::OUString aStrDefault(rtl::OUString::createFromAscii("default")); 323ddde725dSArmin Le Grand static rtl::OUString aStrPreserve(rtl::OUString::createFromAscii("preserve")); 324ddde725dSArmin Le Grand 325ddde725dSArmin Le Grand if(aContent.match(aStrDefault)) 326ddde725dSArmin Le Grand { 327ddde725dSArmin Le Grand setXmlSpace(XmlSpace_default); 328ddde725dSArmin Le Grand } 329ddde725dSArmin Le Grand else if(aContent.match(aStrPreserve)) 330ddde725dSArmin Le Grand { 331ddde725dSArmin Le Grand setXmlSpace(XmlSpace_preserve); 332ddde725dSArmin Le Grand } 333ddde725dSArmin Le Grand } 334ddde725dSArmin Le Grand break; 335ddde725dSArmin Le Grand } 336a275c134SArmin Le Grand case SVGTokenDisplay: 337a275c134SArmin Le Grand { 338a275c134SArmin Le Grand if(aContent.getLength()) 339a275c134SArmin Le Grand { 340*01e92ad6SArmin Le Grand setDisplay(getDisplayFromContent(aContent)); 341a275c134SArmin Le Grand } 342a275c134SArmin Le Grand break; 343a275c134SArmin Le Grand } 344e2bf1e9dSArmin Le Grand default: 345e2bf1e9dSArmin Le Grand { 346e2bf1e9dSArmin Le Grand break; 347e2bf1e9dSArmin Le Grand } 348ddde725dSArmin Le Grand } 349ddde725dSArmin Le Grand } 350ddde725dSArmin Le Grand 351ddde725dSArmin Le Grand void SvgNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DSequence& rTarget, bool bReferenced) const 352ddde725dSArmin Le Grand { 353a275c134SArmin Le Grand if(Display_none == getDisplay()) 354a275c134SArmin Le Grand { 355a275c134SArmin Le Grand return; 356a275c134SArmin Le Grand } 357a275c134SArmin Le Grand 358ddde725dSArmin Le Grand if(!bReferenced) 359ddde725dSArmin Le Grand { 360ddde725dSArmin Le Grand if(SVGTokenDefs == getType() || 361ddde725dSArmin Le Grand SVGTokenSymbol == getType() || 362ddde725dSArmin Le Grand SVGTokenClipPathNode == getType() || 363ddde725dSArmin Le Grand SVGTokenMask == getType() || 364ddde725dSArmin Le Grand SVGTokenMarker == getType() || 365ddde725dSArmin Le Grand SVGTokenPattern == getType()) 366ddde725dSArmin Le Grand { 367ddde725dSArmin Le Grand // do not decompose defs or symbol nodes (these hold only style-like 368ddde725dSArmin Le Grand // objects which may be used by referencing them) except when doing 369ddde725dSArmin Le Grand // so controlled referenced 370ddde725dSArmin Le Grand 371ddde725dSArmin Le Grand // also do not decompose ClipPaths and Masks. These should be embedded 372ddde725dSArmin Le Grand // in a defs node (which gets not decomposed by itself), but you never 373ddde725dSArmin Le Grand // know 374ddde725dSArmin Le Grand 375ddde725dSArmin Le Grand // also not directly used are Markers and Patterns, only indirecty used 376ddde725dSArmin Le Grand // by reference 377a275c134SArmin Le Grand 378a275c134SArmin Le Grand // #121656# also do not decompose nodes which have display="none" set 379a275c134SArmin Le Grand // as property 380ddde725dSArmin Le Grand return; 381ddde725dSArmin Le Grand } 382ddde725dSArmin Le Grand } 383ddde725dSArmin Le Grand 384ddde725dSArmin Le Grand const SvgNodeVector& rChildren = getChildren(); 385ddde725dSArmin Le Grand 386ddde725dSArmin Le Grand if(!rChildren.empty()) 387ddde725dSArmin Le Grand { 388ddde725dSArmin Le Grand const sal_uInt32 nCount(rChildren.size()); 389ddde725dSArmin Le Grand 390ddde725dSArmin Le Grand for(sal_uInt32 a(0); a < nCount; a++) 391ddde725dSArmin Le Grand { 392ddde725dSArmin Le Grand SvgNode* pCandidate = rChildren[a]; 393ddde725dSArmin Le Grand 394a275c134SArmin Le Grand if(pCandidate && Display_none != pCandidate->getDisplay()) 395ddde725dSArmin Le Grand { 396ddde725dSArmin Le Grand drawinglayer::primitive2d::Primitive2DSequence aNewTarget; 397ddde725dSArmin Le Grand 398ddde725dSArmin Le Grand pCandidate->decomposeSvgNode(aNewTarget, bReferenced); 399ddde725dSArmin Le Grand 400ddde725dSArmin Le Grand if(aNewTarget.hasElements()) 401ddde725dSArmin Le Grand { 402ddde725dSArmin Le Grand drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(rTarget, aNewTarget); 403ddde725dSArmin Le Grand } 404ddde725dSArmin Le Grand } 405ddde725dSArmin Le Grand else 406ddde725dSArmin Le Grand { 407ddde725dSArmin Le Grand OSL_ENSURE(false, "Null-Pointer in child node list (!)"); 408ddde725dSArmin Le Grand } 409ddde725dSArmin Le Grand } 410025b0597SArmin Le Grand 411025b0597SArmin Le Grand if(rTarget.hasElements()) 412025b0597SArmin Le Grand { 413025b0597SArmin Le Grand const SvgStyleAttributes* pStyles = getSvgStyleAttributes(); 414025b0597SArmin Le Grand 415025b0597SArmin Le Grand if(pStyles) 416025b0597SArmin Le Grand { 417025b0597SArmin Le Grand // check if we have Title or Desc 418025b0597SArmin Le Grand const rtl::OUString& rTitle = pStyles->getTitle(); 419025b0597SArmin Le Grand const rtl::OUString& rDesc = pStyles->getDesc(); 420025b0597SArmin Le Grand 421025b0597SArmin Le Grand if(rTitle.getLength() || rDesc.getLength()) 422025b0597SArmin Le Grand { 423025b0597SArmin Le Grand // default object name is empty 424025b0597SArmin Le Grand rtl::OUString aObjectName; 425025b0597SArmin Le Grand 426025b0597SArmin Le Grand // use path as object name when outmost element 427025b0597SArmin Le Grand if(SVGTokenSvg == getType()) 428025b0597SArmin Le Grand { 429025b0597SArmin Le Grand aObjectName = getDocument().getAbsolutePath(); 430172c67b2SArmin Le Grand 431172c67b2SArmin Le Grand if(aObjectName.getLength()) 432172c67b2SArmin Le Grand { 433172c67b2SArmin Le Grand INetURLObject aURL(aObjectName); 434172c67b2SArmin Le Grand 435172c67b2SArmin Le Grand aObjectName = aURL.getName( 436172c67b2SArmin Le Grand INetURLObject::LAST_SEGMENT, 437172c67b2SArmin Le Grand true, 438172c67b2SArmin Le Grand INetURLObject::DECODE_WITH_CHARSET); 439172c67b2SArmin Le Grand } 440025b0597SArmin Le Grand } 441025b0597SArmin Le Grand 442025b0597SArmin Le Grand // pack in ObjectInfoPrimitive2D group 443025b0597SArmin Le Grand const drawinglayer::primitive2d::Primitive2DReference xRef( 444025b0597SArmin Le Grand new drawinglayer::primitive2d::ObjectInfoPrimitive2D( 445025b0597SArmin Le Grand rTarget, 446025b0597SArmin Le Grand aObjectName, 447025b0597SArmin Le Grand rTitle, 448025b0597SArmin Le Grand rDesc)); 449025b0597SArmin Le Grand 450025b0597SArmin Le Grand rTarget = drawinglayer::primitive2d::Primitive2DSequence(&xRef, 1); 451025b0597SArmin Le Grand } 452025b0597SArmin Le Grand } 453025b0597SArmin Le Grand } 454ddde725dSArmin Le Grand } 455ddde725dSArmin Le Grand } 456ddde725dSArmin Le Grand 457ddde725dSArmin Le Grand const basegfx::B2DRange* SvgNode::getCurrentViewPort() const 458ddde725dSArmin Le Grand { 459ddde725dSArmin Le Grand if(getParent()) 460ddde725dSArmin Le Grand { 461ddde725dSArmin Le Grand return getParent()->getCurrentViewPort(); 462ddde725dSArmin Le Grand } 463ddde725dSArmin Le Grand else 464ddde725dSArmin Le Grand { 465ddde725dSArmin Le Grand return 0; 466ddde725dSArmin Le Grand } 467ddde725dSArmin Le Grand } 468ddde725dSArmin Le Grand 469ddde725dSArmin Le Grand double SvgNode::getCurrentFontSize() const 470ddde725dSArmin Le Grand { 471ddde725dSArmin Le Grand if(getSvgStyleAttributes()) 472ddde725dSArmin Le Grand { 473ddde725dSArmin Le Grand return getSvgStyleAttributes()->getFontSize().solve(*this, xcoordinate); 474ddde725dSArmin Le Grand } 475ddde725dSArmin Le Grand else if(getParent()) 476ddde725dSArmin Le Grand { 477ddde725dSArmin Le Grand return getParent()->getCurrentFontSize(); 478ddde725dSArmin Le Grand } 479ddde725dSArmin Le Grand else 480ddde725dSArmin Le Grand { 481ddde725dSArmin Le Grand return 0.0; 482ddde725dSArmin Le Grand } 483ddde725dSArmin Le Grand } 484ddde725dSArmin Le Grand 485ddde725dSArmin Le Grand double SvgNode::getCurrentXHeight() const 486ddde725dSArmin Le Grand { 487ddde725dSArmin Le Grand if(getSvgStyleAttributes()) 488ddde725dSArmin Le Grand { 489ddde725dSArmin Le Grand // for XHeight, use FontSize currently 490ddde725dSArmin Le Grand return getSvgStyleAttributes()->getFontSize().solve(*this, ycoordinate); 491ddde725dSArmin Le Grand } 492ddde725dSArmin Le Grand else if(getParent()) 493ddde725dSArmin Le Grand { 494ddde725dSArmin Le Grand return getParent()->getCurrentXHeight(); 495ddde725dSArmin Le Grand } 496ddde725dSArmin Le Grand else 497ddde725dSArmin Le Grand { 498ddde725dSArmin Le Grand return 0.0; 499ddde725dSArmin Le Grand } 500ddde725dSArmin Le Grand } 501ddde725dSArmin Le Grand 502ddde725dSArmin Le Grand void SvgNode::setId(const rtl::OUString* pfId) 503ddde725dSArmin Le Grand { 504ddde725dSArmin Le Grand if(mpId) 505ddde725dSArmin Le Grand { 506ddde725dSArmin Le Grand mrDocument.removeSvgNodeFromMapper(*mpId); 507ddde725dSArmin Le Grand delete mpId; 508ddde725dSArmin Le Grand mpId = 0; 509ddde725dSArmin Le Grand } 510ddde725dSArmin Le Grand 511ddde725dSArmin Le Grand if(pfId) 512ddde725dSArmin Le Grand { 513ddde725dSArmin Le Grand mpId = new rtl::OUString(*pfId); 514ddde725dSArmin Le Grand mrDocument.addSvgNodeToMapper(*mpId, *this); 515ddde725dSArmin Le Grand } 516ddde725dSArmin Le Grand } 517ddde725dSArmin Le Grand 518ddde725dSArmin Le Grand void SvgNode::setClass(const rtl::OUString* pfClass) 519ddde725dSArmin Le Grand { 520ddde725dSArmin Le Grand if(mpClass) 521ddde725dSArmin Le Grand { 522ddde725dSArmin Le Grand mrDocument.removeSvgNodeFromMapper(*mpClass); 523ddde725dSArmin Le Grand delete mpClass; 524ddde725dSArmin Le Grand mpClass = 0; 525ddde725dSArmin Le Grand } 526ddde725dSArmin Le Grand 527ddde725dSArmin Le Grand if(pfClass) 528ddde725dSArmin Le Grand { 529ddde725dSArmin Le Grand mpClass = new rtl::OUString(*pfClass); 530ddde725dSArmin Le Grand mrDocument.addSvgNodeToMapper(*mpClass, *this); 531ddde725dSArmin Le Grand } 532ddde725dSArmin Le Grand } 533ddde725dSArmin Le Grand 534ddde725dSArmin Le Grand XmlSpace SvgNode::getXmlSpace() const 535ddde725dSArmin Le Grand { 536ddde725dSArmin Le Grand if(maXmlSpace != XmlSpace_notset) 537ddde725dSArmin Le Grand { 538ddde725dSArmin Le Grand return maXmlSpace; 539ddde725dSArmin Le Grand } 540ddde725dSArmin Le Grand 541ddde725dSArmin Le Grand if(getParent()) 542ddde725dSArmin Le Grand { 543ddde725dSArmin Le Grand return getParent()->getXmlSpace(); 544ddde725dSArmin Le Grand } 545ddde725dSArmin Le Grand 546ddde725dSArmin Le Grand // default is XmlSpace_default 547ddde725dSArmin Le Grand return XmlSpace_default; 548ddde725dSArmin Le Grand } 549ddde725dSArmin Le Grand 550ddde725dSArmin Le Grand } // end of namespace svgreader 551ddde725dSArmin Le Grand } // end of namespace svgio 552ddde725dSArmin Le Grand 553ddde725dSArmin Le Grand ////////////////////////////////////////////////////////////////////////////// 554ddde725dSArmin Le Grand // eof 555