Update ooo320-m1
[ooovba.git] / drawinglayer / source / primitive2d / wrongspellprimitive2d.cxx
blob5ac16fe972a08865dd91f9045aee33f6bafdd329
1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: wrongspellprimitive2d.cxx,v $
7 * $Revision: 1.5 $
9 * last change: $Author: aw $ $Date: 2008-05-27 14:11:20 $
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 * MA 02111-1307 USA
34 ************************************************************************/
36 // MARKER(update_precomp.py): autogen include statement, do not remove
37 #include "precompiled_drawinglayer.hxx"
39 #include <drawinglayer/primitive2d/wrongspellprimitive2d.hxx>
40 #include <basegfx/polygon/b2dpolygon.hxx>
41 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
42 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
43 #include <drawinglayer/geometry/viewinformation2d.hxx>
45 //////////////////////////////////////////////////////////////////////////////
47 namespace drawinglayer
49 namespace primitive2d
51 Primitive2DSequence WrongSpellPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
53 // ATM this decompose is view-independent, what the original VCL-Display is not. To mimic
54 // the old behaviour here if wanted it is necessary to add get2DDecomposition and implement
55 // it similar to the usage in e.g. HelplinePrimitive2D. Remembering the ViewTransformation
56 // should be enough then.
57 // The view-independent wavelines work well (if You ask me). Maybe the old VCL-Behaviour is only
58 // in place because it was not possible/too expensive at that time to scale the wavelines with the
59 // view...
60 // With the VCL-PixelRenderer this will not even be used since it implements WrongSpellPrimitive2D
61 // directly and mimics the old VCL-Display there. If You implemented a new renderer without
62 // direct WrongSpellPrimitive2D support, You may want to do the described change here.
64 // get the font height (part of scale), so decompose the matrix
65 basegfx::B2DVector aScale, aTranslate;
66 double fRotate, fShearX;
67 getTransformation().decompose(aScale, aTranslate, fRotate, fShearX);
69 // calculate distances based on a static default (to allow testing in debugger)
70 static double fDefaultDistance(0.03);
71 const double fFontHeight(aScale.getY());
72 const double fUnderlineDistance(fFontHeight * fDefaultDistance);
73 const double fWaveWidth(2.0 * fUnderlineDistance);
75 // the Y-distance needs to be relativated to FontHeight since the points get
76 // transformed with the transformation containing that scale already.
77 const double fRelativeUnderlineDistance(basegfx::fTools::equalZero(aScale.getY()) ? 0.0 : fUnderlineDistance / aScale.getY());
78 basegfx::B2DPoint aStart(getStart(), fRelativeUnderlineDistance);
79 basegfx::B2DPoint aStop(getStop(), fRelativeUnderlineDistance);
80 basegfx::B2DPolygon aPolygon;
82 aPolygon.append(getTransformation() * aStart);
83 aPolygon.append(getTransformation() * aStop);
85 // prepare line attribute
86 const attribute::LineAttribute aLineAttribute(getColor());
88 // create the waveline primitive
89 Primitive2DReference xPrimitive(new PolygonWavePrimitive2D(aPolygon, aLineAttribute, fWaveWidth, 0.5 * fWaveWidth));
90 Primitive2DSequence xRetval(&xPrimitive, 1);
92 return xRetval;
95 WrongSpellPrimitive2D::WrongSpellPrimitive2D(
96 const basegfx::B2DHomMatrix& rTransformation,
97 double fStart,
98 double fStop,
99 const basegfx::BColor& rColor)
100 : BasePrimitive2D(),
101 maTransformation(rTransformation),
102 mfStart(fStart),
103 mfStop(fStop),
104 maColor(rColor)
108 bool WrongSpellPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
110 if(BasePrimitive2D::operator==(rPrimitive))
112 const WrongSpellPrimitive2D& rCompare = (WrongSpellPrimitive2D&)rPrimitive;
114 return (getTransformation() == rCompare.getTransformation()
115 && getStart() == rCompare.getStart()
116 && getStop() == rCompare.getStop()
117 && getColor() == rCompare.getColor());
120 return false;
123 // provide unique ID
124 ImplPrimitrive2DIDBlock(WrongSpellPrimitive2D, PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D)
126 } // end of namespace primitive2d
127 } // end of namespace drawinglayer
129 //////////////////////////////////////////////////////////////////////////////
130 // eof