@Deprecated public List<Object> getEGContentCellContent() { return getContent(); }
if (tr.getContent() != null) { for (Object elemCe:tr.getContent()) { if (elemCe instanceof JAXBElement) { elemCe = ((JAXBElement)elemCe).getValue();
@Deprecated public List<Object> getEGContentCellContent() { return getContent(); }
myTr.getContent().add(tcWrapped);
private void walkTableRow(Tr row) { onTableRow(row); for (Object rowContentElement : row.getContent()) { if (XmlUtils.unwrap(rowContentElement) instanceof Tc) { Tc cell = rowContentElement instanceof Tc ? (Tc) rowContentElement : (Tc) ((JAXBElement) rowContentElement).getValue(); walkTableCell(cell); } } }
public void fillWordTableRow(List<String> stringData, org.docx4j.wml.ObjectFactory factory, Tr tableRow) { int columnNumber = 0; for (String s : stringData) { Tc column = (Tc) tableRow.getContent().get(columnNumber++); P columnParagraph = (P) column.getContent().get(0); Text text = factory.createText(); text.setValue(s); R run = factory.createR(); run.getContent().add(text); columnParagraph.getContent().add(run); } }
if (tr.getContent() != null) { for (Object elemCe:tr.getContent()) { if (elemCe instanceof JAXBElement) { elemCe = ((JAXBElement)elemCe).getValue();
private void walkTableRow(TableRowCoordinates rowCoordinates) { onTableRow(rowCoordinates); int cellIndex = 0; for (Object rowContentElement : rowCoordinates.getRow().getContent()) { if (XmlUtils.unwrap(rowContentElement) instanceof Tc) { Tc cell = rowContentElement instanceof Tc ? (Tc) rowContentElement : (Tc) ((JAXBElement) rowContentElement).getValue(); TableCellCoordinates cellCoordinates = new TableCellCoordinates(cell, cellIndex, rowCoordinates); walkTableCell(cellCoordinates); } cellIndex++; } }
tableRow.getContent().add(tableCell); table.getContent().add(tableRow);
private void resolvedExpressionsAreReplacedInNestedTable(WordprocessingMLPackage document) { Tbl table = (Tbl) ((JAXBElement) document.getMainDocumentPart().getContent().get(1)).getValue(); Tr row = (Tr) table.getContent().get(2); Tc cell = (Tc) ((JAXBElement) row.getContent().get(0)).getValue(); Tbl nestedTable = (Tbl) ((JAXBElement) cell.getContent().get(1)).getValue(); Tr nestedRow = (Tr) nestedTable.getContent().get(0); Tc nestedCell = (Tc) ((JAXBElement) nestedRow.getContent().get(1)).getValue(); P nameParagraph = (P) nestedCell.getContent().get(0); Assert.assertEquals("Bart Simpson", new ParagraphWrapper(nameParagraph).getText()); }
private void unresolvedExpressionsAreNotReplacedInNestedTable(WordprocessingMLPackage document) { Tbl table = (Tbl) ((JAXBElement) document.getMainDocumentPart().getContent().get(1)).getValue(); Tr row = (Tr) table.getContent().get(2); Tc cell = (Tc) ((JAXBElement) row.getContent().get(0)).getValue(); Tbl nestedTable = (Tbl) ((JAXBElement) cell.getContent().get(1)).getValue(); Tr nestedRow = (Tr) nestedTable.getContent().get(1); Tc nestedCell = (Tc) ((JAXBElement) nestedRow.getContent().get(1)).getValue(); P nameParagraph = (P) nestedCell.getContent().get(0); Assert.assertEquals("${foo}", new ParagraphWrapper(nameParagraph).getText()); }
Tc column = (Tc) headerRow.getContent().get(f); P columnPara = (P) column.getContent().get(0); f++; int d = 0; for (String key : entry.keySet()) { Tc column = (Tc) row.getContent().get(d); P columnPara = (P) column.getContent().get(0); d++;
private void paragraphsInTableAreRemoved(WordprocessingMLPackage document) { Tbl table = (Tbl) ((JAXBElement) document.getMainDocumentPart().getContent().get(3)).getValue(); Tr row = (Tr) table.getContent().get(1); P p1 = (P) ((Tc) ((JAXBElement) row.getContent().get(0)).getValue()).getContent().get(0); P p2 = (P) ((Tc) ((JAXBElement) row.getContent().get(1)).getValue()).getContent().get(0); Assert.assertEquals("This paragraph stays untouched.", new ParagraphWrapper(p1).getText()); // since the last paragraph was removed from the cell, an empty paragraph was inserted Assert.assertEquals("", new ParagraphWrapper(p2).getText()); }
private void nestedTablesAreRemoved(WordprocessingMLPackage document) { Tbl outerTable = (Tbl) ((JAXBElement) document.getMainDocumentPart().getContent().get(3)).getValue(); Tc cell = (Tc) ((JAXBElement) ((Tr) outerTable.getContent().get(1)).getContent().get(1)).getValue(); Assert.assertEquals("", new ParagraphWrapper((P) cell.getContent().get(0)).getText()); // empty paragraph, since the last element inside the cell was removed }
private void resolvedExpressionsAreReplacedInFirstLevelTable(WordprocessingMLPackage document) { Tbl table = (Tbl) ((JAXBElement) document.getMainDocumentPart().getContent().get(1)).getValue(); Tr row = (Tr) table.getContent().get(0); Tc cell = (Tc) ((JAXBElement) row.getContent().get(1)).getValue(); P nameParagraph = (P) cell.getContent().get(0); Assert.assertEquals("Bart Simpson", new ParagraphWrapper(nameParagraph).getText()); }
private void unresolvedExpressionsAreNotReplacedInFirstLevelTable(WordprocessingMLPackage document) { Tbl table = (Tbl) ((JAXBElement) document.getMainDocumentPart().getContent().get(1)).getValue(); Tr row = (Tr) table.getContent().get(1); Tc cell = (Tc) ((JAXBElement) row.getContent().get(1)).getValue(); P nameParagraph = (P) cell.getContent().get(0); Assert.assertEquals("${foo}", new ParagraphWrapper(nameParagraph).getText()); }
private void paragraphsInNestedTablesAreRemoved(WordprocessingMLPackage document) { final List<Tbl> tables = new ArrayList<>(); CoordinatesWalker walker = new BaseCoordinatesWalker(document) { @Override protected void onTable(TableCoordinates tableCoordinates) { tables.add(tableCoordinates.getTable()); } }; walker.walk(); Tbl nestedTable = tables.get(1); Tc cell = (Tc) ((JAXBElement) ((Tr) nestedTable.getContent().get(1)).getContent().get(0)).getValue(); P p1 = (P) cell.getContent().get(0); Assert.assertEquals(1, cell.getContent().size()); Assert.assertEquals("This paragraph stays untouched.", new ParagraphWrapper(p1).getText()); }