Exemple #1
0
        public Dictionary<string, List<TermContainer>> getTestSpecificationDocTOC(Document doc, ApplicationClass app)
        {
            generateTOC(doc, app);
            Range tocRange = doc.TablesOfContents[1].Range;
            string[] tocContents = delimiterTOC(tocRange.Text);

            Dictionary<string, List<TermContainer>> dict = new Dictionary<string, List<TermContainer>>();
            string chapter = "";

            foreach (string s in tocContents)
            {
                if (isLevel1(s))
                {
                    chapter = s;
                    dict.Add(s, new List<TermContainer>());
                }
                else
                {
                    if (isLevel2(s))
                    {
                        TermContainer term = new TermContainer("", s, null);
                        dict[chapter].Add(term);
                    }
                }

            }
            return dict;
        }
Exemple #2
0
        public Dictionary <string, List <TermContainer> > getTestSpecificationDocTOC(Document doc, ApplicationClass app)
        {
            generateTOC(doc, app);
            Range tocRange = doc.TablesOfContents[1].Range;

            string[] tocContents = delimiterTOC(tocRange.Text);

            Dictionary <string, List <TermContainer> > dict = new Dictionary <string, List <TermContainer> >();
            string chapter = "";

            foreach (string s in tocContents)
            {
                if (isLevel1(s))
                {
                    chapter = s;
                    dict.Add(s, new List <TermContainer>());
                }
                else
                {
                    if (isLevel2(s))
                    {
                        TermContainer term = new TermContainer("", s, null);
                        dict[chapter].Add(term);
                    }
                }
            }
            return(dict);
        }
Exemple #3
0
        /// <summary>
        /// 显示规程文档中目录的备注
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void regTreeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (isTextMode())
            {
                string tip   = "";
                string title = e.Node.Text;

                if (!title.Contains("第") && !title.Contains("节"))
                {
                    ////当前选中节点的父节点
                    TreeNode pTV = e.Node.Parent;
                    if (pTV != null)
                    {
                        ////如果父节点是“章”
                        if (pTV.Text.Contains("第") && pTV.Text.Contains("章"))
                        {
                            string        index = pTV.Text;
                            TermContainer tcc   = regTOCContents[index].Find(delegate(TermContainer tc)
                            {
                                if (tc.TermName.Contains(title))
                                {
                                    return(true);
                                }
                                return(false);
                            });
                            tip = tcc.TermTip;
                        }
                        ////如果父节点是“节”
                        else
                        {
                            string        index = pTV.Parent.Text;
                            TermContainer tcc   = regTOCContents[index].Find(delegate(TermContainer tc)
                            {
                                if (tc.TermName.Contains(title))
                                {
                                    return(true);
                                }
                                return(false);
                            });
                            tip = tcc.TermTip;
                        }

                        lbTermTitle.Text = title;
                        rtbMSG.Clear();
                        rtbMSG.Text = tip;
                    }
                }
            }
            else
            {
            }
        }
Exemple #4
0
        /*
         * get regulation table of content in document or db by name
         */
        public Dictionary <string, List <TermContainer> > getTOCContentsByName(string name)
        {
            string path = System.Environment.CurrentDirectory;

            name = path + "\\resources\\" + name + ".doc";
            ApplicationClass regWord        = new ApplicationClass();
            Document         regDoc         = new Document();
            HandleDocument   handleDocument = new HandleDocument();

            regDoc = handleDocument.openDocument(name, regWord);

            Table table = regDoc.Tables[1];
            int   rows  = table.Rows.Count;
            Dictionary <string, List <TermContainer> > dic = new Dictionary <string, List <TermContainer> >();

            string key     = "";
            string section = "";

            for (int i = 1; i <= rows; i++)
            {
                string text = getTableCellText(table, i, 1);
                if (isLevel1Cell(text))
                {
                    section = "";
                    key     = text;
                    dic.Add(text, new List <TermContainer>());
                }
                else
                {
                    if (isLevelSection(text))
                    {
                        section = text;
                    }
                    else
                    {
                        TermContainer term = getTableCellContainer(section, table, i);
                        dic[key].Add(term);
                    }
                }
            }
            quit(regWord, regDoc);
            return(dic);
        }
Exemple #5
0
        /// <summary>
        /// put new regulation document into system resource and extract toc
        /// </summary>
        /// <param name="filepath"></param>
        /// <returns></returns>
        public Dictionary <string, List <TermContainer> > AddRegToSysResource(string filepath)
        {
            string fname = filepath.Substring(filepath.LastIndexOf("\\") + 1, filepath.LastIndexOf(".") - filepath.LastIndexOf("\\") - 1);

            putNewRegTocInINIFile(fname);

            ApplicationClass regWord        = new ApplicationClass();
            Document         regDoc         = new Document();
            HandleDocument   handleDocument = new HandleDocument();

            regDoc = handleDocument.openDocument(filepath, regWord);

            Table table = regDoc.Tables[1];
            int   rows  = table.Rows.Count;
            Dictionary <string, List <TermContainer> > dic = new Dictionary <string, List <TermContainer> >();

            string key     = "";
            string section = "";

            for (int i = 1; i <= rows; i++)
            {
                string text = getTableCellText(table, i, 1);
                if (isLevel1Cell(text))
                {
                    section = "";
                    key     = text;
                    dic.Add(text, new List <TermContainer>());
                }
                else
                {
                    if (isLevelSection(text))
                    {
                        section = text;
                    }
                    else
                    {
                        TermContainer term = getTableCellContainer(section, table, i);
                        dic[key].Add(term);
                    }
                }
            }

            string path       = System.Environment.CurrentDirectory;
            string name       = path + "\\resources\\" + regDoc.Name;
            object saveAsName = path + "\\resources\\" + regDoc.Name;

            object unknow = Type.Missing;

            if (!File.Exists(name))
            {
                regDoc.SaveAs(ref saveAsName, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow);
            }
            else
            {
                //shifou ti huan
                File.Delete(name);
                regDoc.SaveAs(ref saveAsName, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow);
            }
            quit(regWord, regDoc);
            return(dic);
        }