Example #1
0
        /// <summary>
        /// validate word bookmark (if exist in word but not exit in internal => highlight and markup to return)
        /// </summary>
        /// <param name="iBms"></param>
        /// <returns></returns>
        private List <string> ValidateWordBookmark(WdColorIndex color)
        {
            List <string> deletedList = new List <string>();

            foreach (Bookmark wBm in _doc.Bookmarks)
            {
                InternalBookmarkItem item = iBm.GetInternalBookmarkItem(wBm.Name);

                // 1. check null (can not find ibm)
                if (item == null)
                {
                    // todo: ngocbv_rem => confirm to remove export item
                    //if (!MarkupUtilities.IsProntoDocCommentBookmark(wBm.Name))
                    //{
                    //    deletedList.Add(wBm.Name);
                    //    HighLightBookmark(wBm.Name, color);
                    //}
                    continue;
                }

                // 2. get real biz name
                string bizName = item.IsImage() ? MarkupUtilities.GetBizNameOfBookmarkImage(wBm.Name, _doc.InlineShapes) : wBm.Range.Text;

                if (item.BizName != bizName) // compare key and value
                {
                    deletedList.Add(wBm.Name);
                    HighLightBookmark(wBm.Name, color);
                }
                else if (item != null && item.Type == XsltType.Select) // check match with domain (only check for field)
                {
                    DomainInfo domainInfo = Wkl.MainCtrl.CommonCtrl.GetDomainInfo(item.DomainName);

                    if (domainInfo != null && !domainInfo.Fields.ContainsKey(MarkupUtilities.GetOriginalBizName(wBm.Name, item.BizName)))
                    {
                        deletedList.Add(wBm.Name);
                        HighLightBookmark(wBm.Name, color);
                    }
                }
            }

            return(deletedList);
        }
Example #2
0
        /// <summary>
        /// Get bookmark collection in word
        /// </summary>
        /// <returns>Dictionary with key is bookmark name and value is bookmark text</returns>
        public void GetBookmarkCollection(string key)
        {
            try
            {
                ContentServiceProfile contentProfile = Wkl.MainCtrl.ServiceCtrl.GetProfile(key).ContentService;

                Dictionary <string, string> bookmarks = new Dictionary <string, string>();

                Bookmarks bms = Wkl.MainCtrl.CommonCtrl.CommonProfile.Bookmarks;

                foreach (Bookmark bookmark in bms)
                {
                    if (bookmark.Name.Contains(ProntoMarkup.KeyImage))
                    {
                        bookmarks.Add(bookmark.Name, MarkupUtilities.GetBizNameOfBookmarkImage(bookmark.Name,
                                                                                               Wkl.MainCtrl.CommonCtrl.CommonProfile.ActiveDoc.InlineShapes));
                    }
                    else
                    {
                        bookmarks.Add(bookmark.Name, MarkupUtilities.GetRangeText(bookmark.Range));
                    }
                }

                contentProfile.GetBookmarks_OListBM = bookmarks;
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_GetWordBookmarksError);
                newSrvExp.Errors.Add(srvExp);

                throw newSrvExp;
            }
            catch (Exception ex)
            {
                ServiceException srvExp = new ServiceException(ErrorCode.ipe_GetWordBookmarksError,
                                                               MessageUtils.Expand(Properties.Resources.ipe_GetWordBookmarksError, ex.Message), ex.StackTrace);

                throw srvExp;
            }
        }