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