xref: /AOO41X/main/drawinglayer/source/processor2d/helperwrongspellrenderer.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_drawinglayer.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <helperwrongspellrenderer.hxx>
32*cdf0e10cSrcweir #include <drawinglayer/primitive2d/wrongspellprimitive2d.hxx>
33*cdf0e10cSrcweir #include <tools/gen.hxx>
34*cdf0e10cSrcweir #include <vcl/outdev.hxx>
35*cdf0e10cSrcweir #include <basegfx/color/bcolormodifier.hxx>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir using namespace com::sun::star;
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir namespace drawinglayer
44*cdf0e10cSrcweir {
45*cdf0e10cSrcweir 	bool renderWrongSpellPrimitive2D(
46*cdf0e10cSrcweir 		const primitive2d::WrongSpellPrimitive2D& rWrongSpellCandidate,
47*cdf0e10cSrcweir 		OutputDevice& rOutputDevice,
48*cdf0e10cSrcweir 		const basegfx::B2DHomMatrix& rObjectToViewTransformation,
49*cdf0e10cSrcweir 		const basegfx::BColorModifierStack& rBColorModifierStack)
50*cdf0e10cSrcweir 	{
51*cdf0e10cSrcweir 		const basegfx::B2DHomMatrix aLocalTransform(rObjectToViewTransformation * rWrongSpellCandidate.getTransformation());
52*cdf0e10cSrcweir         const basegfx::B2DVector aFontVectorPixel(aLocalTransform * basegfx::B2DVector(0.0, 1.0));
53*cdf0e10cSrcweir         const sal_uInt32 nFontPixelHeight(basegfx::fround(aFontVectorPixel.getLength()));
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir         static const sal_uInt32 nMinimumFontHeight(5); // #define WRONG_SHOW_MIN 		 5
56*cdf0e10cSrcweir         static const sal_uInt32 nSmallFontHeight(11);  // #define WRONG_SHOW_SMALL 	    11
57*cdf0e10cSrcweir         static const sal_uInt32 nMediumFontHeight(15); // #define WRONG_SHOW_MEDIUM 	15
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir         if(nFontPixelHeight > nMinimumFontHeight)
60*cdf0e10cSrcweir         {
61*cdf0e10cSrcweir             const basegfx::B2DPoint aStart(aLocalTransform * basegfx::B2DPoint(rWrongSpellCandidate.getStart(), 0.0));
62*cdf0e10cSrcweir             const basegfx::B2DPoint aStop(aLocalTransform * basegfx::B2DPoint(rWrongSpellCandidate.getStop(), 0.0));
63*cdf0e10cSrcweir 		    const Point aVclStart(basegfx::fround(aStart.getX()), basegfx::fround(aStart.getY()));
64*cdf0e10cSrcweir 		    const Point aVclStop(basegfx::fround(aStop.getX()), basegfx::fround(aStop.getY()));
65*cdf0e10cSrcweir             sal_uInt16 nWaveStyle(WAVE_FLAT);
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir             if(nFontPixelHeight > nMediumFontHeight)
68*cdf0e10cSrcweir             {
69*cdf0e10cSrcweir                 nWaveStyle = WAVE_NORMAL;
70*cdf0e10cSrcweir             }
71*cdf0e10cSrcweir             else if(nFontPixelHeight > nSmallFontHeight)
72*cdf0e10cSrcweir             {
73*cdf0e10cSrcweir                 nWaveStyle = WAVE_SMALL;
74*cdf0e10cSrcweir             }
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir             // #i101075# draw it. Do not forget to use the evtl. offsetted origin of the target device,
77*cdf0e10cSrcweir             // e.g. when used with mask/transparence buffer device
78*cdf0e10cSrcweir             const Point aOrigin(rOutputDevice.GetMapMode().GetOrigin());
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir             const basegfx::BColor aProcessedColor(rBColorModifierStack.getModifiedColor(rWrongSpellCandidate.getColor()));
81*cdf0e10cSrcweir 			const bool bMapModeEnabledState(rOutputDevice.IsMapModeEnabled());
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir             rOutputDevice.EnableMapMode(false);
84*cdf0e10cSrcweir             rOutputDevice.SetLineColor(Color(aProcessedColor));
85*cdf0e10cSrcweir             rOutputDevice.SetFillColor();
86*cdf0e10cSrcweir             rOutputDevice.DrawWaveLine(aOrigin + aVclStart, aOrigin + aVclStop, nWaveStyle);
87*cdf0e10cSrcweir 			rOutputDevice.EnableMapMode(bMapModeEnabledState);
88*cdf0e10cSrcweir         }
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir 		// cannot really go wrong
91*cdf0e10cSrcweir 		return true;
92*cdf0e10cSrcweir 	}
93*cdf0e10cSrcweir } // end of namespace drawinglayer
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
96*cdf0e10cSrcweir // eof
97