/// <summary> /// Remove all word bookmark that not exist on internal bookmark collection /// </summary> /// <param name="iBms"></param> public void ValidateBookmarkCollection(string key) { // 1. Get all word bookmark // 2. If bookmark in word not exist in internal bookmark // 2.1. markup this to return // 2.2. if isUpdate = true, we delete its try { ContentServiceProfile contentProfile = Wkl.MainCtrl.ServiceCtrl.GetProfile(key).ContentService; InternalBookmark iBms = Wkl.MainCtrl.CommonCtrl.GetTemplateInfo( contentProfile.ValidateBookmark_ITemplateName).InternalBookmark; GetBookmarkCollection(key); List <string> deletedList = new List <string>(); Dictionary <string, string> wBms = contentProfile.GetBookmarks_OListBM; foreach (string bmKey in wBms.Keys) { InternalBookmarkItem item = iBms.GetInternalBookmarkItem(bmKey); if (item == null || item.BizName != wBms[bmKey]) // compare key and value { if (MarkupUtilities.IsProntoDocCommentBookmark(bmKey) || MarkupUtilities.IsPdeTagBookmark(bmKey)) { continue; } deletedList.Add(wBms[bmKey]); contentProfile.HighlightBookmarkName = bmKey; HighlightBookmark(key); if (contentProfile.ValidateBookmark_IIsUpdate) { contentProfile.DeletedBookmarkName = bmKey; contentProfile.DeleteWholeBookmark = false; DeleteBookmark(key); } } } contentProfile.ValidateBookmark_ORemovedList = deletedList; } catch (BaseException srvExp) { Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_ValidateWordBookmarkError); newSrvExp.Errors.Add(srvExp); throw newSrvExp; } catch (Exception ex) { ServiceException srvExp = new ServiceException(ErrorCode.ipe_ValidateWordBookmarkError, MessageUtils.Expand(Properties.Resources.ipe_ValidateWordBookmarkError, ex.Message), ex.StackTrace); throw srvExp; } }
/// <summary> /// Check this section has bookmark or no /// </summary> /// <param name="Sel">Section</param> /// <returns></returns> public string HasBookmark(Selection Sel) { string bmName = string.Empty; if (Sel != null) { if (Sel.Bookmarks != null) { int count = Sel.Bookmarks.Count; if (count > 0) { string selText = Sel.Range.Text; foreach (Bookmark bm in Sel.Bookmarks) { string bmValue = bm.Range.Text; if (string.IsNullOrEmpty(selText)) { if (!MarkupUtilities.IsProntoDocCommentBookmark(bm.Name)) { bm.Range.Select(); bmName = count == 1 ? bm.Name : string.Empty; } continue; } if (!selText.Contains(bmValue) && !MarkupUtilities.IsProntoDocCommentBookmark(bm.Name)) { if (bm.End > Sel.End) // bookmark is end of selection { Sel.End = bm.End; } if (Sel.Start > bm.Start) // bookmark is start of selection { Sel.Start = bm.Start; } bmName = count == 1 ? bm.Name : string.Empty; } } } } } return(bmName); }