public void TestReadSimpleRTF()
        {
            string sFileName = TESTFILE_DIR + "VerySimpleRTF.rtf";
            Assert.IsTrue(File.Exists(sFileName));

            Workshare.Compositor.FCSFilters.Reader readIn = new Workshare.Compositor.FCSFilters.Reader();

            readIn.ReadNamedRTFFile(sFileName);

            int iObjectCount = readIn.FileCollectionSize();
            int iRecognisedObjectCount = 0;
            for (int iIndex = 0; iIndex < iObjectCount; ++iIndex)
            {
                DocElement des = readIn.ReadBackElementFromFileCollection(iIndex);
                if (des == null)
                    continue;

                ++iRecognisedObjectCount;
            }
            Assert.Greater(iRecognisedObjectCount, 0);
        }
        public void TestReadRTFTableWithExplicitCellBorder()
        {
            string sFileName = TESTFILE_DIR + "ExplicitCellBorder.rtf";
            Assert.IsTrue(File.Exists(sFileName));

            Workshare.Compositor.FCSFilters.Reader readIn = new Workshare.Compositor.FCSFilters.Reader();

            readIn.ReadNamedRTFFile(sFileName);
            List<DocElement> elems = readIn.ReadBackAllElementsFromFileCollection();
            int iCount = elems.Count;
            Assert.Greater(iCount, 0);
            List<TableCell> listCells = new List<TableCell>();
            for (int iIndex = 0; iIndex < iCount; ++iIndex)
            {
                if (elems[iIndex].Type == DocElementTypes.WPtableCell)
                    listCells.Add(elems[iIndex] as TableCell);
            }
            Assert.AreEqual(8, listCells.Count);

            TableCell cell2Start = listCells[2];
            Assert.IsTrue(cell2Start.IsStart);
            if (cell2Start.CellFormatting.Border != null)
            {
                Assert.AreEqual(Border.BorderStyle.None, cell2Start.CellFormatting.Border.Top.BorderLineStyle);
                Assert.AreEqual(Border.BorderStyle.None, cell2Start.CellFormatting.Border.Left.BorderLineStyle);
                Assert.AreEqual(Border.BorderStyle.None, cell2Start.CellFormatting.Border.Bottom.BorderLineStyle);
                Assert.AreEqual(Border.BorderStyle.None, cell2Start.CellFormatting.Border.Right.BorderLineStyle);
            }
            TableCell cell2End = listCells[3];
            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 TestReadSimpleRTFTable()
        {
            string sFileName = TESTFILE_DIR + "SimpleRTFTable.rtf";
            Assert.IsTrue(File.Exists(sFileName));

            Workshare.Compositor.FCSFilters.Reader readIn = new Workshare.Compositor.FCSFilters.Reader();

            readIn.ReadNamedRTFFile(sFileName);
            List<DocElement> elems = readIn.ReadBackAllElementsFromFileCollection();
            int iCount = elems.Count;
            Assert.Greater(iCount, 0);
            int iTableStart = -1;
            int iTableEnd  = -1;
            for (int iIndex = 0; iIndex < iCount; ++iIndex)
            {
                if (elems[iIndex].Type != DocElementTypes.WPtable)
                    continue;
                if ((elems[iIndex] as Table).IsStart)
                {
                    Assert.AreEqual(-1, iTableStart, "Should only be 1 table");
                    iTableStart = iIndex;
                }
                if ((elems[iIndex] as Table).IsEnd)
                {
                    Assert.AreNotEqual(-1, iTableStart, "Should have found a start before the end");
                    Assert.AreEqual(-1, iTableEnd,   "Should only be 1 table");
                    iTableEnd = iIndex;
                }
            }
            Assert.AreNotEqual(-1, iTableEnd, "Should have found the table");
            Table tableEnd = elems[iTableEnd] as Table;
            Assert.IsNotNull(tableEnd.TableGrid, "Should have a table grid");
            Assert.AreEqual   (2, tableEnd.TableGrid.ColumnWidths.Count, "Should have 2 columns");
            Assert.AreEqual(1242, tableEnd.TableGrid.ColumnWidths[0]);
            Assert.AreEqual( 993, tableEnd.TableGrid.ColumnWidths[1]);
        }
        public void TestReadRTFTableWithExplicitTableBorder()
        {
            string sFileName = TESTFILE_DIR + "ExplicitTableBorder.rtf";
            Assert.IsTrue(File.Exists(sFileName));

            Workshare.Compositor.FCSFilters.Reader readIn = new Workshare.Compositor.FCSFilters.Reader();

            readIn.ReadNamedRTFFile(sFileName);
            List<DocElement> elems = readIn.ReadBackAllElementsFromFileCollection();

            int iIndex = 14;
            Assert.AreEqual(DocElementTypes.WPtable, elems[iIndex].Type);
            Table tableEnd = elems[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);
        }