예제 #1
0
 public void Bug59058()
 {
     String[] files = { "bug57031.docx", "bug59058.docx" };
     foreach (String f in files)
     {
         ZipFile          zf       = new ZipFile(POIDataSamples.GetDocumentInstance().GetFile(f));
         ZipEntry         entry    = zf.GetEntry("word/document.xml");
         XmlDocument      xml      = POIXMLDocumentPart.ConvertStreamToXml(zf.GetInputStream(entry));
         DocumentDocument document = DocumentDocument.Parse(xml, POIXMLDocumentPart.NamespaceManager);
         Assert.IsNotNull(document);
         zf.Close();
     }
 }
예제 #2
0
 internal override void OnDocumentRead()
 {
     try
     {
         DocumentDocument documentDocument = DocumentDocument.Parse(this.GetPackagePart().GetInputStream());
         this.ctDocument = documentDocument.Document;
         this.InitFootnotes();
         foreach (object obj in this.ctDocument.body.Items)
         {
             if (obj is CT_P)
             {
                 XWPFParagraph xwpfParagraph = new XWPFParagraph((CT_P)obj, (IBody)this);
                 this.bodyElements.Add((IBodyElement)xwpfParagraph);
                 this.paragraphs.Add(xwpfParagraph);
             }
             else if (obj is CT_Tbl)
             {
                 XWPFTable xwpfTable = new XWPFTable((CT_Tbl)obj, (IBody)this);
                 this.bodyElements.Add((IBodyElement)xwpfTable);
                 this.tables.Add(xwpfTable);
             }
         }
         if (documentDocument.Document.body.sectPr != null)
         {
             this.headerFooterPolicy = new XWPFHeaderFooterPolicy(this);
         }
         foreach (POIXMLDocumentPart relation1 in this.GetRelations())
         {
             string relationshipType = relation1.GetPackageRelationship().RelationshipType;
             if (relationshipType.Equals(XWPFRelation.STYLES.Relation))
             {
                 this.styles = (XWPFStyles)relation1;
                 this.styles.OnDocumentRead();
             }
             else if (relationshipType.Equals(XWPFRelation.NUMBERING.Relation))
             {
                 this.numbering = (XWPFNumbering)relation1;
                 this.numbering.OnDocumentRead();
             }
             else if (relationshipType.Equals(XWPFRelation.FOOTER.Relation))
             {
                 XWPFFooter xwpfFooter = (XWPFFooter)relation1;
                 this.footers.Add(xwpfFooter);
                 xwpfFooter.OnDocumentRead();
             }
             else if (relationshipType.Equals(XWPFRelation.HEADER.Relation))
             {
                 XWPFHeader xwpfHeader = (XWPFHeader)relation1;
                 this.headers.Add(xwpfHeader);
                 xwpfHeader.OnDocumentRead();
             }
             else if (relationshipType.Equals(XWPFRelation.COMMENT.Relation))
             {
                 foreach (CT_Comment comment in CommentsDocument.Parse(relation1.GetPackagePart().GetInputStream()).Comments.comment)
                 {
                     this.comments.Add(new XWPFComment(comment, this));
                 }
             }
             else if (relationshipType.Equals(XWPFRelation.SETTINGS.Relation))
             {
                 this.Settings = (XWPFSettings)relation1;
                 this.Settings.OnDocumentRead();
             }
             else if (relationshipType.Equals(XWPFRelation.IMAGES.Relation))
             {
                 XWPFPictureData picData = (XWPFPictureData)relation1;
                 picData.OnDocumentRead();
                 this.RegisterPackagePictureData(picData);
                 this.pictures.Add(picData);
             }
             else if (relationshipType.Equals(XWPFRelation.GLOSSARY_DOCUMENT.Relation))
             {
                 foreach (POIXMLDocumentPart relation2 in relation1.GetRelations())
                 {
                     try
                     {
                         relation2.OnDocumentRead();
                     }
                     catch (Exception ex)
                     {
                         throw new POIXMLException(ex);
                     }
                 }
             }
         }
         this.InitHyperlinks();
     }
     catch (XmlException ex)
     {
         throw new POIXMLException((Exception)ex);
     }
 }