public boolean activateStyle(org.docx4j.wml.Style s) { return activateStyle(s, true); }
public boolean activateStyle( String styleId ) { if (liveStyles.get(styleId)!=null) { // Its already live - nothing to do return true; } // Assumption here is that it doesn't exist in your styles part, so.. java.util.Map<String, org.docx4j.wml.Style> knownStyles = StyleDefinitionsPart.getKnownStyles(); // NB KnownStyles.xml, not those in docx! org.docx4j.wml.Style s = knownStyles.get(styleId); if (s==null) { log.error("Unknown style: " + styleId); return false; } return activateStyle(s, false); // false -> don't replace an existing live style with a template }
/** * Enable the hyperlinkStyle in the docx. * * @param wordMLPackage * @param hyperlinkStyleId */ public void activateHyperlinkStyle(WordprocessingMLPackage wordMLPackage) { if (hyperlinkStyleId !=null) { wordMLPackage.getMainDocumentPart().getPropertyResolver().activateStyle(getHyperlinkStyleId()); } }
log.debug("Inspecting style: " + styleName ); if (getPropertyResolver().activateStyle(styleName)) {
if (s.getBasedOn()!=null) { String basedOn = s.getBasedOn().getVal(); result1 = activateStyle( basedOn ); result2 = activateStyle(link.getVal());
/** * Create a paragraph containing the string simpleText, styled * using the specified style (up to user to ensure it is a paragraph style) * without adding it to the document. * * @param styleId * @param text * @return */ public org.docx4j.wml.P createStyledParagraphOfText(String styleId, String text) { org.docx4j.wml.P p = createParagraphOfText(text); if (getPropertyResolver().activateStyle(styleId)) { // Style is available org.docx4j.wml.ObjectFactory factory = Context.getWmlObjectFactory(); org.docx4j.wml.PPr pPr = factory.createPPr(); p.setPPr(pPr); org.docx4j.wml.PPrBase.PStyle pStyle = factory.createPPrBasePStyle(); pPr.setPStyle(pStyle); pStyle.setVal(styleId); } return p; }
propertyResolver.activateStyle(newStyle);
public boolean activateStyle(org.docx4j.wml.Style s) { return activateStyle(s, true); }
public boolean activateStyle( String styleId ) { if (liveStyles.get(styleId)!=null) { // Its already live - nothing to do return true; } // Assumption here is that it doesn't exist in your styles part, so.. java.util.Map<String, org.docx4j.wml.Style> knownStyles = StyleDefinitionsPart.getKnownStyles(); // NB KnownStyles.xml, not those in docx! org.docx4j.wml.Style s = knownStyles.get(styleId); if (s==null) { log.error("Unknown style: " + styleId); return false; } return activateStyle(s, false); // false -> don't replace an existing live style with a template }
/** * Enable the hyperlinkStyle in the docx. * * @param wordMLPackage * @param hyperlinkStyleId */ public void activateHyperlinkStyle(WordprocessingMLPackage wordMLPackage) { if (hyperlinkStyleId !=null) { wordMLPackage.getMainDocumentPart().getPropertyResolver().activateStyle(getHyperlinkStyleId()); } }
log.debug("Inspecting style: " + styleName ); if (getPropertyResolver().activateStyle(styleName)) {
if (s.getBasedOn()!=null) { String basedOn = s.getBasedOn().getVal(); result1 = activateStyle( basedOn ); result2 = activateStyle(link.getVal());
/** * Create a paragraph containing the string simpleText, styled * using the specified style (up to user to ensure it is a paragraph style) * without adding it to the document. * * @param styleId * @param text * @return */ public org.docx4j.wml.P createStyledParagraphOfText(String styleId, String text) { org.docx4j.wml.P p = createParagraphOfText(text); if (getPropertyResolver().activateStyle(styleId)) { // Style is available org.docx4j.wml.ObjectFactory factory = Context.getWmlObjectFactory(); org.docx4j.wml.PPr pPr = factory.createPPr(); p.setPPr(pPr); org.docx4j.wml.PPrBase.PStyle pStyle = factory.createPPrBasePStyle(); pPr.setPStyle(pStyle); pStyle.setVal(styleId); } return p; }
propertyResolver.activateStyle(newStyle);
((WordprocessingMLPackage)wordMLPackage).getMainDocumentPart().getPropertyResolver().activateStyle(hyperlinkStyleId);