/// <summary> /// write formatted string /// </summary> /// <param name="strText">text</param> /// <param name="info">format</param> public void WriteString(string strText, DocumentFormatInfo info) { if (this.bolCollectionInfo) { myFontTable.Add(info.FontName); myColorTable.Add(info.TextColor); myColorTable.Add(info.BackColor); } else { this.WriteStartString(info); if (info.Multiline) { if (strText != null) { strText = strText.Replace("\n", ""); System.IO.StringReader reader = new System.IO.StringReader(strText); string strLine = reader.ReadLine(); int iCount = 0; while (strLine != null) { if (iCount > 0) { myWriter.WriteKeyword("line"); } iCount++; myWriter.WriteText(strLine); strLine = reader.ReadLine(); } reader.Close(); } } else { myWriter.WriteText(strText); } this.WriteEndString(info); } }
public void WriteEndString(DocumentFormatInfo info) { if (this.bolCollectionInfo) { return; } if (info.Subscript) { myWriter.WriteKeyword("sub0"); } if (info.Superscript) { myWriter.WriteKeyword("super0"); } if (info.Bold) { myWriter.WriteKeyword("b0"); } if (info.Italic) { myWriter.WriteKeyword("i0"); } if (info.Underline) { myWriter.WriteKeyword("ul0"); } if (info.Strikeout) { myWriter.WriteKeyword("strike0"); } if (info.Link != null && info.Link.Length > 0) { myWriter.WriteEndGroup(); myWriter.WriteEndGroup(); myWriter.WriteEndGroup(); } }
public bool EqualsSettings(DocumentFormatInfo format) { if (format == this) { return(true); } if (format == null) { return(false); } if (this.Align != format.Align) { return(false); } if (this.BackColor != format.BackColor) { return(false); } if (this.Bold != format.Bold) { return(false); } if (this.BorderColor != format.BorderColor) { return(false); } if (this.LeftBorder != format.LeftBorder) { return(false); } if (this.TopBorder != format.TopBorder) { return(false); } if (this.RightBorder != format.RightBorder) { return(false); } if (this.BottomBorder != format.BottomBorder) { return(false); } if (this.BorderStyle != format.BorderStyle) { return(false); } if (this.BorderThickness != format.BorderThickness) { return(false); } if (this.BorderSpacing != format.BorderSpacing) { return(false); } if (this.BulletedList != format.BulletedList) { return(false); } if (this.FontName != format.FontName) { return(false); } if (this.FontSize != format.FontSize) { return(false); } if (this.Italic != format.Italic) { return(false); } if (this.Hidden != format.Hidden) { return(false); } if (this.LeftIndent != format.LeftIndent) { return(false); } if (this.LineSpacing != format.LineSpacing) { return(false); } if (this.Link != format.Link) { return(false); } if (this.Multiline != format.Multiline) { return(false); } if (this.NoWwrap != format.NoWwrap) { return(false); } if (this.NumberedList != format.NumberedList) { return(false); } if (this.ParagraphFirstLineIndent != format.ParagraphFirstLineIndent) { return(false); } if (this.Spacing != format.Spacing) { return(false); } if (this.StandTabWidth != format.StandTabWidth) { return(false); } if (this.Strikeout != format.Strikeout) { return(false); } if (this.Subscript != format.Subscript) { return(false); } if (this.Superscript != format.Superscript) { return(false); } if (this.TextColor != format.TextColor) { return(false); } if (this.Underline != format.Underline) { return(false); } if (this.ReadText != format.ReadText) { return(false); } return(true); }
/// <summary> /// start write formatted text /// </summary> /// <param name="info">format</param> /// <remarks> /// This function must assort with WriteEndString strict /// </remarks> public void WriteStartString(DocumentFormatInfo info) { if (this.bolCollectionInfo) { myFontTable.Add(info.FontName); myColorTable.Add(info.TextColor); myColorTable.Add(info.BackColor); if (info.BorderColor.A != 0) { myColorTable.Add(info.BorderColor); } return; } if (info.Link != null && info.Link.Length > 0) { myWriter.WriteStartGroup(); myWriter.WriteKeyword("field"); myWriter.WriteStartGroup(); myWriter.WriteKeyword("fldinst", true); myWriter.WriteStartGroup(); myWriter.WriteKeyword("hich"); myWriter.WriteText(" HYPERLINK \"" + info.Link + "\""); myWriter.WriteEndGroup(); myWriter.WriteEndGroup(); myWriter.WriteStartGroup(); myWriter.WriteKeyword("fldrslt"); myWriter.WriteStartGroup(); } switch (info.Align) { case RTFAlignment.Left: myWriter.WriteKeyword("ql"); break; case RTFAlignment.Center: myWriter.WriteKeyword("qc"); break; case RTFAlignment.Right: myWriter.WriteKeyword("qr"); break; case RTFAlignment.Justify: myWriter.WriteKeyword("qj"); break; } myWriter.WriteKeyword("plain"); int index = 0; index = myFontTable.IndexOf(info.FontName); if (index >= 0) { myWriter.WriteKeyword("f" + index); } if (info.Bold) { myWriter.WriteKeyword("b"); } if (info.Italic) { myWriter.WriteKeyword("i"); } if (info.Underline) { myWriter.WriteKeyword("ul"); } if (info.Strikeout) { myWriter.WriteKeyword("strike"); } myWriter.WriteKeyword("fs" + Convert.ToInt32(info.FontSize * 2)); // back color index = myColorTable.IndexOf(info.BackColor); if (index >= 0) { myWriter.WriteKeyword("chcbpat" + Convert.ToString(index + 1)); } index = myColorTable.IndexOf(info.TextColor); if (index >= 0) { myWriter.WriteKeyword("cf" + Convert.ToString(index + 1)); } if (info.Subscript) { myWriter.WriteKeyword("sub"); } if (info.Superscript) { myWriter.WriteKeyword("super"); } if (info.NoWwrap) { myWriter.WriteKeyword("nowwrap"); } if (info.LeftBorder || info.TopBorder || info.RightBorder || info.BottomBorder) { // border color if (info.BorderColor.A != 0) { myWriter.WriteKeyword("chbrdr"); myWriter.WriteKeyword("brdrs"); myWriter.WriteKeyword("brdrw10"); index = myColorTable.IndexOf(info.BorderColor); if (index >= 0) { myWriter.WriteKeyword("brdrcf" + Convert.ToString(index + 1)); } } } }
/// <summary> /// write write paragraph /// </summary> /// <param name="info">format</param> public void WriteStartParagraph(DocumentFormatInfo info) { if (this.bolCollectionInfo) { myFontTable.Add("Wingdings"); } else { if (bolFirstParagraph) { bolFirstParagraph = false; myWriter.WriteRaw(System.Environment.NewLine); //myWriter.WriteKeyword("par"); } else { myWriter.WriteKeyword("par"); } if (info.NumberedList || info.BulletedList) { if (info.NumberedList) { if (myLastParagraphInfo == null || myLastParagraphInfo.NumberedList != info.NumberedList) { myWriter.WriteKeyword("pard"); myWriter.WriteStartGroup(); myWriter.WriteKeyword("pn", true); myWriter.WriteKeyword("pnlvlbody"); myWriter.WriteKeyword("pnindent400"); myWriter.WriteKeyword("pnstart1"); myWriter.WriteKeyword("pndec"); myWriter.WriteEndGroup(); } } else { if (myLastParagraphInfo == null || myLastParagraphInfo.BulletedList != info.BulletedList) { myWriter.WriteKeyword("pard"); myWriter.WriteStartGroup(); myWriter.WriteKeyword("pn", true); myWriter.WriteKeyword("pnlvlblt"); myWriter.WriteKeyword("pnindent400"); myWriter.WriteKeyword("pnf" + myFontTable.IndexOf("Wingdings")); myWriter.WriteStartGroup(); myWriter.WriteKeyword("pntxtb"); myWriter.WriteText("l"); //myWriter.WriteKeyword("'B7"); myWriter.WriteEndGroup(); myWriter.WriteEndGroup(); } } myWriter.WriteKeyword("fi-400"); } else { if (myLastParagraphInfo != null) { if (myLastParagraphInfo.NumberedList || myLastParagraphInfo.BulletedList) { myWriter.WriteKeyword("pard"); } } } switch (info.Align) { case RTFAlignment.Left: myWriter.WriteKeyword("ql"); break; case RTFAlignment.Center: myWriter.WriteKeyword("qc"); break; case RTFAlignment.Right: myWriter.WriteKeyword("qr"); break; case RTFAlignment.Justify: myWriter.WriteKeyword("qj"); break; } // // if( info.LeftAlign ) // myWriter.WriteKeyword("ql"); // if( info.CenterAlign ) // myWriter.WriteKeyword("qc"); // else if( info.RigthAlign ) // myWriter.WriteKeyword("qr"); if (info.NumberedList == false && info.BulletedList == false) { if (info.ParagraphFirstLineIndent != 0) { myWriter.WriteKeyword("fi" + Convert.ToInt32( info.ParagraphFirstLineIndent * 400 / info.StandTabWidth)); } else { myWriter.WriteKeyword("fi0"); } } //if( info.NumberedList == false && info.BulletedList == false ) { if (info.LeftIndent != 0) { myWriter.WriteKeyword("li" + Convert.ToInt32( info.LeftIndent * 400 / info.StandTabWidth)); } else { myWriter.WriteKeyword("li0"); } } myWriter.WriteKeyword("plain"); } myLastParagraphInfo = info; }