Line data Source code
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 <drawinglayer/attribute/sdrsceneattribute3d.hxx>
21 : #include <rtl/instance.hxx>
22 :
23 :
24 :
25 : namespace drawinglayer
26 : {
27 : namespace attribute
28 : {
29 : class ImpSdrSceneAttribute
30 : {
31 : public:
32 : // 3D scene attribute definitions
33 : double mfDistance;
34 : double mfShadowSlant;
35 : ::com::sun::star::drawing::ProjectionMode maProjectionMode;
36 : ::com::sun::star::drawing::ShadeMode maShadeMode;
37 :
38 : // bitfield
39 : bool mbTwoSidedLighting : 1;
40 :
41 : public:
42 627 : ImpSdrSceneAttribute(
43 : double fDistance,
44 : double fShadowSlant,
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 627 : mbTwoSidedLighting(bTwoSidedLighting)
53 : {
54 627 : }
55 :
56 5 : ImpSdrSceneAttribute()
57 : : mfDistance(0.0),
58 : mfShadowSlant(0.0),
59 : maProjectionMode(::com::sun::star::drawing::ProjectionMode_PARALLEL),
60 : maShadeMode(::com::sun::star::drawing::ShadeMode_FLAT),
61 5 : mbTwoSidedLighting(false)
62 : {
63 5 : }
64 :
65 : // data read access
66 12 : double getDistance() const { return mfDistance; }
67 27 : double getShadowSlant() const { return mfShadowSlant; }
68 1266 : ::com::sun::star::drawing::ProjectionMode getProjectionMode() const { return maProjectionMode; }
69 36692 : ::com::sun::star::drawing::ShadeMode getShadeMode() const { return maShadeMode; }
70 18414 : bool getTwoSidedLighting() const { return mbTwoSidedLighting; }
71 :
72 6 : bool operator==(const ImpSdrSceneAttribute& rCandidate) const
73 : {
74 6 : return (getDistance() == rCandidate.getDistance()
75 6 : && getShadowSlant() == rCandidate.getShadowSlant()
76 6 : && getProjectionMode() == rCandidate.getProjectionMode()
77 6 : && getShadeMode() == rCandidate.getShadeMode()
78 12 : && getTwoSidedLighting() == rCandidate.getTwoSidedLighting());
79 : }
80 : };
81 :
82 : namespace
83 : {
84 : struct theGlobalDefault :
85 : public rtl::Static< SdrSceneAttribute::ImplType, theGlobalDefault > {};
86 : }
87 :
88 627 : SdrSceneAttribute::SdrSceneAttribute(
89 : double fDistance,
90 : double fShadowSlant,
91 : ::com::sun::star::drawing::ProjectionMode aProjectionMode,
92 : ::com::sun::star::drawing::ShadeMode aShadeMode,
93 : bool bTwoSidedLighting)
94 : : mpSdrSceneAttribute(ImpSdrSceneAttribute(
95 627 : fDistance, fShadowSlant, aProjectionMode, aShadeMode, bTwoSidedLighting))
96 : {
97 627 : }
98 :
99 8142 : SdrSceneAttribute::SdrSceneAttribute()
100 8142 : : mpSdrSceneAttribute(theGlobalDefault::get())
101 : {
102 8142 : }
103 :
104 24 : SdrSceneAttribute::SdrSceneAttribute(const SdrSceneAttribute& rCandidate)
105 24 : : mpSdrSceneAttribute(rCandidate.mpSdrSceneAttribute)
106 : {
107 24 : }
108 :
109 8793 : SdrSceneAttribute::~SdrSceneAttribute()
110 : {
111 8793 : }
112 :
113 709 : bool SdrSceneAttribute::isDefault() const
114 : {
115 709 : return mpSdrSceneAttribute.same_object(theGlobalDefault::get());
116 : }
117 :
118 7496 : SdrSceneAttribute& SdrSceneAttribute::operator=(const SdrSceneAttribute& rCandidate)
119 : {
120 7496 : mpSdrSceneAttribute = rCandidate.mpSdrSceneAttribute;
121 7496 : return *this;
122 : }
123 :
124 29 : bool SdrSceneAttribute::operator==(const SdrSceneAttribute& rCandidate) const
125 : {
126 : // tdf#87509 default attr is always != non-default attr, even with same values
127 29 : if(rCandidate.isDefault() != isDefault())
128 0 : return false;
129 :
130 29 : return rCandidate.mpSdrSceneAttribute == mpSdrSceneAttribute;
131 : }
132 :
133 15 : double SdrSceneAttribute::getShadowSlant() const
134 : {
135 15 : return mpSdrSceneAttribute->getShadowSlant();
136 : }
137 :
138 1254 : ::com::sun::star::drawing::ProjectionMode SdrSceneAttribute::getProjectionMode() const
139 : {
140 1254 : return mpSdrSceneAttribute->getProjectionMode();
141 : }
142 :
143 36680 : ::com::sun::star::drawing::ShadeMode SdrSceneAttribute::getShadeMode() const
144 : {
145 36680 : return mpSdrSceneAttribute->getShadeMode();
146 : }
147 :
148 18402 : bool SdrSceneAttribute::getTwoSidedLighting() const
149 : {
150 18402 : return mpSdrSceneAttribute->getTwoSidedLighting();
151 : }
152 :
153 : } // end of namespace attribute
154 : } // end of namespace drawinglayer
155 :
156 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|