public static HtmlCell GetCellByIndex(this HtmlTable @this, int rowIndex, int columnIndex)
 {
     HtmlCell cell = new HtmlCell(@this);
     cell.SearchProperties[HtmlCell.PropertyNames.RowIndex] = rowIndex.ToString();
     cell.SearchProperties[HtmlCell.PropertyNames.ColumnIndex] = columnIndex.ToString();
     cell.Find();
     return cell;
 }
Example #2
0
 private HtmlCell GetCellByIndex(int rowIndex, int columnIndex)
 {
     HtmlCell cell = new HtmlCell(table);
     cell.SearchProperties[HtmlCell.PropertyNames.RowIndex] = rowIndex.ToString();
     cell.SearchProperties[HtmlCell.PropertyNames.ColumnIndex] = columnIndex.ToString();
     cell.Find();
     return cell;
 }
Example #3
0
        public void MouseTest_DraggAndDrop_TestControlAndPoint()
        {
            BrowserWindow.Refresh();
            var parentCell = new HtmlCell(TestPage.Table);

            parentCell.SearchProperties.Add(HtmlCell.PropertyNames.ColumnIndex, "1");
            parentCell.SearchProperties.Add(HtmlCell.PropertyNames.RowIndex, "1");

            var targetCell = new HtmlCell(TestPage.Table);

            targetCell.SearchProperties.Add(HtmlCell.PropertyNames.ColumnIndex, "3");
            targetCell.SearchProperties.Add(HtmlCell.PropertyNames.RowIndex, "2");

            Mouse.StartDragging(TestPage.DivToDrag);
            Mouse.StopDragging(parentCell, new Point(125, 75));

            new HtmlDiv(targetCell).Exists
            .Should().BeTrue("div should have been moved to {0},{1} cell position", 2, 1);
        }
Example #4
0
        public void Initialize(HtmlTable htmlTable, HtmlCell[] htmlCells)
        {
            if (_htmlTable != null)
            {
                throw new InvalidOperationException("Row is already initialized.");
            }

            if (htmlCells.Select(c => c.RowIndex).Distinct().Count() != 1)
            {
                throw new ArgumentException("All cells must have the same RowIndex.", "htmlCells");
            }

            _htmlTable = htmlTable;
            RowIndex = htmlCells[0].RowIndex;

            ResetCache();
            foreach (var htmlCell in htmlCells)
            {
                _htmlCellCache.Set(htmlCell.ColumnIndex, htmlCell);
            }
        }
Example #5
0
        /// <summary>
        /// AssertMethodUserCreated - Use 'AssertMethodUserCreatedExpectedValues' to pass parameters into this method.
        /// </summary>
        public void AssertMethodUserCreated()
        {
            #region Variable Declarations
            HtmlCell      uIBobCell         = this.UIIndexCodedUItestautoWindow.UIIndexCodedUItestautoDocument.UIItemTable.UIBobCell;
            HtmlCell      uISmithCell       = this.UIIndexCodedUItestautoWindow.UIIndexCodedUItestautoDocument.UIItemTable.UISmithCell;
            HtmlCell      uIItem3051996Cell = this.UIIndexCodedUItestautoWindow.UIIndexCodedUItestautoDocument.UIItemTable.UIItem3051996Cell;
            HtmlHyperlink uIBobsmithsomedomaincoHyperlink = this.UIIndexCodedUItestautoWindow.UIIndexCodedUItestautoDocument.UIBobsmithsomedomaincoHyperlink;
            #endregion

            // Verify that the 'InnerText' property of 'Bob' cell equals 'Bob '
            Assert.AreEqual(this.AssertMethodUserCreatedExpectedValues.UIBobCellInnerText, uIBobCell.InnerText, "User not created.");

            // Verify that the 'InnerText' property of 'Smith' cell equals 'Smith '
            Assert.AreEqual(this.AssertMethodUserCreatedExpectedValues.UISmithCellInnerText, uISmithCell.InnerText, "User not created.");

            // Verify that the 'InnerText' property of '3/05/1996' cell equals '3/05/1996 '
            Assert.AreEqual(this.AssertMethodUserCreatedExpectedValues.UIItem3051996CellInnerText, uIItem3051996Cell.InnerText, "User not created.");

            // Verify that the 'InnerText' property of '*****@*****.**' link equals '*****@*****.**'
            Assert.AreEqual(this.AssertMethodUserCreatedExpectedValues.UIBobsmithsomedomaincoHyperlinkInnerText, uIBobsmithsomedomaincoHyperlink.InnerText, "User not created.");
        }
