Esempio n. 1
0
 internal override void OnDocumentRead()
 {
     base.OnDocumentRead();
     try
     {
         this.headerFooter = (CT_HdrFtr)HdrDocument.Parse(this.GetPackagePart().GetInputStream()).Hdr;
         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);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Read the document
        /// </summary>
        internal override void OnDocumentRead()
        {
            base.OnDocumentRead();
            HdrDocument hdrDocument = null;

            try
            {
                XmlDocument xmldoc = ConvertStreamToXml(GetPackagePart().GetInputStream());
                hdrDocument  = HdrDocument.Parse(xmldoc, NamespaceManager);
                headerFooter = hdrDocument.Hdr;
                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);
                    }
                }
            }
            catch (Exception e)
            {
                throw new POIXMLException(e);
            }
        }
Esempio n. 3
0
        /**
         * Reads the document
         * @throws IOException
         */

        internal override void OnDocumentRead()
        {
            base.OnDocumentRead();
            HdrDocument hdrDocument = null;
            Stream      is1;

            try
            {
                is1          = GetPackagePart().GetInputStream();
                hdrDocument  = HdrDocument.Parse(is1);
                headerFooter = hdrDocument.Hdr;
                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);
                    }
                }
                // parse the document with cursor and add
                // the XmlObject to its lists

                /*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);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Read the document
        /// </summary>
        internal override void OnDocumentRead()
        {
            base.OnDocumentRead();
            HdrDocument hdrDocument = null;
            Stream      is1         = null;

            try
            {
                is1 = GetPackagePart().GetInputStream();
                XmlDocument xmldoc = DocumentHelper.LoadDocument(is1);
                hdrDocument  = HdrDocument.Parse(xmldoc, NamespaceManager);
                headerFooter = hdrDocument.Hdr;
                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);
            }
            finally
            {
                if (is1 != null)
                {
                    is1.Close();
                }
            }
        }