1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: helperwrongspellrenderer.cxx,v $
9 * last change: $Author: aw $ $Date: 2008/09/24 14:28:52 $
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,
34 ************************************************************************/
36 // MARKER(update_precomp.py): autogen include statement, do not remove
37 #include "precompiled_drawinglayer.hxx"
39 #include <helperwrongspellrenderer.hxx>
40 #include <drawinglayer/primitive2d/wrongspellprimitive2d.hxx>
41 #include <tools/gen.hxx>
42 #include <vcl/outdev.hxx>
43 #include <basegfx/color/bcolormodifier.hxx>
45 //////////////////////////////////////////////////////////////////////////////
47 using namespace com::sun::star
;
49 //////////////////////////////////////////////////////////////////////////////
51 namespace drawinglayer
53 bool renderWrongSpellPrimitive2D(
54 const primitive2d::WrongSpellPrimitive2D
& rWrongSpellCandidate
,
55 OutputDevice
& rOutputDevice
,
56 const basegfx::B2DHomMatrix
& rObjectToViewTransformation
,
57 const basegfx::BColorModifierStack
& rBColorModifierStack
)
59 const basegfx::B2DHomMatrix
aLocalTransform(rObjectToViewTransformation
* rWrongSpellCandidate
.getTransformation());
60 const basegfx::B2DVector
aFontVectorPixel(aLocalTransform
* basegfx::B2DVector(0.0, 1.0));
61 const sal_uInt32
nFontPixelHeight(basegfx::fround(aFontVectorPixel
.getLength()));
63 static const sal_uInt32
nMinimumFontHeight(5); // #define WRONG_SHOW_MIN 5
64 static const sal_uInt32
nSmallFontHeight(11); // #define WRONG_SHOW_SMALL 11
65 static const sal_uInt32
nMediumFontHeight(15); // #define WRONG_SHOW_MEDIUM 15
67 if(nFontPixelHeight
> nMinimumFontHeight
)
69 const basegfx::B2DPoint
aStart(aLocalTransform
* basegfx::B2DPoint(rWrongSpellCandidate
.getStart(), 0.0));
70 const basegfx::B2DPoint
aStop(aLocalTransform
* basegfx::B2DPoint(rWrongSpellCandidate
.getStop(), 0.0));
71 const Point
aVclStart(basegfx::fround(aStart
.getX()), basegfx::fround(aStart
.getY()));
72 const Point
aVclStop(basegfx::fround(aStop
.getX()), basegfx::fround(aStop
.getY()));
73 sal_uInt16
nWaveStyle(WAVE_FLAT
);
75 if(nFontPixelHeight
> nMediumFontHeight
)
77 nWaveStyle
= WAVE_NORMAL
;
79 else if(nFontPixelHeight
> nSmallFontHeight
)
81 nWaveStyle
= WAVE_SMALL
;
84 // #i101075# draw it. Do not forget to use the evtl. offsetted origin of the target device,
85 // e.g. when used with mask/transparence buffer device
86 const Point
aOrigin(rOutputDevice
.GetMapMode().GetOrigin());
88 const basegfx::BColor
aProcessedColor(rBColorModifierStack
.getModifiedColor(rWrongSpellCandidate
.getColor()));
89 const bool bMapModeEnabledState(rOutputDevice
.IsMapModeEnabled());
91 rOutputDevice
.EnableMapMode(false);
92 rOutputDevice
.SetLineColor(Color(aProcessedColor
));
93 rOutputDevice
.SetFillColor();
94 rOutputDevice
.DrawWaveLine(aOrigin
+ aVclStart
, aOrigin
+ aVclStop
, nWaveStyle
);
95 rOutputDevice
.EnableMapMode(bMapModeEnabledState
);
98 // cannot really go wrong
101 } // end of namespace drawinglayer
103 //////////////////////////////////////////////////////////////////////////////