/src/libreoffice/vcl/source/gdi/print2.cxx
Line | Count | Source |
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> |
24 | | #include <vcl/printer/Options.hxx> |
25 | | |
26 | | #include <utility> |
27 | | #include <vector> |
28 | | |
29 | | void Printer::DrawGradientEx( OutputDevice* pOut, const tools::Rectangle& rRect, const Gradient& rGradient ) |
30 | 0 | { |
31 | 0 | const vcl::printer::Options& rPrinterOptions = GetPrinterOptions(); |
32 | |
|
33 | 0 | if( rPrinterOptions.IsReduceGradients() ) |
34 | 0 | { |
35 | 0 | if( vcl::printer::GradientMode::Stripes == rPrinterOptions.GetReducedGradientMode() ) |
36 | 0 | { |
37 | 0 | if( !rGradient.GetSteps() || ( rGradient.GetSteps() > rPrinterOptions.GetReducedGradientStepCount() ) ) |
38 | 0 | { |
39 | 0 | Gradient aNewGradient( rGradient ); |
40 | |
|
41 | 0 | aNewGradient.SetSteps( rPrinterOptions.GetReducedGradientStepCount() ); |
42 | 0 | pOut->DrawGradient( rRect, aNewGradient ); |
43 | 0 | } |
44 | 0 | else |
45 | 0 | pOut->DrawGradient( rRect, rGradient ); |
46 | 0 | } |
47 | 0 | else |
48 | 0 | { |
49 | 0 | const Color& rStartColor = rGradient.GetStartColor(); |
50 | 0 | const Color& rEndColor = rGradient.GetEndColor(); |
51 | 0 | const tools::Long nR = ( ( static_cast<tools::Long>(rStartColor.GetRed()) * rGradient.GetStartIntensity() ) / 100 + |
52 | 0 | ( static_cast<tools::Long>(rEndColor.GetRed()) * rGradient.GetEndIntensity() ) / 100 ) >> 1; |
53 | 0 | const tools::Long nG = ( ( static_cast<tools::Long>(rStartColor.GetGreen()) * rGradient.GetStartIntensity() ) / 100 + |
54 | 0 | ( static_cast<tools::Long>(rEndColor.GetGreen()) * rGradient.GetEndIntensity() ) / 100 ) >> 1; |
55 | 0 | const tools::Long nB = ( ( static_cast<tools::Long>(rStartColor.GetBlue()) * rGradient.GetStartIntensity() ) / 100 + |
56 | 0 | ( static_cast<tools::Long>(rEndColor.GetBlue()) * rGradient.GetEndIntensity() ) / 100 ) >> 1; |
57 | 0 | const Color aColor( static_cast<sal_uInt8>(nR), static_cast<sal_uInt8>(nG), static_cast<sal_uInt8>(nB) ); |
58 | |
|
59 | 0 | auto popIt = pOut->ScopedPush(vcl::PushFlags::LINECOLOR | vcl::PushFlags::FILLCOLOR); |
60 | 0 | pOut->SetLineColor( aColor ); |
61 | 0 | pOut->SetFillColor( aColor ); |
62 | 0 | pOut->DrawRect( rRect ); |
63 | 0 | } |
64 | 0 | } |
65 | 0 | else |
66 | 0 | pOut->DrawGradient( rRect, rGradient ); |
67 | 0 | } |
68 | | |
69 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |