| 70 | | walkJAXBElements(bodyChildren); |
| 71 | | |
| 72 | | // // Change something |
| 73 | | // org.docx4j.wml.P p = (org.docx4j.wml.P)((JAXBElement)bodyChildren.get(2)).getValue(); |
| 74 | | org.docx4j.wml.P p = (org.docx4j.wml.P)bodyChildren.get(2); |
| 75 | | |
| 76 | | //walkList(p.getParagraphContent()); |
| 77 | | |
| 78 | | org.docx4j.wml.PPr pPr = p.getPPr(); |
| 79 | | |
| 80 | | if (pPr!=null && pPr.getPStyle()!=null) { |
| 81 | | System.out.println( "Style: " + pPr.getPStyle().getVal() ); |
| 82 | | } |
| 83 | | |
| 84 | | org.docx4j.wml.ObjectFactory factory = new org.docx4j.wml.ObjectFactory(); |
| 85 | | org.docx4j.wml.R run = factory.createR(); |
| 86 | | org.docx4j.wml.Text t = factory.createText(); |
| 87 | | |
| 88 | | |
| 89 | | t.setValue("SOMETHING NEW, with added JAXB convenience!"); |
| 90 | | |
| 91 | | run.getRunContent().add(t); |
| 92 | | |
| 93 | | org.docx4j.wml.RPr runProps = factory.createRPr(); |
| 94 | | |
| 95 | | run.setRPr( runProps); |
| 96 | | |
| 97 | | org.docx4j.wml.BooleanDefaultTrue val = factory.createBooleanDefaultTrue(); |
| 98 | | val.setVal(Boolean.valueOf(true)); |
| 99 | | runProps.setB( val ); |
| 100 | | |
| 101 | | // or relying on the default value, could just do: |
| 102 | | // runProps.setB( factory.createBooleanDefaultTrue() ); |
| 103 | | |
| 104 | | p.getParagraphContent().add(run); |
| 105 | | |
| 106 | | // System.out.println( "/n/n What does that look like? /n/n"); |
| 107 | | // walkList(p.getParagraphContent()); |
| | 70 | walkJAXBElements(bodyChildren); |
| | 154 | |
| | 155 | static void describeTable( org.docx4j.wml.Tbl tbl ) { |
| | 156 | |
| | 157 | // What does a table look like? |
| | 158 | boolean suppressDeclaration = false; |
| | 159 | boolean prettyprint = true; |
| | 160 | System.out.println( org.docx4j.XmlUtils.marshaltoString(tbl, suppressDeclaration, prettyprint) ); |
| | 161 | |
| | 162 | // Could get the TblPr if we wanted them |
| | 163 | org.docx4j.wml.TblPr tblPr = tbl.getTblPr(); |
| | 164 | |
| | 165 | // Could get the TblGrid if we wanted it |
| | 166 | org.docx4j.wml.TblGrid tblGrid = tbl.getTblGrid(); |
| | 167 | |
| | 168 | // But here, let's look at the table contents |
| | 169 | for (Object o : tbl.getEGContentRowContent() ) { |
| | 170 | |
| | 171 | if (o instanceof org.docx4j.wml.Tr) { |
| | 172 | |
| | 173 | org.docx4j.wml.Tr tr = (org.docx4j.wml.Tr)o; |
| | 174 | |
| | 175 | for (Object o2 : tr.getEGContentCellContent() ) { |
| | 176 | |
| | 177 | System.out.println(" " + o2.getClass().getName() ); |
| | 178 | if ( o2 instanceof javax.xml.bind.JAXBElement) { |
| | 179 | |
| | 180 | if ( ((JAXBElement)o2).getDeclaredType().getName().equals("org.docx4j.wml.Tc") ) { |
| | 181 | org.docx4j.wml.Tc tc = (org.docx4j.wml.Tc)((JAXBElement)o2).getValue(); |
| | 182 | |
| | 183 | // Look at the paragraphs in the tc |
| | 184 | walkJAXBElements( tc.getEGBlockLevelElts() ); |
| | 185 | |
| | 186 | } else { |
| | 187 | // What is it, if it isn't a Tc? |
| | 188 | System.out.println(" " + ((JAXBElement)o).getName() ); |
| | 189 | System.out.println(" " + ((JAXBElement)o).getDeclaredType().getName()); |
| | 190 | } |
| | 191 | } else { |
| | 192 | System.out.println(" " + o.getClass().getName() ); |
| | 193 | } |
| | 194 | |
| | 195 | } |
| | 196 | |
| | 197 | |
| | 198 | } else { |
| | 199 | System.out.println(" " + o.getClass().getName() ); |
| | 200 | } |
| | 201 | |
| | 202 | } |
| | 203 | |
| | 204 | |
| | 205 | |
| | 206 | } |