1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <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>
33 namespace SvtOptionsDrawinglayer
36 bool IsOverlayBuffer()
38 return officecfg::Office::Common::Drawinglayer::OverlayBuffer::get();
43 return officecfg::Office::Common::Drawinglayer::PaintBuffer::get();
46 Color
GetStripeColorA()
48 return Color(ColorTransparency
, officecfg::Office::Common::Drawinglayer::StripeColorA::get());
51 Color
GetStripeColorB()
53 return Color(ColorTransparency
, officecfg::Office::Common::Drawinglayer::StripeColorB::get());
56 sal_uInt16
GetStripeLength()
58 return officecfg::Office::Common::Drawinglayer::StripeLength::get();
61 bool IsOverlayBuffer_Calc()
63 return !utl::ConfigManager::IsFuzzing() && officecfg::Office::Common::Drawinglayer::OverlayBuffer_Calc::get();
66 bool IsOverlayBuffer_Writer()
68 return !utl::ConfigManager::IsFuzzing() && officecfg::Office::Common::Drawinglayer::OverlayBuffer_Writer::get();
71 bool IsOverlayBuffer_DrawImpress()
73 return !utl::ConfigManager::IsFuzzing() && officecfg::Office::Common::Drawinglayer::OverlayBuffer_DrawImpress::get();
77 bool IsPaintBuffer_Calc()
79 return !utl::ConfigManager::IsFuzzing() && officecfg::Office::Common::Drawinglayer::PaintBuffer_Calc::get();
82 bool IsPaintBuffer_Writer()
84 return !utl::ConfigManager::IsFuzzing() && officecfg::Office::Common::Drawinglayer::PaintBuffer_Writer::get();
87 bool IsPaintBuffer_DrawImpress()
89 return !utl::ConfigManager::IsFuzzing() && officecfg::Office::Common::Drawinglayer::PaintBuffer_DrawImpress::get();
93 sal_uInt32
GetMaximumPaperWidth()
95 return officecfg::Office::Common::Drawinglayer::MaximumPaperWidth::get();
98 sal_uInt32
GetMaximumPaperHeight()
100 return officecfg::Office::Common::Drawinglayer::MaximumPaperHeight::get();
103 sal_uInt32
GetMaximumPaperLeftMargin()
105 return officecfg::Office::Common::Drawinglayer::MaximumPaperLeftMargin::get();
108 sal_uInt32
GetMaximumPaperRightMargin()
110 return officecfg::Office::Common::Drawinglayer::MaximumPaperRightMargin::get();
113 sal_uInt32
GetMaximumPaperTopMargin()
115 return officecfg::Office::Common::Drawinglayer::MaximumPaperTopMargin::get();
118 sal_uInt32
GetMaximumPaperBottomMargin()
120 return officecfg::Office::Common::Drawinglayer::MaximumPaperBottomMargin::get();
123 static bool gbPixelSnapHairlineForwardInitial(false);
124 static bool gbPixelSnapHairlineForwardLast(true);
126 bool IsAAPossibleOnThisSystem()
128 static const bool gbAllowAA
129 = Application::GetDefaultDevice()->SupportsOperation(OutDevSupportType::TransparentRect
);
134 bool IsAntiAliasing()
136 bool bAntiAliasing
= drawinglayer::geometry::ViewInformation2D::getGlobalAntiAliasing();
137 if (bAntiAliasing
&& !IsAAPossibleOnThisSystem())
139 drawinglayer::geometry::ViewInformation2D::setGlobalAntiAliasing(false, true);
140 bAntiAliasing
= false;
142 return bAntiAliasing
;
146 * Some code like to turn this stuff on and off during a drawing operation
147 * so it can "tunnel" information down through several layers,
148 * so we don't want to actually do a config write all the time.
150 void SetAntiAliasing( bool bOn
, bool bTemporary
)
152 drawinglayer::geometry::ViewInformation2D::setGlobalAntiAliasing(bOn
, bTemporary
);
156 bool IsSnapHorVerLinesToDiscrete()
158 const bool bRetval(IsAntiAliasing() && officecfg::Office::Common::Drawinglayer::SnapHorVerLinesToDiscrete::get());
160 if (!gbPixelSnapHairlineForwardInitial
|| gbPixelSnapHairlineForwardLast
!= bRetval
)
162 gbPixelSnapHairlineForwardInitial
= true;
163 gbPixelSnapHairlineForwardLast
= bRetval
;
164 drawinglayer::geometry::ViewInformation2D::forwardPixelSnapHairline(bRetval
);
170 bool IsSolidDragCreate()
172 return officecfg::Office::Common::Drawinglayer::SolidDragCreate::get();
175 bool IsRenderDecoratedTextDirect()
177 return officecfg::Office::Common::Drawinglayer::RenderDecoratedTextDirect::get();
180 bool IsRenderSimpleTextDirect()
182 return officecfg::Office::Common::Drawinglayer::RenderSimpleTextDirect::get();
185 sal_uInt32
GetQuadratic3DRenderLimit()
187 return officecfg::Office::Common::Drawinglayer::Quadratic3DRenderLimit::get();
190 sal_uInt32
GetQuadraticFormControlRenderLimit()
192 return officecfg::Office::Common::Drawinglayer::QuadraticFormControlRenderLimit::get();
195 // #i97672# selection settings
196 bool IsTransparentSelection()
198 return officecfg::Office::Common::Drawinglayer::TransparentSelection::get();
201 sal_uInt16
GetTransparentSelectionPercent()
203 sal_uInt16 aRetval
= officecfg::Office::Common::Drawinglayer::TransparentSelectionPercent::get();
205 // crop to range [10% .. 90%]
219 sal_uInt16
GetSelectionMaximumLuminancePercent()
221 sal_uInt16 aRetval
= officecfg::Office::Common::Drawinglayer::SelectionMaximumLuminancePercent::get();
223 // crop to range [0% .. 100%]
232 Color
getHilightColor()
234 Color
aRetval(Application::GetSettings().GetStyleSettings().GetHighlightColor());
235 const basegfx::BColor
aSelection(aRetval
.getBColor());
236 const double fLuminance(aSelection
.luminance());
237 const double fMaxLum(GetSelectionMaximumLuminancePercent() / 100.0);
239 if(fLuminance
> fMaxLum
)
241 const double fFactor(fMaxLum
/ fLuminance
);
242 const basegfx::BColor
aNewSelection(
243 aSelection
.getRed() * fFactor
,
244 aSelection
.getGreen() * fFactor
,
245 aSelection
.getBlue() * fFactor
);
247 aRetval
= Color(aNewSelection
);
253 } // namespace SvtOptionsDrawinglayer
255 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */