LCOV - code coverage report
Current view: top level - drawinglayer/source/primitive2d - fillgraphicprimitive2d.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 30 40 75.0 %
Date: 2015-06-13 12:38:46 Functions: 3 5 60.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/primitive2d/fillgraphicprimitive2d.hxx>
      21             : #include <drawinglayer/primitive2d/graphicprimitive2d.hxx>
      22             : #include <basegfx/polygon/b2dpolygon.hxx>
      23             : #include <basegfx/polygon/b2dpolygontools.hxx>
      24             : #include <drawinglayer/texture/texture.hxx>
      25             : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      26             : #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
      27             : #include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
      28             : #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
      29             : #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
      30             : #include <drawinglayer/primitive2d/graphicprimitivehelper2d.hxx>
      31             : 
      32             : 
      33             : 
      34             : using namespace com::sun::star;
      35             : 
      36             : 
      37             : 
      38             : namespace drawinglayer
      39             : {
      40             :     namespace primitive2d
      41             :     {
      42          44 :         Primitive2DSequence FillGraphicPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
      43             :         {
      44          44 :             Primitive2DSequence aRetval;
      45          44 :             const attribute::FillGraphicAttribute& rAttribute = getFillGraphic();
      46             : 
      47          44 :             if(!rAttribute.isDefault())
      48             :             {
      49          44 :                 const Graphic& rGraphic = rAttribute.getGraphic();
      50             : 
      51          44 :                 if(GRAPHIC_BITMAP == rGraphic.GetType() || GRAPHIC_GDIMETAFILE == rGraphic.GetType())
      52             :                 {
      53          44 :                     const Size aSize(rGraphic.GetPrefSize());
      54             : 
      55          44 :                     if(aSize.Width() && aSize.Height())
      56             :                     {
      57             :                         // we have a graphic (bitmap or metafile) with some size
      58          44 :                         if(rAttribute.getTiling())
      59             :                         {
      60             :                             // get object range and create tiling matrices
      61           4 :                             ::std::vector< basegfx::B2DHomMatrix > aMatrices;
      62             :                             texture::GeoTexSvxTiled aTiling(
      63           4 :                                 rAttribute.getGraphicRange(),
      64             :                                 rAttribute.getOffsetX(),
      65          12 :                                 rAttribute.getOffsetY());
      66             : 
      67             :                             // get matrices and realloc retval
      68           4 :                             aTiling.appendTransformations(aMatrices);
      69           4 :                             aRetval.realloc(aMatrices.size());
      70             : 
      71             :                             // prepare content primitive
      72             :                             const Primitive2DSequence xSeq = create2DDecompositionOfGraphic(
      73             :                                 rGraphic,
      74           8 :                                 basegfx::B2DHomMatrix());
      75             : 
      76         338 :                             for(size_t a(0); a < aMatrices.size(); a++)
      77             :                             {
      78         668 :                                 aRetval[a] = new TransformPrimitive2D(
      79         668 :                                     getTransformation() * aMatrices[a],
      80         668 :                                     xSeq);
      81           4 :                             }
      82             :                         }
      83             :                         else
      84             :                         {
      85             :                             // add graphic without tiling
      86             :                             const basegfx::B2DHomMatrix aObjectTransform(
      87          40 :                                 getTransformation() * basegfx::tools::createScaleTranslateB2DHomMatrix(
      88          40 :                                     rAttribute.getGraphicRange().getRange(),
      89         120 :                                     rAttribute.getGraphicRange().getMinimum()));
      90             : 
      91          80 :                             aRetval = create2DDecompositionOfGraphic(
      92             :                                 rGraphic,
      93          80 :                                 aObjectTransform);
      94             :                         }
      95             :                     }
      96             :                 }
      97             :             }
      98             : 
      99          44 :             return aRetval;
     100             :         }
     101             : 
     102         410 :         FillGraphicPrimitive2D::FillGraphicPrimitive2D(
     103             :             const basegfx::B2DHomMatrix& rTransformation,
     104             :             const attribute::FillGraphicAttribute& rFillGraphic)
     105             :         :   BufferedDecompositionPrimitive2D(),
     106             :             maTransformation(rTransformation),
     107         410 :             maFillGraphic(rFillGraphic)
     108             :         {
     109         410 :         }
     110             : 
     111           0 :         bool FillGraphicPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
     112             :         {
     113           0 :             if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
     114             :             {
     115           0 :                 const FillGraphicPrimitive2D& rCompare = static_cast< const FillGraphicPrimitive2D& >(rPrimitive);
     116             : 
     117           0 :                 return (getTransformation() == rCompare.getTransformation()
     118           0 :                     && getFillGraphic() == rCompare.getFillGraphic());
     119             :             }
     120             : 
     121           0 :             return false;
     122             :         }
     123             : 
     124           0 :         basegfx::B2DRange FillGraphicPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const
     125             :         {
     126             :             // return range of it
     127           0 :             basegfx::B2DPolygon aPolygon(basegfx::tools::createUnitPolygon());
     128           0 :             aPolygon.transform(getTransformation());
     129             : 
     130           0 :             return basegfx::tools::getRange(aPolygon);
     131             :         }
     132             : 
     133             :         // provide unique ID
     134         378 :         ImplPrimitive2DIDBlock(FillGraphicPrimitive2D, PRIMITIVE2D_ID_FILLGRAPHICPRIMITIVE2D)
     135             : 
     136             :     } // end of namespace primitive2d
     137             : } // end of namespace drawinglayer
     138             : 
     139             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11