示例#1
0
        internal override void OnDocumentRead()
        {
            base.OnDocumentRead();
            FtrDocument ftrDocument = null;

            try {
                XmlDocument xmldoc = ConvertStreamToXml(GetPackagePart().GetInputStream());
                ftrDocument  = FtrDocument.Parse(xmldoc, NamespaceManager);
                headerFooter = ftrDocument.Ftr;
                // parse the document with cursor and add
                // the XmlObject to its lists
                foreach (object o in headerFooter.Items)
                {
                    if (o is CT_P)
                    {
                        XWPFParagraph p = new XWPFParagraph((CT_P)o, this);
                        paragraphs.Add(p);
                        bodyElements.Add(p);
                    }
                    if (o is CT_Tbl)
                    {
                        XWPFTable t = new XWPFTable((CT_Tbl)o, this);
                        tables.Add(t);
                        bodyElements.Add(t);
                    }
                    if (o is CT_SdtBlock)
                    {
                        XWPFSDT c = new XWPFSDT((CT_SdtBlock)o, this);
                        bodyElements.Add(c);
                    }
                }
            } catch (Exception e) {
                throw new POIXMLException(e);
            }
        }
示例#2
0
 internal override void OnDocumentRead()
 {
     base.OnDocumentRead();
     try
     {
         this.headerFooter = (CT_HdrFtr)FtrDocument.Parse(this.GetPackagePart().GetInputStream()).Ftr;
         foreach (object obj in this.headerFooter.Items)
         {
             if (obj is CT_P)
             {
                 XWPFParagraph xwpfParagraph = new XWPFParagraph((CT_P)obj, (IBody)this);
                 this.paragraphs.Add(xwpfParagraph);
                 this.bodyElements.Add((IBodyElement)xwpfParagraph);
             }
             if (obj is CT_Tbl)
             {
                 XWPFTable xwpfTable = new XWPFTable((CT_Tbl)obj, (IBody)this);
                 this.tables.Add(xwpfTable);
                 this.bodyElements.Add((IBodyElement)xwpfTable);
             }
         }
     }
     catch (Exception ex)
     {
         throw new POIXMLException(ex);
     }
 }
示例#3
0
        internal override void OnDocumentRead()
        {
            base.OnDocumentRead();
            FtrDocument ftrDocument = null;
            Stream      is1;

            try {
                is1          = GetPackagePart().GetInputStream();
                ftrDocument  = FtrDocument.Parse(is1);
                headerFooter = ftrDocument.Ftr;
                // parse the document with cursor and add
                // the XmlObject to its lists
                foreach (object o in headerFooter.Items)
                {
                    if (o is CT_P)
                    {
                        XWPFParagraph p = new XWPFParagraph((CT_P)o, this);
                        paragraphs.Add(p);
                        bodyElements.Add(p);
                    }
                    if (o is CT_Tbl)
                    {
                        XWPFTable t = new XWPFTable((CT_Tbl)o, this);
                        tables.Add(t);
                        bodyElements.Add(t);
                    }
                }

                /*XmlCursor cursor = headerFooter.NewCursor();
                 * cursor.SelectPath("./*");
                 * while (cursor.ToNextSelection()) {
                 *  XmlObject o = cursor.Object;
                 *  if (o is CTP) {
                 *      XWPFParagraph p = new XWPFParagraph((CTP)o, this);
                 *      paragraphs.Add(p);
                 *      bodyElements.Add(p);
                 *  }
                 *  if (o is CTTbl) {
                 *      XWPFTable t = new XWPFTable((CTTbl)o, this);
                 *      tables.Add(t);
                 *      bodyElements.Add(t);
                 *  }
                 * }
                 * cursor.Dispose();*/
            } catch (Exception e) {
                throw new POIXMLException(e);
            }
        }