Example #6
0
        public void SetUp()
        {
            cells     = new List <Element>();
            tag       = new Tag("td", new Dictionary <String, String>());
            basicPara = new NoNewLineParagraph();
            basic     = new Chunk("content");

            cell    = new HtmlCell();
            applier = new HtmlCellCssApplier();


            LoggerFactory.GetInstance().SetLogger(new SysoLogger(3));
            Tag parent = new Tag("tr");

            parent.Parent = new Tag("table");
            tag.Parent    = parent;
            basicPara.Add(basic);
            cell.AddElement(basicPara);
            cells.Add(cell);
            config = new HtmlPipelineContext(null);
        }
Example #7
0
        /// <summary>
        /// eduHistory
        /// </summary>
        public void eduHistory()
        {
            #region Variable Declarations
            HtmlHeaderCell uIIDCell     = this.UIEducationHistoryInteWindow.UIEducationHistoryDocument.UIPanelRecordsGridTable.UIIDCell;
            HtmlHeaderCell uIEditCell   = this.UIEducationHistoryInteWindow.UIEducationHistoryDocument.UIPanelRecordsGridTable.UIEditCell;
            HtmlHeaderCell uIDeleteCell = this.UIEducationHistoryInteWindow.UIEducationHistoryDocument.UIPanelRecordsGridTable.UIDeleteCell;
            HtmlCell       uIDDCell     = this.UIEducationHistoryInteWindow.UIEducationHistoryDocument.UIPanelRecordsGridTable.UIDDCell;
            #endregion

            // Click 'ID' cell
            Mouse.Click(uIIDCell, new Point(15, 12));

            // Click 'Edit' cell
            Mouse.Click(uIEditCell, new Point(19, 12));

            // Click 'Delete' cell
            Mouse.Click(uIDeleteCell, new Point(21, 12));

            // Move 'DD' cell
            Mouse.StartDragging(uIDDCell, new Point(37, 17));
            Mouse.StopDragging(uIDDCell, 3, -5);
        }
Example #8
0
        /// <summary>
        /// Open browser; navigate to QA; select ECATest1 user; enter password; click sign in.
        /// </summary>
        public void LogintoQA_ExistingUser()
        {
            #region Variable Declarations
            HtmlCell uIECATest1statedeptusCell = this.UINewtabInternetExplorWindow.UISignintoECAClientDocument4.UIEcatest1_statedept_uTable.UIECATest1statedeptusCell;
            HtmlEdit uIPasswordEdit            = this.UINewtabInternetExplorWindow.UISignintoECAClientDocument4.UIPasswordEdit;
            HtmlSpan uISigninPane = this.UINewtabInternetExplorWindow.UISignintoECAClientDocument4.UISigninPane;
            #endregion

            // Go to web page 'https://eca-kmt-qa.azurewebsites.net/' using new browser instance
            //this.UINewtabInternetExplorWindow.LaunchUrl(new System.Uri(this.LogintoQA_ExistingUserParams.UINewtabInternetExplorWindowUrl));

            // Go to web page 'http://*****:*****@statedept.us' cell
            Mouse.Click(uIECATest1statedeptusCell, new Point(65, 47));

            // Type '********' in 'Password' text box
            uIPasswordEdit.Password = this.LogintoQA_ExistingUserParams.UIPasswordEditPassword;

            // Click 'Sign in' pane
            Mouse.Click(uISigninPane, new Point(20, 13));
        }
 private void SetRightOfBorder(HtmlCell cell, String key, String value, TableStyleValues values)
 {
     if (key.Contains(CSS.Property.WIDTH))
     {
         values.BorderWidthRight = utils.ParsePxInCmMmPcToPt(value);
     }
     if (key.Contains(CSS.Property.COLOR))
     {
         values.BorderColorRight = HtmlUtilities.DecodeColor(value);
     }
     else if (values.BorderColorRight == null)
     {
         values.BorderColorRight = BaseColor.BLACK;
     }
     if (key.Contains("style"))
     {
         //          If any, which are the border styles in iText? simulate in the borderevent?
         if (values.BorderWidthRight == 0)
         {
             values.BorderWidthRight = 2.25f;
         }
     }
 }
Example #10
0
        public static HtmlCell GetHTMLTableControl(string rowIndex, string columnIndex)
        {
            var cell = new HtmlCell(browserWindow);

            try
            {
                cell.SearchProperties.Add(CSVReader.ControlType + ".PropertyNames." + CSVReader.LocatorType, CSVReader.LocatorValue);
                //give the required row and column number
                cell.FilterProperties[HtmlCell.PropertyNames.RowIndex]    = rowIndex;
                cell.FilterProperties[HtmlCell.PropertyNames.ColumnIndex] = columnIndex;
                cell.WaitForControlEnabled();
                cell.WaitForControlReady();
            }
            catch (Exception)
            {
                Assert.Fail("Failed to find " + CSVReader.ControlType + " (Table) Element - Element not Found");
            }
            var cellCollection = cell.FindMatchingControls();
            //cast the uitestcontrol to htmlcell
            var desiredcell = (HtmlCell)cellCollection[0];

            return(desiredcell);
        }
