LCOV - code coverage report
Current view: top level - svgio/source/svgreader - svgstylenode.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 42 0.0 %
Date: 2014-04-14 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <svgio/svgreader/svgstylenode.hxx>
      21             : #include <svgio/svgreader/svgdocument.hxx>
      22             : 
      23             : 
      24             : 
      25             : namespace svgio
      26             : {
      27             :     namespace svgreader
      28             :     {
      29           0 :         SvgStyleNode::SvgStyleNode(
      30             :             SvgDocument& rDocument,
      31             :             SvgNode* pParent)
      32             :         :   SvgNode(SVGTokenStyle, rDocument, pParent),
      33             :             maSvgStyleAttributes(),
      34           0 :             mbTextCss(false)
      35             :         {
      36           0 :         }
      37             : 
      38           0 :         SvgStyleNode::~SvgStyleNode()
      39             :         {
      40           0 :             while(!maSvgStyleAttributes.empty())
      41             :             {
      42           0 :                 delete *(maSvgStyleAttributes.end() - 1);
      43           0 :                 maSvgStyleAttributes.pop_back();
      44             :             }
      45           0 :         }
      46             : 
      47           0 :         void SvgStyleNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
      48             :         {
      49             :             // call parent
      50           0 :             SvgNode::parseAttribute(rTokenName, aSVGToken, aContent);
      51             : 
      52             :             // parse own
      53           0 :             switch(aSVGToken)
      54             :             {
      55             :                 case SVGTokenType:
      56             :                 {
      57           0 :                     if(!aContent.isEmpty())
      58             :                     {
      59           0 :                         if(aContent.startsWith("text/css"))
      60             :                         {
      61           0 :                             setTextCss(true);
      62             :                         }
      63             :                     }
      64           0 :                     break;
      65             :                 }
      66             :                 default:
      67             :                 {
      68           0 :                     break;
      69             :                 }
      70             :             }
      71           0 :         }
      72             : 
      73           0 :         void SvgStyleNode::addCssStyleSheet(const OUString& aContent)
      74             :         {
      75           0 :             const sal_Int32 nLen(aContent.getLength());
      76             : 
      77           0 :             if(nLen)
      78             :             {
      79           0 :                 sal_Int32 nPos(0);
      80           0 :                 OUStringBuffer aTokenValue;
      81             : 
      82           0 :                 while(nPos < nLen)
      83             :                 {
      84           0 :                     const sal_Int32 nInitPos(nPos);
      85           0 :                     skip_char(aContent, ' ', '#', nPos, nLen);
      86           0 :                     copyToLimiter(aContent, '{', nPos, aTokenValue, nLen);
      87           0 :                     const OUString aStyleName = aTokenValue.makeStringAndClear().trim();
      88             : 
      89           0 :                     if(!aStyleName.isEmpty() && nPos < nLen)
      90             :                     {
      91           0 :                         skip_char(aContent, ' ', '{', nPos, nLen);
      92           0 :                         copyToLimiter(aContent, '}', nPos, aTokenValue, nLen);
      93           0 :                         skip_char(aContent, ' ', '}', nPos, nLen);
      94           0 :                         const OUString aStyleContent = aTokenValue.makeStringAndClear().trim();
      95             : 
      96           0 :                         if(!aStyleContent.isEmpty())
      97             :                         {
      98             :                             // create new style
      99           0 :                             SvgStyleAttributes* pNewStyle = new SvgStyleAttributes(*this);
     100           0 :                             maSvgStyleAttributes.push_back(pNewStyle);
     101             : 
     102             :                             // fill with content
     103           0 :                             pNewStyle->readStyle(aStyleContent);
     104             : 
     105             :                             // register new style at document
     106           0 :                             const_cast< SvgDocument& >(getDocument()).addSvgStyleAttributesToMapper(aStyleName, *pNewStyle);
     107           0 :                         }
     108             :                     }
     109             : 
     110           0 :                     if(nInitPos == nPos)
     111             :                     {
     112             :                         OSL_ENSURE(false, "Could not interpret on current position (!)");
     113           0 :                         nPos++;
     114             :                     }
     115           0 :                 }
     116             :             }
     117           0 :         }
     118             : 
     119             :     } // end of namespace svgreader
     120             : } // end of namespace svgio
     121             : 
     122             : 
     123             : // eof
     124             : 
     125             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10