示例#1
0
void RichTxt::FormatInfo::ApplyTo(RichPara::CharFormat& fmt) const
{
	if(charvalid & BOLD)
		fmt.Bold(IsBold());
	if(charvalid & ITALIC)
		fmt.Italic(IsItalic());
	if(charvalid & UNDERLINE)
		fmt.Underline(IsUnderline());
	if(charvalid & STRIKEOUT)
		fmt.Strikeout(IsStrikeout());
	if(charvalid & NOAA)
		fmt.NonAntiAliased(IsNonAntiAliased());
	if(charvalid & CAPITALS)
		fmt.capitals = capitals;
	if(charvalid & DASHED)
		fmt.dashed = dashed;
	if(charvalid & SSCRIPT)
		fmt.sscript = sscript;
	if(charvalid & FACE)
		fmt.Face(GetFace());
	if(charvalid & HEIGHT)
		fmt.Height(GetHeight());
	if(charvalid & LANGUAGE)
		fmt.language = language;
	if(charvalid & INK)
		fmt.ink = ink;
	if(charvalid & PAPER)
		fmt.paper = paper;
	if(charvalid & LANG)
		fmt.language = language;
	if(charvalid & LINK)
		fmt.link = link;
	if(charvalid & INDEXENTRY)
		fmt.indexentry = indexentry;
}
示例#2
0
void RichTxt::FormatInfo::Combine(const RichPara::CharFormat& fmt)
{
	if(IsBold() != fmt.IsBold()) {
		charvalid &= ~BOLD;
		NoBold();
	}
	if(IsItalic() != fmt.IsItalic()) {
		charvalid &= ~ITALIC;
		NoItalic();
	}
	if(IsUnderline() != fmt.IsUnderline()) {
		charvalid &= ~UNDERLINE;
		NoUnderline();
	}
	if(IsStrikeout() != fmt.IsStrikeout()) {
		charvalid &= ~STRIKEOUT;
		NoStrikeout();
	}
	if(IsNonAntiAliased() != fmt.IsNonAntiAliased()) {
		charvalid &= ~NOAA;
		NoNonAntiAliased();
	}
	if(capitals != fmt.capitals) {
		charvalid &= ~CAPITALS;
		capitals = false;
	}
	if(dashed != fmt.dashed) {
		charvalid &= ~DASHED;
		dashed = false;
	}
	if(sscript != fmt.sscript) {
		charvalid &= ~SSCRIPT;
		sscript = 0;
	}
	if(GetFace() != fmt.GetFace())
		charvalid &= ~FACE;
	if(GetHeight() != fmt.GetHeight())
		charvalid &= ~HEIGHT;
	if(ink != fmt.ink) {
		charvalid &= ~INK;
		ink = Null;
	}
	if(paper != fmt.paper) {
		charvalid &= ~PAPER;
		paper = Null;
	}
	if(language != fmt.language) {
		charvalid &= ~LANG;
		language = 0;
	}
	if(link != fmt.link) {
		charvalid &= ~LINK;
		link = Null;
	}
	if(indexentry != fmt.indexentry) {
		charvalid &= ~INDEXENTRY;
		indexentry = Null;
	}
}
示例#3
0
void ApplyCharStyle(RichPara::CharFormat& format, const RichPara::CharFormat& f0,
                    const RichPara::CharFormat& newstyle) { 
	if(format.IsBold() == f0.IsBold())
		format.Bold(newstyle.IsBold());
	if(format.IsUnderline() == f0.IsUnderline())
		format.Underline(newstyle.IsUnderline());
	if(format.IsItalic() == f0.IsItalic())
		format.Italic(newstyle.IsItalic());
	if(format.IsStrikeout() == f0.IsStrikeout())
		format.Strikeout(newstyle.IsStrikeout());
	if(format.IsNonAntiAliased() == f0.IsNonAntiAliased())
		format.NonAntiAliased(newstyle.IsNonAntiAliased());
	if(format.capitals == f0.capitals)
		format.capitals = newstyle.capitals;
	if(format.dashed == f0.dashed)
		format.dashed = newstyle.dashed;
	if(format.sscript == f0.sscript)
		format.sscript = newstyle.sscript;
	if(format.GetFace() == f0.GetFace())
		format.Face(newstyle.GetFace());
	if(format.GetHeight() == f0.GetHeight())
		format.Height(newstyle.GetHeight());
	if(format.ink == f0.ink)
		format.ink = newstyle.ink;
	if(format.paper == f0.paper)
		format.paper = newstyle.paper;
}
示例#4
0
void RichPara::UnpackParts(Stream& in, const RichPara::CharFormat& chrstyle,
                           Array<RichPara::Part>& part, const Array<RichObject>& obj,
                           int& oi) {
	part.Add();
	part.Top().format = format;
	int c;
	while((c = in.Term()) >= 0)
		if(c < 31 && c != 9 && c != FIELD) {
			do
				switch(in.Get()) {
				case BOLD0:
					format.NoBold();
					break;
				case BOLD1:
					format.Bold();
					break;
				case BOLDS:
					format.Bold(chrstyle.IsBold());
					break;
				case ITALIC0:
					format.NoItalic();
					break;
				case ITALIC1:
					format.Italic();
					break;
				case ITALICS:
					format.Italic(chrstyle.IsItalic());
					break;
				case UNDERLINE0:
					format.NoUnderline();
					break;
				case UNDERLINE1:
					format.Underline();
					break;
				case UNDERLINES:
					format.Underline(chrstyle.IsUnderline());
					break;
				case STRIKEOUT0:
					format.NoStrikeout();
					break;
				case STRIKEOUT1:
					format.Strikeout();
					break;
				case STRIKEOUTS:
					format.Strikeout(chrstyle.IsStrikeout());
					break;
				case CAPITALS0:
					format.capitals = false;
					break;
				case CAPITALS1:
					format.capitals = true;
					break;
				case CAPITALSS:
					format.capitals = chrstyle.capitals;
					break;
				case DASHED0:
					format.dashed = false;
					break;
				case DASHED1:
					format.dashed = true;
					break;
				case DASHEDS:
					format.dashed = chrstyle.dashed;
					break;
				case SSCRIPT:
					format.sscript = in.Get();
					if(format.sscript == 3)
						format.sscript = chrstyle.sscript;
					break;
				case FACE:
					c = in.Get16();
					format.Face(c == 0xffff ? chrstyle.GetFace() : c);
					break;
				case HEIGHT:
					c = in.Get16();
					format.Height(c == 0xffff ? chrstyle.GetHeight() : c);
					break;
				case LINK:
					in % format.link;
					break;
				case INDEXENTRY:
					in % format.indexentry;
					break;
				case INK:
					in % format.ink;
					break;
				case PAPER:
					in % format.paper;
					break;
				case LANGUAGE:
					format.language = in.Get32();
					break;
				case EXT:
					switch(in.Get()) {
					case NONAA0:
						format.NonAntiAliased(false);
						break;
					case NONAA1:
						format.NonAntiAliased(true);
						break;
					case NONAAS:
						format.NonAntiAliased(chrstyle.IsNonAntiAliased());
						break;
					}
				}
			while((c = in.Term()) < 31 && c != 9 && c != FIELD && c >= 0);
			if(part.Top().text.GetLength())
				part.Add();
			part.Top().format = format;
		}
		else
		if(in.Term() == FIELD) {
			RichPara::Format pformat = format;
			if(part.Top().text.GetLength()) {
				part.Add();
				part.Top().format = pformat;
			}
			in.Get();
			Part& p = part.Top();
			String id;
			in % id;
			p.field = id;
			in % p.fieldparam;
			String s;
			in % s;
			StringStream sn(s);
			UnpackParts(sn, chrstyle, p.fieldpart, obj, oi);
			part.Add();
			part.Top().format = format = pformat;
		}
		else
		if(in.Term() == OBJECT) {
			if(part.Top().text.GetLength()) {
				part.Add();
				part.Top().format = format;
			}
			part.Top().object = obj[oi++];
			part.Top().format = format;
			part.Add();
			part.Top().format = format;
			in.Get();
		}
		else {
			StringBuffer b;
			b.Reserve(512);
			while(in.Term() >= 32 || in.Term() == 9)
				b.Cat(in.Get());
			part.Top().text.Cat(FromUtf8(~b));
		}
	if(part.Top().text.GetLength() == 0 && part.Top().IsText())
		part.Drop();
}
示例#5
0
void RichPara::Charformat(Stream& out, const RichPara::CharFormat& o,
                          const RichPara::CharFormat& n, const RichPara::CharFormat& s)
{
	if(o.IsBold() != n.IsBold())
		out.Put(n.IsBold() == s.IsBold() ? BOLDS : BOLD0 + n.IsBold());
	if(o.IsItalic() != n.IsItalic())
		out.Put(n.IsItalic() == s.IsItalic() ? ITALICS
		                                     : ITALIC0 + n.IsItalic());
	if(o.IsUnderline() != n.IsUnderline())
		out.Put(n.IsUnderline() == s.IsUnderline() ? UNDERLINES
		                                           : UNDERLINE0 + n.IsUnderline());
	if(o.IsStrikeout() != n.IsStrikeout())
		out.Put(n.IsStrikeout() == s.IsStrikeout() ? STRIKEOUTS
		                                           : STRIKEOUT0 + n.IsStrikeout());
	if(o.IsNonAntiAliased() != n.IsNonAntiAliased()) {
		out.Put(EXT);
		out.Put(n.IsNonAntiAliased() == s.IsNonAntiAliased() ? NONAAS
		                                                     : NONAA0 + n.IsNonAntiAliased());
	}
	if(o.capitals != n.capitals)
		out.Put(n.capitals == s.capitals ? CAPITALSS
		                                 : CAPITALS0 + n.capitals);
	if(o.dashed != n.dashed)
		out.Put(n.dashed == s.dashed ? DASHEDS
		                             : DASHED0 + n.dashed);
	if(o.sscript != n.sscript) {
		out.Put(SSCRIPT);
		out.Put(n.sscript);
	}
	if(o.GetFace() != n.GetFace()) {
		out.Put(FACE);
		out.Put16(n.GetFace() == s.GetFace() ? 0xffff : n.GetFace());
	}
	if(o.GetHeight() != n.GetHeight()) {
		out.Put(HEIGHT);
		out.Put16(n.GetHeight() == s.GetHeight() ? 0xffff : n.GetHeight());
	}
	if(o.link != n.link) {
		out.Put(LINK);
		String s = n.link;
		out % s;
	}
	if(o.ink != n.ink) {
		out.Put(INK);
		Color c = n.ink;
		c.Serialize(out);
	}
	if(o.paper != n.paper) {
		out.Put(PAPER);
		Color c = n.paper;
		c.Serialize(out);
	}
	if(o.language != n.language) {
		out.Put(LANGUAGE);
		out.Put32(n.language);
	}
	if(o.indexentry != n.indexentry) {
		out.Put(INDEXENTRY);
		WString s = n.indexentry;
		out % s;
	}
}