/** * */ public CssAppliers() { chunk = new ChunkCssApplier(); paragraph = new ParagraphCssApplier(); nonewlineparagraph = new NoNewLineParagraphCssApplier(); htmlcell = new HtmlCellCssApplier(); list = new ListStyleTypeCssApplier(); lineseparator = new LineSeparatorCssApplier(); image = new ImageCssApplier(); }
/* * (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; }
virtual 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); }