fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / svx / source / sdr / attribute / sdrformtextoutlineattribute.cxx
blob43384b15d96482aea198c3dc3b4d32ead8826166
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <svx/sdr/attribute/sdrformtextoutlineattribute.hxx>
22 #include <drawinglayer/attribute/lineattribute.hxx>
23 #include <drawinglayer/attribute/strokeattribute.hxx>
25 //////////////////////////////////////////////////////////////////////////////
27 namespace drawinglayer
29 namespace attribute
31 class ImpSdrFormTextOutlineAttribute
33 public:
34 // refcounter
35 sal_uInt32 mnRefCount;
37 // one set of attributes for FormText (FontWork) outline visualisation
38 LineAttribute maLineAttribute;
39 StrokeAttribute maStrokeAttribute;
40 sal_uInt8 mnTransparence;
42 ImpSdrFormTextOutlineAttribute(
43 const LineAttribute& rLineAttribute,
44 const StrokeAttribute& rStrokeAttribute,
45 sal_uInt8 nTransparence)
46 : mnRefCount(0),
47 maLineAttribute(rLineAttribute),
48 maStrokeAttribute(rStrokeAttribute),
49 mnTransparence(nTransparence)
53 // data read access
54 const LineAttribute& getLineAttribute() const { return maLineAttribute; }
55 const StrokeAttribute& getStrokeAttribute() const { return maStrokeAttribute; }
56 sal_uInt8 getTransparence() const { return mnTransparence; }
58 // compare operator
59 bool operator==(const ImpSdrFormTextOutlineAttribute& rCandidate) const
61 return (getLineAttribute() == rCandidate.getLineAttribute()
62 && getStrokeAttribute() == rCandidate.getStrokeAttribute()
63 && getTransparence() == rCandidate.getTransparence());
66 static ImpSdrFormTextOutlineAttribute* get_global_default()
68 static ImpSdrFormTextOutlineAttribute* pDefault = 0;
70 if(!pDefault)
72 pDefault = new ImpSdrFormTextOutlineAttribute(
73 LineAttribute(),
74 StrokeAttribute(),
75 0);
77 // never delete; start with RefCount 1, not 0
78 pDefault->mnRefCount++;
81 return pDefault;
85 SdrFormTextOutlineAttribute::SdrFormTextOutlineAttribute(
86 const LineAttribute& rLineAttribute,
87 const StrokeAttribute& rStrokeAttribute,
88 sal_uInt8 nTransparence)
89 : mpSdrFormTextOutlineAttribute(new ImpSdrFormTextOutlineAttribute(
90 rLineAttribute, rStrokeAttribute, nTransparence))
94 SdrFormTextOutlineAttribute::SdrFormTextOutlineAttribute()
95 : mpSdrFormTextOutlineAttribute(ImpSdrFormTextOutlineAttribute::get_global_default())
97 mpSdrFormTextOutlineAttribute->mnRefCount++;
100 SdrFormTextOutlineAttribute::SdrFormTextOutlineAttribute(const SdrFormTextOutlineAttribute& rCandidate)
101 : mpSdrFormTextOutlineAttribute(rCandidate.mpSdrFormTextOutlineAttribute)
103 mpSdrFormTextOutlineAttribute->mnRefCount++;
106 SdrFormTextOutlineAttribute::~SdrFormTextOutlineAttribute()
108 if(mpSdrFormTextOutlineAttribute->mnRefCount)
110 mpSdrFormTextOutlineAttribute->mnRefCount--;
112 else
114 delete mpSdrFormTextOutlineAttribute;
118 bool SdrFormTextOutlineAttribute::isDefault() const
120 return mpSdrFormTextOutlineAttribute == ImpSdrFormTextOutlineAttribute::get_global_default();
123 SdrFormTextOutlineAttribute& SdrFormTextOutlineAttribute::operator=(const SdrFormTextOutlineAttribute& rCandidate)
125 if(rCandidate.mpSdrFormTextOutlineAttribute != mpSdrFormTextOutlineAttribute)
127 if(mpSdrFormTextOutlineAttribute->mnRefCount)
129 mpSdrFormTextOutlineAttribute->mnRefCount--;
131 else
133 delete mpSdrFormTextOutlineAttribute;
136 mpSdrFormTextOutlineAttribute = rCandidate.mpSdrFormTextOutlineAttribute;
137 mpSdrFormTextOutlineAttribute->mnRefCount++;
140 return *this;
143 bool SdrFormTextOutlineAttribute::operator==(const SdrFormTextOutlineAttribute& rCandidate) const
145 if(rCandidate.mpSdrFormTextOutlineAttribute == mpSdrFormTextOutlineAttribute)
147 return true;
150 if(rCandidate.isDefault() != isDefault())
152 return false;
155 return (*rCandidate.mpSdrFormTextOutlineAttribute == *mpSdrFormTextOutlineAttribute);
158 const LineAttribute& SdrFormTextOutlineAttribute::getLineAttribute() const
160 return mpSdrFormTextOutlineAttribute->getLineAttribute();
163 const StrokeAttribute& SdrFormTextOutlineAttribute::getStrokeAttribute() const
165 return mpSdrFormTextOutlineAttribute->getStrokeAttribute();
168 sal_uInt8 SdrFormTextOutlineAttribute::getTransparence() const
170 return mpSdrFormTextOutlineAttribute->getTransparence();
172 } // end of namespace attribute
173 } // end of namespace drawinglayer
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */