LibreOffice Module vcl (master) 1
print2.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
20#include <sal/log.hxx>
21
22#include <vcl/metaact.hxx>
23#include <vcl/print.hxx>
25
26#include <utility>
27#include <vector>
28
29void Printer::DrawGradientEx( OutputDevice* pOut, const tools::Rectangle& rRect, const Gradient& rGradient )
30{
31 const vcl::printer::Options& rPrinterOptions = GetPrinterOptions();
32
33 if( rPrinterOptions.IsReduceGradients() )
34 {
35 if( vcl::printer::GradientMode::Stripes == rPrinterOptions.GetReducedGradientMode() )
36 {
37 if( !rGradient.GetSteps() || ( rGradient.GetSteps() > rPrinterOptions.GetReducedGradientStepCount() ) )
38 {
39 Gradient aNewGradient( rGradient );
40
41 aNewGradient.SetSteps( rPrinterOptions.GetReducedGradientStepCount() );
42 pOut->DrawGradient( rRect, aNewGradient );
43 }
44 else
45 pOut->DrawGradient( rRect, rGradient );
46 }
47 else
48 {
49 const Color& rStartColor = rGradient.GetStartColor();
50 const Color& rEndColor = rGradient.GetEndColor();
51 const tools::Long nR = ( ( static_cast<tools::Long>(rStartColor.GetRed()) * rGradient.GetStartIntensity() ) / 100 +
52 ( static_cast<tools::Long>(rEndColor.GetRed()) * rGradient.GetEndIntensity() ) / 100 ) >> 1;
53 const tools::Long nG = ( ( static_cast<tools::Long>(rStartColor.GetGreen()) * rGradient.GetStartIntensity() ) / 100 +
54 ( static_cast<tools::Long>(rEndColor.GetGreen()) * rGradient.GetEndIntensity() ) / 100 ) >> 1;
55 const tools::Long nB = ( ( static_cast<tools::Long>(rStartColor.GetBlue()) * rGradient.GetStartIntensity() ) / 100 +
56 ( static_cast<tools::Long>(rEndColor.GetBlue()) * rGradient.GetEndIntensity() ) / 100 ) >> 1;
57 const Color aColor( static_cast<sal_uInt8>(nR), static_cast<sal_uInt8>(nG), static_cast<sal_uInt8>(nB) );
58
60 pOut->SetLineColor( aColor );
61 pOut->SetFillColor( aColor );
62 pOut->DrawRect( rRect );
63 pOut->Pop();
64 }
65 }
66 else
67 pOut->DrawGradient( rRect, rGradient );
68}
69
70/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt8 GetBlue() const
sal_uInt8 GetRed() const
sal_uInt8 GetGreen() const
sal_uInt16 GetStartIntensity() const
sal_uInt16 GetEndIntensity() const
const Color & GetEndColor() const
const Color & GetStartColor() const
void SetSteps(sal_uInt16 nSteps)
sal_uInt16 GetSteps() const
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:170
void DrawGradientEx(OutputDevice *pOut, const tools::Rectangle &rRect, const Gradient &rGradient)
Definition: print2.cxx:29
const vcl::printer::Options & GetPrinterOptions() const
Definition: print.hxx:221
long Long
unsigned char sal_uInt8
oslFileHandle & pOut