fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / drawinglayer / source / processor2d / helperwrongspellrenderer.cxx
blobd28d71eb6fd45a77448b7ebb5a43060cdde8be6b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <helperwrongspellrenderer.hxx>
21 #include <drawinglayer/primitive2d/wrongspellprimitive2d.hxx>
22 #include <tools/gen.hxx>
23 #include <vcl/outdev.hxx>
24 #include <basegfx/color/bcolormodifier.hxx>
26 //////////////////////////////////////////////////////////////////////////////
28 using namespace com::sun::star;
30 //////////////////////////////////////////////////////////////////////////////
32 namespace drawinglayer
34 bool renderWrongSpellPrimitive2D(
35 const primitive2d::WrongSpellPrimitive2D& rWrongSpellCandidate,
36 OutputDevice& rOutputDevice,
37 const basegfx::B2DHomMatrix& rObjectToViewTransformation,
38 const basegfx::BColorModifierStack& rBColorModifierStack)
40 const basegfx::B2DHomMatrix aLocalTransform(rObjectToViewTransformation * rWrongSpellCandidate.getTransformation());
41 const basegfx::B2DVector aFontVectorPixel(aLocalTransform * basegfx::B2DVector(0.0, 1.0));
42 const sal_uInt32 nFontPixelHeight(basegfx::fround(aFontVectorPixel.getLength()));
44 static const sal_uInt32 nMinimumFontHeight(5); // #define WRONG_SHOW_MIN 5
45 static const sal_uInt32 nSmallFontHeight(11); // #define WRONG_SHOW_SMALL 11
46 static const sal_uInt32 nMediumFontHeight(15); // #define WRONG_SHOW_MEDIUM 15
48 if(nFontPixelHeight > nMinimumFontHeight)
50 const basegfx::B2DPoint aStart(aLocalTransform * basegfx::B2DPoint(rWrongSpellCandidate.getStart(), 0.0));
51 const basegfx::B2DPoint aStop(aLocalTransform * basegfx::B2DPoint(rWrongSpellCandidate.getStop(), 0.0));
52 const Point aVclStart(basegfx::fround(aStart.getX()), basegfx::fround(aStart.getY()));
53 const Point aVclStop(basegfx::fround(aStop.getX()), basegfx::fround(aStop.getY()));
54 sal_uInt16 nWaveStyle(WAVE_FLAT);
56 if(nFontPixelHeight > nMediumFontHeight)
58 nWaveStyle = WAVE_NORMAL;
60 else if(nFontPixelHeight > nSmallFontHeight)
62 nWaveStyle = WAVE_SMALL;
65 // #i101075# draw it. Do not forget to use the evtl. offsetted origin of the target device,
66 // e.g. when used with mask/transparence buffer device
67 const Point aOrigin(rOutputDevice.GetMapMode().GetOrigin());
69 const basegfx::BColor aProcessedColor(rBColorModifierStack.getModifiedColor(rWrongSpellCandidate.getColor()));
70 const bool bMapModeEnabledState(rOutputDevice.IsMapModeEnabled());
72 rOutputDevice.EnableMapMode(false);
73 rOutputDevice.SetLineColor(Color(aProcessedColor));
74 rOutputDevice.SetFillColor();
75 rOutputDevice.DrawWaveLine(aOrigin + aVclStart, aOrigin + aVclStop, nWaveStyle);
76 rOutputDevice.EnableMapMode(bMapModeEnabledState);
79 // cannot really go wrong
80 return true;
82 } // end of namespace drawinglayer
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */