public void TestLoopbackSimpleRTFTableGetsGridInfo() { using (Stream sIn = new FileStream(TESTFILE_DIR + "SimpleRTFTable_document.xml", FileMode.Open)) { Workshare.Compositor.FCSFilters.FcsToRtfWriter writerOut = new Workshare.Compositor.FCSFilters.FcsToRtfWriter(); writerOut.RememberElementsWritten = true; ParsingContext context = new ParsingContext(); context.SetDefaultStartContext(); context.ParsingBody = true; Parser pft = new Parser(sIn, new BodyConsumer(context), writerOut); pft.Parse(); List<DocElement> elemsBefore = writerOut.ListOfWrittenElements(); Workshare.Compositor.FCSFilters.Reader readBack = new Workshare.Compositor.FCSFilters.Reader(); readBack.ExtractRTFFileCollectionFromWriter(writerOut); List<DocElement> elemsAfter = readBack.ReadBackAllElementsFromFileCollection(); int iCountBefore = elemsBefore.Count; int iCountAfter = elemsAfter.Count; // At 28-11-2007 count was 15, which is wrong, but will evolve to correctednessness with time, cups of coffee and several Hob Nobbs int iIndex = 14; Assert.AreEqual(DocElementTypes.WPtable, elemsAfter[iIndex].Type); Table tableEnd = elemsAfter[iIndex] as Table; Assert.IsFalse(tableEnd.IsStart); Assert.IsTrue(tableEnd.IsEnd); TableGrid grid = tableEnd.TableGrid; Assert.IsNotNull(grid); Assert.IsNotNull(grid.ColumnWidths); Assert.AreEqual(2, grid.ColumnWidths.Count); Assert.AreEqual(1242, grid.ColumnWidths[0]); Assert.AreEqual(993, grid.ColumnWidths[1]); } }
public void TestLoopbackRTFTableGetsCellBorderInfo() { using (Stream sIn = new FileStream(TESTFILE_DIR + "DocumentExplicitTableAndCellBorders.xml", FileMode.Open)) { Workshare.Compositor.FCSFilters.FcsToRtfWriter writerOut = new Workshare.Compositor.FCSFilters.FcsToRtfWriter(); writerOut.RememberElementsWritten = true; ParsingContext context = new ParsingContext(); context.SetDefaultStartContext(); context.ParsingBody = true; Parser pft = new Parser(sIn, new BodyConsumer(context), writerOut); pft.Parse(); List<DocElement> elemsBefore = writerOut.ListOfWrittenElements(); Workshare.Compositor.FCSFilters.Reader readBack = new Workshare.Compositor.FCSFilters.Reader(); readBack.ExtractRTFFileCollectionFromWriter(writerOut); List<DocElement> elemsAfter = readBack.ReadBackAllElementsFromFileCollection(); int iCountBefore = elemsBefore.Count; int iCountAfter = elemsAfter.Count; int iIndex = 6; Assert.AreEqual(DocElementTypes.WPtableCell, elemsAfter[iIndex].Type); TableCell cell2End = elemsAfter[iIndex] as TableCell; Assert.IsFalse(cell2End.IsStart); Assert.IsTrue(cell2End.IsEnd); Assert.IsNotNull(cell2End.CellFormatting.Border); Assert.AreEqual(Border.BorderStyle.SingleThickness, cell2End.CellFormatting.Border.Top.BorderLineStyle); Assert.AreEqual(Border.BorderStyle.SingleThickness, cell2End.CellFormatting.Border.Left.BorderLineStyle); Assert.AreEqual(Border.BorderStyle.SingleThickness, cell2End.CellFormatting.Border.Bottom.BorderLineStyle); Assert.AreEqual(Border.BorderStyle.SingleThickness, cell2End.CellFormatting.Border.Right.BorderLineStyle); Assert.AreEqual(4, cell2End.CellFormatting.Border.Top.PenWidth); Assert.AreEqual(4, cell2End.CellFormatting.Border.Left.PenWidth); Assert.AreEqual(4, cell2End.CellFormatting.Border.Bottom.PenWidth); Assert.AreEqual(4, cell2End.CellFormatting.Border.Right.PenWidth); } }
public void TestLoopbackRTFTableGetsTableBorderInfo() { using (Stream sIn = new FileStream(TESTFILE_DIR + "DocumentWithExplicitTableBorder.xml", FileMode.Open)) { Workshare.Compositor.FCSFilters.FcsToRtfWriter writerOut = new Workshare.Compositor.FCSFilters.FcsToRtfWriter(); writerOut.RememberElementsWritten = true; ParsingContext context = new ParsingContext(); context.SetDefaultStartContext(); context.ParsingBody = true; Parser pft = new Parser(sIn, new BodyConsumer(context), writerOut); pft.Parse(); List<DocElement> elemsBefore = writerOut.ListOfWrittenElements(); Workshare.Compositor.FCSFilters.Reader readBack = new Workshare.Compositor.FCSFilters.Reader(); readBack.ExtractRTFFileCollectionFromWriter(writerOut); List<DocElement> elemsAfter = readBack.ReadBackAllElementsFromFileCollection(); int iCountBefore = elemsBefore.Count; int iCountAfter = elemsAfter.Count; int iIndex = 14; Assert.AreEqual(DocElementTypes.WPtable, elemsAfter[iIndex].Type); Table tableEnd = elemsAfter[iIndex] as Table; Assert.IsFalse(tableEnd.IsStart); Assert.IsTrue(tableEnd.IsEnd); Assert.IsNotNull(tableEnd.TableProperties); Assert.IsNotNull(tableEnd.TableProperties.TableBorders); Assert.IsNotNull(tableEnd.TableProperties.TableBorders.Top); Border borderTableTop = tableEnd.TableProperties.TableBorders.Top; Assert.AreEqual(Border.BorderStyle.Dashed, borderTableTop.BorderLineStyle); Assert.AreEqual(8, borderTableTop.PenWidth); Assert.IsNotNull(tableEnd.TableProperties.TableBorders.Left); Border borderTableLeft = tableEnd.TableProperties.TableBorders.Left; Assert.AreEqual(Border.BorderStyle.SingleThickness, borderTableLeft.BorderLineStyle); Assert.AreEqual(8, borderTableLeft.PenWidth); Assert.IsNotNull(tableEnd.TableProperties.TableBorders.Bottom); Border borderTableBottom = tableEnd.TableProperties.TableBorders.Bottom; Assert.AreEqual(Border.BorderStyle.None, borderTableBottom.BorderLineStyle); Assert.AreEqual(0, borderTableBottom.PenWidth); Assert.IsNotNull(tableEnd.TableProperties.TableBorders.Right); Border borderTableRight = tableEnd.TableProperties.TableBorders.Right; Assert.AreEqual(Border.BorderStyle.Double, borderTableRight.BorderLineStyle); Assert.AreEqual(8, borderTableRight.PenWidth); Assert.IsNotNull(tableEnd.TableProperties.TableBorders.HorizontalInside); Border borderTableHorizontalInside = tableEnd.TableProperties.TableBorders.HorizontalInside; Assert.AreEqual(Border.BorderStyle.SingleThickness, borderTableHorizontalInside.BorderLineStyle); Assert.AreEqual(4, borderTableHorizontalInside.PenWidth); Assert.IsNotNull(tableEnd.TableProperties.TableBorders.VerticalInside); Border borderTableVerticalInside = tableEnd.TableProperties.TableBorders.VerticalInside; Assert.AreEqual(Border.BorderStyle.SingleThickness, borderTableVerticalInside.BorderLineStyle); Assert.AreEqual(6, borderTableVerticalInside.PenWidth); } }