LCOV - code coverage report
Current view: top level - svgio/inc/svgio/svgreader - svgnode.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 9 10 90.0 %
Date: 2015-06-13 12:38:46 Functions: 9 10 90.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             : #ifndef INCLUDED_SVGIO_INC_SVGIO_SVGREADER_SVGNODE_HXX
      21             : #define INCLUDED_SVGIO_INC_SVGIO_SVGREADER_SVGNODE_HXX
      22             : 
      23             : #include <svgio/svgreader/svgtools.hxx>
      24             : #include <svgio/svgreader/svgtoken.hxx>
      25             : #include <svgio/svgreader/svgpaint.hxx>
      26             : #include <basegfx/matrix/b2dhommatrix.hxx>
      27             : #include <com/sun/star/xml/sax/XAttributeList.hpp>
      28             : #include <vector>
      29             : 
      30             : // predefines
      31             : namespace svgio
      32             : {
      33             :     namespace svgreader
      34             :     {
      35             :         class SvgNode;
      36             :         class SvgDocument;
      37             :         class SvgStyleAttributes;
      38             :     }
      39             : }
      40             : 
      41             : 
      42             : 
      43             : namespace svgio
      44             : {
      45             :     namespace svgreader
      46             :     {
      47             :         typedef ::std::vector< SvgNode* > SvgNodeVector;
      48             :         typedef ::std::vector< const SvgStyleAttributes* > SvgStyleAttributeVector;
      49             : 
      50             :         enum XmlSpace
      51             :         {
      52             :             XmlSpace_notset,
      53             :             XmlSpace_default,
      54             :             XmlSpace_preserve
      55             :         };
      56             : 
      57             :         // display property (see SVG 1.1. 11.5), not inheritable
      58             :         enum Display // #i121656#
      59             :         {
      60             :             Display_inline, // the default
      61             :             Display_block,
      62             :             Display_list_item,
      63             :             Display_run_in,
      64             :             Display_compact,
      65             :             Display_marker,
      66             :             Display_table,
      67             :             Display_inline_table,
      68             :             Display_table_row_group,
      69             :             Display_table_header_group,
      70             :             Display_table_footer_group,
      71             :             Display_table_row,
      72             :             Display_table_column_group,
      73             :             Display_table_column,
      74             :             Display_table_cell,
      75             :             Display_table_caption,
      76             :             Display_none,
      77             :             Display_inherit
      78             :         };
      79             : 
      80             :         // helper to convert a string associated with a token of type SVGTokenDisplay
      81             :         // to the enum Display. Empty trings return the default 'Display_inline' with
      82             :         // which members should be initialized
      83             :         Display getDisplayFromContent(const OUString& aContent);
      84             : 
      85             :         class SvgNode : private boost::noncopyable, public InfoProvider
      86             :         {
      87             :         private:
      88             :             /// basic data, Type, document we belong to and parent (if not root)
      89             :             SVGToken                    maType;
      90             :             SvgDocument&                mrDocument;
      91             :             const SvgNode*              mpParent;
      92             :             const SvgNode*              mpAlternativeParent;
      93             : 
      94             :             /// sub hierarchy
      95             :             SvgNodeVector               maChildren;
      96             : 
      97             :             /// Id svan value
      98             :             OUString*              mpId;
      99             : 
     100             :             /// Class svan value
     101             :             OUString*              mpClass;
     102             : 
     103             :             /// XmlSpace value
     104             :             XmlSpace                    maXmlSpace;
     105             : 
     106             :             /// Display value #i121656#
     107             :             Display                     maDisplay;
     108             : 
     109             :             // CSS style vector chain, used in decompose phase and built up once per node.
     110             :             // It contains the StyleHierarchy for the local node. INdependent from the
     111             :             // node hierarchy itself which also needs to be used in style entry solving
     112             :             SvgStyleAttributeVector     maCssStyleVector;
     113             : 
     114             :             /// possibbe local CssStyle, e.g. style="fill:red; stroke:red;"
     115             :             SvgStyleAttributes*         mpLocalCssStyle;
     116             : 
     117             :             /// bitfield
     118             :             // flag if maCssStyleVector is already computed (done only once)
     119             :             bool                        mbCssStyleVectorBuilt : 1;
     120             : 
     121             :         protected:
     122             :             /// helper to evtl. link to css style
     123             :             const SvgStyleAttributes* checkForCssStyle(const OUString& rClassStr, const SvgStyleAttributes& rOriginal) const;
     124             : 
     125             :             /// helper for filling the CssStyle vector once dependent on mbCssStyleVectorBuilt
     126             :             void fillCssStyleVector(const OUString& rClassStr);
     127             :             void fillCssStyleVectorUsingHierarchyAndSelectors(
     128             :                 const OUString& rClassStr,
     129             :                 const SvgNode& rCurrent,
     130             :                 const OUString& aConcatenated);
     131             : 
     132             :         public:
     133             :             SvgNode(
     134             :                 SVGToken aType,
     135             :                 SvgDocument& rDocument,
     136             :                 SvgNode* pParent);
     137             :             virtual ~SvgNode();
     138             : 
     139             :             /// scan helper to read and interpret a local CssStyle to mpLocalCssStyle
     140             :             void readLocalCssStyle(const OUString& aContent);
     141             : 
     142             :             /// style helpers
     143             :             void parseAttributes(const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttribs);
     144             :             virtual const SvgStyleAttributes* getSvgStyleAttributes() const;
     145             :             virtual void parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent);
     146             :             virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DSequence& rTarget, bool bReferenced) const;
     147             : 
     148             :             /// #i125258# tell if this node is allowed to have a parent style (e.g. defs do not)
     149             :             virtual bool supportsParentStyle() const;
     150             : 
     151             :             /// basic data read access
     152      179140 :             SVGToken getType() const { return maType; }
     153       21903 :             const SvgDocument& getDocument() const { return mrDocument; }
     154      266961 :             const SvgNode* getParent() const { if(mpAlternativeParent) return mpAlternativeParent; return mpParent; }
     155       23127 :             const SvgNodeVector& getChildren() const { return maChildren; }
     156             : 
     157             :             /// InfoProvider support for %, em and ex values
     158             :             virtual const basegfx::B2DRange getCurrentViewPort() const SAL_OVERRIDE;
     159             :             virtual double getCurrentFontSizeInherited() const SAL_OVERRIDE;
     160             :             virtual double getCurrentXHeightInherited() const SAL_OVERRIDE;
     161             : 
     162             :             double getCurrentFontSize() const;
     163             :             double getCurrentXHeight() const;
     164             : 
     165             :             /// Id access
     166          16 :             const OUString* getId() const { return mpId; }
     167             :             void setId(const OUString* pfId = 0);
     168             : 
     169             :             /// Class access
     170          16 :             const OUString* getClass() const { return mpClass; }
     171             :             void setClass(const OUString* pfClass = 0);
     172             : 
     173             :             /// XmlSpace access
     174             :             XmlSpace getXmlSpace() const;
     175         295 :             void setXmlSpace(XmlSpace eXmlSpace = XmlSpace_notset) { maXmlSpace = eXmlSpace; }
     176             : 
     177             :             /// Display access #i121656#
     178       20327 :             Display getDisplay() const { return maDisplay; }
     179           0 :             void setDisplay(Display eDisplay = Display_inherit) { maDisplay = eDisplay; }
     180             : 
     181             :             /// alternative parent
     182         386 :             void setAlternativeParent(const SvgNode* pAlternativeParent = 0) { mpAlternativeParent = pAlternativeParent; }
     183             :         };
     184             :     } // end of namespace svgreader
     185             : } // end of namespace svgio
     186             : 
     187             : #endif // INCLUDED_SVGIO_INC_SVGIO_SVGREADER_SVGNODE_HXX
     188             : 
     189             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11