LCOV - code coverage report
Current view: top level - drawinglayer/source/primitive2d - discretebitmapprimitive2d.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 30 0.0 %
Date: 2014-04-14 Functions: 0 4 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/discretebitmapprimitive2d.hxx>
      21             : #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
      22             : #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
      23             : 
      24             : 
      25             : 
      26             : namespace drawinglayer
      27             : {
      28             :     namespace primitive2d
      29             :     {
      30           0 :         Primitive2DSequence DiscreteBitmapPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
      31             :         {
      32             :             // use getViewTransformation() and getObjectTransformation() from
      33             :             // ObjectAndViewTransformationDependentPrimitive2D to create a BitmapPrimitive2D
      34             :             // with the correct mapping
      35           0 :             Primitive2DSequence xRetval;
      36             : 
      37           0 :             if(!getBitmapEx().IsEmpty())
      38             :             {
      39             :                 // get discrete size
      40           0 :                 const Size& rSizePixel = getBitmapEx().GetSizePixel();
      41           0 :                 const basegfx::B2DVector aDiscreteSize(rSizePixel.Width(), rSizePixel.Height());
      42             : 
      43             :                 // get inverse ViewTransformation
      44           0 :                 basegfx::B2DHomMatrix aInverseViewTransformation(getViewTransformation());
      45           0 :                 aInverseViewTransformation.invert();
      46             : 
      47             :                 // get size and position in world coordinates
      48           0 :                 const basegfx::B2DVector aWorldSize(aInverseViewTransformation * aDiscreteSize);
      49           0 :                 const basegfx::B2DPoint  aWorldTopLeft(getObjectTransformation() * getTopLeft());
      50             : 
      51             :                 // build object matrix in world coordinates so that the top-left
      52             :                 // position remains, but eventual transformations (e.g. rotations)
      53             :                 // in the ObjectToView stack remain and get correctly applied
      54           0 :                 basegfx::B2DHomMatrix aObjectTransform;
      55             : 
      56           0 :                 aObjectTransform.set(0, 0, aWorldSize.getX());
      57           0 :                 aObjectTransform.set(1, 1, aWorldSize.getY());
      58           0 :                 aObjectTransform.set(0, 2, aWorldTopLeft.getX());
      59           0 :                 aObjectTransform.set(1, 2, aWorldTopLeft.getY());
      60             : 
      61             :                 // get inverse ObjectTransformation
      62           0 :                 basegfx::B2DHomMatrix aInverseObjectTransformation(getObjectTransformation());
      63           0 :                 aInverseObjectTransformation.invert();
      64             : 
      65             :                 // transform to object coordinate system
      66           0 :                 aObjectTransform = aInverseObjectTransformation * aObjectTransform;
      67             : 
      68             :                 // create BitmapPrimitive2D with now object-local coordinate data
      69           0 :                 const Primitive2DReference xRef(new BitmapPrimitive2D(getBitmapEx(), aObjectTransform));
      70           0 :                 xRetval = Primitive2DSequence(&xRef, 1);
      71             :             }
      72             : 
      73           0 :             return xRetval;
      74             :         }
      75             : 
      76           0 :         DiscreteBitmapPrimitive2D::DiscreteBitmapPrimitive2D(
      77             :             const BitmapEx& rBitmapEx,
      78             :             const basegfx::B2DPoint& rTopLeft)
      79             :         :   ObjectAndViewTransformationDependentPrimitive2D(),
      80             :             maBitmapEx(rBitmapEx),
      81           0 :             maTopLeft(rTopLeft)
      82             :         {
      83           0 :         }
      84             : 
      85           0 :         bool DiscreteBitmapPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
      86             :         {
      87           0 :             if(ObjectAndViewTransformationDependentPrimitive2D::operator==(rPrimitive))
      88             :             {
      89           0 :                 const DiscreteBitmapPrimitive2D& rCompare = (DiscreteBitmapPrimitive2D&)rPrimitive;
      90             : 
      91           0 :                 return (getBitmapEx() == rCompare.getBitmapEx()
      92           0 :                     && getTopLeft() == rCompare.getTopLeft());
      93             :             }
      94             : 
      95           0 :             return false;
      96             :         }
      97             : 
      98             :         // provide unique ID
      99           0 :         ImplPrimitive2DIDBlock(DiscreteBitmapPrimitive2D, PRIMITIVE2D_ID_DISCRETEBITMAPPRIMITIVE2D)
     100             : 
     101             :     } // end of namespace primitive2d
     102             : } // end of namespace drawinglayer
     103             : 
     104             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10