LCOV - code coverage report
Current view: top level - drawinglayer/source/primitive2d - patternfillprimitive2d.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 39 0.0 %
Date: 2015-06-13 12:38:46 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());
      54             : 
      55           0 :                         aTiling.appendTransformations(aMatrices);
      56             : 
      57             :                         // check if content needs to be clipped
      58           0 :                         const basegfx::B2DRange aUnitRange(0.0, 0.0, 1.0, 1.0);
      59           0 :                         const basegfx::B2DRange aContentRange(getB2DRangeFromPrimitive2DSequence(getChildren(), rViewInformation));
      60           0 :                         Primitive2DSequence aContent(getChildren());
      61             : 
      62           0 :                         if(!aUnitRange.isInside(aContentRange))
      63             :                         {
      64             :                             const Primitive2DReference xRef(
      65             :                                 new MaskPrimitive2D(
      66             :                                     basegfx::B2DPolyPolygon(basegfx::tools::createPolygonFromRect(aUnitRange)),
      67           0 :                                     aContent));
      68             : 
      69           0 :                             aContent = Primitive2DSequence(&xRef, 1);
      70             :                         }
      71             : 
      72             :                         // resize result
      73           0 :                         aRetval.realloc(aMatrices.size());
      74             : 
      75             :                         // create one primitive for each matrix
      76           0 :                         for(size_t a(0); a < aMatrices.size(); a++)
      77             :                         {
      78           0 :                             aRetval[a] = new TransformPrimitive2D(
      79             :                                 aMatrices[a],
      80           0 :                                 aContent);
      81             :                         }
      82             : 
      83             :                         // transform result which is in unit coordinates to mask's object coordiantes
      84             :                         {
      85             :                             const basegfx::B2DHomMatrix aMaskTransform(
      86             :                                 basegfx::tools::createScaleTranslateB2DHomMatrix(
      87             :                                     aMaskRange.getRange(),
      88           0 :                                     aMaskRange.getMinimum()));
      89             : 
      90             :                             const Primitive2DReference xRef(
      91             :                                 new TransformPrimitive2D(
      92             :                                     aMaskTransform,
      93           0 :                                     aRetval));
      94             : 
      95           0 :                             aRetval = Primitive2DSequence(&xRef, 1);
      96             :                         }
      97             : 
      98             :                         // embed result in mask
      99             :                         {
     100             :                             const Primitive2DReference xRef(
     101             :                                 new MaskPrimitive2D(
     102             :                                     getMask(),
     103           0 :                                     aRetval));
     104             : 
     105           0 :                             aRetval = Primitive2DSequence(&xRef, 1);
     106           0 :                         }
     107             : 
     108             :                     }
     109             :                 }
     110             :             }
     111             : 
     112           0 :             return aRetval;
     113             :         }
     114             : 
     115           0 :         PatternFillPrimitive2D::PatternFillPrimitive2D(
     116             :             const basegfx::B2DPolyPolygon& rMask,
     117             :             const Primitive2DSequence& rChildren,
     118             :             const basegfx::B2DRange& rReferenceRange)
     119             :         :   BufferedDecompositionPrimitive2D(),
     120             :             maMask(rMask),
     121             :             maChildren(rChildren),
     122           0 :             maReferenceRange(rReferenceRange)
     123             :         {
     124           0 :         }
     125             : 
     126           0 :         bool PatternFillPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
     127             :         {
     128           0 :             if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
     129             :             {
     130           0 :                 const PatternFillPrimitive2D& rCompare = static_cast< const PatternFillPrimitive2D& >(rPrimitive);
     131             : 
     132           0 :                 return (getMask() == rCompare.getMask()
     133           0 :                     && getChildren() == rCompare.getChildren()
     134           0 :                     && getReferenceRange() == rCompare.getReferenceRange());
     135             :             }
     136             : 
     137           0 :             return false;
     138             :         }
     139             : 
     140           0 :         basegfx::B2DRange PatternFillPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /* rViewInformation */ ) const
     141             :         {
     142           0 :             return getMask().getB2DRange();
     143             :         }
     144             : 
     145             :         // provide unique ID
     146           0 :         ImplPrimitive2DIDBlock(PatternFillPrimitive2D, PRIMITIVE2D_ID_PATTERNFILLPRIMITIVE2D)
     147             : 
     148             :     } // end of namespace primitive2d
     149             : } // end of namespace drawinglayer
     150             : 
     151             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11