LCOV - code coverage report
Current view: top level - drawinglayer/source/primitive2d - fillgraphicprimitive2d.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 31 41 75.6 %
Date: 2014-11-03 Functions: 5 7 71.4 %
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          82 :         Primitive2DSequence FillGraphicPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
      43             :         {
      44          82 :             Primitive2DSequence aRetval;
      45          82 :             const attribute::FillGraphicAttribute& rAttribute = getFillGraphic();
      46             : 
      47          82 :             if(!rAttribute.isDefault())
      48             :             {
      49          82 :                 const Graphic& rGraphic = rAttribute.getGraphic();
      50             : 
      51          82 :                 if(GRAPHIC_BITMAP == rGraphic.GetType() || GRAPHIC_GDIMETAFILE == rGraphic.GetType())
      52             :                 {
      53          82 :                     const Size aSize(rGraphic.GetPrefSize());
      54             : 
      55          82 :                     if(aSize.Width() && aSize.Height())
      56             :                     {
      57             :                         // we have a graphic (bitmap or metafile) with some size
      58          82 :                         if(rAttribute.getTiling())
      59             :                         {
      60             :                             // get object range and create tiling matrices
      61           2 :                             ::std::vector< basegfx::B2DHomMatrix > aMatrices;
      62             :                             texture::GeoTexSvxTiled aTiling(
      63           2 :                                 rAttribute.getGraphicRange(),
      64             :                                 rAttribute.getOffsetX(),
      65           6 :                                 rAttribute.getOffsetY());
      66             : 
      67             :                             // get matrices and realloc retval
      68           2 :                             aTiling.appendTransformations(aMatrices);
      69           2 :                             aRetval.realloc(aMatrices.size());
      70             : 
      71             :                             // prepare content primitive
      72             :                             const Primitive2DSequence xSeq = create2DDecompositionOfGraphic(
      73             :                                 rGraphic,
      74           4 :                                 basegfx::B2DHomMatrix());
      75             : 
      76         664 :                             for(sal_uInt32 a(0); a < aMatrices.size(); a++)
      77             :                             {
      78        1324 :                                 aRetval[a] = new TransformPrimitive2D(
      79        1324 :                                     getTransformation() * aMatrices[a],
      80        1324 :                                     xSeq);
      81           2 :                             }
      82             :                         }
      83             :                         else
      84             :                         {
      85             :                             // add graphic without tiling
      86             :                             const basegfx::B2DHomMatrix aObjectTransform(
      87          80 :                                 getTransformation() * basegfx::tools::createScaleTranslateB2DHomMatrix(
      88          80 :                                     rAttribute.getGraphicRange().getRange(),
      89         240 :                                     rAttribute.getGraphicRange().getMinimum()));
      90             : 
      91         160 :                             aRetval = create2DDecompositionOfGraphic(
      92             :                                 rGraphic,
      93         160 :                                 aObjectTransform);
      94             :                         }
      95             :                     }
      96             :                 }
      97             :             }
      98             : 
      99          82 :             return aRetval;
     100             :         }
     101             : 
     102         290 :         FillGraphicPrimitive2D::FillGraphicPrimitive2D(
     103             :             const basegfx::B2DHomMatrix& rTransformation,
     104             :             const attribute::FillGraphicAttribute& rFillGraphic)
     105             :         :   BufferedDecompositionPrimitive2D(),
     106             :             maTransformation(rTransformation),
     107         290 :             maFillGraphic(rFillGraphic)
     108             :         {
     109         290 :         }
     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         246 :         ImplPrimitive2DIDBlock(FillGraphicPrimitive2D, PRIMITIVE2D_ID_FILLGRAPHICPRIMITIVE2D)
     135             : 
     136             :     } // end of namespace primitive2d
     137        1143 : } // end of namespace drawinglayer
     138             : 
     139             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10