LCOV - code coverage report
Current view: top level - drawinglayer/source/primitive2d - wrongspellprimitive2d.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 28 0.0 %
Date: 2014-11-03 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/wrongspellprimitive2d.hxx>
      21             : #include <basegfx/polygon/b2dpolygon.hxx>
      22             : #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
      23             : #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
      24             : #include <drawinglayer/geometry/viewinformation2d.hxx>
      25             : 
      26             : 
      27             : 
      28             : namespace drawinglayer
      29             : {
      30             :     namespace primitive2d
      31             :     {
      32           0 :         Primitive2DSequence WrongSpellPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
      33             :         {
      34             :             // ATM this decompose is view-independent, what the original VCL-Display is not. To mimic
      35             :             // the old behaviour here if wanted it is necessary to add get2DDecomposition and implement
      36             :             // it similar to the usage in e.g. HelplinePrimitive2D. Remembering the ViewTransformation
      37             :             // should be enough then.
      38             :             // The view-independent wavelines work well (if You ask me). Maybe the old VCL-Behaviour is only
      39             :             // in place because it was not possible/too expensive at that time to scale the wavelines with the
      40             :             // view...
      41             :             // With the VCL-PixelRenderer this will not even be used since it implements WrongSpellPrimitive2D
      42             :             // directly and mimics the old VCL-Display there. If You implemented a new renderer without
      43             :             // direct WrongSpellPrimitive2D support, You may want to do the described change here.
      44             : 
      45             :             // get the font height (part of scale), so decompose the matrix
      46           0 :             basegfx::B2DVector aScale, aTranslate;
      47             :             double fRotate, fShearX;
      48           0 :             getTransformation().decompose(aScale, aTranslate, fRotate, fShearX);
      49             : 
      50             :             // calculate distances based on a static default (to allow testing in debugger)
      51             :             static double fDefaultDistance(0.03);
      52           0 :             const double fFontHeight(aScale.getY());
      53           0 :             const double fUnderlineDistance(fFontHeight * fDefaultDistance);
      54           0 :             const double fWaveWidth(2.0 * fUnderlineDistance);
      55             : 
      56             :             // the Y-distance needs to be relativated to FontHeight since the points get
      57             :             // transformed with the transformation containing that scale already.
      58           0 :             const double fRelativeUnderlineDistance(basegfx::fTools::equalZero(aScale.getY()) ? 0.0 : fUnderlineDistance / aScale.getY());
      59           0 :             basegfx::B2DPoint aStart(getStart(), fRelativeUnderlineDistance);
      60           0 :             basegfx::B2DPoint aStop(getStop(), fRelativeUnderlineDistance);
      61           0 :             basegfx::B2DPolygon aPolygon;
      62             : 
      63           0 :             aPolygon.append(getTransformation() * aStart);
      64           0 :             aPolygon.append(getTransformation() * aStop);
      65             : 
      66             :             // prepare line attribute
      67           0 :             const attribute::LineAttribute aLineAttribute(getColor());
      68             : 
      69             :             // create the waveline primitive
      70           0 :             Primitive2DReference xPrimitive(new PolygonWavePrimitive2D(aPolygon, aLineAttribute, fWaveWidth, 0.5 * fWaveWidth));
      71           0 :             Primitive2DSequence xRetval(&xPrimitive, 1);
      72             : 
      73           0 :             return xRetval;
      74             :         }
      75             : 
      76           0 :         WrongSpellPrimitive2D::WrongSpellPrimitive2D(
      77             :             const basegfx::B2DHomMatrix& rTransformation,
      78             :             double fStart,
      79             :             double fStop,
      80             :             const basegfx::BColor& rColor)
      81             :         :   BufferedDecompositionPrimitive2D(),
      82             :             maTransformation(rTransformation),
      83             :             mfStart(fStart),
      84             :             mfStop(fStop),
      85           0 :             maColor(rColor)
      86             :         {
      87           0 :         }
      88             : 
      89           0 :         bool WrongSpellPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
      90             :         {
      91           0 :             if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
      92             :             {
      93           0 :                 const WrongSpellPrimitive2D& rCompare = static_cast<const WrongSpellPrimitive2D&>(rPrimitive);
      94             : 
      95           0 :                 return (getTransformation() == rCompare.getTransformation()
      96           0 :                     && getStart() == rCompare.getStart()
      97           0 :                     && getStop() == rCompare.getStop()
      98           0 :                     && getColor() == rCompare.getColor());
      99             :             }
     100             : 
     101           0 :             return false;
     102             :         }
     103             : 
     104             :         // provide unique ID
     105           0 :         ImplPrimitive2DIDBlock(WrongSpellPrimitive2D, PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D)
     106             : 
     107             :     } // end of namespace primitive2d
     108             : } // end of namespace drawinglayer
     109             : 
     110             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10