1 /* 2 * Copyright 2013, Stephan Aßmus <superstippi@gmx.de>. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 6 #include "ParagraphStyle.h" 7 8 9 ParagraphStyle::ParagraphStyle() 10 : 11 fStyleData(new ParagraphStyleData(), true) 12 { 13 } 14 15 16 ParagraphStyle::ParagraphStyle(const ParagraphStyle& other) 17 : 18 fStyleData(other.fStyleData) 19 { 20 } 21 22 23 ParagraphStyle& 24 ParagraphStyle::operator=(const ParagraphStyle& other) 25 { 26 if (this == &other) 27 return *this; 28 29 fStyleData = other.fStyleData; 30 return *this; 31 } 32 33 34 bool 35 ParagraphStyle::operator==(const ParagraphStyle& other) const 36 { 37 if (this == &other) 38 return true; 39 40 if (fStyleData == other.fStyleData) 41 return true; 42 43 if (fStyleData.IsSet() && other.fStyleData.IsSet()) 44 return *fStyleData == *other.fStyleData; 45 46 return false; 47 } 48 49 50 bool 51 ParagraphStyle::operator!=(const ParagraphStyle& other) const 52 { 53 return !(*this == other); 54 } 55 56 57 bool 58 ParagraphStyle::SetAlignment(::Alignment alignment) 59 { 60 ParagraphStyleDataRef data = fStyleData->SetAlignment(alignment); 61 if (data == fStyleData) 62 return data->Alignment() == alignment; 63 64 fStyleData = data; 65 return true; 66 } 67 68 69 ::Alignment 70 ParagraphStyle::Alignment() const 71 { 72 return fStyleData->Alignment(); 73 } 74 75 76 bool 77 ParagraphStyle::SetJustify(bool justify) 78 { 79 ParagraphStyleDataRef data = fStyleData->SetJustify(justify); 80 if (data == fStyleData) 81 return data->Justify() == justify; 82 83 fStyleData = data; 84 return true; 85 } 86 87 88 bool 89 ParagraphStyle::Justify() const 90 { 91 return fStyleData->Justify(); 92 } 93 94 95 bool 96 ParagraphStyle::SetFirstLineInset(float inset) 97 { 98 ParagraphStyleDataRef data = fStyleData->SetFirstLineInset(inset); 99 if (data == fStyleData) 100 return data->FirstLineInset() == inset; 101 102 fStyleData = data; 103 return true; 104 } 105 106 107 float 108 ParagraphStyle::FirstLineInset() const 109 { 110 return fStyleData->FirstLineInset(); 111 } 112 113 114 bool 115 ParagraphStyle::SetLineInset(float inset) 116 { 117 ParagraphStyleDataRef data = fStyleData->SetLineInset(inset); 118 if (data == fStyleData) 119 return data->LineInset() == inset; 120 121 fStyleData = data; 122 return true; 123 } 124 125 126 float 127 ParagraphStyle::LineInset() const 128 { 129 return fStyleData->LineInset(); 130 } 131 132 133 bool 134 ParagraphStyle::SetLineSpacing(float spacing) 135 { 136 ParagraphStyleDataRef data = fStyleData->SetLineSpacing(spacing); 137 if (data == fStyleData) 138 return data->LineSpacing() == spacing; 139 140 fStyleData = data; 141 return true; 142 } 143 144 145 float 146 ParagraphStyle::LineSpacing() const 147 { 148 return fStyleData->LineSpacing(); 149 } 150 151 152 bool 153 ParagraphStyle::SetSpacingTop(float spacing) 154 { 155 ParagraphStyleDataRef data = fStyleData->SetSpacingTop(spacing); 156 if (data == fStyleData) 157 return data->SpacingTop() == spacing; 158 159 fStyleData = data; 160 return true; 161 } 162 163 164 float 165 ParagraphStyle::SpacingTop() const 166 { 167 return fStyleData->SpacingTop(); 168 } 169 170 171 bool 172 ParagraphStyle::SetSpacingBottom(float spacing) 173 { 174 ParagraphStyleDataRef data = fStyleData->SetSpacingBottom(spacing); 175 if (data == fStyleData) 176 return data->SpacingBottom() == spacing; 177 178 fStyleData = data; 179 return true; 180 } 181 182 183 float 184 ParagraphStyle::SpacingBottom() const 185 { 186 return fStyleData->SpacingBottom(); 187 } 188 189 190 bool 191 ParagraphStyle::SetBullet(const ::Bullet& bullet) 192 { 193 ParagraphStyleDataRef data = fStyleData->SetBullet(bullet); 194 if (data == fStyleData) 195 return data->Bullet() == bullet; 196 197 fStyleData = data; 198 return true; 199 } 200 201 202 const ::Bullet& 203 ParagraphStyle::Bullet() const 204 { 205 return fStyleData->Bullet(); 206 } 207 208 209