2 * Copyright 2013, Stephan Aßmus <superstippi@gmx.de>.
3 * All rights reserved. Distributed under the terms of the MIT License.
6 #include "ParagraphStyleData.h"
11 ParagraphStyleData::ParagraphStyleData()
13 fAlignment(ALIGN_LEFT
),
16 fFirstLineInset(0.0f
),
28 ParagraphStyleData::ParagraphStyleData(const ParagraphStyleData
& other
)
30 fAlignment(other
.fAlignment
),
31 fJustify(other
.fJustify
),
33 fFirstLineInset(other
.fFirstLineInset
),
34 fLineInset(other
.fLineInset
),
35 fLineSpacing(other
.fLineSpacing
),
37 fSpacingTop(other
.fSpacingTop
),
38 fSpacingBottom(other
.fSpacingBottom
),
40 fBullet(other
.fBullet
)
46 ParagraphStyleData::operator==(const ParagraphStyleData
& other
) const
51 return fAlignment
== other
.fAlignment
52 && fJustify
== other
.fJustify
53 && fFirstLineInset
== other
.fFirstLineInset
54 && fLineInset
== other
.fLineInset
55 && fLineSpacing
== other
.fLineSpacing
56 && fSpacingTop
== other
.fSpacingTop
57 && fSpacingBottom
== other
.fSpacingBottom
58 && fBullet
== other
.fBullet
;
63 ParagraphStyleData::operator!=(const ParagraphStyleData
& other
) const
65 return !(*this == other
);
70 ParagraphStyleData::SetAlignment(::Alignment alignment
)
72 if (fAlignment
== alignment
)
73 return ParagraphStyleDataRef(this);
75 ParagraphStyleData
* ret
= new(std::nothrow
) ParagraphStyleData(*this);
77 return ParagraphStyleDataRef(this);
79 ret
->fAlignment
= alignment
;
80 return ParagraphStyleDataRef(ret
, true);
85 ParagraphStyleData::SetJustify(bool justify
)
87 if (fJustify
== justify
)
88 return ParagraphStyleDataRef(this);
90 ParagraphStyleData
* ret
= new(std::nothrow
) ParagraphStyleData(*this);
92 return ParagraphStyleDataRef(this);
94 ret
->fJustify
= justify
;
95 return ParagraphStyleDataRef(ret
, true);
100 ParagraphStyleData::SetFirstLineInset(float inset
)
102 if (fFirstLineInset
== inset
)
103 return ParagraphStyleDataRef(this);
105 ParagraphStyleData
* ret
= new(std::nothrow
) ParagraphStyleData(*this);
107 return ParagraphStyleDataRef(this);
109 ret
->fFirstLineInset
= inset
;
110 return ParagraphStyleDataRef(ret
, true);
114 ParagraphStyleDataRef
115 ParagraphStyleData::SetLineInset(float inset
)
117 if (fLineInset
== inset
)
118 return ParagraphStyleDataRef(this);
120 ParagraphStyleData
* ret
= new(std::nothrow
) ParagraphStyleData(*this);
122 return ParagraphStyleDataRef(this);
124 ret
->fLineInset
= inset
;
125 return ParagraphStyleDataRef(ret
, true);
129 ParagraphStyleDataRef
130 ParagraphStyleData::SetLineSpacing(float spacing
)
132 if (fLineSpacing
== spacing
)
133 return ParagraphStyleDataRef(this);
135 ParagraphStyleData
* ret
= new(std::nothrow
) ParagraphStyleData(*this);
137 return ParagraphStyleDataRef(this);
139 ret
->fLineSpacing
= spacing
;
140 return ParagraphStyleDataRef(ret
, true);
144 ParagraphStyleDataRef
145 ParagraphStyleData::SetSpacingTop(float spacing
)
147 if (fSpacingTop
== spacing
)
148 return ParagraphStyleDataRef(this);
150 ParagraphStyleData
* ret
= new(std::nothrow
) ParagraphStyleData(*this);
152 return ParagraphStyleDataRef(this);
154 ret
->fSpacingTop
= spacing
;
155 return ParagraphStyleDataRef(ret
, true);
159 ParagraphStyleDataRef
160 ParagraphStyleData::SetSpacingBottom(float spacing
)
162 if (fSpacingBottom
== spacing
)
163 return ParagraphStyleDataRef(this);
165 ParagraphStyleData
* ret
= new(std::nothrow
) ParagraphStyleData(*this);
167 return ParagraphStyleDataRef(this);
169 ret
->fSpacingBottom
= spacing
;
170 return ParagraphStyleDataRef(ret
, true);
174 ParagraphStyleDataRef
175 ParagraphStyleData::SetBullet(const ::Bullet
& bullet
)
177 if (fBullet
== bullet
)
178 return ParagraphStyleDataRef(this);
180 ParagraphStyleData
* ret
= new(std::nothrow
) ParagraphStyleData(*this);
182 return ParagraphStyleDataRef(this);
184 ret
->fBullet
= bullet
;
185 return ParagraphStyleDataRef(ret
, true);
189 // #pragma mark - private
193 ParagraphStyleData::operator=(const ParagraphStyleData
& other
)