Exemple #1
0
        private bool ProcessStartForeachTag(string ibmItemKey, string ibmItemBizName,
                                            ref GenOsqlParamInfo paramInfo, ref Dictionary <string, bool> dataTagChecker)
        {
            if (ibmItemKey.Contains(BaseProntoMarkup.KeyStartForeach)) // update for add sort item in for-each
            {
                Dictionary <string, OrderByType> sorteds = BaseMarkupUtilities.GetOldOrderBy(ibmItemBizName, false);
                if (sorteds.Count > 0) // has sort in for-each
                {
                    foreach (string orderBizName in sorteds.Keys)
                    {
                        string sortBizName = paramInfo.DomainInfo.GetUdfSortedBizName(orderBizName);
                        if (sortBizName != orderBizName) // has order by bizname
                        {
                            if (dataTagChecker.ContainsKey(sortBizName))
                            {
                                continue;
                            }

                            InternalBookmarkItem bm = AddUdfFields(sortBizName, ref paramInfo);
                            dataTagChecker.Add(BaseMarkupUtilities.GetOriginalBizName(bm.Key, bm.BizName), true);
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
Exemple #2
0
        private bool ProcessUSCTag(InternalBookmarkItem ibmItem, DSIconType dataTagType, string itemName,
                                   ref GenOsqlParamInfo paramInfo, ref Dictionary <string, bool> dataTagChecker)
        {
            if (dataTagType == DSIconType.USC)
            {
                GetTableIndexForUSC(ibmItem, ref paramInfo);
                USCItem usc            = paramInfo.UscItems[itemName];
                string  orderFieldName = usc.BaseOnField;

                if (!string.IsNullOrWhiteSpace(orderFieldName) && !dataTagChecker.ContainsKey(orderFieldName))
                {
                    InternalBookmarkItem exist = (from c in paramInfo.IbmDomain.InternalBookmarkItems
                                                  where (c.TableIndex == usc.TableIndex) && (string.Equals(c.ItemType, DSIconType.Field.ToString()))
                                                  select c).FirstOrDefault();
                    //If existed one data field in selected tag, shouldnot include data field in udf
                    if (exist == null || string.IsNullOrEmpty(exist.BizName))
                    {
                        InternalBookmarkItem bm = AddUdfFields(orderFieldName, ref paramInfo);
                        dataTagChecker.Add(BaseMarkupUtilities.GetOriginalBizName(bm.Key, bm.BizName), true);
                    }
                    else
                    {
                        dataTagChecker.Add(itemName, true);
                        paramInfo.AddDataTags(ibmItem, true);
                    }
                }

                return(true);
            }

            return(false);
        }
Exemple #3
0
        public void btnForEach_Click(Office.IRibbonControl control)
        {
            try
            {
                string bookmarkKey      = DateTime.Now.ToString(ProntoMarkup.BookmarkKeyFormat);
                InternalBookmarkItem bm = new InternalBookmarkItem(bookmarkKey, ProntoMarkup.TagContentSForeach,
                                                                   ProntoMarkup.TagContentEForeach, DSIconType.ForEach.ToString());
                bm.Type = XsltType.Foreach;
                AddForeachBookmark(bm);
            }
            catch (BaseException baseExp)
            {
                ManagerException mgrExp = new ManagerException(ErrorCode.ipe_AddForechTagError);
                mgrExp.Errors.Add(baseExp);

                LogUtils.LogManagerError(mgrExp);
            }
            catch (Exception ex)
            {
                ManagerException mgrExp = new ManagerException(ErrorCode.ipe_AddForechTagError,
                                                               MessageUtils.Expand(Properties.Resources.ipe_AddForechTagError, ex.Message), ex.StackTrace);

                throw mgrExp;
            }
        }
Exemple #4
0
        /// <summary>
        /// Add bookmark into word document (word object and internal bookmark)
        /// </summary>
        /// <param name="item"></param>
        private void AddForeachBookmark(InternalBookmarkItem item)
        {
            MainManager _mainManager = new MainManager();

            _mainManager.RegisterEvents();

            string          key;
            ServicesProfile serviceProfile = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out key);

            // validate position of data tag with foreach tags
            serviceProfile.ContentService.DomainName = Wkl.MainCtrl.CommonCtrl.CommonProfile.CurrentTemplateInfo.SelectedDomainName;
            _mainManager.MainService.BookmarkService.ValidateDataTagPosition(key);
            if (!serviceProfile.ContentService.IsValid)
            {
                MessageBox.Show(serviceProfile.Message.ToString());
                Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(key);
                return;
            }

            // add into internal bookmark
            serviceProfile.IntegrationService.AddInternalBM_IBookmark = item;
            _mainManager.MainService.PropertyService.AddInternalBookmark(key);

            // add into work bookmark
            serviceProfile.ContentService.AddBookmark_IBookmark = item;
            _mainManager.MainService.BookmarkService.AddBookmark(key);

            Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(key);
        }
Exemple #5
0
        protected string GenSelectClauseForUSC(InternalBookmarkItem ibmItem, ref GenOsqlParamInfo paramInfo)
        {
            //1.Find USC bookmark in the list Conditions to get actual USC.
            //2.Build SQl
            string sqlClause = string.Empty;
            string itemName  = BaseMarkupUtilities.GetOriginalBizName(ibmItem.Key, ibmItem.BizName);

            if (paramInfo.UscItems == null || paramInfo.UscItems.Count <= 0 || ibmItem.Key.EndsWith(BaseProntoMarkup.KeyEndIf))
            {
                return(sqlClause);
            }

            USCItem uscItem = null;

            if (paramInfo.UscItems.Keys.Contains(itemName))
            {
                uscItem = paramInfo.UscItems[itemName];
            }

            //
            Dictionary <string, DSTreeView> lowerFields = new Dictionary <string, DSTreeView>();

            foreach (string key in paramInfo.DomainInfo.Fields.Keys)
            {
                lowerFields.Add(key.ToLower(), paramInfo.DomainInfo.Fields[key]);
            }

            //Validate and Build SQl
            if (uscItem != null)
            {
                List <Token>       lstTokens       = new List <Token>();
                string             error           = string.Empty;
                ExpressionProvider expressProvider = new ExpressionProvider();
                expressProvider.DoTokenize(uscItem.SQLExpression, ref lstTokens, ref error);

                foreach (Token token in lstTokens)
                {
                    string key = string.Empty;
                    if (token.Name.Contains("[") && token.Name.Contains("]"))
                    {
                        key = token.Name.Substring(1, token.Name.Length - 2).ToLower();
                        if (lowerFields.ContainsKey(key))
                        {
                            token.Name = lowerFields[key].TechName;

                            if (paramInfo.DSRelationRow == null)
                            {
                                paramInfo.DSRelationRow = lowerFields[key].Relation.Clone();
                            }
                            else
                            {
                                paramInfo.DSRelationRow.OrRow(lowerFields[key].Relation);
                            }
                        }
                    }
                    sqlClause += token.Name + " ";
                }
            }
            return(sqlClause.Trim());
        }
Exemple #6
0
        /// <summary>
        /// Add select bookmark
        /// </summary>
        /// <param name="name">Name of bookmark</param>
        /// <param name="value">Value of bookmark</param>
        private void AddSingleBookmark(InternalBookmarkItem bm)
        {
            string          key;
            ServicesProfile servicePro = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out key);

            //Add a space before text.
            servicePro.ContentService.AddToSelection_Text       = " ";
            servicePro.ContentService.AddToSelection_IsSelected = false;
            AddTextToCurrentSelection(key);

            // add select text
            servicePro.ContentService.AddToSelection_Text       = MarkupUtilities.GenTextXslTag(bm.BizName, bm.Type, true);
            servicePro.ContentService.AddToSelection_IsSelected = true;
            AddTextToCurrentSelection(key);

            // add select bookmark
            servicePro.ContentService.AddBookmark_Name = MarkupUtilities.GenKeyForXslTag(bm.Key, bm.Type, true);
            AddBookmarkInCurrentSelection(key);

            // set cursor after bookmark
            servicePro.ContentService.MoveChars_Count  = 1;
            servicePro.ContentService.MoveChars_IsLeft = false;
            MoveChars(key);

            Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(key);
        }
Exemple #7
0
        /// <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;
            }
        }
Exemple #8
0
        /// <summary>
        /// extract all field in UDF tag
        /// </summary>
        /// <param name="bizName"></param>
        /// <param name="dataTagFields"></param>
        /// <param name="dataTagOthers"></param>
        /// <returns></returns>
        private InternalBookmarkItem AddUdfFields(string bizName, ref GenOsqlParamInfo paramInfo)
        {
            string               bookmarkKey = DateTime.Now.ToString(BaseProntoMarkup.BookmarkKeyFormat);
            DSTreeView           item        = paramInfo.DomainInfo.GetField(bizName);
            InternalBookmarkItem bm          = new InternalBookmarkItem(bookmarkKey, item.Text, item.TechName,
                                                                        item.Type.ToString(), item.TableIndex, item.Relation, 1);

            bm.UniqueName = item.UniqueName;
            bm.DataType   = item.DataType;
            bm.Type       = XsltType.Select;
            paramInfo.AddDataTags(bm, true);

            return(bm);
        }
Exemple #9
0
        public void AddDataTags(InternalBookmarkItem ibmItem, bool isUsc)
        {
            if (ibmItem == null)
            {
                return;
            }
            if (DataTagFields == null)
            {
                DataTagFields = new List <InternalBookmarkItem>();
            }

            ibmItem.OrderNo = isUsc ? 0 : 1;
            DataTagFields.Add(ibmItem);
        }
Exemple #10
0
        private string GetPdeDataType(string key, InternalBookmark ibm)
        {
            if (ibm == null || string.IsNullOrWhiteSpace(key))
            {
                return(string.Empty);
            }

            InternalBookmarkItem ibmItem = ibm.GetInternalBookmarkItem(key);

            if (ibmItem == null)
            {
                return(string.Empty);
            }

            return(MarkupUtilities.SqlDbType2XsdDataType(ibmItem.DataType));
        }
Exemple #11
0
        private void GenSelectClauseForField(InternalBookmarkItem bmItem, ref GenOsqlParamInfo paramInfo)
        {
            string     itemName = BaseMarkupUtilities.GetOriginalBizName(bmItem.Key, bmItem.BizName);
            DSTreeView item     = paramInfo.DomainInfo.GetField(itemName);
            DSIconType type     = (DSIconType)Enum.Parse(typeof(DSIconType), bmItem.ItemType);

            double     i         = Math.Log((double)bmItem.TableIndex, (double)2);
            DSOnClause table     = paramInfo.DomainInfo.DSDomainData.OnClauses.Items[bmItem.TableIndex];
            string     tableName = table.Alias;

            paramInfo.PutSelectedTable(tableName, false);
            paramInfo.SelectedTableIndexes.Add(item.TableIndex);

            UpdateSelectedColumns(ref paramInfo, tableName, itemName);
            InternalBookmarkItem existedItem = paramInfo.DataTagFields.FirstOrDefault(a => a.TableIndex == item.TableIndex && a.DSIconType == DSIconType.Field);
            bool isImageTrunc = bmItem.IsTruncImage();

            if (isImageTrunc && existedItem != null && existedItem.BizName == bmItem.BizName && !paramInfo.TablesHasField.Contains(item.TableIndex))
            { // this table has only image that is chunked then we need to add one default column
                GenSelectClauseItem(DSIconType.Field, item.TechName,
                                    string.Empty, Guid.NewGuid().ToString(), false, true, ref paramInfo);
                paramInfo.TablesHasField.Add(item.TableIndex);
                paramInfo.HasImage = true;
            }
            GenSelectClauseItem(type, bmItem.TechName, item.JavaClause, itemName, bmItem.IsTruncImage(), true, ref paramInfo);

            if (!string.IsNullOrEmpty(item.RenderXYOrder))
            {
                List <string> renderParam = item.RenderXYOrder.Split(';').ToList <string>();
                for (int j = 0; j < renderParam.Count; j++)
                {
                    AddItemToListJParameters((renderParam[j] == "1") ? FrameworkConstants.RenderArgumentX : FrameworkConstants.RenderArgumentY,
                                             ref paramInfo, OracleQueryConstants.DicSelectClauseParamName);
                }
            }

            #region Build Extra field
            if (existedItem == null && !string.IsNullOrEmpty(item.OrginalField) && !paramInfo.TablesHasField.Contains(item.TableIndex))
            {
                GenSelectClauseItem(DSIconType.Field, item.OrginalField, string.Empty, Guid.NewGuid().ToString(), false, true, ref paramInfo);
                paramInfo.TablesHasField.Add(item.TableIndex);
                return;
            }
            #endregion
        }
Exemple #12
0
        private bool ProcessSelectTag(InternalBookmarkItem ibmItem, DSIconType dataTagType, string itemName,
                                      ref GenOsqlParamInfo paramInfo, ref Dictionary <string, bool> dataTagChecker)
        {
            if ((ibmItem.TableIndex >= 0 && dataTagType != DSIconType.USC) ||
                (dataTagType == DSIconType.SystemInfo) || (dataTagType == DSIconType.Condition) || (dataTagType == DSIconType.RenderXY))
            {
                if (dataTagType == DSIconType.SystemInfo || (dataTagType == DSIconType.Condition) || (dataTagType == DSIconType.RenderXY))
                {
                    ibmItem.TableIndex = Math.Max(0, ibmItem.TableIndex);
                }
                dataTagChecker.Add(itemName, true);
                bool isUdf = dataTagType == DSIconType.UDF || dataTagType == DSIconType.Condition;
                paramInfo.AddDataTags(ibmItem, isUdf);
                return(true);
            }

            return(false);
        }
Exemple #13
0
        /// <summary>
        /// Add bookmark into word document (word object and internal bookmark)
        /// </summary>
        /// <param name="item"></param>
        private void AddCommentBookmark(InternalBookmarkItem item)
        {
            MainManager _mainManager = new MainManager();

            _mainManager.RegisterEvents();

            string          key;
            ServicesProfile serviceProfile = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out key);

            // validate position of data tag with foreach tags
            serviceProfile.ContentService.DomainName = Wkl.MainCtrl.CommonCtrl.CommonProfile.CurrentTemplateInfo.SelectedDomainName;

            // add into work bookmark
            serviceProfile.ContentService.AddBookmark_IBookmark = item;
            _mainManager.MainService.BookmarkService.AddBookmark(key);

            Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(key);
        }