Example #11
0
        /// <summary>
        /// InvokeItemDetailsPage
        /// </summary>
        public void InvokeItemDetailsPage()
        {
            #region Variable Declarations
            HtmlHeaderCell uINameCell       = this.UIABCnetworksInventoryWindow.UIABCnetworksInventoryDocument2.UICtl00_ctl00_MainContTable.UINameCell;
            HtmlCell       uIXenonCell      = this.UIABCnetworksInventoryWindow.UIABCnetworksInventoryDocument2.UICtl00_ctl00_MainContTable1.UIXenonCell;
            HtmlHyperlink  uIXenonHyperlink = this.UIABCnetworksInventoryWindow.UIABCnetworksInventoryDocument2.UIXenonHyperlink;
            #endregion

            // Set flag to allow play back to continue if non-essential actions fail. (For example, if a mouse hover action fails.)
            Playback.PlaybackSettings.ContinueOnError = true;

            // Mouse hover 'Name' cell at (1, 1)
            Mouse.Hover(uINameCell, new Point(1, 1));

            // Mouse hover 'Xenon' cell at (1, 1)
            Mouse.Hover(uIXenonCell, new Point(1, 1));

            // Reset flag to ensure that play back stops if there is an error.
            Playback.PlaybackSettings.ContinueOnError = false;

            uIXenonHyperlink.SearchProperties.Add("InnerText", "Xenon", PropertyExpressionOperator.EqualTo);
            // Click 'Xenon' link
            Mouse.Click(uIXenonHyperlink, new Point(14, 12));
        }
Example #12
0
        /*
         * (non-Javadoc)
         *
         * @see
         * com.itextpdf.tool.xml.TagProcessor#endElement(com.itextpdf.tool.xml.Tag,
         * java.util.List, com.itextpdf.text.Document)
         */
        public override IList <IElement> End(IWorkerContext ctx, Tag tag, IList <IElement> currentContent)
        {
            HtmlCell cell = new HtmlCell();

            try {
                HtmlPipelineContext htmlPipelineContext = GetHtmlPipelineContext(ctx);
                cell = (HtmlCell)GetCssAppliers().Apply(cell, tag, htmlPipelineContext);
            } catch (NoCustomContextException e1) {
                throw new RuntimeWorkerException(LocaleMessages.GetInstance().GetMessage(LocaleMessages.NO_CUSTOM_CONTEXT), e1);
            }
            IList <IElement> l         = new List <IElement>(1);
            IList <IElement> chunks    = new List <IElement>();
            IList <ListItem> listItems = new List <ListItem>();
            int index = -1;

            foreach (IElement e in currentContent)
            {
                index++;
                if (e is Chunk || e is NoNewLineParagraph || e is LineSeparator)
                {
                    if (listItems.Count > 0)
                    {
                        ProcessListItems(ctx, tag, listItems, cell);
                    }
                    if (e is Chunk && Chunk.NEWLINE.Content.Equals(((Chunk)e).Content))
                    {
                        if (index == currentContent.Count - 1)
                        {
                            continue;
                        }
                        else
                        {
                            IElement nextElement = currentContent[index + 1];
                            if (chunks.Count > 0 && !(nextElement is Chunk) && !(nextElement is NoNewLineParagraph))
                            {
                                continue;
                            }
                        }
                    }
                    else if (e is LineSeparator)
                    {
                        try {
                            HtmlPipelineContext htmlPipelineContext = GetHtmlPipelineContext(ctx);
                            Chunk newLine = (Chunk)GetCssAppliers().Apply(new Chunk(Chunk.NEWLINE), tag, htmlPipelineContext);
                            chunks.Add(newLine);
                        } catch (NoCustomContextException exc) {
                            throw new RuntimeWorkerException(LocaleMessages.GetInstance().GetMessage(LocaleMessages.NO_CUSTOM_CONTEXT), exc);
                        }
                    }
                    chunks.Add(e);
                    continue;
                }
                else if (e is ListItem)
                {
                    if (chunks.Count > 0)
                    {
                        ProcessChunkItems(chunks, cell);
                    }
                    listItems.Add((ListItem)e);
                    continue;
                }
                else
                {
                    if (chunks.Count > 0)
                    {
                        ProcessChunkItems(chunks, cell);
                    }
                    if (listItems.Count > 0)
                    {
                        ProcessListItems(ctx, tag, listItems, cell);
                    }
                }

                if (e is Paragraph)
                {
                    ((Paragraph)e).Alignment = cell.HorizontalAlignment;
                }

                cell.AddElement(e);
            }
            if (chunks.Count > 0)
            {
                ProcessChunkItems(chunks, cell);
            }
            l.Add(cell);
            return(l);
        }
Example #13
0
        private void ProcessListItems(IWorkerContext ctx, Tag tag, IList <ListItem> listItems, HtmlCell cell)
        {
            try {
                List list = new List();
                list.Autoindent      = false;
                list                 = (List)GetCssAppliers().Apply(list, tag, GetHtmlPipelineContext(ctx));
                list.IndentationLeft = 0;
                foreach (ListItem li in listItems)
                {
                    ListItem listItem = (ListItem)GetCssAppliers().Apply(li, tag, GetHtmlPipelineContext(ctx));
                    listItem.SpacingAfter  = 0;
                    listItem.SpacingBefore = 0;

                    listItem.MultipliedLeading = 1.2f;
                    list.Add(listItem);
                }
                cell.AddElement(list);
                listItems.Clear();
            } catch (NoCustomContextException e) {
                throw new RuntimeWorkerException(LocaleMessages.GetInstance().GetMessage(LocaleMessages.NO_CUSTOM_CONTEXT), e);
            }
        }
 public HtmlCellControlPageModelWrapper(HtmlCell cell, Func <string, TValue> stringToValueFunc) : this(cell, stringToValueFunc, x => x.Value)
 {
 }
Example #15
0
        /*
         * (non-Javadoc)
         *
         * @see
         * com.itextpdf.tool.xml.TagProcessor#endElement(com.itextpdf.tool.xml.Tag,
         * java.util.List, com.itextpdf.text.Document)
         */
        public override IList <IElement> End(IWorkerContext ctx, Tag tag, IList <IElement> currentContent)
        {
            HtmlCell cell      = new HtmlCell();
            int      direction = GetRunDirection(tag);

            if (direction != PdfWriter.RUN_DIRECTION_DEFAULT)
            {
                cell.RunDirection = direction;
            }

            if (HTML.Tag.TH.Equals(tag.Name, StringComparison.OrdinalIgnoreCase))
            {
                cell.Role = PdfName.TH;
            }
            try {
                HtmlPipelineContext htmlPipelineContext = GetHtmlPipelineContext(ctx);
                cell = (HtmlCell)GetCssAppliers().Apply(cell, tag, htmlPipelineContext);
            } catch (NoCustomContextException e1) {
                throw new RuntimeWorkerException(LocaleMessages.GetInstance().GetMessage(LocaleMessages.NO_CUSTOM_CONTEXT), e1);
            }
            IList <IElement> l         = new List <IElement>(1);
            IList <IElement> chunks    = new List <IElement>();
            IList <ListItem> listItems = new List <ListItem>();
            int index = -1;

            foreach (IElement e in currentContent)
            {
                index++;
                if (e is Chunk || e is NoNewLineParagraph || e is LineSeparator)
                {
                    if (listItems.Count > 0)
                    {
                        ProcessListItems(ctx, tag, listItems, cell);
                    }
                    if (e is Chunk && Chunk.NEWLINE.Content.Equals(((Chunk)e).Content))
                    {
                        if (index == currentContent.Count - 1)
                        {
                            continue;
                        }
                        else
                        {
                            IElement nextElement = currentContent[index + 1];
                            if (chunks.Count > 0 && !(nextElement is Chunk) && !(nextElement is NoNewLineParagraph))
                            {
                                continue;
                            }
                        }
                    }
                    else if (e is LineSeparator)
                    {
                        try {
                            HtmlPipelineContext htmlPipelineContext = GetHtmlPipelineContext(ctx);
                            Chunk newLine = (Chunk)GetCssAppliers().Apply(new Chunk(Chunk.NEWLINE), tag, htmlPipelineContext);
                            chunks.Add(newLine);
                        } catch (NoCustomContextException exc) {
                            throw new RuntimeWorkerException(LocaleMessages.GetInstance().GetMessage(LocaleMessages.NO_CUSTOM_CONTEXT), exc);
                        }
                    }
                    chunks.Add(e);
                    continue;
                }
                else if (e is ListItem)
                {
                    if (chunks.Count > 0)
                    {
                        ProcessChunkItems(chunks, cell);
                    }
                    listItems.Add((ListItem)e);
                    continue;
                }
                else
                {
                    if (chunks.Count > 0)
                    {
                        ProcessChunkItems(chunks, cell);
                    }
                    if (listItems.Count > 0)
                    {
                        ProcessListItems(ctx, tag, listItems, cell);
                    }
                }

                if (e is Paragraph)
                {
                    if (((Paragraph)e).Alignment == Element.ALIGN_UNDEFINED)
                    {
                        ((Paragraph)e).Alignment = cell.HorizontalAlignment;
                    }
                }

                cell.AddElement(e);
            }
            if (chunks.Count > 0)
            {
                ProcessChunkItems(chunks, cell);
            }
            l.Add(cell);
            return(l);
        }
Example #16
0
        /*
         * (non-Javadoc)
         *
         * @see
         * com.itextpdf.tool.xml.TagProcessor#endElement(com.itextpdf.tool.xml.Tag,
         * java.util.List, com.itextpdf.text.Document)
         */
        public override IList <IElement> End(IWorkerContext ctx, Tag tag, IList <IElement> currentContent)
        {
            HtmlCell cell = new HtmlCell();

            try {
                HtmlPipelineContext htmlPipelineContext = GetHtmlPipelineContext(ctx);
                cell = new HtmlCellCssApplier().Apply(cell, tag, htmlPipelineContext, htmlPipelineContext);
            } catch (NoCustomContextException e1) {
                throw new RuntimeWorkerException(LocaleMessages.GetInstance().GetMessage(LocaleMessages.NO_CUSTOM_CONTEXT), e1);
            }
            IList <IElement> l      = new List <IElement>(1);
            IList <IElement> chunks = new List <IElement>();

            foreach (IElement e in currentContent)
            {
                if (e is Chunk || e is NoNewLineParagraph || e is LineSeparator)
                {
                    if (e == Chunk.NEWLINE)
                    {
                        int index = currentContent.IndexOf(e);
                        if (index == currentContent.Count - 1)
                        {
                            continue;
                        }
                        else
                        {
                            IElement nextElement = currentContent[index + 1];
                            if (nextElement is Paragraph)
                            {
                                continue;
                            }
                            if (chunks.Count == 0)
                            {
                                continue;
                            }
                        }
                    }
                    else if (e is LineSeparator)
                    {
                        chunks.Add(Chunk.NEWLINE);
                    }
                    chunks.Add(e);
                    continue;
                }
                else if (chunks.Count > 0)
                {
                    Paragraph p = new Paragraph();
                    p.MultipliedLeading = 1.2f;
                    p.AddAll(chunks);
                    p.Alignment = cell.HorizontalAlignment;
                    cell.AddElement(p);
                    chunks.Clear();
                }

                if (e is Paragraph)
                {
                    ((Paragraph)e).Alignment = cell.HorizontalAlignment;
                }

                cell.AddElement(e);
            }
            if (chunks.Count > 0)
            {
                Paragraph p = new Paragraph();
                p.MultipliedLeading = 1.2f;
                p.AddAll(chunks);
                p.Alignment = cell.HorizontalAlignment;
                cell.AddElement(p);
            }
            l.Add(cell);
            return(l);
        }
Example #17
0
 public static HtmlCell GetHTMLTableControl(string rowIndex, string columnIndex)
 {
     var cell = new HtmlCell(browserWindow);
     try
     {
         cell.SearchProperties.Add(CSVReader.ControlType + ".PropertyNames." + CSVReader.LocatorType, CSVReader.LocatorValue);
         //give the required row and column number
         cell.FilterProperties[HtmlCell.PropertyNames.RowIndex] = rowIndex;
         cell.FilterProperties[HtmlCell.PropertyNames.ColumnIndex] = columnIndex;
         cell.WaitForControlEnabled();
         cell.WaitForControlReady();
     }
     catch (Exception)
     {
         Assert.Fail("Failed to find " + CSVReader.ControlType + " (Table) Element - Element not Found");
     }
     var cellCollection = cell.FindMatchingControls();
     //cast the uitestcontrol to htmlcell
     var desiredcell = (HtmlCell)cellCollection[0];
     return desiredcell;
 }
Example #18
0
        public string GetCellText(int cellRowIndex, int cellColumnIndex)
        {
            HtmlCell cell = this.GetCellByIndex(cellRowIndex, cellColumnIndex);

            return(cell.InnerText);
        }
Example #19
0
 public void TdClick(string id)
 {
     HtmlCell Td = new HtmlCell(Doc);
     Td.SearchProperties[HtmlCell.PropertyNames.Id] = id;
     Mouse.Click(Td);
 }
 public HtmlCellControlPageModelWrapper(HtmlCell cell, Func <string, TValue> stringToValueFunc, Func <HtmlCell, string> cellToStringFunc) : base(cell, stringToValueFunc, cellToStringFunc)
 {
 }
 public static ITextValuedPageModel <string> AsPageModel(this HtmlCell cell)
 {
     // NOTE: do not return AsStringValuedPageModel since
     // the cell has a property specifically for the value text
     return(cell.AsPageModel(StandardFunctionProvider.StringReturnSelf));
 }
 public static ITextValuedPageModel <string> AsPageModel(this HtmlCell cell, Func <HtmlCell, string> cellToStringFunc)
 {
     return(cell.AsPageModel(StandardFunctionProvider.StringReturnSelf, cellToStringFunc));
 }
 public static ITextValuedPageModel <TValue> AsPageModel <TValue>(this HtmlCell cell, Func <string, TValue> stringToValueFunc)
 {
     return(new HtmlCellControlPageModelWrapper <TValue>(cell, stringToValueFunc));
 }
Example #24
0
 public void Handle(ReportCellProperty property, HtmlCell cell)
 {
 }
        /*
         * (non-Javadoc)
         *
         * @see
         * com.itextpdf.tool.xml.css.CssApplier#apply(com.itextpdf.text.Element,
         * com.itextpdf.tool.xml.Tag)
         */
        public HtmlCell Apply(HtmlCell cell, Tag t, IMarginMemory memory, IPageSizeContainable psc)
        {
            TableStyleValues values = new TableStyleValues();
            Tag table = t.Parent;
            Tag row   = t.Parent;

            while (row != null && !row.Name.Equals(HTML.Tag.TR))
            {
                row = row.Parent;
            }
            while (table != null && !table.Name.Equals(HTML.Tag.TABLE))
            {
                table = table.Parent;
            }
            String border;

            table.Attributes.TryGetValue(CSS.Property.BORDER, out border);
            if (border != null && !border.Equals("0"))
            {
                values.BorderColor = BaseColor.BLACK;
                values.BorderWidth = 0.75f;
            }
            IDictionary <String, String> css = t.CSS;
            String emptyCells;

            css.TryGetValue(CSS.Property.EMPTY_CELLS, out emptyCells);
            if (null != emptyCells && Util.EqualsIgnoreCase(CSS.Value.HIDE, emptyCells) && cell.CompositeElements == null)
            {
                cell.Border = Rectangle.NO_BORDER;
            }
            else
            {
                cell.VerticalAlignment = Element.ALIGN_MIDDLE; // Default css behavior. Implementation of "vertical-align" style further along.
                String vAlign = null;
                if (t.Attributes.ContainsKey(HTML.Attribute.VALIGN))
                {
                    vAlign = t.Attributes[HTML.Attribute.VALIGN];
                }
                else if (css.ContainsKey(HTML.Attribute.VALIGN))
                {
                    vAlign = css[HTML.Attribute.VALIGN];
                }
                else if (row != null)
                {
                    if (row.Attributes.ContainsKey(HTML.Attribute.VALIGN))
                    {
                        vAlign = row.Attributes[HTML.Attribute.VALIGN];
                    }
                    else if (row.CSS.ContainsKey(HTML.Attribute.VALIGN))
                    {
                        vAlign = row.CSS[HTML.Attribute.VALIGN];
                    }
                }
                if (vAlign != null)
                {
                    if (Util.EqualsIgnoreCase(CSS.Value.TOP, vAlign))
                    {
                        cell.VerticalAlignment = Element.ALIGN_TOP;
                    }
                    else if (Util.EqualsIgnoreCase(CSS.Value.BOTTOM, vAlign))
                    {
                        cell.VerticalAlignment = Element.ALIGN_BOTTOM;
                    }
                }

                String align = null;
                if (t.Attributes.ContainsKey(HTML.Attribute.ALIGN))
                {
                    align = t.Attributes[HTML.Attribute.ALIGN];
                }
                else if (css.ContainsKey(CSS.Property.TEXT_ALIGN))
                {
                    align = css[CSS.Property.TEXT_ALIGN];
                }

                if (align != null)
                {
                    if (Util.EqualsIgnoreCase(CSS.Value.CENTER, align))
                    {
                        cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    }
                    else if (Util.EqualsIgnoreCase(CSS.Value.RIGHT, align))
                    {
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                    }
                    else if (Util.EqualsIgnoreCase(CSS.Value.JUSTIFY, align))
                    {
                        cell.HorizontalAlignment = Element.ALIGN_JUSTIFIED;
                    }
                }

                if (t.Attributes.ContainsKey(HTML.Attribute.WIDTH) || css.ContainsKey(HTML.Attribute.WIDTH))
                {
                    cell.FixedWidth = new WidthCalculator().GetWidth(t, memory.GetRootTags(), psc.PageSize.Width);
                }

                HeightCalculator heightCalc = new HeightCalculator();
                float?           height     = heightCalc.GetHeight(t, psc.PageSize.Height);
                if (height == null && row != null)
                {
                    height = heightCalc.GetHeight(row, psc.PageSize.Height);
                }
                if (height != null)
                {
                    cell.MinimumHeight = height.Value;
                }

                String colspan;
                if (t.Attributes.TryGetValue(HTML.Attribute.COLSPAN, out colspan))
                {
                    cell.Colspan = int.Parse(colspan);
                }
                String rowspan;
                t.Attributes.TryGetValue(HTML.Attribute.ROWSPAN, out rowspan);
                if (null != rowspan)
                {
                    cell.Rowspan = int.Parse(rowspan);
                }
                foreach (KeyValuePair <String, String> entry in css)
                {
                    String key   = entry.Key;
                    String value = entry.Value;
                    cell.UseBorderPadding = true;
                    if (Util.EqualsIgnoreCase(key, CSS.Property.BACKGROUND_COLOR))
                    {
                        values.Background = HtmlUtilities.DecodeColor(value);
                    }
                    else if (Util.EqualsIgnoreCase(key, CSS.Property.VERTICAL_ALIGN))
                    {
                        if (Util.EqualsIgnoreCase(value, CSS.Value.TOP))
                        {
                            cell.VerticalAlignment = Element.ALIGN_TOP;
                            cell.PaddingTop        = cell.PaddingTop + 6;
                        }
                        else if (Util.EqualsIgnoreCase(value, CSS.Value.BOTTOM))
                        {
                            cell.VerticalAlignment = Element.ALIGN_BOTTOM;
                            cell.PaddingBottom     = cell.PaddingBottom + 6;
                        }
                    }
                    else if (key.Contains(CSS.Property.BORDER))
                    {
                        if (key.Contains(CSS.Value.TOP))
                        {
                            SetTopOfBorder(cell, key, value, values);
                        }
                        else if (key.Contains(CSS.Value.BOTTOM))
                        {
                            SetBottomOfBorder(cell, key, value, values);
                        }
                        else if (key.Contains(CSS.Value.LEFT))
                        {
                            SetLeftOfBorder(cell, key, value, values);
                        }
                        else if (key.Contains(CSS.Value.RIGHT))
                        {
                            SetRightOfBorder(cell, key, value, values);
                        }
                    }
                    else if (key.Contains(CSS.Property.CELLPADDING) || key.Contains(CSS.Property.PADDING))
                    {
                        if (key.Contains(CSS.Value.TOP))
                        {
                            cell.PaddingTop = cell.PaddingTop + utils.ParsePxInCmMmPcToPt(value);
                        }
                        else if (key.Contains(CSS.Value.BOTTOM))
                        {
                            cell.PaddingBottom = cell.PaddingBottom + utils.ParsePxInCmMmPcToPt(value);
                        }
                        else if (key.Contains(CSS.Value.LEFT))
                        {
                            cell.PaddingLeft = cell.PaddingLeft + utils.ParsePxInCmMmPcToPt(value);
                        }
                        else if (key.Contains(CSS.Value.RIGHT))
                        {
                            cell.PaddingRight = cell.PaddingRight + utils.ParsePxInCmMmPcToPt(value);
                        }
                    }
                    else if (key.Contains(CSS.Property.TEXT_ALIGN))
                    {
                        if (Util.EqualsIgnoreCase(value, CSS.Value.LEFT))
                        {
                            cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        }
                        else if (Util.EqualsIgnoreCase(value, CSS.Value.CENTER))
                        {
                            cell.HorizontalAlignment = Element.ALIGN_CENTER;
                        }
                        else if (Util.EqualsIgnoreCase(value, CSS.Value.RIGHT))
                        {
                            cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        }
                    }
                }
                float horSpacing = Table.GetBorderOrCellSpacing(true, table.CSS, table.Attributes);
                float verSpacing = Table.GetBorderOrCellSpacing(false, table.CSS, table.Attributes);
                values.HorBorderSpacing = horSpacing;
                values.VerBorderSpacing = verSpacing;
                cell.PaddingLeft        = cell.PaddingLeft + horSpacing + values.BorderWidthLeft;
                cell.PaddingRight       = cell.PaddingRight + values.BorderWidthRight;
                cell.PaddingTop         = cell.PaddingTop + verSpacing + values.BorderWidthTop;
                cell.PaddingBottom      = cell.PaddingBottom + values.BorderWidthBottom + 1;
            }
            cell.Border     = Rectangle.NO_BORDER;
            cell.CellEvent  = new CellSpacingEvent(values);
            cell.CellValues = values;
            return(cell);
        }
Example #26
0
        private UITestControl GetColumnInfo(string header, string fullName)
        {
            //1 Get Header Table
            HtmlCell headerTable= new HtmlCell(GetStudentsTable);
            headerTable.SearchProperties.Add(HtmlCell.PropertyNames.TagName, "TH");
            headerTable.SearchProperties.Add(HtmlCell.PropertyNames.InnerText, header, PropertyExpressionOperator.Contains);

            //2 Get Column Index Position
            int headerIndex = headerTable.ColumnIndex;

            //3 Get Row
            HtmlRow row = GetRow(fullName);

            //4 Match info
            return row.Cells[headerIndex];
        }
Example #27
0
        /**
         * Sets the default cell width and widest word of a cell.
         * <ul>
         * <li>cell width = {@link Table#getCellStartWidth(HtmlCell)} + the width of the widest line of text.</li>
         * <li>widest word = {@link Table#getCellStartWidth(HtmlCell)} + the widest word of the cell.</li>
         * </ul>
         * These 2 widths are used as the starting point when determining the width of the table in
         * @param cell HtmlCell of which the widths are needed.
         * @return float array containing the default cell width and the widest word.
         * <ul>
         * <li>float[0] = cell width.</li>
         * <li>float[1] = widest word.</li>
         * </ul>
         */
        private float[] SetCellWidthAndWidestWord(HtmlCell cell)
        {
            IList <float>    rulesWidth        = new List <float>();
            float            widestWordOfCell  = 0f;
            float            startWidth        = GetCellStartWidth(cell);
            float            cellWidth         = startWidth;
            IList <IElement> compositeElements = cell.CompositeElements;

            if (compositeElements != null)
            {
                foreach (IElement baseLevel in compositeElements)
                {
                    if (baseLevel is Phrase)
                    {
                        for (int i = 0; i < ((Phrase)baseLevel).Count; i++)
                        {
                            IElement inner = ((Phrase)baseLevel)[i];
                            if (inner is Chunk)
                            {
                                cellWidth += ((Chunk)inner).GetWidthPoint();
                                float widestWord = startWidth + new ChunkCssApplier().GetWidestWord((Chunk)inner);
                                if (widestWord > widestWordOfCell)
                                {
                                    widestWordOfCell = widestWord;
                                }
                            }
                        }
                        rulesWidth.Add(cellWidth);
                        cellWidth = startWidth;
                    }
                    else if (baseLevel is List)
                    {
                        foreach (IElement li in ((List)baseLevel).Items)
                        {
                            rulesWidth.Add(cellWidth);
                            cellWidth = startWidth + ((ListItem)li).IndentationLeft;
                            foreach (Chunk c in ((ListItem)li).Chunks)
                            {
                                cellWidth += c.GetWidthPoint();
                                float widestWord = new ChunkCssApplier().GetWidestWord(c);
                                if (startWidth + widestWord > widestWordOfCell)
                                {
                                    widestWordOfCell = startWidth + widestWord;
                                }
                            }
                        }
                        rulesWidth.Add(cellWidth);
                        cellWidth = startWidth;
                    }
                    else if (baseLevel is PdfPTable)
                    {
                        rulesWidth.Add(cellWidth);
                        cellWidth = startWidth + ((PdfPTable)baseLevel).TotalWidth;
                        foreach (PdfPRow innerRow in ((PdfPTable)baseLevel).Rows)
                        {
                            int size = innerRow.GetCells().Length;
                            TableBorderEvent evente      = (TableBorderEvent)((PdfPTable)baseLevel).TableEvent;
                            TableStyleValues values      = evente.TableStyleValues;
                            float            minRowWidth = values.BorderWidthLeft + (size + 1) * values.HorBorderSpacing + values.BorderWidthRight;
                            int celnr = 0;
                            foreach (PdfPCell innerCell in innerRow.GetCells())
                            {
                                celnr++;
                                if (innerCell != null)
                                {
                                    float innerWidestWordOfCell = SetCellWidthAndWidestWord(new HtmlCell(innerCell, celnr == size))[1];
                                    minRowWidth += innerWidestWordOfCell;
                                }
                            }
                            if (minRowWidth > widestWordOfCell)
                            {
                                widestWordOfCell = minRowWidth;
                            }
                        }
                        rulesWidth.Add(cellWidth);
                        cellWidth = startWidth;
                    }
                }
            }
            foreach (float width in rulesWidth)
            {
                if (width > cellWidth)
                {
                    cellWidth = width;
                }
            }
            return(new float[] { cellWidth, widestWordOfCell });
        }
Example #28
0
        public bool CellCheck(string expect)
        {
            HtmlCell hc = new HtmlCell(Doc);
            //except的内容必需是cell的全文字段
            hc.SearchProperties[HtmlCell.PropertyNames.InnerText] = expect;
            //hc.SearchProperties[HtmlCell.PropertyNames.InnerText].Contains(expect);

            if (hc.InnerText.Contains(expect))
            {
                return true;
            }
            else
            {
                return false;
            }
        }