Ejemplo n.º 1
0
        /// <summary>
        /// Split the representative speech content in the document
        /// </summary>
        /// <param name="document"> Document that contains the whole content</param>
        /// <returns></returns>
        public static DocumentEntity ParsingDocument(Word.Document document,
                                                     List <RepresentativeEntity> representativeEntities)
        {
            DocumentEntity documentesEntity = new DocumentEntity();

            DocumentParagraph documentParagraph = new DocumentParagraph();

            documentesEntity.paragraphs.Add(documentParagraph);
            foreach (Word.Paragraph para in TextHelpers.GetText(document))
            {
                string styleName = ((Word.Style)para.get_Style()).NameLocal;
                if (styleName.Equals(Constants.RerpesentativeStyle))
                {
                    RepresentativeEntity entity = FindRepresentative(representativeEntities, para.Range.Text);
                    if (entity != null)
                    {
                        documentParagraph = new DocumentParagraph();
                        documentesEntity.paragraphs.Add(documentParagraph);
                        documentParagraph.belongTo           = entity;
                        documentParagraph.belongTo.fullTitle = Utils.FormatRepresentative(entity.name, entity.duty);
                    }
                    else
                    {
                        if (!para.Range.Text.Trim().Equals(""))
                        {
                            documentParagraph = new DocumentParagraph();
                            documentesEntity.paragraphs.Add(documentParagraph);
                            documentParagraph.belongTo           = new RepresentativeEntity();
                            documentParagraph.belongTo.fullTitle = para.Range.Text.Trim();
                        }
                    }
                }
                else if (!Constants.TitleStyles.Contains(styleName))
                {
                    ///Do not get the title content
                    if (!para.Range.Text.Trim().Equals(""))
                    {
                        documentParagraph.contents.Add(para.Range.Text);
                    }
                }
            }

            return(documentesEntity);
        }
Ejemplo n.º 2
0
 public static bool CheckRepresentativeList(Word.Document document,
                                            List <RepresentativeEntity> representativeEntities, out string reprentativeName)
 {
     foreach (Word.Paragraph para in TextHelpers.GetText(document))
     {
         string styleName = ((Word.Style)para.get_Style()).NameLocal;
         if (styleName.Equals(Constants.RerpesentativeStyle) &&
             !para.Range.Text.Trim().Equals(""))
         {
             RepresentativeEntity entity = FindRepresentative(representativeEntities, para.Range.Text);
             if (entity == null)
             {
                 reprentativeName = para.Range.Text;
                 return(false);
             }
         }
     }
     reprentativeName = "";
     return(true);
 }