Exemple #14
0
        private int GetTableIndexForUSC(InternalBookmarkItem ibmItem, ref GenOsqlParamInfo paramInfo)
        {
            if (paramInfo.UscItems == null || paramInfo.UscItems.Count <= 0)
            {
                return(-1);
            }
            string  itemName = BaseMarkupUtilities.GetOriginalBizName(ibmItem.Key, ibmItem.BizName);
            USCItem item     = paramInfo.UscItems[itemName];
            int     maxIndex = -1;

            if (item.Fields.Count > 0)
            {
                foreach (USCItem subField in item.Fields)
                {
                    if (paramInfo.DomainInfo.Fields.Keys.Contains(subField.BusinessName))
                    {
                        if (maxIndex < paramInfo.DomainInfo.Fields[subField.BusinessName].TableIndex)
                        {
                            maxIndex         = paramInfo.DomainInfo.Fields[subField.BusinessName].TableIndex;
                            item.BaseOnField = string.IsNullOrWhiteSpace(paramInfo.DomainInfo.Fields[subField.BusinessName].OrginalField) ?
                                               paramInfo.DomainInfo.Fields[subField.BusinessName].Text : paramInfo.DomainInfo.Fields[subField.BusinessName].OrginalField;
                        }
                    }
                }
            }
            ibmItem.TableIndex = maxIndex;
            item.TableIndex    = maxIndex;

            //Update to Relation
            DSOnClause table     = paramInfo.DomainInfo.DSDomainData.OnClauses.Items[maxIndex];
            string     tableName = table.Alias;

            if (!paramInfo.DomainInfo.Relations.MapInfos.ContainsKey(itemName))
            {
                paramInfo.DomainInfo.Relations.MapInfos.Add(itemName, new Mapping(itemName, tableName, itemName));
            }
            else
            {
                paramInfo.DomainInfo.Relations.MapInfos[itemName].TableName = tableName;
            }

            return(maxIndex);
        }
