repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / apps / haikudepot / textview / ParagraphStyle.cpp
blob9c27c706c74a47c4003fb88a3611b0ef45d6c930
1 /*
2 * Copyright 2013, Stephan Aßmus <superstippi@gmx.de>.
3 * All rights reserved. Distributed under the terms of the MIT License.
4 */
6 #include "ParagraphStyle.h"
9 ParagraphStyle::ParagraphStyle()
11 fStyleData(new ParagraphStyleData(), true)
16 ParagraphStyle::ParagraphStyle(const ParagraphStyle& other)
18 fStyleData(other.fStyleData)
23 ParagraphStyle&
24 ParagraphStyle::operator=(const ParagraphStyle& other)
26 if (this == &other)
27 return *this;
29 fStyleData = other.fStyleData;
30 return *this;
34 bool
35 ParagraphStyle::operator==(const ParagraphStyle& other) const
37 if (this == &other)
38 return true;
40 if (fStyleData == other.fStyleData)
41 return true;
43 if (fStyleData.Get() != NULL && other.fStyleData.Get() != NULL)
44 return *fStyleData.Get() == *other.fStyleData.Get();
46 return false;
50 bool
51 ParagraphStyle::operator!=(const ParagraphStyle& other) const
53 return !(*this == other);
57 bool
58 ParagraphStyle::SetAlignment(::Alignment alignment)
60 ParagraphStyleDataRef data = fStyleData->SetAlignment(alignment);
61 if (data == fStyleData)
62 return data->Alignment() == alignment;
64 fStyleData = data;
65 return true;
69 ::Alignment
70 ParagraphStyle::Alignment() const
72 return fStyleData->Alignment();
76 bool
77 ParagraphStyle::SetJustify(bool justify)
79 ParagraphStyleDataRef data = fStyleData->SetJustify(justify);
80 if (data == fStyleData)
81 return data->Justify() == justify;
83 fStyleData = data;
84 return true;
88 bool
89 ParagraphStyle::Justify() const
91 return fStyleData->Justify();
95 bool
96 ParagraphStyle::SetFirstLineInset(float inset)
98 ParagraphStyleDataRef data = fStyleData->SetFirstLineInset(inset);
99 if (data == fStyleData)
100 return data->FirstLineInset() == inset;
102 fStyleData = data;
103 return true;
107 float
108 ParagraphStyle::FirstLineInset() const
110 return fStyleData->FirstLineInset();
114 bool
115 ParagraphStyle::SetLineInset(float inset)
117 ParagraphStyleDataRef data = fStyleData->SetLineInset(inset);
118 if (data == fStyleData)
119 return data->LineInset() == inset;
121 fStyleData = data;
122 return true;
126 float
127 ParagraphStyle::LineInset() const
129 return fStyleData->LineInset();
133 bool
134 ParagraphStyle::SetLineSpacing(float spacing)
136 ParagraphStyleDataRef data = fStyleData->SetLineSpacing(spacing);
137 if (data == fStyleData)
138 return data->LineSpacing() == spacing;
140 fStyleData = data;
141 return true;
145 float
146 ParagraphStyle::LineSpacing() const
148 return fStyleData->LineSpacing();
152 bool
153 ParagraphStyle::SetSpacingTop(float spacing)
155 ParagraphStyleDataRef data = fStyleData->SetSpacingTop(spacing);
156 if (data == fStyleData)
157 return data->SpacingTop() == spacing;
159 fStyleData = data;
160 return true;
164 float
165 ParagraphStyle::SpacingTop() const
167 return fStyleData->SpacingTop();
171 bool
172 ParagraphStyle::SetSpacingBottom(float spacing)
174 ParagraphStyleDataRef data = fStyleData->SetSpacingBottom(spacing);
175 if (data == fStyleData)
176 return data->SpacingBottom() == spacing;
178 fStyleData = data;
179 return true;
183 float
184 ParagraphStyle::SpacingBottom() const
186 return fStyleData->SpacingBottom();
190 bool
191 ParagraphStyle::SetBullet(const ::Bullet& bullet)
193 ParagraphStyleDataRef data = fStyleData->SetBullet(bullet);
194 if (data == fStyleData)
195 return data->Bullet() == bullet;
197 fStyleData = data;
198 return true;
202 const ::Bullet&
203 ParagraphStyle::Bullet() const
205 return fStyleData->Bullet();