LCOV - code coverage report
Current view: top level - libreoffice/drawinglayer/source/primitive2d - primitivetools2d.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 7 36 19.4 %
Date: 2012-12-27 Functions: 1 4 25.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/primitivetools2d.hxx>
      21             : #include <basegfx/vector/b2dvector.hxx>
      22             : #include <drawinglayer/geometry/viewinformation2d.hxx>
      23             : 
      24             : //////////////////////////////////////////////////////////////////////////////
      25             : 
      26             : namespace drawinglayer
      27             : {
      28             :     namespace primitive2d
      29             :     {
      30          57 :         Primitive2DSequence DiscreteMetricDependentPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
      31             :         {
      32          57 :             ::osl::MutexGuard aGuard( m_aMutex );
      33             : 
      34             :             // get the current DiscreteUnit
      35          57 :             const double fDiscreteUnit((rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0)).getLength());
      36             : 
      37          57 :             if(getBuffered2DDecomposition().hasElements() && !basegfx::fTools::equal(fDiscreteUnit, getDiscreteUnit()))
      38             :             {
      39             :                 // conditions of last local decomposition have changed, delete
      40           0 :                 const_cast< DiscreteMetricDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence());
      41             :             }
      42             : 
      43          57 :             if(!getBuffered2DDecomposition().hasElements())
      44             :             {
      45             :                 // remember new valid DiscreteUnit
      46          48 :                 const_cast< DiscreteMetricDependentPrimitive2D* >(this)->mfDiscreteUnit = fDiscreteUnit;
      47             :             }
      48             : 
      49             :             // call base implementation
      50          57 :             return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation);
      51             :         }
      52             :     } // end of namespace primitive2d
      53             : } // end of namespace drawinglayer
      54             : 
      55             : //////////////////////////////////////////////////////////////////////////////
      56             : 
      57             : namespace drawinglayer
      58             : {
      59             :     namespace primitive2d
      60             :     {
      61           0 :         Primitive2DSequence ViewportDependentPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
      62             :         {
      63           0 :             ::osl::MutexGuard aGuard( m_aMutex );
      64             : 
      65             :             // get the current Viewport
      66           0 :             const basegfx::B2DRange& rViewport = rViewInformation.getViewport();
      67             : 
      68           0 :             if(getBuffered2DDecomposition().hasElements() && !rViewport.equal(getViewport()))
      69             :             {
      70             :                 // conditions of last local decomposition have changed, delete
      71           0 :                 const_cast< ViewportDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence());
      72             :             }
      73             : 
      74           0 :             if(!getBuffered2DDecomposition().hasElements())
      75             :             {
      76             :                 // remember new valid DiscreteUnit
      77           0 :                 const_cast< ViewportDependentPrimitive2D* >(this)->maViewport = rViewport;
      78             :             }
      79             : 
      80             :             // call base implementation
      81           0 :             return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation);
      82             :         }
      83             :     } // end of namespace primitive2d
      84             : } // end of namespace drawinglayer
      85             : 
      86             : //////////////////////////////////////////////////////////////////////////////
      87             : 
      88             : namespace drawinglayer
      89             : {
      90             :     namespace primitive2d
      91             :     {
      92           0 :         Primitive2DSequence ViewTransformationDependentPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
      93             :         {
      94           0 :             ::osl::MutexGuard aGuard( m_aMutex );
      95             : 
      96             :             // get the current ViewTransformation
      97           0 :             const basegfx::B2DHomMatrix& rViewTransformation = rViewInformation.getViewTransformation();
      98             : 
      99           0 :             if(getBuffered2DDecomposition().hasElements() && rViewTransformation != getViewTransformation())
     100             :             {
     101             :                 // conditions of last local decomposition have changed, delete
     102           0 :                 const_cast< ViewTransformationDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence());
     103             :             }
     104             : 
     105           0 :             if(!getBuffered2DDecomposition().hasElements())
     106             :             {
     107             :                 // remember new valid ViewTransformation
     108           0 :                 const_cast< ViewTransformationDependentPrimitive2D* >(this)->maViewTransformation = rViewTransformation;
     109             :             }
     110             : 
     111             :             // call base implementation
     112           0 :             return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation);
     113             :         }
     114             :     } // end of namespace primitive2d
     115             : } // end of namespace drawinglayer
     116             : 
     117             : //////////////////////////////////////////////////////////////////////////////
     118             : 
     119             : namespace drawinglayer
     120             : {
     121             :     namespace primitive2d
     122             :     {
     123           0 :         Primitive2DSequence ObjectAndViewTransformationDependentPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
     124             :         {
     125           0 :             ::osl::MutexGuard aGuard( m_aMutex );
     126             : 
     127             :             // get the current ViewTransfromation
     128           0 :             const basegfx::B2DHomMatrix& rViewTransformation = rViewInformation.getViewTransformation();
     129             : 
     130           0 :             if(getBuffered2DDecomposition().hasElements() && rViewTransformation != getViewTransformation())
     131             :             {
     132             :                 // conditions of last local decomposition have changed, delete
     133           0 :                 const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence());
     134             :             }
     135             : 
     136             :             // get the current ObjectTransformation
     137           0 :             const basegfx::B2DHomMatrix& rObjectTransformation = rViewInformation.getObjectTransformation();
     138             : 
     139           0 :             if(getBuffered2DDecomposition().hasElements() && rObjectTransformation != getObjectTransformation())
     140             :             {
     141             :                 // conditions of last local decomposition have changed, delete
     142           0 :                 const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence());
     143             :             }
     144             : 
     145           0 :             if(!getBuffered2DDecomposition().hasElements())
     146             :             {
     147             :                 // remember new valid ViewTransformation, and ObjectTransformation
     148           0 :                 const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->maViewTransformation = rViewTransformation;
     149           0 :                 const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->maObjectTransformation = rObjectTransformation;
     150             :             }
     151             : 
     152             :             // call base implementation
     153           0 :             return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation);
     154             :         }
     155             :     } // end of namespace primitive2d
     156             : } // end of namespace drawinglayer
     157             : 
     158             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10