Exemple #15
0
        /// <summary>
        /// get list of data tag fields, data tag others and renderxy
        /// </summary>
        /// <param name="paramInfo"></param>
        protected void AnalyzeDataTag(ref GenOsqlParamInfo paramInfo)
        {
            paramInfo.RenderXY = 0;
            paramInfo.UpdateUSCItemsDictionary();

            int itemIndex = 0;
            Dictionary <string, bool> dataTagChecker = new Dictionary <string, bool>();

            while (itemIndex < paramInfo.IbmDomain.InternalBookmarkItems.Count)
            {
                InternalBookmarkItem ibmItem = paramInfo.IbmDomain.InternalBookmarkItems[itemIndex];
                DSIconType           type    = ibmItem.DSIconType;
                string     itemName          = BaseMarkupUtilities.GetOriginalBizName(ibmItem.Key, ibmItem.BizName);
                DSTreeView dsObject          = paramInfo.DomainInfo.GetField(itemName);

                if (dsObject != null)
                {
                    paramInfo.RenderXY = paramInfo.RenderXY | CheckRenderXY(dsObject.RenderXYOrder);
                }
                else
                {
                    paramInfo.RenderXY = paramInfo.RenderXY | CheckRenderXY("0");
                }

                itemIndex++;
                if (ProcessEndForeachIfTag(ref paramInfo, ibmItem.Key, itemName, dataTagChecker))
                {
                    continue;
                }

                if (ProcessStartForeachTag(ibmItem.Key, ibmItem.BizName, ref paramInfo, ref dataTagChecker))
                {
                    continue;
                }

                if (ProcessUSCTag(ibmItem, type, itemName, ref paramInfo, ref dataTagChecker))
                {
                    continue;
                }

                ProcessSelectTag(ibmItem, type, itemName, ref paramInfo, ref dataTagChecker);
            }
        }
