/src/libreoffice/svtools/source/config/optionsdrawinglayer.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 <svtools/optionsdrawinglayer.hxx> |
21 | | #include <vcl/svapp.hxx> |
22 | | #include <vcl/outdev.hxx> |
23 | | #include <vcl/settings.hxx> |
24 | | #include <officecfg/Office/Common.hxx> |
25 | | #include <unotools/configmgr.hxx> |
26 | | #include <drawinglayer/geometry/viewinformation2d.hxx> |
27 | | #include <mutex> |
28 | | |
29 | | // #i73602# |
30 | | // #i74769#, #i75172# |
31 | | // #i4219# |
32 | | |
33 | | namespace SvtOptionsDrawinglayer |
34 | | { |
35 | | |
36 | | Color GetStripeColorA() |
37 | 3 | { |
38 | 3 | return Color(ColorTransparency, officecfg::Office::Common::Drawinglayer::StripeColorA::get()); |
39 | 3 | } |
40 | | |
41 | | Color GetStripeColorB() |
42 | 3 | { |
43 | 3 | return Color(ColorTransparency, officecfg::Office::Common::Drawinglayer::StripeColorB::get()); |
44 | 3 | } |
45 | | |
46 | | bool IsAntiAliasing() |
47 | 593 | { |
48 | 593 | return drawinglayer::geometry::ViewInformation2D::getGlobalAntiAliasing(); |
49 | 593 | } |
50 | | |
51 | | /** |
52 | | * Some code like to turn this stuff on and off during a drawing operation |
53 | | * so it can "tunnel" information down through several layers, |
54 | | * so we don't want to actually do a config write all the time. |
55 | | */ |
56 | | void SetAntiAliasing( bool bOn, bool bTemporary ) |
57 | 0 | { |
58 | 0 | drawinglayer::geometry::ViewInformation2D::setGlobalAntiAliasing(bOn, bTemporary); |
59 | 0 | } |
60 | | |
61 | | |
62 | | bool IsSnapHorVerLinesToDiscrete() |
63 | 0 | { |
64 | 0 | return IsAntiAliasing() && officecfg::Office::Common::Drawinglayer::SnapHorVerLinesToDiscrete::get(); |
65 | 0 | } |
66 | | |
67 | | sal_uInt16 GetTransparentSelectionPercent() |
68 | 0 | { |
69 | 0 | sal_uInt16 aRetval = officecfg::Office::Common::Drawinglayer::TransparentSelectionPercent::get(); |
70 | | |
71 | | // crop to range [10% .. 90%] |
72 | 0 | if(aRetval < 10) |
73 | 0 | { |
74 | 0 | aRetval = 10; |
75 | 0 | } |
76 | |
|
77 | 0 | if(aRetval > 90) |
78 | 0 | { |
79 | 0 | aRetval = 90; |
80 | 0 | } |
81 | |
|
82 | 0 | return aRetval; |
83 | 0 | } |
84 | | |
85 | | sal_uInt16 GetSelectionMaximumLuminancePercent() |
86 | 0 | { |
87 | 0 | sal_uInt16 aRetval = officecfg::Office::Common::Drawinglayer::SelectionMaximumLuminancePercent::get(); |
88 | | |
89 | | // crop to range [0% .. 100%] |
90 | 0 | if(aRetval > 90) |
91 | 0 | { |
92 | 0 | aRetval = 90; |
93 | 0 | } |
94 | |
|
95 | 0 | return aRetval; |
96 | 0 | } |
97 | | |
98 | | Color getHilightColor() |
99 | 0 | { |
100 | 0 | Color aRetval(Application::GetSettings().GetStyleSettings().GetHighlightColor()); |
101 | 0 | const basegfx::BColor aSelection(aRetval.getBColor()); |
102 | 0 | const double fLuminance(aSelection.luminance()); |
103 | 0 | const double fMaxLum(GetSelectionMaximumLuminancePercent() / 100.0); |
104 | |
|
105 | 0 | if(fLuminance > fMaxLum) |
106 | 0 | { |
107 | 0 | const double fFactor(fMaxLum / fLuminance); |
108 | 0 | const basegfx::BColor aNewSelection( |
109 | 0 | aSelection.getRed() * fFactor, |
110 | 0 | aSelection.getGreen() * fFactor, |
111 | 0 | aSelection.getBlue() * fFactor); |
112 | |
|
113 | 0 | aRetval = Color(aNewSelection); |
114 | 0 | } |
115 | |
|
116 | 0 | return aRetval; |
117 | 0 | } |
118 | | |
119 | | } // namespace SvtOptionsDrawinglayer |
120 | | |
121 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |