32 static
STRING ParagraphJustificationToString(
34 switch (justification) {
35 case JUSTIFICATION_LEFT:
37 case JUSTIFICATION_RIGHT:
39 case JUSTIFICATION_CENTER:
47 int rindent,
int rmargin)
const {
48 switch (justification_) {
49 case JUSTIFICATION_LEFT:
50 return NearlyEqual(lmargin + lindent, margin_ + first_indent_,
52 case JUSTIFICATION_RIGHT:
53 return NearlyEqual(rmargin + rindent, margin_ + first_indent_,
55 case JUSTIFICATION_CENTER:
56 return NearlyEqual(lindent, rindent, tolerance_ * 2);
64 int rindent,
int rmargin)
const {
65 switch (justification_) {
66 case JUSTIFICATION_LEFT:
67 return NearlyEqual(lmargin + lindent, margin_ + body_indent_,
69 case JUSTIFICATION_RIGHT:
70 return NearlyEqual(rmargin + rindent, margin_ + body_indent_,
72 case JUSTIFICATION_CENTER:
73 return NearlyEqual(lindent, rindent, tolerance_ * 2);
81 if (justification_ != other.justification_)
83 if (justification_ == JUSTIFICATION_CENTER ||
84 justification_ == JUSTIFICATION_UNKNOWN)
86 int tolerance = (tolerance_ + other.tolerance_) / 4;
88 other.margin_ + other.first_indent_, tolerance) &&
90 other.margin_ + other.body_indent_, tolerance);
95 const STRING &alignment = ParagraphJustificationToString(justification_);
96 snprintf(buffer,
sizeof(buffer),
97 "margin: %d, first_indent: %d, body_indent: %d, alignment: %s",
98 margin_, first_indent_, body_indent_, alignment.
string());
#define ELISTIZE(CLASSNAME)
bool ValidBodyLine(int lmargin, int lindent, int rindent, int rmargin) const
bool ValidFirstLine(int lmargin, int lindent, int rindent, int rmargin) const
bool NearlyEqual(T x, T y, T tolerance)
bool Comparable(const ParagraphModel &other) const
const char * string() const