Exemple #16
0
        /// <summary>
        /// get all internal bookmark item (include USC) from document
        /// </summary>
        /// <param name="ibmDomain"></param>
        /// <returns></returns>
        private List <InternalBookmarkItem> GetInternalBookmarkItemCollection(InternalBookmarkDomain ibmDomain)
        {
            List <InternalBookmarkItem> items = new List <InternalBookmarkItem>();

            // internal bookmark item
            foreach (InternalBookmarkItem item in ibmDomain.InternalBookmarkItems)
            {
                InternalBookmarkItem newItem = null;
                if (item.Key.EndsWith(ProntoMarkup.KeySelect))
                {
                    newItem = new InternalBookmarkItem(MarkupUtilities.RemoveChars(item.BizName, 1, 2), item.UniqueName, item.DataType, XsltType.Select);
                }
                else if (item.Key.EndsWith(ProntoMarkup.KeyStartIf) && item.ItemType == DSIconType.Condition.ToString())
                {
                    newItem = new InternalBookmarkItem(MarkupUtilities.RemoveChars(item.BizName, 1, 1), item.UniqueName, item.DataType, XsltType.If);
                }

                if (newItem != null)
                {
                    if (string.IsNullOrEmpty(newItem.UniqueName)) // ngocbv: make sure unique name not is null in case UDF
                    {
                        newItem.UniqueName = item.TechName;
                    }
                    newItem.Key      = newItem.BizName; // ngocbv: keep key for highlight
                    newItem.TechName = item.TechName;
                    items.Add(newItem);
                }
            }

            // usc
            foreach (USCItem usc in ibmDomain.USCItems)
            {
                foreach (USCItem item in usc.Fields)
                {
                    InternalBookmarkItem newItem = new InternalBookmarkItem(item.BusinessName, item.UniqueName, item.DataType, XsltType.If);
                    newItem.Key = usc.BusinessName; // ngocbv: keep key for highlight
                    items.Add(newItem);
                }
            }

            return(items);
        }
Exemple #17
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);
        }
Exemple #18
0
        private List <string> GetPdwSelectedTables(BaseBookmark pbmItem)
        {
            string ibmItemKey = pbmItem.Key;
            InternalBookmarkDomain ibmDomain = _ibm.GetInternalBookmarkDomainByItemKey(ibmItemKey);
            string bizName = pbmItem.BizName;

            if (string.IsNullOrWhiteSpace(bizName))
            {
                InternalBookmarkItem ibmItem = ibmDomain.InternalBookmarkItems.FirstOrDefault(c => c.Key == ibmItemKey);
                bizName = ibmItem.OrginalBizName;
            }
            Relations relations = GetRelations(pbmItem);

            if (relations != null && relations.MapInfos.ContainsKey(bizName))
            {
                string tableName = relations.MapInfos[bizName].TableName;
                return(ibmDomain.GetSelectedTabledOfPath(tableName));
            }
            return(ibmDomain.GetAllSelectedTables());
        }
Exemple #19
0
        public void DataBind(string key)
        {
            ServicesProfile profile = Wkl.MainCtrl.ServiceCtrl.GetProfile(key);

            ControlBase control      = profile.PdmProfile.Control;
            string      propertyName = profile.PdmProfile.CurrentPropertyName;
            string      bindingPath  = profile.PdmProfile.DatabindingPath;

            if (control == null || string.IsNullOrEmpty(propertyName))
            {
                //TODO:FORM CONTROLS - DataBind, Exception type
                throw new ArgumentException();
            }

            AddInternalBookmarkItem(key);

            InternalBookmarkItem bookmark = profile.IbmItem;

            BindDataToControl(control, bookmark, propertyName, bindingPath);
        }
Exemple #20
0
        private void BindDataToControl(ControlBase control, InternalBookmarkItem bookmark, string propertyName, string path)
        {
            if (control is ISelectable)
            {
                bool isBindingKeyProperty = IsSpecifiedProperty(c => ((ISelectable)c).DataBindingSelectKey, propertyName);

                if (isBindingKeyProperty)
                {
                    ISelectable selControl = control as ISelectable;
                    selControl.DataBindingSelectPath = path;
                    selControl.DataBindingSelectKey  = bookmark.Key;
                }
            }
            else
            {
                control.DataBindingPath = path;
                control.DataBindingKey  = bookmark.Key;
            }

            control.DataBind = true;
        }
Exemple #21
0
        /// <summary>
        /// Occurs when the selection changes in the active document window. (Inherited from ApplicationEvents4_Event.)
        /// When user change selection in word document
        /// </summary>
        /// <param name="Sel"></param>
        private void Application_WindowSelectionChange(Word.Selection Sel)
        {
            TemplateInfo template = this.TemplateInfo;

            if (template.IsProntoDoc)
            {
                DataIntegrationManager bmMgr = new DataIntegrationManager();
                string bmName = bmMgr.HasBookmark(Sel);
                if (bmMgr.GetForeachTag(Sel) != null)
                {
                    BaseManager.ChangeOrderByStatus(true);
                }
                else
                {
                    BaseManager.ChangeOrderByStatus(false);
                }

                #region update full map
                TemplateInfo templateInfo = this.TemplateInfo;
                if (templateInfo.RightPanel != null)
                {
                    ProntoDocMarkup proMarkupCtrl = templateInfo.RightPanel.Control as ProntoDocMarkup;
                    if (string.IsNullOrEmpty(bmName))
                    {
                        proMarkupCtrl.UpdateFullMap(null);
                    }
                    else
                    {
                        InternalBookmarkItem iBm = TemplateInfo.InternalBookmark.GetInternalBookmarkItem(bmName);
                        proMarkupCtrl.UpdateFullMap(iBm);
                    }
                }
                #endregion
            }
            else
            {
                BaseManager.ChangeOrderByStatus(false);
            }
        }
