/*** * This is for situation where you pass the Paragraph so template can't have one * */ private void processMiddleForParagraph(StringBuilder th, ITableItemStrategy item, Paragraph... cols) { String templateWithoutParagraph = " <w:tc> " +"\n <w:tcPr> " +"\n <w:tcW w:w=\"4258\" w:type=\"dxa\"/> " +"\n </w:tcPr> " +"\n {value} " +"\n </w:tc> " ; for (int i = 0; i < cols.length; i++) { if(cols[i] != null && cols[i].getContent() != ""){ th.append("\n" + templateWithoutParagraph.replace("{value}", cols[i].getContent())); } else { //th.append("\n" + this.getMyMiddle().replace("{value}", "")); th.append("\n" + item.getMiddle().replace("{value}", Paragraph.with("").create().getContent() )); } } }
/*** * This is for situation where you pass the Paragraph so template can't have one * */ private void processMiddleForParagraph(StringBuilder th, ITableItemStrategy item, Paragraph... cols) { String templateWithoutParagraph = " <w:tc> " +"\n <w:tcPr> " +"\n <w:tcW w:w=\"4258\" w:type=\"dxa\"/> " +"\n </w:tcPr> " +"\n {value} " +"\n </w:tc> " ; for (int i = 0; i < cols.length; i++) { if(cols[i] != null && cols[i].getContent() != ""){ th.append("\n" + templateWithoutParagraph.replace("{value}", cols[i].getContent())); } else { //th.append("\n" + this.getMyMiddle().replace("{value}", "")); th.append("\n" + item.getMiddle().replace("{value}", Paragraph.with("").create().getContent() )); } } }
txt.append("<w:p><w:r></w:r></w:p>");//Empty Paragraph }else{ txt.append(Paragraph.with(cellValue).create().getContent());
txt.append("<w:p><w:r></w:r></w:p>");//Empty Paragraph }else{ txt.append(Paragraph.with(cellValue).create().getContent());
@Test public void testPiecesMany() { ParagraphPiece piece01 = ParagraphPiece.with("Piece11111"); ParagraphPiece piece02 = ParagraphPiece.with("Piece22222").withStyle().bold().italic().create(); Paragraph p01 = Paragraph.withPieces(piece01, piece02); assertEquals(1, TestUtils.regexCount(p01.getContent(), "<w:t>Piece11111</w:t>")); assertEquals(1, TestUtils.regexCount(p01.getContent(), "<w:t>Piece22222</w:t>")); assertEquals(1, TestUtils.regexCount(p01.getContent(), "<w:p wsp:rsidR=")); assertEquals(4, TestUtils.regexCount(p01.getContent(), "<*w:r>")); assertEquals(1, TestUtils.regexCount(p01.getContent(), "</w:p>")); assertEquals(1, TestUtils.regexCount(p01.getContent(), "<w:b/>")); assertEquals(1, TestUtils.regexCount(p01.getContent(), "<w:i/>")); }
@Test public void testTab(){ Paragraph p01 = Paragraph.withPieces( ParagraphPiece.with("Bloc 1 Price :").withStyle().font(Font.CALIBRI).fontSize(Integer.toString(2*11)).create(), ParagraphPiece.with(" \t 3 200,00 $").withStyle().font(Font.CALIBRI).fontSize(Integer.toString(2*11)).create() ).addTab(TabAlign.RIGHT, 8931).create(); assertEquals(2, TestUtils.regexCount(p01.getContent(), "<w:pPr>")); assertEquals(1, TestUtils.regexCount(p01.getContent(), "<w:tabs>")); assertEquals(1, TestUtils.regexCount(p01.getContent(), "</w:tabs>")); assertEquals(2, TestUtils.regexCount(p01.getContent(), "</w:pPr>")); }
@Test public void testPiecesOneWithStyle() { ParagraphPiece piece01 = ParagraphPiece.with("Piece01").withStyle().bold().italic().underline().create(); Paragraph p01 = new Paragraph(piece01); assertEquals(1, TestUtils.regexCount(p01.getContent(), "<w:b/>")); //bold assertEquals(1, TestUtils.regexCount(p01.getContent(), "<w:i/>")); //italic assertEquals(1, TestUtils.regexCount(p01.getContent(), "<w:u w:val=\"single\"/>")); //underline basicParagraphCheckings(p01, "Piece01", null); }
@Test public void testEmptyPiecesEtc() { ParagraphPiece piece01 = ParagraphPiece.with(""); ParagraphPiece piece02 = ParagraphPiece.with(""); Paragraph p01 = new Paragraph(piece01, piece02); assertEquals("", p01.getContent()); }
@Test public void testBidiNoValue(){ ParagraphPiece pieces = ParagraphPiece.with("111"); Paragraph p01 = Paragraph.withPieces(pieces); basicParagraphCheckings(p01, "111", null); assertEquals(0, TestUtils.regexCount(p01.getContent(), "<w:lang w:bidi=\".*\" />")); }
Paragraph p04 = Paragraph.with("4) Hope for the best").create(); String instructions = p01.getContent() + p02.getContent() + p03.getContent() + p04.getContent();
@Test public void testParagraphIndentStyle() { Paragraph p01 = (Paragraph) Paragraph.with("111").withStyle().indent(ParagraphStyle.Indent.ONE).create(); assertEquals(1, TestUtils.regexCount(p01.getContent(), "w:left=\"540\"")); }
@Test public void testBidi(){ ParagraphPiece pieces = ParagraphPiece.with("111"); Paragraph p01 = (Paragraph) Paragraph.withPieces(pieces).withStyle().bidi("HE").create(); basicParagraphCheckings(p01, "111", null); assertEquals(1, TestUtils.regexCount(p01.getContent(), "<w:lang w:bidi=\"HE\" />")); }