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 namespace drawinglayer::attribute 25 { 26 class ImpSdrSceneAttribute 27 { 28 public: 29 // 3D scene attribute definitions 30 double mfDistance; 31 double mfShadowSlant; 32 css::drawing::ProjectionMode maProjectionMode; 33 css::drawing::ShadeMode maShadeMode; 34 35 bool mbTwoSidedLighting : 1; 36 37 public: ImpSdrSceneAttribute(double fDistance,double fShadowSlant,css::drawing::ProjectionMode aProjectionMode,css::drawing::ShadeMode aShadeMode,bool bTwoSidedLighting)38 ImpSdrSceneAttribute( 39 double fDistance, 40 double fShadowSlant, 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) 49 { 50 } 51 ImpSdrSceneAttribute()52 ImpSdrSceneAttribute() 53 : mfDistance(0.0), 54 mfShadowSlant(0.0), 55 maProjectionMode(css::drawing::ProjectionMode_PARALLEL), 56 maShadeMode(css::drawing::ShadeMode_FLAT), 57 mbTwoSidedLighting(false) 58 { 59 } 60 61 // data read access getShadowSlant() const62 double getShadowSlant() const { return mfShadowSlant; } getProjectionMode() const63 css::drawing::ProjectionMode getProjectionMode() const { return maProjectionMode; } getShadeMode() const64 css::drawing::ShadeMode getShadeMode() const { return maShadeMode; } getTwoSidedLighting() const65 bool getTwoSidedLighting() const { return mbTwoSidedLighting; } 66 operator ==(const ImpSdrSceneAttribute & rCandidate) const67 bool operator==(const ImpSdrSceneAttribute& rCandidate) const 68 { 69 return (mfDistance == rCandidate.mfDistance 70 && getShadowSlant() == rCandidate.getShadowSlant() 71 && getProjectionMode() == rCandidate.getProjectionMode() 72 && getShadeMode() == rCandidate.getShadeMode() 73 && getTwoSidedLighting() == rCandidate.getTwoSidedLighting()); 74 } 75 }; 76 77 namespace 78 { 79 struct theGlobalDefault : 80 public rtl::Static< SdrSceneAttribute::ImplType, theGlobalDefault > {}; 81 } 82 SdrSceneAttribute(double fDistance,double fShadowSlant,css::drawing::ProjectionMode aProjectionMode,css::drawing::ShadeMode aShadeMode,bool bTwoSidedLighting)83 SdrSceneAttribute::SdrSceneAttribute( 84 double fDistance, 85 double fShadowSlant, 86 css::drawing::ProjectionMode aProjectionMode, 87 css::drawing::ShadeMode aShadeMode, 88 bool bTwoSidedLighting) 89 : mpSdrSceneAttribute(ImpSdrSceneAttribute( 90 fDistance, fShadowSlant, aProjectionMode, aShadeMode, bTwoSidedLighting)) 91 { 92 } 93 SdrSceneAttribute()94 SdrSceneAttribute::SdrSceneAttribute() 95 : mpSdrSceneAttribute(theGlobalDefault::get()) 96 { 97 } 98 99 SdrSceneAttribute::SdrSceneAttribute(const SdrSceneAttribute&) = default; 100 101 SdrSceneAttribute::SdrSceneAttribute(SdrSceneAttribute&&) = default; 102 103 SdrSceneAttribute::~SdrSceneAttribute() = default; 104 isDefault() const105 bool SdrSceneAttribute::isDefault() const 106 { 107 return mpSdrSceneAttribute.same_object(theGlobalDefault::get()); 108 } 109 110 SdrSceneAttribute& SdrSceneAttribute::operator=(const SdrSceneAttribute&) = default; 111 112 SdrSceneAttribute& SdrSceneAttribute::operator=(SdrSceneAttribute&&) = default; 113 operator ==(const SdrSceneAttribute & rCandidate) const114 bool SdrSceneAttribute::operator==(const SdrSceneAttribute& rCandidate) const 115 { 116 // tdf#87509 default attr is always != non-default attr, even with same values 117 if(rCandidate.isDefault() != isDefault()) 118 return false; 119 120 return rCandidate.mpSdrSceneAttribute == mpSdrSceneAttribute; 121 } 122 getShadowSlant() const123 double SdrSceneAttribute::getShadowSlant() const 124 { 125 return mpSdrSceneAttribute->getShadowSlant(); 126 } 127 getProjectionMode() const128 css::drawing::ProjectionMode SdrSceneAttribute::getProjectionMode() const 129 { 130 return mpSdrSceneAttribute->getProjectionMode(); 131 } 132 getShadeMode() const133 css::drawing::ShadeMode SdrSceneAttribute::getShadeMode() const 134 { 135 return mpSdrSceneAttribute->getShadeMode(); 136 } 137 getTwoSidedLighting() const138 bool SdrSceneAttribute::getTwoSidedLighting() const 139 { 140 return mpSdrSceneAttribute->getTwoSidedLighting(); 141 } 142 143 } // end of namespace 144 145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 146