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