public void TestReadBackCharacterFormattingIncludesColourInfo() { using (Stream sIn = new FileStream(TESTFILE_DIR + "CharacterPropertiesTestDocument.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.Parse(); int iReadBackIndex = 2; DocElement de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex); Assert.IsTrue(de.GetType() == typeof(CharacterFormatting)); Assert.IsTrue((de as CharacterFormatting).Properties.UnderlineStyle == CharacterProperties.UnderlineStyles.None); iReadBackIndex += 3; de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex); Assert.IsTrue(de.GetType() == typeof(CharacterFormatting)); Assert.IsTrue((de as CharacterFormatting).Properties.UnderlineStyle == CharacterProperties.UnderlineStyles.Continuous); iReadBackIndex += 4; de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex); Assert.IsTrue(de.GetType() == typeof(CharacterFormatting)); Assert.IsTrue((de as CharacterFormatting).Properties.UnderlineStyle == CharacterProperties.UnderlineStyles.None); } }
public void TestGeneratesSectionObjects() { 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.Parse(); DocElement de = null; int iObjectCount = writerOut.FileCollectionSize(); for(int iIndex = 0; iIndex < iObjectCount; ++iIndex) { de = writerOut.ReadBackElementFromFileCollection(iIndex); if (de == null) continue; if (de.GetType() == typeof(Section)) break; de = null; } Assert.IsNotNull(de, "Failed to find any Section objects in the output"); } }
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 TestReadBackCharacterFormatting_2() { using (Stream sIn = new FileStream(TESTFILE_DIR + "Test Additional Character Properties Document.xml", FileMode.Open)) { Workshare.Compositor.FCSFilters.FcsToRtfWriter writerOut = new Workshare.Compositor.FCSFilters.FcsToRtfWriter(); ParsingContext context = new ParsingContext(); context.SetDefaultStartContext(); Parser pft = new Parser(sIn, new BodyConsumer(context), writerOut); pft.Parse(); int iReadBackIndex = 4; DocElement de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex); Assert.IsTrue(de.GetType() == typeof(CharacterFormatting)); Assert.IsTrue((de as CharacterFormatting).Properties.StrikeThrough, "Expected strikethrough"); iReadBackIndex = 8; de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex); Assert.IsTrue(de.GetType() == typeof(CharacterFormatting)); Assert.IsTrue((de as CharacterFormatting).Properties.DoubleStrikeThrough, "Expected DoubleStrikeThrough"); iReadBackIndex = 12; de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex); Assert.IsTrue(de.GetType() == typeof(CharacterFormatting)); Assert.IsTrue((de as CharacterFormatting).Properties.Superscript, "Expected Superscript"); iReadBackIndex = 16; de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex); Assert.IsTrue(de.GetType() == typeof(CharacterFormatting)); Assert.IsTrue((de as CharacterFormatting).Properties.Subscript, "Expected Subscript"); Assert.IsFalse((de as CharacterFormatting).Properties.Superscript, "Expected Superscript to be off now"); iReadBackIndex = 20; de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex); Assert.IsTrue(de.GetType() == typeof(CharacterFormatting)); Assert.IsTrue((de as CharacterFormatting).Properties.Shadow, "Expected Shadow"); Assert.IsFalse((de as CharacterFormatting).Properties.Subscript, "Expected Subscript to be off now"); Assert.IsFalse((de as CharacterFormatting).Properties.Superscript, "Expected Superscript to be off now"); iReadBackIndex = 24; de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex); Assert.IsTrue(de.GetType() == typeof(CharacterFormatting)); Assert.IsTrue((de as CharacterFormatting).Properties.Outline, "Expected Outline"); iReadBackIndex = 28; de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex); Assert.IsTrue(de.GetType() == typeof(CharacterFormatting)); Assert.IsTrue((de as CharacterFormatting).Properties.Emboss, "Expected Emboss"); iReadBackIndex = 32; de = writerOut.ReadBackElementFromFileCollection(iReadBackIndex); Assert.IsTrue(de.GetType() == typeof(CharacterFormatting)); Assert.IsTrue((de as CharacterFormatting).Properties.Engrave, "Expected Engrave"); } }
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 } }