LCOV - code coverage report
Current view: top level - drawinglayer/source/primitive2d - mediaprimitive2d.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 52 0.0 %
Date: 2012-08-25 Functions: 0 5 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 158 0.0 %

           Branch data     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/mediaprimitive2d.hxx>
      21                 :            : #include <basegfx/polygon/b2dpolygon.hxx>
      22                 :            : #include <basegfx/polygon/b2dpolygontools.hxx>
      23                 :            : #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
      24                 :            : #include <svtools/grfmgr.hxx>
      25                 :            : #include <drawinglayer/primitive2d/graphicprimitive2d.hxx>
      26                 :            : #include <drawinglayer/geometry/viewinformation2d.hxx>
      27                 :            : #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
      28                 :            : #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
      29                 :            : #include <drawinglayer/primitive2d/hiddengeometryprimitive2d.hxx>
      30                 :            : 
      31                 :            : //////////////////////////////////////////////////////////////////////////////
      32                 :            : 
      33                 :            : namespace drawinglayer
      34                 :            : {
      35                 :            :     namespace primitive2d
      36                 :            :     {
      37                 :          0 :         Primitive2DSequence MediaPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
      38                 :            :         {
      39         [ #  # ]:          0 :             Primitive2DSequence xRetval(1);
      40                 :            : 
      41                 :            :             // create background object
      42         [ #  # ]:          0 :             basegfx::B2DPolygon aBackgroundPolygon(basegfx::tools::createUnitPolygon());
      43         [ #  # ]:          0 :             aBackgroundPolygon.transform(getTransform());
      44                 :            :             const Primitive2DReference xRefBackground(
      45                 :            :                 new PolyPolygonColorPrimitive2D(
      46                 :            :                     basegfx::B2DPolyPolygon(aBackgroundPolygon),
      47 [ #  # ][ #  # ]:          0 :                     getBackgroundColor()));
         [ #  # ][ #  # ]
                 [ #  # ]
      48 [ #  # ][ #  # ]:          0 :             xRetval[0] = xRefBackground;
      49                 :            : 
      50 [ #  # ][ #  # ]:          0 :             if(GRAPHIC_BITMAP == maSnapshot.GetType() || GRAPHIC_GDIMETAFILE == maSnapshot.GetType())
         [ #  # ][ #  # ]
                 [ #  # ]
      51                 :            :             {
      52         [ #  # ]:          0 :                 const GraphicObject aGraphicObject(maSnapshot);
      53         [ #  # ]:          0 :                 const GraphicAttr aGraphicAttr;
      54         [ #  # ]:          0 :                 xRetval.realloc(2);
      55 [ #  # ][ #  # ]:          0 :                 xRetval[0] = xRefBackground;
      56 [ #  # ][ #  # ]:          0 :                 xRetval[1] = Primitive2DReference(new GraphicPrimitive2D(getTransform(), aGraphicObject, aGraphicAttr));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      57                 :            :             }
      58                 :            : 
      59         [ #  # ]:          0 :             if(getDiscreteBorder())
      60                 :            :             {
      61         [ #  # ]:          0 :                 const basegfx::B2DVector aDiscreteInLogic(rViewInformation.getInverseObjectToViewTransformation() *
      62         [ #  # ]:          0 :                     basegfx::B2DVector((double)getDiscreteBorder(), (double)getDiscreteBorder()));
      63                 :          0 :                 const double fDiscreteSize(aDiscreteInLogic.getX() + aDiscreteInLogic.getY());
      64                 :            : 
      65         [ #  # ]:          0 :                 basegfx::B2DRange aSourceRange(0.0, 0.0, 1.0, 1.0);
      66         [ #  # ]:          0 :                 aSourceRange.transform(getTransform());
      67                 :            : 
      68                 :          0 :                 basegfx::B2DRange aDestRange(aSourceRange);
      69         [ #  # ]:          0 :                 aDestRange.grow(-0.5 * fDiscreteSize);
      70                 :            : 
      71 [ #  # ][ #  # ]:          0 :                 if(basegfx::fTools::equalZero(aDestRange.getWidth()) || basegfx::fTools::equalZero(aDestRange.getHeight()))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
                   #  # ]
      72                 :            :                 {
      73                 :            :                     // shrunk primitive has no content (zero size in X or Y), nothing to display. Still create
      74                 :            :                     // invisible content for HitTest and BoundRect
      75 [ #  # ][ #  # ]:          0 :                     const Primitive2DReference xHiddenLines(new HiddenGeometryPrimitive2D(xRetval));
                 [ #  # ]
      76                 :            : 
      77 [ #  # ][ #  # ]:          0 :                     xRetval = Primitive2DSequence(&xHiddenLines, 1);
                 [ #  # ]
      78                 :            :                 }
      79                 :            :                 else
      80                 :            :                 {
      81                 :            :                     // create transformation matrix from original range to shrunk range
      82         [ #  # ]:          0 :                     basegfx::B2DHomMatrix aTransform;
      83 [ #  # ][ #  # ]:          0 :                     aTransform.translate(-aSourceRange.getMinX(), -aSourceRange.getMinY());
                 [ #  # ]
      84 [ #  # ][ #  # ]:          0 :                     aTransform.scale(aDestRange.getWidth() / aSourceRange.getWidth(), aDestRange.getHeight() / aSourceRange.getHeight());
         [ #  # ][ #  # ]
                 [ #  # ]
      85 [ #  # ][ #  # ]:          0 :                     aTransform.translate(aDestRange.getMinX(), aDestRange.getMinY());
                 [ #  # ]
      86                 :            : 
      87                 :            :                     // add transform primitive
      88 [ #  # ][ #  # ]:          0 :                     const Primitive2DReference aScaled(new TransformPrimitive2D(aTransform, xRetval));
                 [ #  # ]
      89 [ #  # ][ #  # ]:          0 :                     xRetval = Primitive2DSequence(&aScaled, 1L);
         [ #  # ][ #  # ]
      90                 :          0 :                 }
      91                 :            :             }
      92                 :            : 
      93         [ #  # ]:          0 :             return xRetval;
      94                 :            :         }
      95                 :            : 
      96                 :          0 :         MediaPrimitive2D::MediaPrimitive2D(
      97                 :            :             const basegfx::B2DHomMatrix& rTransform,
      98                 :            :             const rtl::OUString& rURL,
      99                 :            :             const basegfx::BColor& rBackgroundColor,
     100                 :            :             sal_uInt32 nDiscreteBorder,
     101                 :            :             const Graphic &rSnapshot)
     102                 :            :         :   BufferedDecompositionPrimitive2D(),
     103                 :            :             maTransform(rTransform),
     104                 :            :             maURL(rURL),
     105                 :            :             maBackgroundColor(rBackgroundColor),
     106                 :            :             mnDiscreteBorder(nDiscreteBorder),
     107 [ #  # ][ #  # ]:          0 :             maSnapshot(rSnapshot)
     108                 :            :         {
     109                 :          0 :         }
     110                 :            : 
     111                 :          0 :         bool MediaPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
     112                 :            :         {
     113         [ #  # ]:          0 :             if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
     114                 :            :             {
     115                 :          0 :                 const MediaPrimitive2D& rCompare = (MediaPrimitive2D&)rPrimitive;
     116                 :            : 
     117                 :          0 :                 return (getTransform() == rCompare.getTransform()
     118                 :          0 :                     && getURL() == rCompare.getURL()
     119                 :          0 :                     && getBackgroundColor() == rCompare.getBackgroundColor()
     120 [ #  # ][ #  #  :          0 :                     && getDiscreteBorder() == rCompare.getDiscreteBorder());
             #  #  #  # ]
     121                 :            :             }
     122                 :            : 
     123                 :          0 :             return false;
     124                 :            :         }
     125                 :            : 
     126                 :          0 :         basegfx::B2DRange MediaPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const
     127                 :            :         {
     128                 :          0 :             basegfx::B2DRange aRetval(0.0, 0.0, 1.0, 1.0);
     129                 :          0 :             aRetval.transform(getTransform());
     130                 :            : 
     131         [ #  # ]:          0 :             if(getDiscreteBorder())
     132                 :            :             {
     133         [ #  # ]:          0 :                 const basegfx::B2DVector aDiscreteInLogic(rViewInformation.getInverseObjectToViewTransformation() *
     134         [ #  # ]:          0 :                     basegfx::B2DVector((double)getDiscreteBorder(), (double)getDiscreteBorder()));
     135                 :          0 :                 const double fDiscreteSize(aDiscreteInLogic.getX() + aDiscreteInLogic.getY());
     136                 :            : 
     137         [ #  # ]:          0 :                 aRetval.grow(-0.5 * fDiscreteSize);
     138                 :            :             }
     139                 :            : 
     140                 :          0 :             return aRetval;
     141                 :            :         }
     142                 :            : 
     143                 :            :         // provide unique ID
     144                 :          0 :         ImplPrimitrive2DIDBlock(MediaPrimitive2D, PRIMITIVE2D_ID_MEDIAPRIMITIVE2D)
     145                 :            : 
     146                 :            :     } // end of namespace primitive2d
     147                 :            : } // end of namespace drawinglayer
     148                 :            : 
     149                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10