/// <summary> /// 设置段落样式 /// </summary> /// <param name="newStyle"></param> /// <returns></returns> public DomElementList SetParagraphStyle(DocumentContentStyle newStyle) { DomDocument document = this._DocumentContent.OwnerDocument; Dictionary <DomElement, int> styleIndexs = new Dictionary <DomElement, int>(); if (this.Document.Options.SecurityOptions.EnablePermission) { newStyle.DisableDefaultValue = true; newStyle.CreatorIndex = this.Document.UserHistories.CurrentIndex; newStyle.DeleterIndex = -1; } else { newStyle.DisableDefaultValue = true; newStyle.CreatorIndex = -1; newStyle.DeleterIndex = -1; } foreach (DomParagraphFlagElement p in this.ParagraphsEOFs) { if (document.DocumentControler.CanModify(p)) { DocumentContentStyle rs = (DocumentContentStyle)p.RuntimeStyle.Clone(); if (XDependencyObject.MergeValues(newStyle, rs, true) > 0) { rs.DefaultValuePropertyNames = newStyle.GetDefaultValuePropertyNames(); int newStyleIndex = document.ContentStyles.GetStyleIndex(rs); if (newStyleIndex != p.StyleIndex) { styleIndexs[p] = newStyleIndex; } } } }//foreach if (styleIndexs.Count > 0) { DomElementList result = document.EditorSetParagraphStyle(styleIndexs, true); return(result); } else { return(null); } }