public override void Apply(WordDocument doc) { _doc = doc; //start the document _writer.WriteStartDocument(); _writer.WriteStartElement("w", "document", OpenXmlNamespaces.WordprocessingML); //write namespaces _writer.WriteAttributeString("xmlns", "v", null, OpenXmlNamespaces.VectorML); _writer.WriteAttributeString("xmlns", "o", null, OpenXmlNamespaces.Office); _writer.WriteAttributeString("xmlns", "w10", null, OpenXmlNamespaces.OfficeWord); _writer.WriteAttributeString("xmlns", "r", null, OpenXmlNamespaces.Relationships); _writer.WriteStartElement("w", "body", OpenXmlNamespaces.WordprocessingML); //convert the document _lastValidPapx = _doc.AllPapxFkps[0].grppapx[0]; Int32 cp = 0; while (cp < doc.FIB.ccpText) { Int32 fc = _doc.PieceTable.FileCharacterPositions[cp]; ParagraphPropertyExceptions papx = findValidPapx(fc); TableInfo tai = new TableInfo(papx); if (tai.fInTable) { //this PAPX is for a table cp = writeTable(cp, tai.iTap); } else { //this PAPX is for a normal paragraph cp = writeParagraph(cp); } } //write the section properties of the body with the last SEPX int lastSepxCp = 0; foreach (int sepxCp in _doc.AllSepx.Keys) { lastSepxCp = sepxCp; } SectionPropertyExceptions lastSepx = _doc.AllSepx[lastSepxCp]; lastSepx.Convert(new SectionPropertiesMapping(_writer, _ctx, _sectionNr)); //end the document _writer.WriteEndElement(); _writer.WriteEndElement(); _writer.WriteEndDocument(); _writer.Flush(); }
public ParagraphPropertiesMapping( XmlWriter writer, ConversionContext ctx, WordDocument parentDoc, CharacterPropertyExceptions paraEndChpx, SectionPropertyExceptions sepx, int sectionNr) : base(writer) { this._parentDoc = parentDoc; this._pPr = this._nodeFactory.CreateElement("w", "pPr", OpenXmlNamespaces.WordprocessingML); this._framePr = this._nodeFactory.CreateElement("w", "framePr", OpenXmlNamespaces.WordprocessingML); this._paraEndChpx = paraEndChpx; this._sepx = sepx; this._ctx = ctx; this._sectionNr = sectionNr; }