LCOV - code coverage report
Current view: top level - libreoffice/svgio/inc/svgio/svgreader - svgstyleattributes.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 30 0.0 %
Date: 2012-12-27 Functions: 0 30 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             : #ifndef INCLUDED_SVGIO_SVGREADER_SVGSTYLEATTRIBUTES_HXX
      21             : #define INCLUDED_SVGIO_SVGREADER_SVGSTYLEATTRIBUTES_HXX
      22             : 
      23             : #include <svgio/svgreader/svgpaint.hxx>
      24             : #include <svgio/svgreader/svgnode.hxx>
      25             : #include <vcl/vclenum.hxx>
      26             : 
      27             : //////////////////////////////////////////////////////////////////////////////
      28             : // predefines
      29             : 
      30             : namespace svgio { namespace svgreader {
      31             :     class SvgGradientNode;
      32             :     class SvgPatternNode;
      33             :     class SvgMarkerNode;
      34             : }}
      35             : 
      36             : //////////////////////////////////////////////////////////////////////////////
      37             : 
      38             : namespace svgio
      39             : {
      40             :     namespace svgreader
      41             :     {
      42             :         enum StrokeLinecap
      43             :         {
      44             :             StrokeLinecap_notset,
      45             :             StrokeLinecap_butt,
      46             :             StrokeLinecap_round,
      47             :             StrokeLinecap_square
      48             :         };
      49             : 
      50             :         enum StrokeLinejoin
      51             :         {
      52             :             StrokeLinejoin_notset,
      53             :             StrokeLinejoin_miter,
      54             :             StrokeLinejoin_round,
      55             :             StrokeLinejoin_bevel
      56             :         };
      57             : 
      58             :         enum FontStretch
      59             :         {
      60             :             FontStretch_notset,
      61             :             FontStretch_normal,
      62             :             FontStretch_wider,
      63             :             FontStretch_narrower,
      64             :             FontStretch_ultra_condensed,
      65             :             FontStretch_extra_condensed,
      66             :             FontStretch_condensed,
      67             :             FontStretch_semi_condensed,
      68             :             FontStretch_semi_expanded,
      69             :             FontStretch_expanded,
      70             :             FontStretch_extra_expanded,
      71             :             FontStretch_ultra_expanded
      72             :         };
      73             : 
      74             :         FontStretch getWider(FontStretch aSource);
      75             :         FontStretch getNarrower(FontStretch aSource);
      76             : 
      77             :         enum FontStyle
      78             :         {
      79             :             FontStyle_notset,
      80             :             FontStyle_normal,
      81             :             FontStyle_italic,
      82             :             FontStyle_oblique
      83             :         };
      84             : 
      85             :         enum FontVariant
      86             :         {
      87             :             FontVariant_notset,
      88             :             FontVariant_normal,
      89             :             FontVariant_small_caps
      90             :         };
      91             : 
      92             :         enum FontWeight
      93             :         {
      94             :             FontWeight_notset,
      95             :             FontWeight_100,
      96             :             FontWeight_200,
      97             :             FontWeight_300,
      98             :             FontWeight_400, // same as FontWeight_normal
      99             :             FontWeight_500,
     100             :             FontWeight_600,
     101             :             FontWeight_700, // same as FontWeight_bold
     102             :             FontWeight_800,
     103             :             FontWeight_900,
     104             :             FontWeight_bolder,
     105             :             FontWeight_lighter,
     106             :         };
     107             : 
     108             :         FontWeight getBolder(FontWeight aSource);
     109             :         FontWeight getLighter(FontWeight aSource);
     110             :         ::FontWeight getVclFontWeight(FontWeight aSource);
     111             : 
     112             :         enum TextAlign
     113             :         {
     114             :             TextAlign_notset,
     115             :             TextAlign_left,
     116             :             TextAlign_right,
     117             :             TextAlign_center,
     118             :             TextAlign_justify
     119             :         };
     120             : 
     121             :         enum TextDecoration
     122             :         {
     123             :             TextDecoration_notset,
     124             :             TextDecoration_none,
     125             :             TextDecoration_underline,
     126             :             TextDecoration_overline,
     127             :             TextDecoration_line_through,
     128             :             TextDecoration_blink
     129             :         };
     130             : 
     131             :         enum TextAnchor
     132             :         {
     133             :             TextAnchor_notset,
     134             :             TextAnchor_start,
     135             :             TextAnchor_middle,
     136             :             TextAnchor_end
     137             :         };
     138             : 
     139             :         class SvgStyleAttributes
     140             :         {
     141             :         private:
     142             :             SvgNode&                    mrOwner;
     143             :             const SvgStyleAttributes*   mpCssStyleParent;
     144             : 
     145             :             SvgPaint                    maFill;
     146             :             SvgPaint                    maStroke;
     147             :             SvgPaint                    maStopColor;
     148             :             SvgNumber                   maStrokeWidth;
     149             :             SvgNumber                   maStopOpacity;
     150             :             const SvgGradientNode*      mpSvgGradientNodeFill;
     151             :             const SvgGradientNode*      mpSvgGradientNodeStroke;
     152             :             const SvgPatternNode*       mpSvgPatternNodeFill;
     153             :             const SvgPatternNode*       mpSvgPatternNodeStroke;
     154             :             SvgNumber                   maFillOpacity;
     155             :             SvgNumberVector             maStrokeDasharray;
     156             :             SvgNumber                   maStrokeDashOffset;
     157             :             StrokeLinecap               maStrokeLinecap;
     158             :             StrokeLinejoin              maStrokeLinejoin;
     159             :             SvgNumber                   maStrokeMiterLimit;
     160             :             SvgNumber                   maStrokeOpacity;
     161             :             SvgStringVector             maFontFamily;
     162             :             SvgNumber                   maFontSize;
     163             :             FontStretch                 maFontStretch;
     164             :             FontStyle                   maFontStyle;
     165             :             FontVariant                 maFontVariant;
     166             :             FontWeight                  maFontWeight;
     167             :             TextAlign                   maTextAlign;
     168             :             TextDecoration              maTextDecoration;
     169             :             TextAnchor                  maTextAnchor;
     170             :             SvgPaint                    maColor;
     171             :             SvgNumber                   maOpacity;
     172             : 
     173             :             /// link to content. If set, the node can be fetched on demand
     174             :             rtl::OUString               maClipPathXLink;
     175             :             rtl::OUString               maMaskXLink;
     176             : 
     177             :             /// link to markers. If set, the node can be fetched on demand
     178             :             rtl::OUString               maMarkerStartXLink;
     179             :             const SvgMarkerNode*        mpMarkerStartXLink;
     180             :             rtl::OUString               maMarkerMidXLink;
     181             :             const SvgMarkerNode*        mpMarkerMidXLink;
     182             :             rtl::OUString               maMarkerEndXLink;
     183             :             const SvgMarkerNode*        mpMarkerEndXLink;
     184             : 
     185             :             /// bitfield
     186             :             bool                        maFillRule : 1; // true: NonZero, false: EvenOdd
     187             :             bool                        maFillRuleSet : 1;
     188             : 
     189             :             // defines if this attributes are part of a ClipPath. If yes,
     190             :             // rough geometry will be created on decomposition by patching
     191             :             // vaules for fill, stroke, strokeWidth and others
     192             :             bool                        mbIsClipPathContent : 1;
     193             : 
     194             :             // ClipRule setting (only valid wne mbIsClipPathContent == true)
     195             :             bool                        mbClipRule : 1; // true == nonzero(default), false == evenodd
     196             : 
     197             :             /// internal helpers
     198             :             void add_fillGradient(
     199             :                 const basegfx::B2DPolyPolygon& rPath,
     200             :                 drawinglayer::primitive2d::Primitive2DSequence& rTarget,
     201             :                 const SvgGradientNode& rFillGradient,
     202             :                 const basegfx::B2DRange& rGeoRange) const;
     203             :             void add_fillPatternTransform(
     204             :                 const basegfx::B2DPolyPolygon& rPath,
     205             :                 drawinglayer::primitive2d::Primitive2DSequence& rTarget,
     206             :                 const SvgPatternNode& rFillGradient,
     207             :                 const basegfx::B2DRange& rGeoRange) const;
     208             :             void add_fillPattern(
     209             :                 const basegfx::B2DPolyPolygon& rPath,
     210             :                 drawinglayer::primitive2d::Primitive2DSequence& rTarget,
     211             :                 const SvgPatternNode& rFillGradient,
     212             :                 const basegfx::B2DRange& rGeoRange) const;
     213             :             void add_fill(
     214             :                 const basegfx::B2DPolyPolygon& rPath,
     215             :                 drawinglayer::primitive2d::Primitive2DSequence& rTarget,
     216             :                 const basegfx::B2DRange& rGeoRange) const;
     217             :             void add_stroke(
     218             :                 const basegfx::B2DPolyPolygon& rPath,
     219             :                 drawinglayer::primitive2d::Primitive2DSequence& rTarget,
     220             :                 const basegfx::B2DRange& rGeoRange) const;
     221             :             bool prepare_singleMarker(
     222             :                 drawinglayer::primitive2d::Primitive2DSequence& rMarkerPrimitives,
     223             :                 basegfx::B2DHomMatrix& rMarkerTransform,
     224             :                 basegfx::B2DRange& rClipRange,
     225             :                 const SvgMarkerNode& rMarker) const;
     226             :             void add_singleMarker(
     227             :                 drawinglayer::primitive2d::Primitive2DSequence& rTarget,
     228             :                 const drawinglayer::primitive2d::Primitive2DSequence& rMarkerPrimitives,
     229             :                 const basegfx::B2DHomMatrix& rMarkerTransform,
     230             :                 const basegfx::B2DRange& rClipRange,
     231             :                 const SvgMarkerNode& rMarker,
     232             :                 const basegfx::B2DPolygon& rCandidate,
     233             :                 const sal_uInt32 nIndex) const;
     234             :             void add_markers(
     235             :                 const basegfx::B2DPolyPolygon& rPath,
     236             :                 drawinglayer::primitive2d::Primitive2DSequence& rTarget) const;
     237             : 
     238             :         public:
     239             :             /// local attribute scanner
     240             :             void parseStyleAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent);
     241             : 
     242             :             /// helper which does the necessary with a given path
     243             :             void add_text(
     244             :                 drawinglayer::primitive2d::Primitive2DSequence& rTarget,
     245             :                 drawinglayer::primitive2d::Primitive2DSequence& rSource) const;
     246             :             void add_path(
     247             :                 const basegfx::B2DPolyPolygon& rPath,
     248             :                 drawinglayer::primitive2d::Primitive2DSequence& rTarget) const;
     249             :             void add_postProcess(
     250             :                 drawinglayer::primitive2d::Primitive2DSequence& rTarget,
     251             :                 const drawinglayer::primitive2d::Primitive2DSequence& rSource,
     252             :                 const basegfx::B2DHomMatrix* pTransform) const;
     253             : 
     254             :             /// helper to evtl. link to css style
     255             :             void checkForCssStyle(const rtl::OUString& rClassStr) const;
     256             : 
     257             :             /// scan helpers
     258             :             void readStyle(const rtl::OUString& rCandidate);
     259             :             const SvgStyleAttributes* getParentStyle() const;
     260             : 
     261             :             SvgStyleAttributes(SvgNode& rOwner);
     262             :             ~SvgStyleAttributes();
     263             : 
     264             :             /// fill content
     265             :             const basegfx::BColor* getFill() const;
     266           0 :             void setFill(const SvgPaint& rFill) { maFill = rFill; }
     267             : 
     268             :             /// stroke content
     269             :             const basegfx::BColor* getStroke() const;
     270           0 :             void setStroke(const SvgPaint& rStroke) { maStroke = rStroke; }
     271             : 
     272             :             /// stop color content
     273             :             const basegfx::BColor& getStopColor() const;
     274           0 :             void setStopColor(const SvgPaint& rStopColor) { maStopColor = rStopColor; }
     275             : 
     276             :             /// stroke-width content
     277             :             const SvgNumber getStrokeWidth() const;
     278           0 :             void setStrokeWidth(const SvgNumber& rStrokeWidth = SvgNumber()) { maStrokeWidth = rStrokeWidth; }
     279             : 
     280             :             /// stop opacity content
     281             :             const SvgNumber getStopOpacity() const;
     282           0 :             void setStopOpacity(const SvgNumber& rStopOpacity = SvgNumber()) { maStopOpacity = rStopOpacity; }
     283             : 
     284             :             /// access to evtl. set fill gradient
     285             :             const SvgGradientNode* getSvgGradientNodeFill() const;
     286           0 :             void setSvgGradientNodeFill(const SvgGradientNode* pNew) { mpSvgGradientNodeFill = pNew; }
     287             : 
     288             :             /// access to evtl. set fill pattern
     289             :             const SvgPatternNode* getSvgPatternNodeFill() const;
     290           0 :             void setSvgPatternNodeFill(const SvgPatternNode* pNew) { mpSvgPatternNodeFill = pNew; }
     291             : 
     292             :             /// access to evtl. set stroke gradient
     293             :             const SvgGradientNode* getSvgGradientNodeStroke() const;
     294           0 :             void setSvgGradientNodeStroke(const SvgGradientNode* pNew) { mpSvgGradientNodeStroke = pNew; }
     295             : 
     296             :             /// access to evtl. set stroke pattern
     297             :             const SvgPatternNode* getSvgPatternNodeStroke() const;
     298           0 :             void setSvgPatternNodeStroke(const SvgPatternNode* pNew) { mpSvgPatternNodeStroke = pNew; }
     299             : 
     300             :             /// fill opacity content
     301             :             const SvgNumber getFillOpacity() const;
     302           0 :             void setFillOpacity(const SvgNumber& rFillOpacity = SvgNumber()) { maFillOpacity = rFillOpacity; }
     303             : 
     304             :             /// fill rule content
     305             :             bool getFillRule() const;
     306             : 
     307             :             /// fill StrokeDasharray content
     308             :             const SvgNumberVector& getStrokeDasharray() const;
     309           0 :             void setStrokeDasharray(const SvgNumberVector& rStrokeDasharray = SvgNumberVector()) { maStrokeDasharray = rStrokeDasharray; }
     310             : 
     311             :             /// StrokeDashOffset content
     312             :             const SvgNumber getStrokeDashOffset() const;
     313           0 :             void setStrokeDashOffset(const SvgNumber& rStrokeDashOffset = SvgNumber()) { maStrokeDashOffset = rStrokeDashOffset; }
     314             : 
     315             :             /// StrokeLinecap content
     316             :             StrokeLinecap getStrokeLinecap() const;
     317           0 :             void setStrokeLinecap(const StrokeLinecap aStrokeLinecap = StrokeLinecap_notset) { maStrokeLinecap = aStrokeLinecap; }
     318             : 
     319             :             /// StrokeLinejoin content
     320             :             StrokeLinejoin getStrokeLinejoin() const;
     321           0 :             void setStrokeLinejoin(const StrokeLinejoin aStrokeLinejoin = StrokeLinejoin_notset) { maStrokeLinejoin = aStrokeLinejoin; }
     322             : 
     323             :             /// StrokeMiterLimit content
     324             :             const SvgNumber getStrokeMiterLimit() const;
     325           0 :             void setStrokeMiterLimit(const SvgNumber& rStrokeMiterLimit = SvgNumber()) { maStrokeMiterLimit = rStrokeMiterLimit; }
     326             : 
     327             :             /// StrokeOpacity content
     328             :             const SvgNumber getStrokeOpacity() const;
     329           0 :             void setStrokeOpacity(const SvgNumber& rStrokeOpacity = SvgNumber()) { maStrokeOpacity = rStrokeOpacity; }
     330             : 
     331             :             /// Font content
     332             :             const SvgStringVector& getFontFamily() const;
     333           0 :             void setFontFamily(const SvgStringVector& rSvgStringVector = SvgStringVector()) { maFontFamily = rSvgStringVector; }
     334             : 
     335             :             /// FontSize content
     336             :             const SvgNumber getFontSize() const;
     337           0 :             void setFontSize(const SvgNumber& rFontSize = SvgNumber()) { maFontSize = rFontSize; }
     338             : 
     339             :             /// FontStretch content
     340             :             FontStretch getFontStretch() const;
     341           0 :             void setFontStretch(const FontStretch aFontStretch = FontStretch_notset) { maFontStretch = aFontStretch; }
     342             : 
     343             :             /// FontStyle content
     344             :             FontStyle getFontStyle() const;
     345           0 :             void setFontStyle(const FontStyle aFontStyle = FontStyle_notset) { maFontStyle = aFontStyle; }
     346             : 
     347             :             /// FontVariant content
     348             :             FontVariant getFontVariant() const;
     349           0 :             void setFontVariant(const FontVariant aFontVariant = FontVariant_notset) { maFontVariant = aFontVariant; }
     350             : 
     351             :             /// FontWeight content
     352             :             FontWeight getFontWeight() const;
     353           0 :             void setFontWeight(const FontWeight aFontWeight = FontWeight_notset) { maFontWeight = aFontWeight; }
     354             : 
     355             :             /// TextAlign content
     356             :             TextAlign getTextAlign() const;
     357           0 :             void setTextAlign(const TextAlign aTextAlign = TextAlign_notset) { maTextAlign = aTextAlign; }
     358             : 
     359             :             /// TextDecoration content
     360             :             const SvgStyleAttributes* getTextDecorationDefiningSvgStyleAttributes() const;
     361             :             TextDecoration getTextDecoration() const;
     362           0 :             void setTextDecoration(const TextDecoration aTextDecoration = TextDecoration_notset) { maTextDecoration = aTextDecoration; }
     363             : 
     364             :             /// TextAnchor content
     365             :             TextAnchor getTextAnchor() const;
     366           0 :             void setTextAnchor(const TextAnchor aTextAnchor = TextAnchor_notset) { maTextAnchor = aTextAnchor; }
     367             : 
     368             :             /// Color content
     369             :             const basegfx::BColor* getColor() const;
     370           0 :             void setColor(const SvgPaint& rColor) { maColor = rColor; }
     371             : 
     372             :             /// Opacity content
     373           0 :             const SvgNumber getOpacity() const { return maOpacity; }
     374           0 :             void setOpacity(const SvgNumber& rOpacity = SvgNumber()) { maOpacity = rOpacity; }
     375             : 
     376             :             // ClipPathXLink content
     377           0 :             const rtl::OUString getClipPathXLink() const { return maClipPathXLink; }
     378             :             void setClipPathXLink(const rtl::OUString& rNew) { maClipPathXLink = rNew; }
     379             : 
     380             :             // MaskXLink content
     381           0 :             const rtl::OUString getMaskXLink() const { return maMaskXLink; }
     382             :             void setMaskXLink(const rtl::OUString& rNew) { maMaskXLink = rNew; }
     383             : 
     384             :             // MarkerStartXLink content
     385             :             const rtl::OUString getMarkerStartXLink() const;
     386             :             const SvgMarkerNode* accessMarkerStartXLink() const;
     387             :             void setMarkerStartXLink(const rtl::OUString& rNew) { maMarkerStartXLink = rNew; }
     388             : 
     389             :             // MarkerMidXLink content
     390             :             const rtl::OUString getMarkerMidXLink() const;
     391             :             const SvgMarkerNode* accessMarkerMidXLink() const;
     392             :             void setMarkerMidXLink(const rtl::OUString& rNew) { maMarkerMidXLink = rNew; }
     393             : 
     394             :             // MarkerEndXLink content
     395             :             const rtl::OUString getMarkerEndXLink() const;
     396             :             const SvgMarkerNode* accessMarkerEndXLink() const;
     397             :             void setMarkerEndXLink(const rtl::OUString& rNew) { maMarkerEndXLink = rNew; }
     398             : 
     399             :         };
     400             :     } // end of namespace svgreader
     401             : } // end of namespace svgio
     402             : 
     403             : //////////////////////////////////////////////////////////////////////////////
     404             : 
     405             : #endif //INCLUDED_SVGIO_SVGREADER_SVGSTYLEATTRIBUTES_HXX
     406             : 
     407             : // eof
     408             : 
     409             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10