public void TestReadBackSectionObjects() { using (Stream sIn = new FileStream(TESTFILE_DIR + "DocumentHasTwoSections.xml", FileMode.Open)) { Workshare.Compositor.FCSFilters.FcsToRtfWriter writerOut = new Workshare.Compositor.FCSFilters.FcsToRtfWriter(); ParsingContext context = new ParsingContext(); context.SetDefaultStartContext(); context.ParsingBody = true; Parser pft = new Parser(sIn, new BodyConsumer(context), writerOut); pft.EmitContextStart(); pft.Parse(); int iFoundNSectionsWhereN = 0; int iObjectCount = writerOut.FileCollectionSize(); for (int iIndex = 0; iIndex < iObjectCount; ++iIndex) { DocElement des = writerOut.ReadBackElementFromFileCollection(iIndex); if (des == null) continue; if(des.GetType() == typeof(Section)) ++iFoundNSectionsWhereN; } Assert.IsTrue(iFoundNSectionsWhereN == 2); int iReadBackIndex = 0; DocElement de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex); Assert.IsTrue(de.GetType() == typeof(Section)); Assert.AreEqual(1440, (de as Section).SectionFormatting.FCSPageInformation.TopMargin); Assert.AreEqual(1440, (de as Section).SectionFormatting.FCSPageInformation.RightMargin); Assert.AreEqual(1440, (de as Section).SectionFormatting.FCSPageInformation.BottomMargin); Assert.AreEqual(1440, (de as Section).SectionFormatting.FCSPageInformation.LeftMargin); iReadBackIndex += 6; de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex); Assert.IsTrue(de.GetType() == typeof(Section)); Assert.AreEqual(720, (de as Section).SectionFormatting.FCSPageInformation.TopMargin); Assert.AreEqual(720, (de as Section).SectionFormatting.FCSPageInformation.RightMargin); Assert.AreEqual(720, (de as Section).SectionFormatting.FCSPageInformation.BottomMargin); Assert.AreEqual(720, (de as Section).SectionFormatting.FCSPageInformation.LeftMargin); } }
public void TestReadBackTableObject() { using (Stream sIn = new FileStream(TESTFILE_DIR + "DocumentWithASimpleTable.xml", FileMode.Open)) { Workshare.Compositor.FCSFilters.FcsToRtfWriter writerOut = new Workshare.Compositor.FCSFilters.FcsToRtfWriter(); ParsingContext context = new ParsingContext(); context.SetDefaultStartContext(); context.ParsingBody = true; Parser pft = new Parser(sIn, new BodyConsumer(context), writerOut); pft.EmitContextStart(); pft.Parse(); int iFoundNTablesWhereN = 0; int iObjectCount = writerOut.FileCollectionSize(); for (int iIndex = 0; iIndex < iObjectCount; ++iIndex) { DocElement des = writerOut.ReadBackElementFromFileCollection(iIndex); if (des == null) continue; if (des.GetType() == typeof(Table)) ++iFoundNTablesWhereN; } Assert.IsTrue(iFoundNTablesWhereN == 1); int iReadBackIndex = 1; DocElement de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex); Assert.IsTrue(de.GetType() == typeof(Table)); // Only returns a table start indicator - proper readback requires the Reader class } }