Teach symstore more duplicated DLLs
[LibreOffice.git] / drawinglayer / source / primitive2d / wrongspellprimitive2d.cxx
blobf1271dd13069bfa587fb661ed734174cb992455e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
27 namespace drawinglayer
29 namespace primitive2d
31 void WrongSpellPrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& /*rViewInformation*/) const
33 // ATM this decompose is view-independent, what the original VCL-Display is not. To mimic
34 // the old behaviour here if wanted it is necessary to add get2DDecomposition and implement
35 // it similar to the usage in e.g. HelplinePrimitive2D. Remembering the ViewTransformation
36 // should be enough then.
37 // The view-independent wavelines work well (if You ask me). Maybe the old VCL-Behaviour is only
38 // in place because it was not possible/too expensive at that time to scale the wavelines with the
39 // view...
40 // With the VCL-PixelRenderer this will not even be used since it implements WrongSpellPrimitive2D
41 // directly and mimics the old VCL-Display there. If You implemented a new renderer without
42 // direct WrongSpellPrimitive2D support, You may want to do the described change here.
44 // get the font height (part of scale), so decompose the matrix
45 basegfx::B2DVector aScale, aTranslate;
46 double fRotate, fShearX;
47 getTransformation().decompose(aScale, aTranslate, fRotate, fShearX);
49 // calculate distances based on a static default (to allow testing in debugger)
50 static const double fDefaultDistance(0.03);
51 const double fFontHeight(aScale.getY());
52 const double fUnderlineDistance(fFontHeight * fDefaultDistance);
53 const double fWaveWidth(2.0 * fUnderlineDistance);
55 // the Y-distance needs to be relative to FontHeight since the points get
56 // transformed with the transformation containing that scale already.
57 const double fRelativeUnderlineDistance(basegfx::fTools::equalZero(aScale.getY()) ? 0.0 : fUnderlineDistance / aScale.getY());
58 basegfx::B2DPoint aStart(getStart(), fRelativeUnderlineDistance);
59 basegfx::B2DPoint aStop(getStop(), fRelativeUnderlineDistance);
60 basegfx::B2DPolygon aPolygon;
62 aPolygon.append(getTransformation() * aStart);
63 aPolygon.append(getTransformation() * aStop);
65 // prepare line attribute
66 const attribute::LineAttribute aLineAttribute(getColor());
68 // create the waveline primitive
69 rContainer.push_back(new PolygonWavePrimitive2D(aPolygon, aLineAttribute, fWaveWidth, 0.5 * fWaveWidth));
72 WrongSpellPrimitive2D::WrongSpellPrimitive2D(
73 const basegfx::B2DHomMatrix& rTransformation,
74 double fStart,
75 double fStop,
76 const basegfx::BColor& rColor)
77 : BufferedDecompositionPrimitive2D(),
78 maTransformation(rTransformation),
79 mfStart(fStart),
80 mfStop(fStop),
81 maColor(rColor)
85 bool WrongSpellPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
87 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
89 const WrongSpellPrimitive2D& rCompare = static_cast<const WrongSpellPrimitive2D&>(rPrimitive);
91 return (getTransformation() == rCompare.getTransformation()
92 && getStart() == rCompare.getStart()
93 && getStop() == rCompare.getStop()
94 && getColor() == rCompare.getColor());
97 return false;
100 // provide unique ID
101 ImplPrimitive2DIDBlock(WrongSpellPrimitive2D, PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D)
103 } // end of namespace primitive2d
104 } // end of namespace drawinglayer
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */