String defaultParagraphStyleName = "Normal"; if (defaultParagraphStyle!=null) { defaultParagraphStyleName=defaultParagraphStyle.getName().getVal(); for (Style s : this.getJaxbElement().getStyle()) { if (!allowedStyleNames.contains(s.getName().getVal())) { if (stylesInUse.contains(s.getName().getVal())) {
styleName.setVal(name); style.setName(styleName);
if( s.getType().equals("paragraph") && s.getName()!=null && s.getName().getVal().equals("Default") ) { log.debug("Style with name " + s.getName().getVal() + ", id '" + s.getStyleId() + "' is default " + s.getType() + " style"); defaultParagraphStyle=s; break; if( s.getType().equals("paragraph") && s.getStyleId().equals("style0") ) { log.debug("Style with name " + s.getName().getVal() + ", id '" + s.getStyleId() + "' is default " + s.getType() + " style"); defaultParagraphStyle=s; break;
defaultPStyleName=sdp.getDefaultParagraphStyle().getName().getVal(); defaultPStyleId = sdp.getDefaultParagraphStyle().getStyleId(); if (s.getName().getVal().startsWith("toc") || s.getName().getVal().equals(defaultPStyleName) || s.getName().getVal().equals(TOC_HEADING) || s.getName().getVal().equals(HEADING_1) // in order to create a TOC Heading, if necessary ) { styleNameToID.put(s.getName().getVal(), s.getStyleId());
/** * If one parameter is passed then search style by id (1st parameter), * if style by id is not found then search style by name (also 1st parameter). * <br>If two - then search by id (1st parameter) and if style by id is not found then search style by name (2nd parameter). * <br>Other parameters are ignored. */ protected Style getStyleByIdOrName(String... parameters) { String id = parameters[0]; String name = parameters.length > 1 ? parameters[1] : id; Style s = null; // Our XHTML export gives a space separated list of class names, // reflecting the style hierarchy. Here, we just want the first one. int pos = id.indexOf(" "); if (pos > -1) { id = id.substring(0, pos); } // try Id s = this.stylesByID.get(id); if(s == null) { // try name, which can have spaces for(Style style: this.stylesByID.values()) { if(style.getName() != null && style.getName().getVal().equals(name)) { s = style; break; } } } return s; }
/** * Refresh the style name - ID bimaps, based on styles currently defined in this part. * @since 3.3.0 */ public void refreshNameIdBiMaps() { styleIdToName= HashBiMap.create(); for (Style s : this.getJaxbElement().getStyle()) { if (s.getName()==null || s.getName().getVal()==null) { log.info("style has no name!"); } else if (s.getStyleId()==null || s.getStyleId().trim().length()==0) { log.info("style has no id!"); } else { styleIdToName.put(s.getStyleId(), s.getName().getVal()); } } styleNameToId = styleIdToName.inverse(); }
private Style getDefaultStyle(String type) { for ( org.docx4j.wml.Style s : this.getJaxbElement().getStyle() ) { if( s.isDefault() && s.getType().equals(type)) { log.debug("Style with name " + s.getName().getVal() + ", id '" + s.getStyleId() + "' is default " + s.getType() + " style"); return s; } } return null; }
/** * Create an instance of {@link org.docx4j.wml.Style.Name } * */ public org.docx4j.wml.Style.Name createStyleName() { return new org.docx4j.wml.Style.Name(); }
/** * This method is invoked by the JAXB implementation on each instance when unmarshalling completes. * * @param parent * The parent object in the object tree. * @param unmarshaller * The unmarshaller that generated the instance. */ public void afterUnmarshal(Unmarshaller unmarshaller, Object parent) { setParent(parent); }
private void initializeStyleNames(WordprocessingMLPackage out) { final StyleDefinitionsPart styleDefinitionsPart = out.getMainDocumentPart().getStyleDefinitionsPart(); try { final Styles contents = styleDefinitionsPart.getContents(); final List<Style> styles = contents.getStyle(); for (Style style : styles) { final String styleId = style.getStyleId(); final String styleName = style.getName().getVal(); styleIdToStyleName.put(styleId, styleName); nameToStyleStyleId.put(styleName, styleId); } } catch (Docx4JException e) { e.printStackTrace(); } } }
String defaultParagraphStyleName = "Normal"; if (defaultParagraphStyle!=null) { defaultParagraphStyleName=defaultParagraphStyle.getName().getVal(); for (Style s : this.getJaxbElement().getStyle()) { if (!allowedStyleNames.contains(s.getName().getVal())) { if (stylesInUse.contains(s.getName().getVal())) {
styleName.setVal(name); style.setName(styleName);
if( s.getType().equals("paragraph") && s.getName()!=null && s.getName().getVal().equals("Default") ) { log.debug("Style with name " + s.getName().getVal() + ", id '" + s.getStyleId() + "' is default " + s.getType() + " style"); defaultParagraphStyle=s; break; if( s.getType().equals("paragraph") && s.getStyleId().equals("style0") ) { log.debug("Style with name " + s.getName().getVal() + ", id '" + s.getStyleId() + "' is default " + s.getType() + " style"); defaultParagraphStyle=s; break;