protected DRDesignStyle transformStyle( DRIReportStyle style, boolean textStyle, DefaultStyleType defaultStyleType) throws DRException { if (style == null) { return getDefaultStyle(defaultStyleType); } String styleName = style.hashCode() + "_" + textStyle; if (designStyles.containsKey(styleName)) { return designStyles.get(styleName); } DRDesignStyle designStyle = style(getStyle(style), textStyle, defaultStyleType); if (textStyle) { if (StyleResolver.getFontName(designStyle) == null) { designStyle.getFont().setFontName(accessor.getTemplateTransform().getDefaultFontName()); } if (StyleResolver.getFontSize(designStyle) == null) { designStyle.getFont().setFontSize(accessor.getTemplateTransform().getDefaultFontSize()); } if (StyleResolver.getFontBold(designStyle) == null) { designStyle.getFont().setBold(accessor.getTemplateTransform().getDefaultFontBold()); } if (StyleResolver.getFontItalic(designStyle) == null) { designStyle.getFont().setItalic(accessor.getTemplateTransform().getDefaultFontItalic()); } if (StyleResolver.getFontUnderline(designStyle) == null) { designStyle .getFont() .setUnderline(accessor.getTemplateTransform().getDefaultFontUnderline()); } if (StyleResolver.getFontStrikeThrough(designStyle) == null) { designStyle .getFont() .setStrikeThrough(accessor.getTemplateTransform().getDefaultFontStrikeThrough()); } if (StyleResolver.getPdfFontName(designStyle) == null) { designStyle .getFont() .setPdfFontName(accessor.getTemplateTransform().getDefaultFontPdfFontName()); } if (StyleResolver.getPdfEncoding(designStyle) == null) { designStyle .getFont() .setPdfEncoding(accessor.getTemplateTransform().getDefaultFontPdfEncoding()); } if (StyleResolver.getPdfEmbedded(designStyle) == null) { designStyle .getFont() .setPdfEmbedded(accessor.getTemplateTransform().getDefaultFontPdfEmbedded()); } } addStyle(styleName, designStyle); return designStyle; }
private void addStyle(String styleName, DRDesignStyle designStyle) { if (designStyle == null) { return; } if (styles.containsKey(designStyle.getName())) { if (!styles.get(designStyle.getName()).equals(designStyle)) { throw new DRDesignReportException( "Duplicate declaration of style \"" + designStyle.getName() + "\""); } return; } styles.put(designStyle.getName(), designStyle); designStyles.put(styleName, designStyle); }
private DRDesignStyle style(DRIStyle style, boolean textStyle, DefaultStyleType defaultStyleType) throws DRException { final DRDesignStyle designStyle; if (StringUtils.isBlank(style.getName())) { designStyle = new DRDesignStyle(); } else { designStyle = new DRDesignStyle(style.getName()); } baseStyle(designStyle, style); if (style.getParentStyle() != null) { designStyle.setParentStyle( transformStyle(style.getParentStyle(), textStyle, defaultStyleType)); } for (DRIConditionalStyle conditionalStyle : style.getConditionalStyles()) { designStyle.addConditionalStyle(conditionalStyle(conditionalStyle)); } return designStyle; }