LCOV - code coverage report
Current view: top level - drawinglayer/source/processor2d - textaspolygonextractor2d.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 15 64 23.4 %
Date: 2015-06-13 12:38:46 Functions: 3 4 75.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 <drawinglayer/processor2d/textaspolygonextractor2d.hxx>
      21             : #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
      22             : #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
      23             : #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
      24             : #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
      25             : #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
      26             : 
      27             : 
      28             : 
      29             : namespace drawinglayer
      30             : {
      31             :     namespace processor2d
      32             :     {
      33         144 :         void TextAsPolygonExtractor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate)
      34             :         {
      35         144 :             switch(rCandidate.getPrimitive2DID())
      36             :             {
      37             :                 case PRIMITIVE2D_ID_TEXTDECORATEDPORTIONPRIMITIVE2D :
      38             :                 {
      39             :                     // TextDecoratedPortionPrimitive2D can produce the following primitives
      40             :                     // when being decomposed:
      41             :                     //
      42             :                     // - TextSimplePortionPrimitive2D
      43             :                     // - PolygonWavePrimitive2D
      44             :                     //      - PolygonStrokePrimitive2D
      45             :                     // - PolygonStrokePrimitive2D
      46             :                     //      - PolyPolygonColorPrimitive2D
      47             :                     //      - PolyPolygonHairlinePrimitive2D
      48             :                     //          - PolygonHairlinePrimitive2D
      49             :                     // - ShadowPrimitive2D
      50             :                     //      - ModifiedColorPrimitive2D
      51             :                     //      - TransformPrimitive2D
      52             :                     // - TextEffectPrimitive2D
      53             :                     //      - ModifiedColorPrimitive2D
      54             :                     //      - TransformPrimitive2D
      55             :                     //      - GroupPrimitive2D
      56             : 
      57             :                     // encapsulate with flag and use decomposition
      58           0 :                     mnInText++;
      59           0 :                     process(rCandidate.get2DDecomposition(getViewInformation2D()));
      60           0 :                     mnInText--;
      61             : 
      62           0 :                     break;
      63             :                 }
      64             :                 case PRIMITIVE2D_ID_TEXTSIMPLEPORTIONPRIMITIVE2D :
      65             :                 {
      66             :                     // TextSimplePortionPrimitive2D can produce the following primitives
      67             :                     // when being decomposed:
      68             :                     //
      69             :                     // - PolyPolygonColorPrimitive2D
      70             :                     // - TextEffectPrimitive2D
      71             :                     //      - ModifiedColorPrimitive2D
      72             :                     //      - TransformPrimitive2D
      73             :                     //      - GroupPrimitive2D
      74             : 
      75             :                     // encapsulate with flag and use decomposition
      76           0 :                     mnInText++;
      77           0 :                     process(rCandidate.get2DDecomposition(getViewInformation2D()));
      78           0 :                     mnInText--;
      79             : 
      80           0 :                     break;
      81             :                 }
      82             : 
      83             :                 // as can be seen from the TextSimplePortionPrimitive2D and the
      84             :                 // TextDecoratedPortionPrimitive2D, inside of the mnInText marks
      85             :                 // the following primitives can occur containing geometry data
      86             :                 // from text decomposition:
      87             :                 //
      88             :                 // - PolyPolygonColorPrimitive2D
      89             :                 // - PolygonHairlinePrimitive2D
      90             :                 // - PolyPolygonHairlinePrimitive2D (for convenience)
      91             :                 //
      92             :                 case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D :
      93             :                 {
      94          73 :                     if(mnInText)
      95             :                     {
      96           0 :                         const primitive2d::PolyPolygonColorPrimitive2D& rPoPoCoCandidate(static_cast< const primitive2d::PolyPolygonColorPrimitive2D& >(rCandidate));
      97           0 :                         basegfx::B2DPolyPolygon aPolyPolygon(rPoPoCoCandidate.getB2DPolyPolygon());
      98             : 
      99           0 :                         if(aPolyPolygon.count())
     100             :                         {
     101             :                             // transform the PolyPolygon
     102           0 :                             aPolyPolygon.transform(getViewInformation2D().getObjectToViewTransformation());
     103             : 
     104             :                             // get evtl. corrected color
     105           0 :                             const basegfx::BColor aColor(maBColorModifierStack.getModifiedColor(rPoPoCoCandidate.getBColor()));
     106             : 
     107             :                             // add to result vector
     108           0 :                             maTarget.push_back(TextAsPolygonDataNode(aPolyPolygon, aColor, true));
     109           0 :                         }
     110             :                     }
     111             : 
     112          73 :                     break;
     113             :                 }
     114             :                 case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D :
     115             :                 {
     116           0 :                     if(mnInText)
     117             :                     {
     118           0 :                         const primitive2d::PolygonHairlinePrimitive2D& rPoHaCandidate(static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(rCandidate));
     119           0 :                         basegfx::B2DPolygon aPolygon(rPoHaCandidate.getB2DPolygon());
     120             : 
     121           0 :                         if(aPolygon.count())
     122             :                         {
     123             :                             // transform the Polygon
     124           0 :                             aPolygon.transform(getViewInformation2D().getObjectToViewTransformation());
     125             : 
     126             :                             // get evtl. corrected color
     127           0 :                             const basegfx::BColor aColor(maBColorModifierStack.getModifiedColor(rPoHaCandidate.getBColor()));
     128             : 
     129             :                             // add to result vector
     130           0 :                             maTarget.push_back(TextAsPolygonDataNode(basegfx::B2DPolyPolygon(aPolygon), aColor, false));
     131           0 :                         }
     132             :                     }
     133             : 
     134           0 :                     break;
     135             :                 }
     136             :                 case PRIMITIVE2D_ID_POLYPOLYGONHAIRLINEPRIMITIVE2D :
     137             :                 {
     138          19 :                     if(mnInText)
     139             :                     {
     140           0 :                         const primitive2d::PolyPolygonHairlinePrimitive2D& rPoPoHaCandidate(static_cast< const primitive2d::PolyPolygonHairlinePrimitive2D& >(rCandidate));
     141           0 :                         basegfx::B2DPolyPolygon aPolyPolygon(rPoPoHaCandidate.getB2DPolyPolygon());
     142             : 
     143           0 :                         if(aPolyPolygon.count())
     144             :                         {
     145             :                             // transform the Polygon
     146           0 :                             aPolyPolygon.transform(getViewInformation2D().getObjectToViewTransformation());
     147             : 
     148             :                             // get evtl. corrected color
     149           0 :                             const basegfx::BColor aColor(maBColorModifierStack.getModifiedColor(rPoPoHaCandidate.getBColor()));
     150             : 
     151             :                             // add to result vector
     152           0 :                             maTarget.push_back(TextAsPolygonDataNode(aPolyPolygon, aColor, false));
     153           0 :                         }
     154             :                     }
     155             : 
     156          19 :                     break;
     157             :                 }
     158             : 
     159             :                 // usage of color modification stack is needed
     160             :                 case PRIMITIVE2D_ID_MODIFIEDCOLORPRIMITIVE2D :
     161             :                 {
     162           0 :                     const primitive2d::ModifiedColorPrimitive2D& rModifiedColorCandidate(static_cast< const primitive2d::ModifiedColorPrimitive2D& >(rCandidate));
     163             : 
     164           0 :                     if(rModifiedColorCandidate.getChildren().hasElements())
     165             :                     {
     166           0 :                         maBColorModifierStack.push(rModifiedColorCandidate.getColorModifier());
     167           0 :                         process(rModifiedColorCandidate.getChildren());
     168           0 :                         maBColorModifierStack.pop();
     169             :                     }
     170             : 
     171           0 :                     break;
     172             :                 }
     173             : 
     174             :                 // usage of transformation stack is needed
     175             :                 case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D :
     176             :                 {
     177             :                     // remember current transformation and ViewInformation
     178           0 :                     const primitive2d::TransformPrimitive2D& rTransformCandidate(static_cast< const primitive2d::TransformPrimitive2D& >(rCandidate));
     179           0 :                     const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D());
     180             : 
     181             :                     // create new transformations for CurrentTransformation and for local ViewInformation2D
     182             :                     const geometry::ViewInformation2D aViewInformation2D(
     183           0 :                         getViewInformation2D().getObjectTransformation() * rTransformCandidate.getTransformation(),
     184           0 :                         getViewInformation2D().getViewTransformation(),
     185           0 :                         getViewInformation2D().getViewport(),
     186           0 :                         getViewInformation2D().getVisualizedPage(),
     187           0 :                         getViewInformation2D().getViewTime(),
     188           0 :                         getViewInformation2D().getExtendedInformationSequence());
     189           0 :                     updateViewInformation(aViewInformation2D);
     190             : 
     191             :                     // process content
     192           0 :                     process(rTransformCandidate.getChildren());
     193             : 
     194             :                     // restore transformations
     195           0 :                     updateViewInformation(aLastViewInformation2D);
     196             : 
     197           0 :                     break;
     198             :                 }
     199             : 
     200             :                 // ignorable primitives
     201             :                 case PRIMITIVE2D_ID_SCENEPRIMITIVE2D :
     202             :                 case PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D :
     203             :                 case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D :
     204             :                 case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D :
     205             :                 case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D :
     206             :                 case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D :
     207             :                 case PRIMITIVE2D_ID_MASKPRIMITIVE2D :
     208             :                 {
     209           1 :                     break;
     210             :                 }
     211             : 
     212             :                 default :
     213             :                 {
     214             :                     // process recursively
     215          51 :                     process(rCandidate.get2DDecomposition(getViewInformation2D()));
     216          51 :                     break;
     217             :                 }
     218             :             }
     219         144 :         }
     220             : 
     221          26 :         TextAsPolygonExtractor2D::TextAsPolygonExtractor2D(const geometry::ViewInformation2D& rViewInformation)
     222             :         :   BaseProcessor2D(rViewInformation),
     223             :             maTarget(),
     224             :             maBColorModifierStack(),
     225          26 :             mnInText(0)
     226             :         {
     227          26 :         }
     228             : 
     229          26 :         TextAsPolygonExtractor2D::~TextAsPolygonExtractor2D()
     230             :         {
     231          26 :         }
     232             :     } // end of namespace processor2d
     233             : } // end of namespace drawinglayer
     234             : 
     235             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11