1*4bfbcde8SAndrew Rist /************************************************************** 2*4bfbcde8SAndrew Rist * 3*4bfbcde8SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*4bfbcde8SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*4bfbcde8SAndrew Rist * distributed with this work for additional information 6*4bfbcde8SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*4bfbcde8SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*4bfbcde8SAndrew Rist * "License"); you may not use this file except in compliance 9*4bfbcde8SAndrew Rist * with the License. You may obtain a copy of the License at 10*4bfbcde8SAndrew Rist * 11*4bfbcde8SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*4bfbcde8SAndrew Rist * 13*4bfbcde8SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*4bfbcde8SAndrew Rist * software distributed under the License is distributed on an 15*4bfbcde8SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*4bfbcde8SAndrew Rist * KIND, either express or implied. See the License for the 17*4bfbcde8SAndrew Rist * specific language governing permissions and limitations 18*4bfbcde8SAndrew Rist * under the License. 19*4bfbcde8SAndrew Rist * 20*4bfbcde8SAndrew Rist *************************************************************/ 21cdf0e10cSrcweir 22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 23cdf0e10cSrcweir #include "precompiled_drawinglayer.hxx" 24cdf0e10cSrcweir 25cdf0e10cSrcweir #include <drawinglayer/attribute/sdrsceneattribute3d.hxx> 26cdf0e10cSrcweir 27cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 28cdf0e10cSrcweir 29cdf0e10cSrcweir namespace drawinglayer 30cdf0e10cSrcweir { 31cdf0e10cSrcweir namespace attribute 32cdf0e10cSrcweir { 33cdf0e10cSrcweir class ImpSdrSceneAttribute 34cdf0e10cSrcweir { 35cdf0e10cSrcweir public: 36cdf0e10cSrcweir // refcounter 37cdf0e10cSrcweir sal_uInt32 mnRefCount; 38cdf0e10cSrcweir 39cdf0e10cSrcweir // 3D scene attribute definitions 40cdf0e10cSrcweir double mfDistance; 41cdf0e10cSrcweir double mfShadowSlant; 42cdf0e10cSrcweir ::com::sun::star::drawing::ProjectionMode maProjectionMode; 43cdf0e10cSrcweir ::com::sun::star::drawing::ShadeMode maShadeMode; 44cdf0e10cSrcweir 45cdf0e10cSrcweir // bitfield 46cdf0e10cSrcweir unsigned mbTwoSidedLighting : 1; 47cdf0e10cSrcweir 48cdf0e10cSrcweir public: ImpSdrSceneAttribute(double fDistance,double fShadowSlant,::com::sun::star::drawing::ProjectionMode aProjectionMode,::com::sun::star::drawing::ShadeMode aShadeMode,bool bTwoSidedLighting)49cdf0e10cSrcweir ImpSdrSceneAttribute( 50cdf0e10cSrcweir double fDistance, 51cdf0e10cSrcweir double fShadowSlant, 52cdf0e10cSrcweir ::com::sun::star::drawing::ProjectionMode aProjectionMode, 53cdf0e10cSrcweir ::com::sun::star::drawing::ShadeMode aShadeMode, 54cdf0e10cSrcweir bool bTwoSidedLighting) 55cdf0e10cSrcweir : mnRefCount(0), 56cdf0e10cSrcweir mfDistance(fDistance), 57cdf0e10cSrcweir mfShadowSlant(fShadowSlant), 58cdf0e10cSrcweir maProjectionMode(aProjectionMode), 59cdf0e10cSrcweir maShadeMode(aShadeMode), 60cdf0e10cSrcweir mbTwoSidedLighting(bTwoSidedLighting) 61cdf0e10cSrcweir { 62cdf0e10cSrcweir } 63cdf0e10cSrcweir 64cdf0e10cSrcweir // data read access getDistance() const65cdf0e10cSrcweir double getDistance() const { return mfDistance; } getShadowSlant() const66cdf0e10cSrcweir double getShadowSlant() const { return mfShadowSlant; } getProjectionMode() const67cdf0e10cSrcweir ::com::sun::star::drawing::ProjectionMode getProjectionMode() const { return maProjectionMode; } getShadeMode() const68cdf0e10cSrcweir ::com::sun::star::drawing::ShadeMode getShadeMode() const { return maShadeMode; } getTwoSidedLighting() const69cdf0e10cSrcweir bool getTwoSidedLighting() const { return mbTwoSidedLighting; } 70cdf0e10cSrcweir operator ==(const ImpSdrSceneAttribute & rCandidate) const71cdf0e10cSrcweir bool operator==(const ImpSdrSceneAttribute& rCandidate) const 72cdf0e10cSrcweir { 73cdf0e10cSrcweir return (getDistance() == rCandidate.getDistance() 74cdf0e10cSrcweir && getShadowSlant() == rCandidate.getShadowSlant() 75cdf0e10cSrcweir && getProjectionMode() == rCandidate.getProjectionMode() 76cdf0e10cSrcweir && getShadeMode() == rCandidate.getShadeMode() 77cdf0e10cSrcweir && getTwoSidedLighting() == rCandidate.getTwoSidedLighting()); 78cdf0e10cSrcweir } 79cdf0e10cSrcweir get_global_default()80cdf0e10cSrcweir static ImpSdrSceneAttribute* get_global_default() 81cdf0e10cSrcweir { 82cdf0e10cSrcweir static ImpSdrSceneAttribute* pDefault = 0; 83cdf0e10cSrcweir 84cdf0e10cSrcweir if(!pDefault) 85cdf0e10cSrcweir { 86cdf0e10cSrcweir pDefault = new ImpSdrSceneAttribute( 87cdf0e10cSrcweir 0.0, 0.0, 88cdf0e10cSrcweir ::com::sun::star::drawing::ProjectionMode_PARALLEL, 89cdf0e10cSrcweir ::com::sun::star::drawing::ShadeMode_FLAT, 90cdf0e10cSrcweir false); 91cdf0e10cSrcweir 92cdf0e10cSrcweir // never delete; start with RefCount 1, not 0 93cdf0e10cSrcweir pDefault->mnRefCount++; 94cdf0e10cSrcweir } 95cdf0e10cSrcweir 96cdf0e10cSrcweir return pDefault; 97cdf0e10cSrcweir } 98cdf0e10cSrcweir }; 99cdf0e10cSrcweir SdrSceneAttribute(double fDistance,double fShadowSlant,::com::sun::star::drawing::ProjectionMode aProjectionMode,::com::sun::star::drawing::ShadeMode aShadeMode,bool bTwoSidedLighting)100cdf0e10cSrcweir SdrSceneAttribute::SdrSceneAttribute( 101cdf0e10cSrcweir double fDistance, 102cdf0e10cSrcweir double fShadowSlant, 103cdf0e10cSrcweir ::com::sun::star::drawing::ProjectionMode aProjectionMode, 104cdf0e10cSrcweir ::com::sun::star::drawing::ShadeMode aShadeMode, 105cdf0e10cSrcweir bool bTwoSidedLighting) 106cdf0e10cSrcweir : mpSdrSceneAttribute(new ImpSdrSceneAttribute( 107cdf0e10cSrcweir fDistance, fShadowSlant, aProjectionMode, aShadeMode, bTwoSidedLighting)) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir } 110cdf0e10cSrcweir SdrSceneAttribute()111cdf0e10cSrcweir SdrSceneAttribute::SdrSceneAttribute() 112cdf0e10cSrcweir : mpSdrSceneAttribute(ImpSdrSceneAttribute::get_global_default()) 113cdf0e10cSrcweir { 114cdf0e10cSrcweir mpSdrSceneAttribute->mnRefCount++; 115cdf0e10cSrcweir } 116cdf0e10cSrcweir SdrSceneAttribute(const SdrSceneAttribute & rCandidate)117cdf0e10cSrcweir SdrSceneAttribute::SdrSceneAttribute(const SdrSceneAttribute& rCandidate) 118cdf0e10cSrcweir : mpSdrSceneAttribute(rCandidate.mpSdrSceneAttribute) 119cdf0e10cSrcweir { 120cdf0e10cSrcweir mpSdrSceneAttribute->mnRefCount++; 121cdf0e10cSrcweir } 122cdf0e10cSrcweir ~SdrSceneAttribute()123cdf0e10cSrcweir SdrSceneAttribute::~SdrSceneAttribute() 124cdf0e10cSrcweir { 125cdf0e10cSrcweir if(mpSdrSceneAttribute->mnRefCount) 126cdf0e10cSrcweir { 127cdf0e10cSrcweir mpSdrSceneAttribute->mnRefCount--; 128cdf0e10cSrcweir } 129cdf0e10cSrcweir else 130cdf0e10cSrcweir { 131cdf0e10cSrcweir delete mpSdrSceneAttribute; 132cdf0e10cSrcweir } 133cdf0e10cSrcweir } 134cdf0e10cSrcweir isDefault() const135cdf0e10cSrcweir bool SdrSceneAttribute::isDefault() const 136cdf0e10cSrcweir { 137cdf0e10cSrcweir return mpSdrSceneAttribute == ImpSdrSceneAttribute::get_global_default(); 138cdf0e10cSrcweir } 139cdf0e10cSrcweir operator =(const SdrSceneAttribute & rCandidate)140cdf0e10cSrcweir SdrSceneAttribute& SdrSceneAttribute::operator=(const SdrSceneAttribute& rCandidate) 141cdf0e10cSrcweir { 142cdf0e10cSrcweir if(rCandidate.mpSdrSceneAttribute != mpSdrSceneAttribute) 143cdf0e10cSrcweir { 144cdf0e10cSrcweir if(mpSdrSceneAttribute->mnRefCount) 145cdf0e10cSrcweir { 146cdf0e10cSrcweir mpSdrSceneAttribute->mnRefCount--; 147cdf0e10cSrcweir } 148cdf0e10cSrcweir else 149cdf0e10cSrcweir { 150cdf0e10cSrcweir delete mpSdrSceneAttribute; 151cdf0e10cSrcweir } 152cdf0e10cSrcweir 153cdf0e10cSrcweir mpSdrSceneAttribute = rCandidate.mpSdrSceneAttribute; 154cdf0e10cSrcweir mpSdrSceneAttribute->mnRefCount++; 155cdf0e10cSrcweir } 156cdf0e10cSrcweir 157cdf0e10cSrcweir return *this; 158cdf0e10cSrcweir } 159cdf0e10cSrcweir operator ==(const SdrSceneAttribute & rCandidate) const160cdf0e10cSrcweir bool SdrSceneAttribute::operator==(const SdrSceneAttribute& rCandidate) const 161cdf0e10cSrcweir { 162cdf0e10cSrcweir if(rCandidate.mpSdrSceneAttribute == mpSdrSceneAttribute) 163cdf0e10cSrcweir { 164cdf0e10cSrcweir return true; 165cdf0e10cSrcweir } 166cdf0e10cSrcweir 167cdf0e10cSrcweir if(rCandidate.isDefault() != isDefault()) 168cdf0e10cSrcweir { 169cdf0e10cSrcweir return false; 170cdf0e10cSrcweir } 171cdf0e10cSrcweir 172cdf0e10cSrcweir return (*rCandidate.mpSdrSceneAttribute == *mpSdrSceneAttribute); 173cdf0e10cSrcweir } 174cdf0e10cSrcweir getDistance() const175cdf0e10cSrcweir double SdrSceneAttribute::getDistance() const 176cdf0e10cSrcweir { 177cdf0e10cSrcweir return mpSdrSceneAttribute->getDistance(); 178cdf0e10cSrcweir } 179cdf0e10cSrcweir getShadowSlant() const180cdf0e10cSrcweir double SdrSceneAttribute::getShadowSlant() const 181cdf0e10cSrcweir { 182cdf0e10cSrcweir return mpSdrSceneAttribute->getShadowSlant(); 183cdf0e10cSrcweir } 184cdf0e10cSrcweir getProjectionMode() const185cdf0e10cSrcweir ::com::sun::star::drawing::ProjectionMode SdrSceneAttribute::getProjectionMode() const 186cdf0e10cSrcweir { 187cdf0e10cSrcweir return mpSdrSceneAttribute->getProjectionMode(); 188cdf0e10cSrcweir } 189cdf0e10cSrcweir getShadeMode() const190cdf0e10cSrcweir ::com::sun::star::drawing::ShadeMode SdrSceneAttribute::getShadeMode() const 191cdf0e10cSrcweir { 192cdf0e10cSrcweir return mpSdrSceneAttribute->getShadeMode(); 193cdf0e10cSrcweir } 194cdf0e10cSrcweir getTwoSidedLighting() const195cdf0e10cSrcweir bool SdrSceneAttribute::getTwoSidedLighting() const 196cdf0e10cSrcweir { 197cdf0e10cSrcweir return mpSdrSceneAttribute->getTwoSidedLighting(); 198cdf0e10cSrcweir } 199cdf0e10cSrcweir 200cdf0e10cSrcweir } // end of namespace attribute 201cdf0e10cSrcweir } // end of namespace drawinglayer 202cdf0e10cSrcweir 203cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 204cdf0e10cSrcweir // eof 205