Exemple #22
0
 public void chkCollapseForEach_Click(Office.IRibbonControl control, bool pressed)
 {
     try
     {
         foreach (Microsoft.Office.Interop.Word.Bookmark bm in Wkl.MainCtrl.CommonCtrl.CommonProfile.Bookmarks)
         {
             string bmName = bm.Name;
             if (bmName.EndsWith(MarkupConstant.MarkupStartForeach)) // is for-each tag
             {
                 InternalBookmarkItem ibm =
                     Wkl.MainCtrl.CommonCtrl.CommonProfile.CurrentTemplateInfo.InternalBookmark.GetInternalBookmarkItem(bmName);
                 if (ibm != null && ibm.BizName.StartsWith(Constants.OrderBy.ForeachSortMark)) // has collation
                 {
                     Microsoft.Office.Interop.Word.Range range = bm.Range;
                     if (!pressed) // collapse
                     {
                         range.Font.Hidden = 0;
                     }
                     else // expand old: ibm.BizName != range.Text
                     {
                         int start     = bm.Start;
                         int end       = bm.End;
                         int startHide = start + ProntoMarkup.TagStartSForeach.Length + ProntoMarkup.TagContentSForeach.Length;
                         int endHide   = end - ProntoMarkup.TagEndSForeah.Length;
                         range.SetRange(startHide, endHide);
                         range.Font.Hidden = 1;
                         range.SetRange(start, end);
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         LogUtils.Log("btnCollapseForEach_Click", ex);
     }
 }
Exemple #23
0
        public PartBookmark(string name, InternalBookmark ibookmark)
        {
            InternalBookmarkItem bookmark = ibookmark.GetInternalBookmarkItem(name);

            if (bookmark != null)
            {
                BizName = bookmark.OrginalBizName;

                Key = name;
            }
            else
            {
                PdeDataTagInfo pdeTag = ibookmark.GetPdeDataTagInfo(name);

                if (pdeTag != null)
                {
                    BizName = pdeTag.BookmarkName;

                    Key = name;
                }
            }

            InitializeBookmark();
        }
Exemple #24
0
        /// <summary>
        /// item match with datasegment when it (bizname, uniquename, DataType.Name) exist in datasegment
        /// </summary>
        /// <param name="item"></param>
        /// <param name="sFields"></param>
        /// <returns></returns>
        private bool IsMatchWithDataSegment(InternalBookmarkItem item, Dictionary <string, DSTreeView> sFields)
        {
            string bizName = item.BizName;

            if (sFields.ContainsKey(bizName))
            {
                DSTreeView sField = sFields[bizName];

                if (sField.Type == DSIconType.SystemInfo)
                {
                    return((item.BizName == sField.Text) && (item.TechName == sField.TechName) && sField.Visible);
                }
                if (sField.Type == DSIconType.RenderXY)
                {
                    string techname = sField.TechName.Replace("@", "");
                    return((item.BizName == sField.Text) && (item.TechName == techname) && sField.Visible);
                }

                return(item.OriginalUniqueName == System.Xml.XmlConvert.DecodeName(sField.UniqueName) &&
                       item.DataType.Name == sField.DataType.Name && sField.Visible);
            }

            return(false);
        }
Exemple #25
0
        private void ReplaceBookmarkTag()
        {
            _foreach = new List <ForeachItem>();
            for (int index = 0; index < _textParser.Bookmarks.Count; index++)
            {
                PartBookmark  bookmark       = _textParser.Bookmarks[index];
                List <string> selectedTables = GetSelectedTables(bookmark);
                Relations     relations      = GetRelations(bookmark);
                if (!bookmark.IsDelete)
                {
                    string xslPath = string.Empty;
                    switch (bookmark.Type)
                    {
                    case Core.BookmarkType.EndForeach:
                        bookmark.XslString = Mht.XslContent.XslFormat.XslEndForeach;
                        if (_foreach.Count > 0)
                        {
                            _foreach.RemoveAt(_foreach.Count - 1);
                        }
                        UpdateBookmarkPart(bookmark);
                        break;

                    case Core.BookmarkType.EndIf:
                        bookmark.XslString = Mht.XslContent.XslFormat.XslEndIf;
                        UpdateBookmarkPart(bookmark);
                        break;

                    case Core.BookmarkType.Image:
                        break;

                    case Core.BookmarkType.Select:
                        xslPath            = GetXslPath(bookmark, bookmark.BizName, false, selectedTables, relations);
                        bookmark.XslString = Mht.XslContent.XslValueOfTag(xslPath, false);
                        UpdateBookmarkPart(bookmark);
                        break;

                    case Core.BookmarkType.StartIf:
                        xslPath            = GetXslPath(bookmark, bookmark.BizName, true, selectedTables, relations);
                        bookmark.XslString = Mht.XslContent.XslStartIfTag(xslPath, false);
                        UpdateBookmarkPart(bookmark);
                        break;

                    case Core.BookmarkType.StartForeach:
                        int    indexForeach = _foreach.Count + 1;
                        string variant      = Core.MarkupConstant.XslVariableImage + index.ToString();
                        InternalBookmarkDomain ibmDomain = _ibm.GetInternalBookmarkDomainByItemKey(bookmark.Key);
                        ForeachItem            fItem     = new ForeachItem(index, _textParser.Bookmarks.Cast <Base.BaseBookmark>(),
                                                                           relations, ibmDomain.SelectedTables,
                                                                           indexForeach, variant, string.Empty);
                        _foreach.Add(fItem);

                        xslPath = GetXslPath(bookmark, string.Empty, false, selectedTables, relations);
                        InternalBookmarkItem ibmItem = _ibm.GetInternalBookmarkItem(bookmark.Key);
                        string sort = GetSortXsl(bookmark.BizName, ibmItem.DomainName, selectedTables, relations, false);
                        bookmark.XslString = Mht.XslContent.XslStartForeachTag(xslPath,
                                                                               variant, Core.MarkupConstant.XslMultiPosition, sort, false);
                        fItem.XslString = bookmark.XslString;

                        UpdateBookmarkPart(bookmark);
                        break;

                    default:
                        break;
                    }
                }
            }
        }
Exemple #26
0
        /// <summary>
        /// Add foreach bookmark
        /// </summary>
        /// <param name="name">Name of bookmark</param>
        /// <param name="value">Value of bookmark</param>
        private void AddDoubleBookmark(InternalBookmarkItem bm)
        {
            //1. Get FontColor of BM
            //2. Generate tag
            //3. Add start tag (text) to document
            //4. Add start tag to BM
            //5. Move cursor to after
            //6. Add end tag (text) to document
            //7. Add end tag to BM
            //8. Move cursor to between two tags
            //9. Set color

            string          key;
            ServicesProfile servicePro = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out key);

            WdColor fontColor  = GetFontColor(bm.Type);
            WdColor textColor  = WdColor.wdColorBlack;
            int     textLength = 0;

            if (Globals.ThisAddIn.Application.Selection.Range.Start != Globals.ThisAddIn.Application.Selection.Range.End)
            {
                textLength = Globals.ThisAddIn.Application.Selection.Range.Text.Length;
                textColor  = Globals.ThisAddIn.Application.Selection.Range.Font.Color;
                servicePro.ContentService.MoveChars_Count  = 1;
                servicePro.ContentService.MoveChars_IsLeft = true;
                MoveChars(key);
            }

            //2.Generate tag
            string startTag = MarkupUtilities.GenTextXslTag(bm.BizName, bm.Type, true);

            //Add a space before text
            servicePro.ContentService.AddToSelection_Text       = " ";
            servicePro.ContentService.AddToSelection_IsSelected = false;
            AddTextToCurrentSelection(key);

            //3. add start foreach text
            servicePro.ContentService.AddToSelection_Text       = startTag.Trim();
            servicePro.ContentService.AddToSelection_IsSelected = true;
            AddTextToCurrentSelection(key);

            //4. add start foreach bookmark
            servicePro.ContentService.AddBookmark_Name = MarkupUtilities.GenKeyForXslTag(bm.Key, bm.Type, true);
            AddBookmarkInCurrentSelection(key);
            servicePro.ContentService.AddBookmark_BookmarkReturn.Range.Font.Color = fontColor;
            //if (bm.Type == XsltType.If) // todo: ngocbv add highlight color for condition tag
            //    servicePro.ContentService.AddBookmark_BookmarkReturn.Range.HighlightColorIndex = ProntoMarkup.IfColorBackground;

            //5. add space
            servicePro.ContentService.MoveChars_Count  = (textLength > 0 ? textLength + 1 : 1);
            servicePro.ContentService.MoveChars_IsLeft = false;
            MoveChars(key);

            servicePro.ContentService.AddToSelection_Text       = " ";
            servicePro.ContentService.AddToSelection_IsSelected = false;
            AddTextToCurrentSelection(key);

            Globals.ThisAddIn.Application.Selection.Font.Color = textColor;

            //6. add end foreach text
            servicePro.ContentService.AddToSelection_Text       = MarkupUtilities.GenTextXslTag(bm.BizName, bm.Type, false);
            servicePro.ContentService.AddToSelection_IsSelected = true;
            AddTextToCurrentSelection(key);

            //7. add end foreach bookmarl
            servicePro.ContentService.AddBookmark_Name = MarkupUtilities.GenKeyForXslTag(bm.Key, bm.Type, false);
            AddBookmarkInCurrentSelection(key);
            servicePro.ContentService.AddBookmark_BookmarkReturn.Range.Font.Color = fontColor;
            //if (bm.Type == XsltType.If) // todo: ngocbv add highlight color for condition tag
            //    servicePro.ContentService.AddBookmark_BookmarkReturn.Range.HighlightColorIndex = ProntoMarkup.IfColorBackground;

            //8.set cursor before end tag
            servicePro.ContentService.MoveChars_Count  = 2;
            servicePro.ContentService.MoveChars_IsLeft = true;

            MoveChars(key);

            //9. reset color
            Globals.ThisAddIn.Application.Selection.Font.Color = textColor;

            Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(key);
        }
Exemple #27
0
        /// <summary>
        /// separate osql to multi paths
        /// </summary>
        /// <param name="fullItems"></param>
        /// <param name="dsDomain"></param>
        /// <returns></returns>
        protected List <List <InternalBookmarkItem> > GetPaths(ref GenOsqlParamInfo paramInfo,
                                                               List <InternalBookmarkItem> fullItems, DSDomain dsDomain)
        {
            List <List <InternalBookmarkItem> > paths = new List <List <InternalBookmarkItem> >();

            #region calculate used table indexes
            Dictionary <int, List <InternalBookmarkItem> > usedTableIndexes = new Dictionary <int, List <InternalBookmarkItem> >();
            List <int> sortedTableIndexes = new List <int>();
            foreach (InternalBookmarkItem ibmItem in fullItems)
            {
                if (!usedTableIndexes.ContainsKey(ibmItem.TableIndex))
                {
                    usedTableIndexes.Add(ibmItem.TableIndex, new List <InternalBookmarkItem>());
                    sortedTableIndexes.Add(ibmItem.TableIndex);
                }

                usedTableIndexes[ibmItem.TableIndex].Add(ibmItem);
            }
            if (!usedTableIndexes.ContainsKey(0))
            {
                usedTableIndexes.Add(0, new List <InternalBookmarkItem>());
                sortedTableIndexes.Add(0);
            }
            sortedTableIndexes = sortedTableIndexes.OrderBy(c => c).ToList();
            #endregion

            #region get paths
            string whereClauseName                    = "WhereClause";
            Dictionary <int, bool> checker            = new Dictionary <int, bool>();
            List <DSRelationRow>   dsRelationRows     = dsDomain.TableRelations.Rows.Items;
            DSRelationRow          dsWhereRelationRow = dsRelationRows.FirstOrDefault(
                c => whereClauseName.Equals(c.Name, StringComparison.OrdinalIgnoreCase));
            string whereRelations = BitHelper.ToBinaryFormat(dsWhereRelationRow.Data, true);
            whereRelations = BaseMarkupUtilities.ReverseString(whereRelations);
            foreach (DSRelationRow dsRelationRow in dsRelationRows)
            {
                if (whereClauseName.Equals(dsRelationRow.Name, StringComparison.OrdinalIgnoreCase))
                {
                    paramInfo.DSWhereClauseRelationRow = dsRelationRow;
                    continue;
                }

                List <InternalBookmarkItem> path = new List <InternalBookmarkItem>();
                string relations = BitHelper.ToBinaryFormat(dsRelationRow.Data, true);
                relations = BaseMarkupUtilities.ReverseString(relations);
                bool hasTable = false;
                foreach (int tableIndex in sortedTableIndexes)
                {
                    int index = tableIndex;
                    if (relations.Length > index && relations[index] == '1')
                    {
                        path.AddRange(usedTableIndexes[tableIndex]);
                        if (!checker.ContainsKey(tableIndex))
                        {
                            hasTable = true;
                            checker.Add(tableIndex, true);
                        }
                    }
                }

                if (hasTable)
                {
                    int parentTableIndex = GetParentTableInexInJoinClause(dsWhereRelationRow, dsRelationRow);
                    if (!usedTableIndexes.ContainsKey(parentTableIndex))
                    {
                        usedTableIndexes.Add(parentTableIndex, new List <InternalBookmarkItem>());
                    }
                    InternalBookmarkItem ibmItem = usedTableIndexes[parentTableIndex].FirstOrDefault(
                        c => c.TableIndex == parentTableIndex && c.DSIconType == DSIconType.Field);
                    if (ibmItem == null)
                    {
                        DSTreeView firstField = paramInfo.DomainInfo.Fields.Values.FirstOrDefault(
                            c => c.TableIndex == parentTableIndex && c.Type == DSIconType.Field);
                        if (firstField != null)
                        {
                            ibmItem = new InternalBookmarkItem()
                            {
                                BizName    = firstField.Text,
                                ItemType   = "Field",
                                JavaName   = firstField.JavaClause,
                                Key        = Guid.NewGuid().ToString(),
                                OrderNo    = 1,
                                TableIndex = parentTableIndex,
                                TechName   = firstField.TechName,
                                Type       = XsltType.Select
                            };

                            usedTableIndexes[parentTableIndex].Insert(0, ibmItem);
                            path.Insert(0, ibmItem);
                        }
                    }

                    paths.Add(path);
                }
            }
            #endregion

            return(paths);
        }
Exemple #28
0
        /// <summary>
        /// Add a bookmark into current document
        /// </summary>
        /// <param name="name">Name of bookmark</param>
        /// <param name="value">Value of bookmark</param>
        /// <param name="xsltType">XsltType (Select, Foreach or If)</param>
        /// <returns></returns>
        public bool AddBookmark(string key)
        {
            try
            {
                ServicesProfile      serviceProfile = Wkl.MainCtrl.ServiceCtrl.GetProfile(key);
                InternalBookmarkItem bm             = serviceProfile.ContentService.AddBookmark_IBookmark;
                Wkl.MainCtrl.CommonCtrl.CommonProfile.CurrentTemplateInfo.IsAdding = true;

                serviceProfile.ContentService.MarkProntDoc = true;
                switch (bm.Type)
                {
                case XsltType.Foreach:
                    AddDoubleBookmark(bm);
                    MarkProntoDoc(key);
                    break;

                case XsltType.If:
                    AddDoubleBookmark(bm);
                    MarkProntoDoc(key);
                    break;

                case XsltType.Select:
                    if (bm.IsImage())
                    {
                        serviceProfile.WbmKey          = bm.Key + ProntoMarkup.KeyImage;
                        serviceProfile.WbmValue        = MarkupUtilities.GenTextXslTag(bm.BizName, bm.Type, true);
                        serviceProfile.AlternativeText = MarkupUtilities.CreateAlternativeText(serviceProfile.WbmKey,
                                                                                               serviceProfile.WbmValue);
                        AddBookmarkImageEvent(key);
                    }
                    else
                    {
                        AddSingleBookmark(bm);
                    }
                    MarkProntoDoc(key);
                    break;

                case XsltType.Comment:
                    AddCommentBookmark(bm);
                    break;

                default:
                    break;
                }

                Wkl.MainCtrl.CommonCtrl.CommonProfile.CurrentTemplateInfo.IsAdding = false;
                return(true);
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_AddBookmarkError);
                newSrvExp.Errors.Add(srvExp);

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

                throw srvExp;
            }
        }
Exemple #29
0
        /// <summary>
        /// Add internal bookmark item
        /// </summary>
        /// <param name="bm"></param>
        public void AddInternalBookmark(string key)
        {
            try
            {
                ServicesProfile           serviceProfile = Wkl.MainCtrl.ServiceCtrl.GetProfile(key);
                IntegrationServiceProfile integrationPro = serviceProfile.IntegrationService;
                InternalBookmarkItem      ibmItem        = integrationPro.AddInternalBM_IBookmark;
                if (string.IsNullOrWhiteSpace(ibmItem.DomainName))
                {
                    ibmItem.DomainName = Wkl.MainCtrl.CommonCtrl.CommonProfile.CurrentTemplateInfo.SelectedDomainName;
                }
                switch (ibmItem.Type)
                {
                case XsltType.Foreach:
                case XsltType.If:
                    InternalBookmarkItem start = ibmItem.Clone();
                    InternalBookmarkItem end   = ibmItem.Clone();

                    start.BizName = MarkupUtilities.GenTextXslTag(ibmItem.BizName, ibmItem.Type, true);
                    start.Key     = MarkupUtilities.GenKeyForXslTag(ibmItem.Key, ibmItem.Type, true);

                    serviceProfile.IbmItem = start;
                    AddInternalBookmarkItem(key);

                    end.BizName            = MarkupUtilities.GenTextXslTag(ibmItem.BizName, ibmItem.Type, false);
                    end.Key                = MarkupUtilities.GenKeyForXslTag(ibmItem.Key, ibmItem.Type, false);
                    serviceProfile.IbmItem = end;
                    AddInternalBookmarkItem(key);
                    break;

                case XsltType.Select:
                    InternalBookmarkItem select = ibmItem.Clone();
                    select.BizName = MarkupUtilities.GenTextXslTag(select.BizName, select.Type, true);
                    select.Key     = ibmItem.IsImage() ? select.Key + ProntoMarkup.KeyImage
                            : MarkupUtilities.GenKeyForXslTag(select.Key, select.Type, true);

                    serviceProfile.IbmItem = select;
                    AddInternalBookmarkItem(key);
                    break;

                case XsltType.Comment:
                    InternalBookmarkItem comment = ibmItem.Clone();
                    comment.BizName = MarkupUtilities.GenTextXslTag(comment.BizName, comment.Type, true);
                    comment.Key     = ibmItem.IsImage() ? comment.Key + ProntoMarkup.KeyImage
                            : MarkupUtilities.GenKeyForXslTag(comment.Key, comment.Type, true);

                    serviceProfile.IbmItem = comment;
                    AddInternalBookmarkItem(key);
                    break;

                default:
                    break;
                }
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_AddIbmItemError);
                newSrvExp.Errors.Add(srvExp);

                throw newSrvExp;
            }
            catch (Exception ex)
            {
                ServiceException srvExp = new ServiceException(ErrorCode.ipe_AddIbmItemError,
                                                               MessageUtils.Expand(Properties.Resources.ipe_AddIbmItemError, ex.Message), ex.StackTrace);
                throw srvExp;
            }
        }
Exemple #30
0
        /// <summary>
        /// add a comment
        /// </summary>
        /// <pparam name="bm"></pparam>
        private void AddCommentBookmark(InternalBookmarkItem bm)
        {
            string          key;
            ServicesProfile servicePro = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out key);

            // add a space before comment
            servicePro.ContentService.AddToSelection_Text       = " ";
            servicePro.ContentService.AddToSelection_IsSelected = false;
            AddTextToCurrentSelection(key);

            // change font color to Red
            servicePro.ContentService.WdColorIndex = WdColorIndex.wdRed;
            SetFontForCurrentSelection(key);

            // add select text
            string commentText = MarkupUtilities.GenTextXslTag(bm.BizName, bm.Type, true);

            servicePro.ContentService.AddToSelection_Text       = commentText;
            servicePro.ContentService.AddToSelection_IsSelected = false;
            AddTextToCurrentSelection(key);

            // change font color to normal
            servicePro.ContentService.WdColorIndex = WdColorIndex.wdBlack;
            SetFontForCurrentSelection(key);

            // add a space after comment
            servicePro.ContentService.AddToSelection_Text       = " ";
            servicePro.ContentService.AddToSelection_IsSelected = false;
            AddTextToCurrentSelection(key);

            // move left a character to back to comment
            servicePro.ContentService.MoveChars_Count    = 1;
            servicePro.ContentService.MoveChars_IsLeft   = true;
            servicePro.ContentService.MoveChars_IsExtend = false;
            MoveChars(key);

            // select comment
            servicePro.ContentService.MoveChars_Count    = commentText.Length;
            servicePro.ContentService.MoveChars_IsLeft   = true;
            servicePro.ContentService.MoveChars_IsExtend = true;
            MoveChars(key);

            // add select bookmark
            servicePro.ContentService.AddBookmark_Name = MarkupUtilities.GenKeyForXslTag(bm.Key, bm.Type, true);
            AddBookmarkInCurrentSelection(key);

            // move to end of comment
            servicePro.ContentService.MoveChars_Count    = 1;
            servicePro.ContentService.MoveChars_IsLeft   = false;
            servicePro.ContentService.MoveChars_IsExtend = false;
            MoveChars(key);

            // move to comment text position
            servicePro.ContentService.MoveChars_Count    = ProntoMarkup.ValueCommentTextPosition;
            servicePro.ContentService.MoveChars_IsLeft   = true;
            servicePro.ContentService.MoveChars_IsExtend = false;
            MoveChars(key);

            // change font color to normal
            servicePro.ContentService.WdColorIndex = WdColorIndex.wdBlack;
            SetFontForCurrentSelection(key);

            Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(key);
        }