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 <drawinglayer/attribute/sdrsceneattribute3d.hxx>
21 #include <rtl/instance.hxx>
24 namespace drawinglayer::attribute
26 class ImpSdrSceneAttribute
29 // 3D scene attribute definitions
32 css::drawing::ProjectionMode maProjectionMode
;
33 css::drawing::ShadeMode maShadeMode
;
35 bool mbTwoSidedLighting
: 1;
41 css::drawing::ProjectionMode aProjectionMode
,
42 css::drawing::ShadeMode aShadeMode
,
43 bool bTwoSidedLighting
)
44 : mfDistance(fDistance
),
45 mfShadowSlant(fShadowSlant
),
46 maProjectionMode(aProjectionMode
),
47 maShadeMode(aShadeMode
),
48 mbTwoSidedLighting(bTwoSidedLighting
)
52 ImpSdrSceneAttribute()
55 maProjectionMode(css::drawing::ProjectionMode_PARALLEL
),
56 maShadeMode(css::drawing::ShadeMode_FLAT
),
57 mbTwoSidedLighting(false)
62 double getShadowSlant() const { return mfShadowSlant
; }
63 css::drawing::ProjectionMode
getProjectionMode() const { return maProjectionMode
; }
64 css::drawing::ShadeMode
getShadeMode() const { return maShadeMode
; }
65 bool getTwoSidedLighting() const { return mbTwoSidedLighting
; }
67 bool operator==(const ImpSdrSceneAttribute
& rCandidate
) const
69 return (mfDistance
== rCandidate
.mfDistance
70 && getShadowSlant() == rCandidate
.getShadowSlant()
71 && getProjectionMode() == rCandidate
.getProjectionMode()
72 && getShadeMode() == rCandidate
.getShadeMode()
73 && getTwoSidedLighting() == rCandidate
.getTwoSidedLighting());
79 struct theGlobalDefault
:
80 public rtl::Static
< SdrSceneAttribute::ImplType
, theGlobalDefault
> {};
83 SdrSceneAttribute::SdrSceneAttribute(
86 css::drawing::ProjectionMode aProjectionMode
,
87 css::drawing::ShadeMode aShadeMode
,
88 bool bTwoSidedLighting
)
89 : mpSdrSceneAttribute(ImpSdrSceneAttribute(
90 fDistance
, fShadowSlant
, aProjectionMode
, aShadeMode
, bTwoSidedLighting
))
94 SdrSceneAttribute::SdrSceneAttribute()
95 : mpSdrSceneAttribute(theGlobalDefault::get())
99 SdrSceneAttribute::SdrSceneAttribute(const SdrSceneAttribute
&) = default;
101 SdrSceneAttribute::SdrSceneAttribute(SdrSceneAttribute
&&) = default;
103 SdrSceneAttribute::~SdrSceneAttribute() = default;
105 bool SdrSceneAttribute::isDefault() const
107 return mpSdrSceneAttribute
.same_object(theGlobalDefault::get());
110 SdrSceneAttribute
& SdrSceneAttribute::operator=(const SdrSceneAttribute
&) = default;
112 SdrSceneAttribute
& SdrSceneAttribute::operator=(SdrSceneAttribute
&&) = default;
114 bool SdrSceneAttribute::operator==(const SdrSceneAttribute
& rCandidate
) const
116 // tdf#87509 default attr is always != non-default attr, even with same values
117 if(rCandidate
.isDefault() != isDefault())
120 return rCandidate
.mpSdrSceneAttribute
== mpSdrSceneAttribute
;
123 double SdrSceneAttribute::getShadowSlant() const
125 return mpSdrSceneAttribute
->getShadowSlant();
128 css::drawing::ProjectionMode
SdrSceneAttribute::getProjectionMode() const
130 return mpSdrSceneAttribute
->getProjectionMode();
133 css::drawing::ShadeMode
SdrSceneAttribute::getShadeMode() const
135 return mpSdrSceneAttribute
->getShadeMode();
138 bool SdrSceneAttribute::getTwoSidedLighting() const
140 return mpSdrSceneAttribute
->getTwoSidedLighting();
143 } // end of namespace
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */