LCOV - code coverage report
Current view: top level - libreoffice/drawinglayer/source/primitive2d - patternfillprimitive2d.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 39 0.0 %
Date: 2012-12-27 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/patternfillprimitive2d.hxx>
      21             : #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
      22             : #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
      23             : #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
      24             : #include <basegfx/polygon/b2dpolygontools.hxx>
      25             : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      26             : #include <drawinglayer/texture/texture.hxx>
      27             : #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
      28             : 
      29             : //////////////////////////////////////////////////////////////////////////////
      30             : 
      31             : using namespace com::sun::star;
      32             : 
      33             : //////////////////////////////////////////////////////////////////////////////
      34             : 
      35             : namespace drawinglayer
      36             : {
      37             :     namespace primitive2d
      38             :     {
      39           0 :         Primitive2DSequence PatternFillPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
      40             :         {
      41           0 :             Primitive2DSequence aRetval;
      42             : 
      43           0 :             if(getChildren().hasElements())
      44             :             {
      45           0 :                 if(!getReferenceRange().isEmpty() && getReferenceRange().getWidth() > 0.0 && getReferenceRange().getHeight() > 0.0)
      46             :                 {
      47           0 :                     const basegfx::B2DRange aMaskRange(getMask().getB2DRange());
      48             : 
      49           0 :                     if(!aMaskRange.isEmpty() && aMaskRange.getWidth() > 0.0 && aMaskRange.getHeight() > 0.0)
      50             :                     {
      51             :                         // create tiling matrices
      52           0 :                         ::std::vector< basegfx::B2DHomMatrix > aMatrices;
      53           0 :                         texture::GeoTexSvxTiled aTiling(getReferenceRange().getMinimum(), getReferenceRange().getRange());
      54           0 :                         aTiling.appendTransformations(aMatrices);
      55             : 
      56             :                         // check if content needs to be clipped
      57           0 :                         const basegfx::B2DRange aUnitRange(0.0, 0.0, 1.0, 1.0);
      58           0 :                         const basegfx::B2DRange aContentRange(getB2DRangeFromPrimitive2DSequence(getChildren(), rViewInformation));
      59           0 :                         Primitive2DSequence aContent(getChildren());
      60             : 
      61           0 :                         if(!aUnitRange.isInside(aContentRange))
      62             :                         {
      63             :                             const Primitive2DReference xRef(
      64             :                                 new MaskPrimitive2D(
      65             :                                     basegfx::B2DPolyPolygon(basegfx::tools::createPolygonFromRect(aUnitRange)),
      66           0 :                                     aContent));
      67             : 
      68           0 :                             aContent = Primitive2DSequence(&xRef, 1);
      69             :                         }
      70             : 
      71             :                         // resize result
      72           0 :                         aRetval.realloc(aMatrices.size());
      73             : 
      74             :                         // create one primitive for each matrix
      75           0 :                         for(sal_uInt32 a(0); a < aMatrices.size(); a++)
      76             :                         {
      77           0 :                             aRetval[a] = new TransformPrimitive2D(
      78             :                                 aMatrices[a],
      79           0 :                                 aContent);
      80             :                         }
      81             : 
      82             :                         // transform result which is in unit coordinates to mask's object coordiantes
      83             :                         {
      84             :                             const basegfx::B2DHomMatrix aMaskTransform(
      85             :                                 basegfx::tools::createScaleTranslateB2DHomMatrix(
      86             :                                     aMaskRange.getRange(),
      87           0 :                                     aMaskRange.getMinimum()));
      88             : 
      89             :                             const Primitive2DReference xRef(
      90             :                                 new TransformPrimitive2D(
      91             :                                     aMaskTransform,
      92           0 :                                     aRetval));
      93             : 
      94           0 :                             aRetval = Primitive2DSequence(&xRef, 1);
      95             :                         }
      96             : 
      97             :                         // embed result in mask
      98             :                         {
      99             :                             const Primitive2DReference xRef(
     100             :                                 new MaskPrimitive2D(
     101             :                                     getMask(),
     102           0 :                                     aRetval));
     103             : 
     104           0 :                             aRetval = Primitive2DSequence(&xRef, 1);
     105           0 :                         }
     106             : 
     107             :                     }
     108             :                 }
     109             :             }
     110             : 
     111           0 :             return aRetval;
     112             :         }
     113             : 
     114           0 :         PatternFillPrimitive2D::PatternFillPrimitive2D(
     115             :             const basegfx::B2DPolyPolygon& rMask,
     116             :             const Primitive2DSequence& rChildren,
     117             :             const basegfx::B2DRange& rReferenceRange)
     118             :         :   BufferedDecompositionPrimitive2D(),
     119             :             maMask(rMask),
     120             :             maChildren(rChildren),
     121           0 :             maReferenceRange(rReferenceRange)
     122             :         {
     123           0 :         }
     124             : 
     125           0 :         bool PatternFillPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
     126             :         {
     127           0 :             if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
     128             :             {
     129           0 :                 const PatternFillPrimitive2D& rCompare = static_cast< const PatternFillPrimitive2D& >(rPrimitive);
     130             : 
     131           0 :                 return (getMask() == rCompare.getMask()
     132           0 :                     && getChildren() == rCompare.getChildren()
     133           0 :                     && getReferenceRange() == rCompare.getReferenceRange());
     134             :             }
     135             : 
     136           0 :             return false;
     137             :         }
     138             : 
     139           0 :         basegfx::B2DRange PatternFillPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /* rViewInformation */ ) const
     140             :         {
     141           0 :             return getMask().getB2DRange();
     142             :         }
     143             : 
     144             :         // provide unique ID
     145           0 :         ImplPrimitrive2DIDBlock(PatternFillPrimitive2D, PRIMITIVE2D_ID_PATTERNFILLPRIMITIVE2D)
     146             : 
     147             :     } // end of namespace primitive2d
     148             : } // end of namespace drawinglayer
     149             : 
     150             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10