LibreOffice Module drawinglayer (master) 1
helperwrongspellrenderer.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
22#include <tools/gen.hxx>
23#include <vcl/outdev.hxx>
26
27using namespace css;
28
29namespace drawinglayer
30{
31namespace
32{
33constexpr sal_uInt32 constMinimumFontHeight = 5; // #define WRONG_SHOW_MIN 5
34}
35
37 OutputDevice& rOutputDevice,
38 const basegfx::B2DHomMatrix& rObjectToViewTransformation,
39 const basegfx::BColorModifierStack& rBColorModifierStack)
40{
41 const basegfx::B2DHomMatrix aLocalTransform(rObjectToViewTransformation
42 * rWrongSpellCandidate.getTransformation());
43 const basegfx::B2DVector aFontVectorPixel(aLocalTransform * basegfx::B2DVector(0.0, 1.0));
44 const sal_uInt32 nFontPixelHeight(basegfx::fround(aFontVectorPixel.getLength()));
45
46 if (nFontPixelHeight <= constMinimumFontHeight)
47 return true;
48
49 const basegfx::B2DPoint aStart(aLocalTransform
50 * basegfx::B2DPoint(rWrongSpellCandidate.getStart(), 0.0));
51 const basegfx::B2DPoint aStop(aLocalTransform
52 * basegfx::B2DPoint(rWrongSpellCandidate.getStop(), 0.0));
53 const Point aVclStart(basegfx::fround(aStart.getX()), basegfx::fround(aStart.getY()));
54 const Point aVclStop(basegfx::fround(aStop.getX()), basegfx::fround(aStop.getY()));
55
56 // #i101075# draw it. Do not forget to use the evtl. offsetted origin of the target device,
57 // e.g. when used with mask/transparence buffer device
58 const Point aOrigin(rOutputDevice.GetMapMode().GetOrigin());
59
60 const basegfx::BColor aProcessedColor(
61 rBColorModifierStack.getModifiedColor(rWrongSpellCandidate.getColor()));
62 const bool bMapModeEnabledState(rOutputDevice.IsMapModeEnabled());
63
64 vcl::ScopedAntialiasing a(rOutputDevice, true);
65 rOutputDevice.EnableMapMode(false);
66 rOutputDevice.SetLineColor(Color(aProcessedColor));
67 rOutputDevice.SetFillColor();
68 rOutputDevice.DrawWaveLine(aOrigin + aVclStart, aOrigin + aVclStop);
69 rOutputDevice.EnableMapMode(bMapModeEnabledState);
70
71 // cannot really go wrong
72 return true;
73}
74} // end of namespace drawinglayer
75
76/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const Point & GetOrigin() const
void EnableMapMode(bool bEnable=true)
void DrawWaveLine(const Point &rStartPos, const Point &rEndPos, tools::Long nLineWidth=1, tools::Long nWaveHeight=3)
void SetLineColor()
void SetFillColor()
const MapMode & GetMapMode() const
bool IsMapModeEnabled() const
double getLength() const
::basegfx::BColor getModifiedColor(const ::basegfx::BColor &rSource) const
TYPE getX() const
TYPE getY() const
const basegfx::B2DHomMatrix & getTransformation() const
data read access
uno_Any a
B2IRange fround(const B2DRange &rRange)
bool renderWrongSpellPrimitive2D(const primitive2d::WrongSpellPrimitive2D &rWrongSpellCandidate, OutputDevice &rOutputDevice, const basegfx::B2DHomMatrix &rObjectToViewTransformation, const basegfx::BColorModifierStack &rBColorModifierStack)