@Test
public void testTblStyle_BasedOnNormal() throws Exception {
// A style basedOn Normal is honoured, provided it (not Normal) contributes the font size
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
wordMLPackage.getMainDocumentPart().setContents(
(Document)XmlUtils.unmarshalString(mdpXml_tblStyle) );
wordMLPackage.getMainDocumentPart().getStyleDefinitionsPart().setContents(
(Styles)XmlUtils.unmarshalString(styles_in_basedOn_Normal) );
// Use our style!
List<Object> xpathResults = wordMLPackage.getMainDocumentPart().getJAXBNodesViaXPath("//w:p", true);
PPr ppr = Context.getWmlObjectFactory().createPPr();
((P)xpathResults.get(0)).setPPr(ppr);
PStyle ps = Context.getWmlObjectFactory().createPPrBasePStyle();
ps.setVal("testStyle");
ppr.setPStyle(ps);
setSetting(wordMLPackage, OVERRIDE);
wordMLPackage.save(new File(System.getProperty("user.dir") + "/OUT_PStyleInTableTest.docx"));
ParagraphStylesInTableFix.process(wordMLPackage);
// // Revert style and save:
// ppr.setPStyle(ps); // doesn't work - wrong ref!
// wordMLPackage.save(new File(System.getProperty("user.dir") + "/OUT_PStyleInTableTest.docx"));
Style ours = null;
for (Style s : wordMLPackage.getMainDocumentPart().getStyleDefinitionsPart().getContents().getStyle()) {
if ("testStyle-TableGrid-BR".equals(s.getStyleId())) {
ours = s;
break;
}
}