/// <summary> /// Method for testing FKP PAPX /// </summary> private static void testFKPPAPX() { //Get all PAPX FKPs List <FormattedDiskPagePAPX> papxFkps = FormattedDiskPagePAPX.GetAllPAPXFKPs(doc.FIB, doc.WordDocumentStream, doc.TableStream, doc.DataStream); Console.WriteLine("There are " + papxFkps.Count + " FKPs with PAPX in this file: \n"); foreach (FormattedDiskPagePAPX fkp in papxFkps) { Console.Write("FKP matches on " + fkp.crun + " paragraphs: "); foreach (int mark in fkp.rgfc) { Console.Write(mark + " "); } Console.WriteLine(""); for (int i = 0; i < fkp.crun; i++) { FormattedDiskPagePAPX.BX bx = fkp.rgbx[i]; ParagraphPropertyExceptions papx = fkp.grppapx[i]; Console.WriteLine("PAPX: has style " + papx.istd); //foreach (SinglePropertyModifier sprm in papx.grpprl) //{ // Console.WriteLine(String.Format("\tSPRM: modifies " + sprm.Type + " property 0x{0:x4} (" + sprm.Arguments.Length + " bytes)", sprm.OpCode)); //} } Console.WriteLine(""); } }
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 CharacterPropertiesMapping(XmlWriter writer, WordDocument doc, RevisionData rev, ParagraphPropertyExceptions currentPapx, bool styleChpx) : base(writer) { _doc = doc; _rPr = _nodeFactory.CreateElement("w", "rPr", OpenXmlNamespaces.WordprocessingML); _revisionData = rev; _currentPapx = currentPapx; _styleChpx = styleChpx; _currentIstd = UInt16.MaxValue; }
public CharacterPropertiesMapping(XmlElement rPr, WordDocument doc, RevisionData rev, ParagraphPropertyExceptions currentPapx, bool styleChpx) : base(null) { _doc = doc; _nodeFactory = rPr.OwnerDocument; _rPr = rPr; _revisionData = rev; _currentPapx = currentPapx; _styleChpx = styleChpx; _currentIstd = UInt16.MaxValue; }
public override void Apply(WordDocument doc) { _doc = doc; _writer.WriteStartElement("v", "textbox", OpenXmlNamespaces.VectorML); _writer.WriteStartElement("w", "txbxContent", OpenXmlNamespaces.WordprocessingML); Int32 cp = 0; Int32 cpEnd = 0; BreakDescriptor bkd = null; Int32 txtbxSubdocStart = doc.FIB.ccpText + doc.FIB.ccpFtn + doc.FIB.ccpHdr + doc.FIB.ccpAtn + doc.FIB.ccpEdn; if (_targetPart.GetType() == typeof(MainDocumentPart)) { cp = txtbxSubdocStart + doc.TextboxBreakPlex.CharacterPositions[_textboxIndex]; cpEnd = txtbxSubdocStart + doc.TextboxBreakPlex.CharacterPositions[_textboxIndex + 1]; bkd = (BreakDescriptor)doc.TextboxBreakPlex.Elements[_textboxIndex]; } if (_targetPart.GetType() == typeof(HeaderPart) || _targetPart.GetType() == typeof(FooterPart)) { txtbxSubdocStart += doc.FIB.ccpTxbx; cp = txtbxSubdocStart + doc.TextboxBreakPlexHeader.CharacterPositions[_textboxIndex]; cpEnd = txtbxSubdocStart + doc.TextboxBreakPlexHeader.CharacterPositions[_textboxIndex + 1]; bkd = (BreakDescriptor)doc.TextboxBreakPlexHeader.Elements[_textboxIndex]; } //convert the textbox text _lastValidPapx = _doc.AllPapxFkps[0].grppapx[0]; while (cp < cpEnd) { 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); } } _writer.WriteEndElement(); _writer.WriteEndElement(); _writer.Flush(); }
public override void Apply(WordDocument doc) { _doc = doc; _writer.WriteStartDocument(); _writer.WriteStartElement("w", "ftr", OpenXmlNamespaces.WordprocessingML); //convert the footer text _lastValidPapx = _doc.AllPapxFkps[0].grppapx[0]; Int32 cp = _ftr.CharacterPosition; Int32 cpMax = _ftr.CharacterPosition + _ftr.CharacterCount; //the CharacterCount of the footers also counts the guard paragraph mark. //this additional paragraph mark shall not be converted. cpMax--; while (cp < cpMax) { 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); } } _writer.WriteEndElement(); _writer.WriteEndDocument(); _writer.Flush(); }
public TableInfo(ParagraphPropertyExceptions papx) { foreach (var sprm in papx.grpprl) { if (sprm.OpCode == SinglePropertyModifier.OperationCode.sprmPFInTable) { this.fInTable = Utils.ByteToBool(sprm.Arguments[0]); } if (sprm.OpCode == SinglePropertyModifier.OperationCode.sprmPFTtp) { this.fTtp = Utils.ByteToBool(sprm.Arguments[0]); } if (sprm.OpCode == SinglePropertyModifier.OperationCode.sprmPFInnerTableCell) { this.fInnerTableCell = Utils.ByteToBool(sprm.Arguments[0]); } if (sprm.OpCode == SinglePropertyModifier.OperationCode.sprmPFInnerTtp) { this.fInnerTtp = Utils.ByteToBool(sprm.Arguments[0]); } if (sprm.OpCode == SinglePropertyModifier.OperationCode.sprmPItap) { this.iTap = System.BitConverter.ToUInt32(sprm.Arguments, 0); if (this.iTap > 0) { this.fInTable = true; } } if ((int)sprm.OpCode == 0x66A) { //add value! this.iTap = System.BitConverter.ToUInt32(sprm.Arguments, 0); if (this.iTap > 0) { this.fInTable = true; } } } }
private static void buildFirstCHP() { CharacterPropertyExceptions chpx = doc.AllChpxFkps[0].grpchpx[0]; ParagraphPropertyExceptions papx = doc.AllPapxFkps[0].grppapx[0]; CharacterProperties chp = new CharacterProperties(chpx, papx, doc); }