14bfbcde8SAndrew Rist /************************************************************** 24bfbcde8SAndrew Rist * 34bfbcde8SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 44bfbcde8SAndrew Rist * or more contributor license agreements. See the NOTICE file 54bfbcde8SAndrew Rist * distributed with this work for additional information 64bfbcde8SAndrew Rist * regarding copyright ownership. The ASF licenses this file 74bfbcde8SAndrew Rist * to you under the Apache License, Version 2.0 (the 84bfbcde8SAndrew Rist * "License"); you may not use this file except in compliance 94bfbcde8SAndrew Rist * with the License. You may obtain a copy of the License at 104bfbcde8SAndrew Rist * 114bfbcde8SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 124bfbcde8SAndrew Rist * 134bfbcde8SAndrew Rist * Unless required by applicable law or agreed to in writing, 144bfbcde8SAndrew Rist * software distributed under the License is distributed on an 154bfbcde8SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 164bfbcde8SAndrew Rist * KIND, either express or implied. See the License for the 174bfbcde8SAndrew Rist * specific language governing permissions and limitations 184bfbcde8SAndrew Rist * under the License. 194bfbcde8SAndrew Rist * 204bfbcde8SAndrew Rist *************************************************************/ 21cdf0e10cSrcweir 22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 23cdf0e10cSrcweir #include "precompiled_drawinglayer.hxx" 24cdf0e10cSrcweir 25cdf0e10cSrcweir #include <drawinglayer/attribute/fillhatchattribute.hxx> 26cdf0e10cSrcweir #include <basegfx/color/bcolor.hxx> 27cdf0e10cSrcweir 28cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 29cdf0e10cSrcweir 30cdf0e10cSrcweir namespace drawinglayer 31cdf0e10cSrcweir { 32cdf0e10cSrcweir namespace attribute 33cdf0e10cSrcweir { 34cdf0e10cSrcweir class ImpFillHatchAttribute 35cdf0e10cSrcweir { 36cdf0e10cSrcweir public: 37cdf0e10cSrcweir // refcounter 38cdf0e10cSrcweir sal_uInt32 mnRefCount; 39cdf0e10cSrcweir 40cdf0e10cSrcweir // data definitions 41cdf0e10cSrcweir HatchStyle meStyle; 42cdf0e10cSrcweir double mfDistance; 43cdf0e10cSrcweir double mfAngle; 44cdf0e10cSrcweir basegfx::BColor maColor; 45*0702bc67SArmin Le Grand sal_uInt32 mnMinimalDiscreteDistance; 46cdf0e10cSrcweir 47cdf0e10cSrcweir // bitfield 48cdf0e10cSrcweir unsigned mbFillBackground : 1; 49cdf0e10cSrcweir ImpFillHatchAttribute(HatchStyle eStyle,double fDistance,double fAngle,const basegfx::BColor & rColor,sal_uInt32 nMinimalDiscreteDistance,bool bFillBackground)50cdf0e10cSrcweir ImpFillHatchAttribute( 51cdf0e10cSrcweir HatchStyle eStyle, 52cdf0e10cSrcweir double fDistance, 53cdf0e10cSrcweir double fAngle, 54cdf0e10cSrcweir const basegfx::BColor& rColor, 55*0702bc67SArmin Le Grand sal_uInt32 nMinimalDiscreteDistance, 56cdf0e10cSrcweir bool bFillBackground) 57cdf0e10cSrcweir : mnRefCount(0), 58cdf0e10cSrcweir meStyle(eStyle), 59cdf0e10cSrcweir mfDistance(fDistance), 60cdf0e10cSrcweir mfAngle(fAngle), 61cdf0e10cSrcweir maColor(rColor), 62*0702bc67SArmin Le Grand mnMinimalDiscreteDistance(nMinimalDiscreteDistance), 63cdf0e10cSrcweir mbFillBackground(bFillBackground) 64cdf0e10cSrcweir { 65cdf0e10cSrcweir } 66cdf0e10cSrcweir 67cdf0e10cSrcweir // data read access getStyle() const68cdf0e10cSrcweir HatchStyle getStyle() const { return meStyle; } getDistance() const69cdf0e10cSrcweir double getDistance() const { return mfDistance; } getAngle() const70cdf0e10cSrcweir double getAngle() const { return mfAngle; } getColor() const71cdf0e10cSrcweir const basegfx::BColor& getColor() const { return maColor; } getMinimalDiscreteDistance() const72*0702bc67SArmin Le Grand sal_uInt32 getMinimalDiscreteDistance() const { return mnMinimalDiscreteDistance; } isFillBackground() const73cdf0e10cSrcweir bool isFillBackground() const { return mbFillBackground; } 74cdf0e10cSrcweir operator ==(const ImpFillHatchAttribute & rCandidate) const75cdf0e10cSrcweir bool operator==(const ImpFillHatchAttribute& rCandidate) const 76cdf0e10cSrcweir { 77cdf0e10cSrcweir return (getStyle() == rCandidate.getStyle() 78cdf0e10cSrcweir && getDistance() == rCandidate.getDistance() 79cdf0e10cSrcweir && getAngle() == rCandidate.getAngle() 80cdf0e10cSrcweir && getColor() == rCandidate.getColor() 81*0702bc67SArmin Le Grand && getMinimalDiscreteDistance() == rCandidate.getMinimalDiscreteDistance() 82*0702bc67SArmin Le Grand && isFillBackground() == rCandidate.isFillBackground()); 83cdf0e10cSrcweir } 84cdf0e10cSrcweir get_global_default()85cdf0e10cSrcweir static ImpFillHatchAttribute* get_global_default() 86cdf0e10cSrcweir { 87cdf0e10cSrcweir static ImpFillHatchAttribute* pDefault = 0; 88cdf0e10cSrcweir 89cdf0e10cSrcweir if(!pDefault) 90cdf0e10cSrcweir { 91cdf0e10cSrcweir pDefault = new ImpFillHatchAttribute( 92cdf0e10cSrcweir HATCHSTYLE_SINGLE, 93cdf0e10cSrcweir 0.0, 0.0, 94cdf0e10cSrcweir basegfx::BColor(), 95*0702bc67SArmin Le Grand 3, // same as VCL 96cdf0e10cSrcweir false); 97cdf0e10cSrcweir 98cdf0e10cSrcweir // never delete; start with RefCount 1, not 0 99cdf0e10cSrcweir pDefault->mnRefCount++; 100cdf0e10cSrcweir } 101cdf0e10cSrcweir 102cdf0e10cSrcweir return pDefault; 103cdf0e10cSrcweir } 104cdf0e10cSrcweir }; 105cdf0e10cSrcweir FillHatchAttribute(HatchStyle eStyle,double fDistance,double fAngle,const basegfx::BColor & rColor,sal_uInt32 nMinimalDiscreteDistance,bool bFillBackground)106cdf0e10cSrcweir FillHatchAttribute::FillHatchAttribute( 107cdf0e10cSrcweir HatchStyle eStyle, 108cdf0e10cSrcweir double fDistance, 109cdf0e10cSrcweir double fAngle, 110cdf0e10cSrcweir const basegfx::BColor& rColor, 111*0702bc67SArmin Le Grand sal_uInt32 nMinimalDiscreteDistance, 112cdf0e10cSrcweir bool bFillBackground) 113*0702bc67SArmin Le Grand : mpFillHatchAttribute( 114*0702bc67SArmin Le Grand new ImpFillHatchAttribute( 115*0702bc67SArmin Le Grand eStyle, 116*0702bc67SArmin Le Grand fDistance, 117*0702bc67SArmin Le Grand fAngle, 118*0702bc67SArmin Le Grand rColor, 119*0702bc67SArmin Le Grand nMinimalDiscreteDistance, 120*0702bc67SArmin Le Grand bFillBackground)) 121cdf0e10cSrcweir { 122cdf0e10cSrcweir } 123cdf0e10cSrcweir FillHatchAttribute()124cdf0e10cSrcweir FillHatchAttribute::FillHatchAttribute() 125cdf0e10cSrcweir : mpFillHatchAttribute(ImpFillHatchAttribute::get_global_default()) 126cdf0e10cSrcweir { 127cdf0e10cSrcweir mpFillHatchAttribute->mnRefCount++; 128cdf0e10cSrcweir } 129cdf0e10cSrcweir FillHatchAttribute(const FillHatchAttribute & rCandidate)130cdf0e10cSrcweir FillHatchAttribute::FillHatchAttribute(const FillHatchAttribute& rCandidate) 131cdf0e10cSrcweir : mpFillHatchAttribute(rCandidate.mpFillHatchAttribute) 132cdf0e10cSrcweir { 133cdf0e10cSrcweir mpFillHatchAttribute->mnRefCount++; 134cdf0e10cSrcweir } 135cdf0e10cSrcweir ~FillHatchAttribute()136cdf0e10cSrcweir FillHatchAttribute::~FillHatchAttribute() 137cdf0e10cSrcweir { 138cdf0e10cSrcweir if(mpFillHatchAttribute->mnRefCount) 139cdf0e10cSrcweir { 140cdf0e10cSrcweir mpFillHatchAttribute->mnRefCount--; 141cdf0e10cSrcweir } 142cdf0e10cSrcweir else 143cdf0e10cSrcweir { 144cdf0e10cSrcweir delete mpFillHatchAttribute; 145cdf0e10cSrcweir } 146cdf0e10cSrcweir } 147cdf0e10cSrcweir isDefault() const148cdf0e10cSrcweir bool FillHatchAttribute::isDefault() const 149cdf0e10cSrcweir { 150cdf0e10cSrcweir return mpFillHatchAttribute == ImpFillHatchAttribute::get_global_default(); 151cdf0e10cSrcweir } 152cdf0e10cSrcweir operator =(const FillHatchAttribute & rCandidate)153cdf0e10cSrcweir FillHatchAttribute& FillHatchAttribute::operator=(const FillHatchAttribute& rCandidate) 154cdf0e10cSrcweir { 155cdf0e10cSrcweir if(rCandidate.mpFillHatchAttribute != mpFillHatchAttribute) 156cdf0e10cSrcweir { 157cdf0e10cSrcweir if(mpFillHatchAttribute->mnRefCount) 158cdf0e10cSrcweir { 159cdf0e10cSrcweir mpFillHatchAttribute->mnRefCount--; 160cdf0e10cSrcweir } 161cdf0e10cSrcweir else 162cdf0e10cSrcweir { 163cdf0e10cSrcweir delete mpFillHatchAttribute; 164cdf0e10cSrcweir } 165cdf0e10cSrcweir 166cdf0e10cSrcweir mpFillHatchAttribute = rCandidate.mpFillHatchAttribute; 167cdf0e10cSrcweir mpFillHatchAttribute->mnRefCount++; 168cdf0e10cSrcweir } 169cdf0e10cSrcweir 170cdf0e10cSrcweir return *this; 171cdf0e10cSrcweir } 172cdf0e10cSrcweir operator ==(const FillHatchAttribute & rCandidate) const173cdf0e10cSrcweir bool FillHatchAttribute::operator==(const FillHatchAttribute& rCandidate) const 174cdf0e10cSrcweir { 175cdf0e10cSrcweir if(rCandidate.mpFillHatchAttribute == mpFillHatchAttribute) 176cdf0e10cSrcweir { 177cdf0e10cSrcweir return true; 178cdf0e10cSrcweir } 179cdf0e10cSrcweir 180cdf0e10cSrcweir if(rCandidate.isDefault() != isDefault()) 181cdf0e10cSrcweir { 182cdf0e10cSrcweir return false; 183cdf0e10cSrcweir } 184cdf0e10cSrcweir 185cdf0e10cSrcweir return (*rCandidate.mpFillHatchAttribute == *mpFillHatchAttribute); 186cdf0e10cSrcweir } 187cdf0e10cSrcweir 188cdf0e10cSrcweir // data read access getStyle() const189cdf0e10cSrcweir HatchStyle FillHatchAttribute::getStyle() const 190cdf0e10cSrcweir { 191cdf0e10cSrcweir return mpFillHatchAttribute->getStyle(); 192cdf0e10cSrcweir } 193cdf0e10cSrcweir getDistance() const194cdf0e10cSrcweir double FillHatchAttribute::getDistance() const 195cdf0e10cSrcweir { 196cdf0e10cSrcweir return mpFillHatchAttribute->getDistance(); 197cdf0e10cSrcweir } 198cdf0e10cSrcweir getAngle() const199cdf0e10cSrcweir double FillHatchAttribute::getAngle() const 200cdf0e10cSrcweir { 201cdf0e10cSrcweir return mpFillHatchAttribute->getAngle(); 202cdf0e10cSrcweir } 203cdf0e10cSrcweir getColor() const204cdf0e10cSrcweir const basegfx::BColor& FillHatchAttribute::getColor() const 205cdf0e10cSrcweir { 206cdf0e10cSrcweir return mpFillHatchAttribute->getColor(); 207cdf0e10cSrcweir } 208cdf0e10cSrcweir getMinimalDiscreteDistance() const209*0702bc67SArmin Le Grand sal_uInt32 FillHatchAttribute::getMinimalDiscreteDistance() const 210*0702bc67SArmin Le Grand { 211*0702bc67SArmin Le Grand return mpFillHatchAttribute->getMinimalDiscreteDistance(); 212*0702bc67SArmin Le Grand } 213*0702bc67SArmin Le Grand isFillBackground() const214cdf0e10cSrcweir bool FillHatchAttribute::isFillBackground() const 215cdf0e10cSrcweir { 216cdf0e10cSrcweir return mpFillHatchAttribute->isFillBackground(); 217cdf0e10cSrcweir } 218cdf0e10cSrcweir 219cdf0e10cSrcweir } // end of namespace attribute 220cdf0e10cSrcweir } // end of namespace drawinglayer 221cdf0e10cSrcweir 222cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 223cdf0e10cSrcweir // eof 224