Branch data Line data Source code
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 : :
21 : : #include <svx/sdr/attribute/sdrformtextoutlineattribute.hxx>
22 : : #include <drawinglayer/attribute/lineattribute.hxx>
23 : : #include <drawinglayer/attribute/strokeattribute.hxx>
24 : :
25 : : //////////////////////////////////////////////////////////////////////////////
26 : :
27 : : namespace drawinglayer
28 : : {
29 : : namespace attribute
30 : : {
31 [ # # ]: 0 : class ImpSdrFormTextOutlineAttribute
32 : : {
33 : : public:
34 : : // refcounter
35 : : sal_uInt32 mnRefCount;
36 : :
37 : : // one set of attributes for FormText (FontWork) outline visualisation
38 : : LineAttribute maLineAttribute;
39 : : StrokeAttribute maStrokeAttribute;
40 : : sal_uInt8 mnTransparence;
41 : :
42 : 63 : ImpSdrFormTextOutlineAttribute(
43 : : const LineAttribute& rLineAttribute,
44 : : const StrokeAttribute& rStrokeAttribute,
45 : : sal_uInt8 nTransparence)
46 : : : mnRefCount(0),
47 : : maLineAttribute(rLineAttribute),
48 : : maStrokeAttribute(rStrokeAttribute),
49 [ + - ]: 63 : mnTransparence(nTransparence)
50 : : {
51 : 63 : }
52 : :
53 : : // data read access
54 : 0 : const LineAttribute& getLineAttribute() const { return maLineAttribute; }
55 : 0 : const StrokeAttribute& getStrokeAttribute() const { return maStrokeAttribute; }
56 : 0 : sal_uInt8 getTransparence() const { return mnTransparence; }
57 : :
58 : : // compare operator
59 : 0 : bool operator==(const ImpSdrFormTextOutlineAttribute& rCandidate) const
60 : : {
61 : 0 : return (getLineAttribute() == rCandidate.getLineAttribute()
62 : 0 : && getStrokeAttribute() == rCandidate.getStrokeAttribute()
63 [ # # ]: 0 : && getTransparence() == rCandidate.getTransparence());
[ # # # # ]
64 : : }
65 : :
66 : 126 : static ImpSdrFormTextOutlineAttribute* get_global_default()
67 : : {
68 : : static ImpSdrFormTextOutlineAttribute* pDefault = 0;
69 : :
70 [ + + ]: 126 : if(!pDefault)
71 : : {
72 : : pDefault = new ImpSdrFormTextOutlineAttribute(
73 : : LineAttribute(),
74 : : StrokeAttribute(),
75 [ + - ][ + - ]: 63 : 0);
[ + - ][ + - ]
76 : :
77 : : // never delete; start with RefCount 1, not 0
78 : 63 : pDefault->mnRefCount++;
79 : : }
80 : :
81 : 126 : return pDefault;
82 : : }
83 : : };
84 : :
85 : 0 : SdrFormTextOutlineAttribute::SdrFormTextOutlineAttribute(
86 : : const LineAttribute& rLineAttribute,
87 : : const StrokeAttribute& rStrokeAttribute,
88 : : sal_uInt8 nTransparence)
89 : : : mpSdrFormTextOutlineAttribute(new ImpSdrFormTextOutlineAttribute(
90 [ # # ]: 0 : rLineAttribute, rStrokeAttribute, nTransparence))
91 : : {
92 : 0 : }
93 : :
94 : 126 : SdrFormTextOutlineAttribute::SdrFormTextOutlineAttribute()
95 : 126 : : mpSdrFormTextOutlineAttribute(ImpSdrFormTextOutlineAttribute::get_global_default())
96 : : {
97 : 126 : mpSdrFormTextOutlineAttribute->mnRefCount++;
98 : 126 : }
99 : :
100 : 0 : SdrFormTextOutlineAttribute::SdrFormTextOutlineAttribute(const SdrFormTextOutlineAttribute& rCandidate)
101 : 0 : : mpSdrFormTextOutlineAttribute(rCandidate.mpSdrFormTextOutlineAttribute)
102 : : {
103 : 0 : mpSdrFormTextOutlineAttribute->mnRefCount++;
104 : 0 : }
105 : :
106 : 0 : SdrFormTextOutlineAttribute::~SdrFormTextOutlineAttribute()
107 : : {
108 [ # # ]: 0 : if(mpSdrFormTextOutlineAttribute->mnRefCount)
109 : : {
110 : 0 : mpSdrFormTextOutlineAttribute->mnRefCount--;
111 : : }
112 : : else
113 : : {
114 [ # # ]: 0 : delete mpSdrFormTextOutlineAttribute;
115 : : }
116 : 0 : }
117 : :
118 : 0 : bool SdrFormTextOutlineAttribute::isDefault() const
119 : : {
120 : 0 : return mpSdrFormTextOutlineAttribute == ImpSdrFormTextOutlineAttribute::get_global_default();
121 : : }
122 : :
123 : 0 : SdrFormTextOutlineAttribute& SdrFormTextOutlineAttribute::operator=(const SdrFormTextOutlineAttribute& rCandidate)
124 : : {
125 [ # # ]: 0 : if(rCandidate.mpSdrFormTextOutlineAttribute != mpSdrFormTextOutlineAttribute)
126 : : {
127 [ # # ]: 0 : if(mpSdrFormTextOutlineAttribute->mnRefCount)
128 : : {
129 : 0 : mpSdrFormTextOutlineAttribute->mnRefCount--;
130 : : }
131 : : else
132 : : {
133 [ # # ]: 0 : delete mpSdrFormTextOutlineAttribute;
134 : : }
135 : :
136 : 0 : mpSdrFormTextOutlineAttribute = rCandidate.mpSdrFormTextOutlineAttribute;
137 : 0 : mpSdrFormTextOutlineAttribute->mnRefCount++;
138 : : }
139 : :
140 : 0 : return *this;
141 : : }
142 : :
143 : 0 : bool SdrFormTextOutlineAttribute::operator==(const SdrFormTextOutlineAttribute& rCandidate) const
144 : : {
145 [ # # ]: 0 : if(rCandidate.mpSdrFormTextOutlineAttribute == mpSdrFormTextOutlineAttribute)
146 : : {
147 : 0 : return true;
148 : : }
149 : :
150 [ # # ]: 0 : if(rCandidate.isDefault() != isDefault())
151 : : {
152 : 0 : return false;
153 : : }
154 : :
155 : 0 : return (*rCandidate.mpSdrFormTextOutlineAttribute == *mpSdrFormTextOutlineAttribute);
156 : : }
157 : :
158 : 0 : const LineAttribute& SdrFormTextOutlineAttribute::getLineAttribute() const
159 : : {
160 : 0 : return mpSdrFormTextOutlineAttribute->getLineAttribute();
161 : : }
162 : :
163 : 0 : const StrokeAttribute& SdrFormTextOutlineAttribute::getStrokeAttribute() const
164 : : {
165 : 0 : return mpSdrFormTextOutlineAttribute->getStrokeAttribute();
166 : : }
167 : :
168 : 0 : sal_uInt8 SdrFormTextOutlineAttribute::getTransparence() const
169 : : {
170 : 0 : return mpSdrFormTextOutlineAttribute->getTransparence();
171 : : }
172 : : } // end of namespace attribute
173 : : } // end of namespace drawinglayer
174 : :
175 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|