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