1*f6e50924SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*f6e50924SAndrew Rist * distributed with this work for additional information 6*f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9*f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10*f6e50924SAndrew Rist * 11*f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*f6e50924SAndrew Rist * 13*f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*f6e50924SAndrew Rist * software distributed under the License is distributed on an 15*f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17*f6e50924SAndrew Rist * specific language governing permissions and limitations 18*f6e50924SAndrew Rist * under the License. 19*f6e50924SAndrew Rist * 20*f6e50924SAndrew Rist *************************************************************/ 21*f6e50924SAndrew Rist 22*f6e50924SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include "precompiled_svx.hxx" 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <svx/sdr/attribute/sdrformtextoutlineattribute.hxx> 27cdf0e10cSrcweir #include <drawinglayer/attribute/lineattribute.hxx> 28cdf0e10cSrcweir #include <drawinglayer/attribute/strokeattribute.hxx> 29cdf0e10cSrcweir 30cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 31cdf0e10cSrcweir 32cdf0e10cSrcweir namespace drawinglayer 33cdf0e10cSrcweir { 34cdf0e10cSrcweir namespace attribute 35cdf0e10cSrcweir { 36cdf0e10cSrcweir class ImpSdrFormTextOutlineAttribute 37cdf0e10cSrcweir { 38cdf0e10cSrcweir public: 39cdf0e10cSrcweir // refcounter 40cdf0e10cSrcweir sal_uInt32 mnRefCount; 41cdf0e10cSrcweir 42cdf0e10cSrcweir // one set of attributes for FormText (FontWork) outline visualisation 43cdf0e10cSrcweir LineAttribute maLineAttribute; 44cdf0e10cSrcweir StrokeAttribute maStrokeAttribute; 45cdf0e10cSrcweir sal_uInt8 mnTransparence; 46cdf0e10cSrcweir ImpSdrFormTextOutlineAttribute(const LineAttribute & rLineAttribute,const StrokeAttribute & rStrokeAttribute,sal_uInt8 nTransparence)47cdf0e10cSrcweir ImpSdrFormTextOutlineAttribute( 48cdf0e10cSrcweir const LineAttribute& rLineAttribute, 49cdf0e10cSrcweir const StrokeAttribute& rStrokeAttribute, 50cdf0e10cSrcweir sal_uInt8 nTransparence) 51cdf0e10cSrcweir : mnRefCount(0), 52cdf0e10cSrcweir maLineAttribute(rLineAttribute), 53cdf0e10cSrcweir maStrokeAttribute(rStrokeAttribute), 54cdf0e10cSrcweir mnTransparence(nTransparence) 55cdf0e10cSrcweir { 56cdf0e10cSrcweir } 57cdf0e10cSrcweir 58cdf0e10cSrcweir // data read access getLineAttribute() const59cdf0e10cSrcweir const LineAttribute& getLineAttribute() const { return maLineAttribute; } getStrokeAttribute() const60cdf0e10cSrcweir const StrokeAttribute& getStrokeAttribute() const { return maStrokeAttribute; } getTransparence() const61cdf0e10cSrcweir sal_uInt8 getTransparence() const { return mnTransparence; } 62cdf0e10cSrcweir 63cdf0e10cSrcweir // compare operator operator ==(const ImpSdrFormTextOutlineAttribute & rCandidate) const64cdf0e10cSrcweir bool operator==(const ImpSdrFormTextOutlineAttribute& rCandidate) const 65cdf0e10cSrcweir { 66cdf0e10cSrcweir return (getLineAttribute() == rCandidate.getLineAttribute() 67cdf0e10cSrcweir && getStrokeAttribute() == rCandidate.getStrokeAttribute() 68cdf0e10cSrcweir && getTransparence() == rCandidate.getTransparence()); 69cdf0e10cSrcweir } 70cdf0e10cSrcweir get_global_default()71cdf0e10cSrcweir static ImpSdrFormTextOutlineAttribute* get_global_default() 72cdf0e10cSrcweir { 73cdf0e10cSrcweir static ImpSdrFormTextOutlineAttribute* pDefault = 0; 74cdf0e10cSrcweir 75cdf0e10cSrcweir if(!pDefault) 76cdf0e10cSrcweir { 77cdf0e10cSrcweir pDefault = new ImpSdrFormTextOutlineAttribute( 78cdf0e10cSrcweir LineAttribute(), 79cdf0e10cSrcweir StrokeAttribute(), 80cdf0e10cSrcweir 0); 81cdf0e10cSrcweir 82cdf0e10cSrcweir // never delete; start with RefCount 1, not 0 83cdf0e10cSrcweir pDefault->mnRefCount++; 84cdf0e10cSrcweir } 85cdf0e10cSrcweir 86cdf0e10cSrcweir return pDefault; 87cdf0e10cSrcweir } 88cdf0e10cSrcweir }; 89cdf0e10cSrcweir SdrFormTextOutlineAttribute(const LineAttribute & rLineAttribute,const StrokeAttribute & rStrokeAttribute,sal_uInt8 nTransparence)90cdf0e10cSrcweir SdrFormTextOutlineAttribute::SdrFormTextOutlineAttribute( 91cdf0e10cSrcweir const LineAttribute& rLineAttribute, 92cdf0e10cSrcweir const StrokeAttribute& rStrokeAttribute, 93cdf0e10cSrcweir sal_uInt8 nTransparence) 94cdf0e10cSrcweir : mpSdrFormTextOutlineAttribute(new ImpSdrFormTextOutlineAttribute( 95cdf0e10cSrcweir rLineAttribute, rStrokeAttribute, nTransparence)) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir } 98cdf0e10cSrcweir SdrFormTextOutlineAttribute()99cdf0e10cSrcweir SdrFormTextOutlineAttribute::SdrFormTextOutlineAttribute() 100cdf0e10cSrcweir : mpSdrFormTextOutlineAttribute(ImpSdrFormTextOutlineAttribute::get_global_default()) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir mpSdrFormTextOutlineAttribute->mnRefCount++; 103cdf0e10cSrcweir } 104cdf0e10cSrcweir SdrFormTextOutlineAttribute(const SdrFormTextOutlineAttribute & rCandidate)105cdf0e10cSrcweir SdrFormTextOutlineAttribute::SdrFormTextOutlineAttribute(const SdrFormTextOutlineAttribute& rCandidate) 106cdf0e10cSrcweir : mpSdrFormTextOutlineAttribute(rCandidate.mpSdrFormTextOutlineAttribute) 107cdf0e10cSrcweir { 108cdf0e10cSrcweir mpSdrFormTextOutlineAttribute->mnRefCount++; 109cdf0e10cSrcweir } 110cdf0e10cSrcweir ~SdrFormTextOutlineAttribute()111cdf0e10cSrcweir SdrFormTextOutlineAttribute::~SdrFormTextOutlineAttribute() 112cdf0e10cSrcweir { 113cdf0e10cSrcweir if(mpSdrFormTextOutlineAttribute->mnRefCount) 114cdf0e10cSrcweir { 115cdf0e10cSrcweir mpSdrFormTextOutlineAttribute->mnRefCount--; 116cdf0e10cSrcweir } 117cdf0e10cSrcweir else 118cdf0e10cSrcweir { 119cdf0e10cSrcweir delete mpSdrFormTextOutlineAttribute; 120cdf0e10cSrcweir } 121cdf0e10cSrcweir } 122cdf0e10cSrcweir isDefault() const123cdf0e10cSrcweir bool SdrFormTextOutlineAttribute::isDefault() const 124cdf0e10cSrcweir { 125cdf0e10cSrcweir return mpSdrFormTextOutlineAttribute == ImpSdrFormTextOutlineAttribute::get_global_default(); 126cdf0e10cSrcweir } 127cdf0e10cSrcweir operator =(const SdrFormTextOutlineAttribute & rCandidate)128cdf0e10cSrcweir SdrFormTextOutlineAttribute& SdrFormTextOutlineAttribute::operator=(const SdrFormTextOutlineAttribute& rCandidate) 129cdf0e10cSrcweir { 130cdf0e10cSrcweir if(rCandidate.mpSdrFormTextOutlineAttribute != mpSdrFormTextOutlineAttribute) 131cdf0e10cSrcweir { 132cdf0e10cSrcweir if(mpSdrFormTextOutlineAttribute->mnRefCount) 133cdf0e10cSrcweir { 134cdf0e10cSrcweir mpSdrFormTextOutlineAttribute->mnRefCount--; 135cdf0e10cSrcweir } 136cdf0e10cSrcweir else 137cdf0e10cSrcweir { 138cdf0e10cSrcweir delete mpSdrFormTextOutlineAttribute; 139cdf0e10cSrcweir } 140cdf0e10cSrcweir 141cdf0e10cSrcweir mpSdrFormTextOutlineAttribute = rCandidate.mpSdrFormTextOutlineAttribute; 142cdf0e10cSrcweir mpSdrFormTextOutlineAttribute->mnRefCount++; 143cdf0e10cSrcweir } 144cdf0e10cSrcweir 145cdf0e10cSrcweir return *this; 146cdf0e10cSrcweir } 147cdf0e10cSrcweir operator ==(const SdrFormTextOutlineAttribute & rCandidate) const148cdf0e10cSrcweir bool SdrFormTextOutlineAttribute::operator==(const SdrFormTextOutlineAttribute& rCandidate) const 149cdf0e10cSrcweir { 150cdf0e10cSrcweir if(rCandidate.mpSdrFormTextOutlineAttribute == mpSdrFormTextOutlineAttribute) 151cdf0e10cSrcweir { 152cdf0e10cSrcweir return true; 153cdf0e10cSrcweir } 154cdf0e10cSrcweir 155cdf0e10cSrcweir if(rCandidate.isDefault() != isDefault()) 156cdf0e10cSrcweir { 157cdf0e10cSrcweir return false; 158cdf0e10cSrcweir } 159cdf0e10cSrcweir 160cdf0e10cSrcweir return (*rCandidate.mpSdrFormTextOutlineAttribute == *mpSdrFormTextOutlineAttribute); 161cdf0e10cSrcweir } 162cdf0e10cSrcweir getLineAttribute() const163cdf0e10cSrcweir const LineAttribute& SdrFormTextOutlineAttribute::getLineAttribute() const 164cdf0e10cSrcweir { 165cdf0e10cSrcweir return mpSdrFormTextOutlineAttribute->getLineAttribute(); 166cdf0e10cSrcweir } 167cdf0e10cSrcweir getStrokeAttribute() const168cdf0e10cSrcweir const StrokeAttribute& SdrFormTextOutlineAttribute::getStrokeAttribute() const 169cdf0e10cSrcweir { 170cdf0e10cSrcweir return mpSdrFormTextOutlineAttribute->getStrokeAttribute(); 171cdf0e10cSrcweir } 172cdf0e10cSrcweir getTransparence() const173cdf0e10cSrcweir sal_uInt8 SdrFormTextOutlineAttribute::getTransparence() const 174cdf0e10cSrcweir { 175cdf0e10cSrcweir return mpSdrFormTextOutlineAttribute->getTransparence(); 176cdf0e10cSrcweir } 177cdf0e10cSrcweir } // end of namespace attribute 178cdf0e10cSrcweir } // end of namespace drawinglayer 179cdf0e10cSrcweir 180cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 181cdf0e10cSrcweir // eof 182