#pragma warning disable CA1822 // Mark members as static protected void AddComments(Document book, DocumentRange range, WriteOptions options) #pragma warning restore CA1822 // Mark members as static { var comment = options.Comment; if (!string.IsNullOrWhiteSpace(comment)) { var bookComment = book.Comments.Create(range, Environment.UserName); var docComment = bookComment.BeginUpdate(); try { if (options.CommentHtml) { docComment.AppendHtmlText(comment, InsertOptions.KeepSourceFormatting); } else { docComment.AppendText(comment); } } finally { bookComment.EndUpdate(docComment); } } var bookmark = options.Bookmark; if (!string.IsNullOrWhiteSpace(bookmark)) { var oldBookmark = book.Bookmarks[bookmark]; if (oldBookmark != null) { book.Bookmarks.Remove(oldBookmark); } book.Bookmarks.Create(range, bookmark); } var hyperlink = options.Hyperlink; if (!string.IsNullOrWhiteSpace(hyperlink)) { var hyperlinkBookmark = book.Bookmarks[hyperlink]; var link = book.Hyperlinks.Create(range); if (hyperlinkBookmark != null) { link.Anchor = hyperlinkBookmark.Name; } else { link.NavigateUri = hyperlink; } if (!string.IsNullOrWhiteSpace(options.HyperlinkTooltip)) { link.ToolTip = options.HyperlinkTooltip; } if (!string.IsNullOrWhiteSpace(options.HyperlinkTarget)) { link.Target = options.HyperlinkTarget; } } }
protected internal virtual void DoWriteImage(Document book, Image chartBitmap, WriteOptions options) { if (chartBitmap == null) { return; } using (new UsingProcessor(() => book.BeginUpdate(), () => { book.EndUpdate(); })) { var image = book.Images.Append(chartBitmap); if (options.Scale != 1.0f) { image.ScaleX = image.ScaleY = options.Scale; } var range = image.Range; if (!string.IsNullOrWhiteSpace(options.ParagraphStyle) || options.FirstLineIdent.HasValue || options.FirstLineIndentType.HasValue || options.LeftIndent.HasValue || options.RightIndent.HasValue) { var pp = book.BeginUpdateParagraphs(range); try { if (!string.IsNullOrWhiteSpace(options.ParagraphStyle)) { var style = book.ParagraphStyles[options.ParagraphStyle] ?? throw new Exception($"Paragraph style '{options.ParagraphStyle}' does not exist."); pp.Style = style; } if (options.FirstLineIdent.HasValue) { pp.FirstLineIndent = options.FirstLineIdent; } if (options.FirstLineIndentType.HasValue) { pp.FirstLineIndentType = (DevExpress.XtraRichEdit.API.Native.ParagraphFirstLineIndent)options.FirstLineIndentType; } if (options.LeftIndent.HasValue) { pp.LeftIndent = options.LeftIndent; } if (options.RightIndent.HasValue) { pp.RightIndent = options.RightIndent; } } finally { book.EndUpdateParagraphs(pp); } } var rangeNewLine = book.AppendText(Environment.NewLine); AddComments(book, range, options); book.CaretPosition = rangeNewLine.End; if (book.CaretPosition != null) { Script.Book.SCBook.ResetBookFormatting(book, book.CaretPosition); } ScrollToCaret(); } }