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