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>
25 namespace drawinglayer
29 class ImpSdrSceneAttribute
32 // 3D scene attribute definitions
35 ::com::sun::star::drawing::ProjectionMode maProjectionMode
;
36 ::com::sun::star::drawing::ShadeMode maShadeMode
;
39 bool mbTwoSidedLighting
: 1;
45 ::com::sun::star::drawing::ProjectionMode aProjectionMode
,
46 ::com::sun::star::drawing::ShadeMode aShadeMode
,
47 bool bTwoSidedLighting
)
48 : mfDistance(fDistance
),
49 mfShadowSlant(fShadowSlant
),
50 maProjectionMode(aProjectionMode
),
51 maShadeMode(aShadeMode
),
52 mbTwoSidedLighting(bTwoSidedLighting
)
56 ImpSdrSceneAttribute()
59 maProjectionMode(::com::sun::star::drawing::ProjectionMode_PARALLEL
),
60 maShadeMode(::com::sun::star::drawing::ShadeMode_FLAT
),
61 mbTwoSidedLighting(false)
66 double getDistance() const { return mfDistance
; }
67 double getShadowSlant() const { return mfShadowSlant
; }
68 ::com::sun::star::drawing::ProjectionMode
getProjectionMode() const { return maProjectionMode
; }
69 ::com::sun::star::drawing::ShadeMode
getShadeMode() const { return maShadeMode
; }
70 bool getTwoSidedLighting() const { return mbTwoSidedLighting
; }
72 bool operator==(const ImpSdrSceneAttribute
& rCandidate
) const
74 return (getDistance() == rCandidate
.getDistance()
75 && getShadowSlant() == rCandidate
.getShadowSlant()
76 && getProjectionMode() == rCandidate
.getProjectionMode()
77 && getShadeMode() == rCandidate
.getShadeMode()
78 && getTwoSidedLighting() == rCandidate
.getTwoSidedLighting());
84 struct theGlobalDefault
:
85 public rtl::Static
< SdrSceneAttribute::ImplType
, theGlobalDefault
> {};
88 SdrSceneAttribute::SdrSceneAttribute(
91 ::com::sun::star::drawing::ProjectionMode aProjectionMode
,
92 ::com::sun::star::drawing::ShadeMode aShadeMode
,
93 bool bTwoSidedLighting
)
94 : mpSdrSceneAttribute(ImpSdrSceneAttribute(
95 fDistance
, fShadowSlant
, aProjectionMode
, aShadeMode
, bTwoSidedLighting
))
99 SdrSceneAttribute::SdrSceneAttribute()
100 : mpSdrSceneAttribute(theGlobalDefault::get())
104 SdrSceneAttribute::SdrSceneAttribute(const SdrSceneAttribute
& rCandidate
)
105 : mpSdrSceneAttribute(rCandidate
.mpSdrSceneAttribute
)
109 SdrSceneAttribute::~SdrSceneAttribute()
113 bool SdrSceneAttribute::isDefault() const
115 return mpSdrSceneAttribute
.same_object(theGlobalDefault::get());
118 SdrSceneAttribute
& SdrSceneAttribute::operator=(const SdrSceneAttribute
& rCandidate
)
120 mpSdrSceneAttribute
= rCandidate
.mpSdrSceneAttribute
;
124 bool SdrSceneAttribute::operator==(const SdrSceneAttribute
& rCandidate
) const
126 // tdf#87509 default attr is always != non-default attr, even with same values
127 if(rCandidate
.isDefault() != isDefault())
130 return rCandidate
.mpSdrSceneAttribute
== mpSdrSceneAttribute
;
133 double SdrSceneAttribute::getShadowSlant() const
135 return mpSdrSceneAttribute
->getShadowSlant();
138 ::com::sun::star::drawing::ProjectionMode
SdrSceneAttribute::getProjectionMode() const
140 return mpSdrSceneAttribute
->getProjectionMode();
143 ::com::sun::star::drawing::ShadeMode
SdrSceneAttribute::getShadeMode() const
145 return mpSdrSceneAttribute
->getShadeMode();
148 bool SdrSceneAttribute::getTwoSidedLighting() const
150 return mpSdrSceneAttribute
->getTwoSidedLighting();
153 } // end of namespace attribute
154 } // end of namespace drawinglayer
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */