Example #1
0
        /**
         * Read document
         */

        internal override void OnDocumentRead()
        {
            FootnotesDocument notesDoc;
            Stream            is1 = null;

            try
            {
                is1 = GetPackagePart().GetInputStream();
                XmlDocument xmldoc = ConvertStreamToXml(is1);
                notesDoc    = FootnotesDocument.Parse(xmldoc, NamespaceManager);
                ctFootnotes = notesDoc.Footnotes;
            }
            catch (XmlException)
            {
                throw new POIXMLException();
            }
            finally
            {
                if (is1 != null)
                {
                    is1.Close();
                }
            }
            //get any Footnote
            if (ctFootnotes.footnote != null)
            {
                foreach (CT_FtnEdn note in ctFootnotes.footnote)
                {
                    listFootnote.Add(new XWPFFootnote(note, this));
                }
            }
        }
Example #2
0
 public XWPFFootnotes CreateFootnotes()
 {
     if (this.footnotes == null)
     {
         FootnotesDocument footnotesDocument = new FootnotesDocument();
         XWPFRelation      footnote          = XWPFRelation.FOOTNOTE;
         int           relationIndex         = this.GetRelationIndex(footnote);
         XWPFFootnotes relationship          = (XWPFFootnotes)this.CreateRelationship((POIXMLRelation)footnote, (POIXMLFactory)XWPFFactory.GetInstance(), relationIndex);
         relationship.SetFootnotes(footnotesDocument.Footnotes);
         this.footnotes = relationship;
     }
     return(this.footnotes);
 }
Example #3
0
 internal override void OnDocumentRead()
 {
     try
     {
         this.ctFootnotes = FootnotesDocument.Parse(this.GetPackagePart().GetInputStream()).Footnotes;
     }
     catch (XmlException ex)
     {
         throw new POIXMLException();
     }
     foreach (CT_FtnEdn footnote in this.ctFootnotes.FootnoteList)
     {
         this.listFootnote.Add(new XWPFFootnote(footnote, this));
     }
 }
Example #4
0
        protected internal override void Commit()
        {
            /*XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
             * xmlOptions.SaveSyntheticDocumentElement=(new QName(CTFootnotes.type.Name.NamespaceURI, "footnotes"));
             * Dictionary<String,String> map = new Dictionary<String,String>();
             * map.Put("http://schemas.Openxmlformats.org/officeDocument/2006/relationships", "r");
             * map.Put("http://schemas.Openxmlformats.org/wordProcessingml/2006/main", "w");
             * xmlOptions.SaveSuggestedPrefixes=(map);*/
            PackagePart part = GetPackagePart();

            using (Stream out1 = part.GetOutputStream())
            {
                FootnotesDocument notesDoc = new FootnotesDocument(ctFootnotes);
                notesDoc.Save(out1);
            }
        }
Example #5
0
        /**
         * Read document
         */

        internal override void OnDocumentRead()
        {
            FootnotesDocument notesDoc;

            try {
                Stream is1 = GetPackagePart().GetInputStream();
                notesDoc    = FootnotesDocument.Parse(is1);
                ctFootnotes = notesDoc.Footnotes;
            } catch (XmlException) {
                throw new POIXMLException();
            }

            //get any Footnote
            foreach (CT_FtnEdn note in ctFootnotes.FootnoteList)
            {
                listFootnote.Add(new XWPFFootnote(note, this));
            }
        }
Example #6
0
        protected override void Commit()
        {
            /*XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
             * xmlOptions.SaveSyntheticDocumentElement=(new QName(CTFootnotes.type.Name.NamespaceURI, "footnotes"));
             * Dictionary<String,String> map = new Dictionary<String,String>();
             * map.Put("http://schemas.Openxmlformats.org/officeDocument/2006/relationships", "r");
             * map.Put("http://schemas.Openxmlformats.org/wordProcessingml/2006/main", "w");
             * xmlOptions.SaveSuggestedPrefixes=(map);*/
            PackagePart             part       = GetPackagePart();
            Stream                  out1       = part.GetOutputStream();
            XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces(new XmlQualifiedName[] {
                new XmlQualifiedName("w", "http://schemas.Openxmlformats.org/wordProcessingml/2006/main"),
                new XmlQualifiedName("r", "http://schemas.Openxmlformats.org/officeDocument/2006/relationships")
            });
            FootnotesDocument notesDoc = new FootnotesDocument(ctFootnotes);

            notesDoc.Save(out1, null);
            out1.Close();
        }
Example #7
0
 private void InitFootnotes()
 {
     foreach (POIXMLDocumentPart relation in this.GetRelations())
     {
         string relationshipType = relation.GetPackageRelationship().RelationshipType;
         if (relationshipType.Equals(XWPFRelation.FOOTNOTE.Relation))
         {
             FootnotesDocument footnotesDocument = FootnotesDocument.Parse(relation.GetPackagePart().GetInputStream());
             this.footnotes = (XWPFFootnotes)relation;
             this.footnotes.OnDocumentRead();
             foreach (CT_FtnEdn note in footnotesDocument.Footnotes.footnote)
             {
                 this.footnotes.AddFootnote(note);
             }
         }
         else if (relationshipType.Equals(XWPFRelation.ENDNOTE.Relation))
         {
             foreach (CT_FtnEdn body in EndnotesDocument.Parse(relation.GetPackagePart().GetInputStream()).Endnotes.endnote)
             {
                 this.endnotes.Add(int.Parse(body.id), new XWPFFootnote(this, body));
             }
         }
     }
 }