1*464702f4SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*464702f4SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*464702f4SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*464702f4SAndrew Rist  * distributed with this work for additional information
6*464702f4SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*464702f4SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*464702f4SAndrew Rist  * "License"); you may not use this file except in compliance
9*464702f4SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*464702f4SAndrew Rist  *
11*464702f4SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*464702f4SAndrew Rist  *
13*464702f4SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*464702f4SAndrew Rist  * software distributed under the License is distributed on an
15*464702f4SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*464702f4SAndrew Rist  * KIND, either express or implied.  See the License for the
17*464702f4SAndrew Rist  * specific language governing permissions and limitations
18*464702f4SAndrew Rist  * under the License.
19*464702f4SAndrew Rist  *
20*464702f4SAndrew Rist  *************************************************************/
21*464702f4SAndrew Rist 
22*464702f4SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_drawinglayer.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <helperwrongspellrenderer.hxx>
28cdf0e10cSrcweir #include <drawinglayer/primitive2d/wrongspellprimitive2d.hxx>
29cdf0e10cSrcweir #include <tools/gen.hxx>
30cdf0e10cSrcweir #include <vcl/outdev.hxx>
31cdf0e10cSrcweir #include <basegfx/color/bcolormodifier.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
34cdf0e10cSrcweir 
35cdf0e10cSrcweir using namespace com::sun::star;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
38cdf0e10cSrcweir 
39cdf0e10cSrcweir namespace drawinglayer
40cdf0e10cSrcweir {
renderWrongSpellPrimitive2D(const primitive2d::WrongSpellPrimitive2D & rWrongSpellCandidate,OutputDevice & rOutputDevice,const basegfx::B2DHomMatrix & rObjectToViewTransformation,const basegfx::BColorModifierStack & rBColorModifierStack)41cdf0e10cSrcweir 	bool renderWrongSpellPrimitive2D(
42cdf0e10cSrcweir 		const primitive2d::WrongSpellPrimitive2D& rWrongSpellCandidate,
43cdf0e10cSrcweir 		OutputDevice& rOutputDevice,
44cdf0e10cSrcweir 		const basegfx::B2DHomMatrix& rObjectToViewTransformation,
45cdf0e10cSrcweir 		const basegfx::BColorModifierStack& rBColorModifierStack)
46cdf0e10cSrcweir 	{
47cdf0e10cSrcweir 		const basegfx::B2DHomMatrix aLocalTransform(rObjectToViewTransformation * rWrongSpellCandidate.getTransformation());
48cdf0e10cSrcweir         const basegfx::B2DVector aFontVectorPixel(aLocalTransform * basegfx::B2DVector(0.0, 1.0));
49cdf0e10cSrcweir         const sal_uInt32 nFontPixelHeight(basegfx::fround(aFontVectorPixel.getLength()));
50cdf0e10cSrcweir 
51cdf0e10cSrcweir         static const sal_uInt32 nMinimumFontHeight(5); // #define WRONG_SHOW_MIN 		 5
52cdf0e10cSrcweir         static const sal_uInt32 nSmallFontHeight(11);  // #define WRONG_SHOW_SMALL 	    11
53cdf0e10cSrcweir         static const sal_uInt32 nMediumFontHeight(15); // #define WRONG_SHOW_MEDIUM 	15
54cdf0e10cSrcweir 
55cdf0e10cSrcweir         if(nFontPixelHeight > nMinimumFontHeight)
56cdf0e10cSrcweir         {
57cdf0e10cSrcweir             const basegfx::B2DPoint aStart(aLocalTransform * basegfx::B2DPoint(rWrongSpellCandidate.getStart(), 0.0));
58cdf0e10cSrcweir             const basegfx::B2DPoint aStop(aLocalTransform * basegfx::B2DPoint(rWrongSpellCandidate.getStop(), 0.0));
59cdf0e10cSrcweir 		    const Point aVclStart(basegfx::fround(aStart.getX()), basegfx::fround(aStart.getY()));
60cdf0e10cSrcweir 		    const Point aVclStop(basegfx::fround(aStop.getX()), basegfx::fround(aStop.getY()));
61cdf0e10cSrcweir             sal_uInt16 nWaveStyle(WAVE_FLAT);
62cdf0e10cSrcweir 
63cdf0e10cSrcweir             if(nFontPixelHeight > nMediumFontHeight)
64cdf0e10cSrcweir             {
65cdf0e10cSrcweir                 nWaveStyle = WAVE_NORMAL;
66cdf0e10cSrcweir             }
67cdf0e10cSrcweir             else if(nFontPixelHeight > nSmallFontHeight)
68cdf0e10cSrcweir             {
69cdf0e10cSrcweir                 nWaveStyle = WAVE_SMALL;
70cdf0e10cSrcweir             }
71cdf0e10cSrcweir 
72cdf0e10cSrcweir             // #i101075# draw it. Do not forget to use the evtl. offsetted origin of the target device,
73cdf0e10cSrcweir             // e.g. when used with mask/transparence buffer device
74cdf0e10cSrcweir             const Point aOrigin(rOutputDevice.GetMapMode().GetOrigin());
75cdf0e10cSrcweir 
76cdf0e10cSrcweir             const basegfx::BColor aProcessedColor(rBColorModifierStack.getModifiedColor(rWrongSpellCandidate.getColor()));
77cdf0e10cSrcweir 			const bool bMapModeEnabledState(rOutputDevice.IsMapModeEnabled());
78cdf0e10cSrcweir 
79cdf0e10cSrcweir             rOutputDevice.EnableMapMode(false);
80cdf0e10cSrcweir             rOutputDevice.SetLineColor(Color(aProcessedColor));
81cdf0e10cSrcweir             rOutputDevice.SetFillColor();
82cdf0e10cSrcweir             rOutputDevice.DrawWaveLine(aOrigin + aVclStart, aOrigin + aVclStop, nWaveStyle);
83cdf0e10cSrcweir 			rOutputDevice.EnableMapMode(bMapModeEnabledState);
84cdf0e10cSrcweir         }
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 		// cannot really go wrong
87cdf0e10cSrcweir 		return true;
88cdf0e10cSrcweir 	}
89cdf0e10cSrcweir } // end of namespace drawinglayer
90cdf0e10cSrcweir 
91cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
92cdf0e10cSrcweir // eof
93