LCOV - code coverage report
Current view: top level - sw/source/core/layout - fillattributes.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 48 0.0 %
Date: 2014-04-14 Functions: 0 10 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 <fillattributes.hxx>
      21             : #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
      22             : #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
      23             : #include <basegfx/polygon/b2dpolygontools.hxx>
      24             : #include <basegfx/matrix/b2dhommatrix.hxx>
      25             : #include <basegfx/polygon/b2dpolygon.hxx>
      26             : #include <drawinglayer/attribute/fillhatchattribute.hxx>
      27             : #include <drawinglayer/attribute/sdrfillgraphicattribute.hxx>
      28             : #include <svx/xfillit0.hxx>
      29             : #include <tools/color.hxx>
      30             : #include <vcl/graph.hxx>
      31             : 
      32           0 : void FillAttributes::createPrimitive2DSequence(
      33             :     const basegfx::B2DRange& rPaintRange,
      34             :     const basegfx::B2DRange& rDefineRange)
      35             : {
      36             :     // reset and remember new target range for object geometry
      37           0 :     maLastPaintRange = rPaintRange;
      38           0 :     maLastDefineRange = rDefineRange;
      39             : 
      40           0 :     if(isUsed())
      41             :     {
      42           0 :         maPrimitives.realloc(1);
      43           0 :         maPrimitives[0] = drawinglayer::primitive2d::createPolyPolygonFillPrimitive(
      44             :             basegfx::B2DPolyPolygon(
      45             :                 basegfx::tools::createPolygonFromRect(
      46             :                     maLastPaintRange)),
      47             :                 maLastDefineRange,
      48           0 :             maFillAttribute.get() ? *maFillAttribute.get() : drawinglayer::attribute::SdrFillAttribute(),
      49           0 :             maFillGradientAttribute.get() ? *maFillGradientAttribute.get() : drawinglayer::attribute::FillGradientAttribute());
      50             :     }
      51           0 : }
      52             : 
      53           0 : FillAttributes::FillAttributes()
      54             : :   maLastPaintRange(),
      55             :     maLastDefineRange(),
      56             :     maFillAttribute(),
      57             :     maFillGradientAttribute(),
      58           0 :     maPrimitives()
      59             : {
      60           0 : }
      61             : 
      62           0 : FillAttributes::FillAttributes(const Color& rColor)
      63             : :   maLastPaintRange(),
      64             :     maLastDefineRange(),
      65             :     maFillAttribute(),
      66             :     maFillGradientAttribute(),
      67           0 :     maPrimitives()
      68             : {
      69             :     maFillAttribute.reset(
      70             :         new drawinglayer::attribute::SdrFillAttribute(
      71             :             0.0,
      72             :             Color(rColor.GetRGBColor()).getBColor(),
      73             :             drawinglayer::attribute::FillGradientAttribute(),
      74             :             drawinglayer::attribute::FillHatchAttribute(),
      75           0 :             drawinglayer::attribute::SdrFillGraphicAttribute()));
      76           0 : }
      77             : 
      78           0 : FillAttributes::FillAttributes(const SfxItemSet& rSet)
      79             : :   maLastPaintRange(),
      80             :     maLastDefineRange(),
      81             :     maFillAttribute(
      82             :         new drawinglayer::attribute::SdrFillAttribute(
      83           0 :             drawinglayer::primitive2d::createNewSdrFillAttribute(rSet))),
      84             :     maFillGradientAttribute(
      85             :         new drawinglayer::attribute::FillGradientAttribute(
      86           0 :             drawinglayer::primitive2d::createNewTransparenceGradientAttribute(rSet))),
      87           0 :     maPrimitives()
      88             : {
      89           0 : }
      90             : 
      91           0 : FillAttributes::~FillAttributes()
      92             : {
      93           0 : }
      94             : 
      95           0 : bool FillAttributes::isUsed() const
      96             : {
      97             :     // only depends on fill, FillGradientAttribute alone defines no fill
      98           0 :     return maFillAttribute.get() && !maFillAttribute->isDefault();
      99             : }
     100             : 
     101           0 : bool FillAttributes::isTransparent() const
     102             : {
     103           0 :     if(hasSdrFillAttribute() && 0.0 != maFillAttribute->getTransparence())
     104             :     {
     105           0 :         return true;
     106             :     }
     107             : 
     108           0 :     if(hasFillGradientAttribute() && !maFillGradientAttribute->isDefault())
     109             :     {
     110           0 :         return true;
     111             :     }
     112             : 
     113           0 :     if(hasSdrFillAttribute())
     114             :     {
     115           0 :         const Graphic& rGraphic = getFillAttribute().getFillGraphic().getFillGraphic();
     116             : 
     117           0 :         return rGraphic.IsSupportedGraphic() && rGraphic.IsTransparent();
     118             :     }
     119             : 
     120           0 :     return false;
     121             : }
     122             : 
     123           0 : const drawinglayer::attribute::SdrFillAttribute& FillAttributes::getFillAttribute() const
     124             : {
     125           0 :     if(!maFillAttribute.get())
     126             :     {
     127           0 :         const_cast< FillAttributes* >(this)->maFillAttribute.reset(new drawinglayer::attribute::SdrFillAttribute());
     128             :     }
     129             : 
     130           0 :     return *maFillAttribute.get();
     131             : }
     132             : 
     133           0 : const drawinglayer::attribute::FillGradientAttribute& FillAttributes::getFillGradientAttribute() const
     134             : {
     135           0 :     if(!maFillGradientAttribute.get())
     136             :     {
     137           0 :         const_cast< FillAttributes* >(this)->maFillGradientAttribute.reset(new drawinglayer::attribute::FillGradientAttribute());
     138             :     }
     139             : 
     140           0 :     return *maFillGradientAttribute.get();
     141             : }
     142             : 
     143           0 : const drawinglayer::primitive2d::Primitive2DSequence& FillAttributes::getPrimitive2DSequence(
     144             :     const basegfx::B2DRange& rPaintRange,
     145             :     const basegfx::B2DRange& rDefineRange) const
     146             : {
     147           0 :     if(maPrimitives.getLength() && (maLastPaintRange != rPaintRange || maLastDefineRange != rDefineRange))
     148             :     {
     149           0 :         const_cast< FillAttributes* >(this)->maPrimitives.realloc(0);
     150             :     }
     151             : 
     152           0 :     if(!maPrimitives.getLength())
     153             :     {
     154           0 :         const_cast< FillAttributes* >(this)->createPrimitive2DSequence(rPaintRange, rDefineRange);
     155             :     }
     156             : 
     157           0 :     return maPrimitives;
     158             : }
     159             : 
     160             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10