From dfb5cc106d0084efed7a93a014421e1244a2366e Mon Sep 17 00:00:00 2001 From: Thomas Gutmann <41593722+speckyspooky@users.noreply.github.com> Date: Tue, 6 Aug 2024 21:00:15 +0200 Subject: [PATCH] Enhance java documentation and remove java warnings of HTML2PDF layout (#1840) --- .../engine/api/script/IReportContext.java | 96 ++++++++---- .../engine/layout/pdf/util/BulletFrame.java | 76 ++++++++- .../engine/layout/pdf/util/HTML2Content.java | 26 ++-- .../engine/layout/pdf/util/HTMLConstants.java | 144 ++++++++++++++++++ .../layout/pdf/util/HTMLStyleProcessor.java | 19 +-- .../layout/pdf/util/PropertiesProcessor.java | 70 ++++++--- .../layout/pdf/util/ShortHandProcessor.java | 44 ++++-- .../layout/pdf/util/StyleProperties.java | 55 ++++++- .../engine/layout/pdf/util/Tag2Style.java | 88 +++++++---- 9 files changed, 495 insertions(+), 123 deletions(-) diff --git a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/api/script/IReportContext.java b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/api/script/IReportContext.java index ec2dae8ff79..aaf70068ed8 100644 --- a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/api/script/IReportContext.java +++ b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/api/script/IReportContext.java @@ -34,33 +34,37 @@ * properties. */ public interface IReportContext { + /** property: page label */ String PAGE_VAR_PAGE_LABEL = "pageLabel"; /** * return the report runnable used to create/render this report * - * @return + * @return the report runnable used to create/render this report */ IReportRunnable getReportRunnable(); /** + * Get the parameter value * - * @param name - * @return + * @param name parameter name + * @return the parameter value */ Object getParameterValue(String name); /** + * Set the parameter value * - * @param name - * @param value + * @param name parameter name + * @param value object value */ void setParameterValue(String name, Object value); /** + * Get the display text * - * @param name - * @return + * @param name parameter name + * @return the display text */ Object getParameterDisplayText(String name); @@ -72,38 +76,44 @@ public interface IReportContext { void setParameterDisplayText(String name, String value); /** + * Get the locale * - * @return + * @return the locale */ Locale getLocale(); /** - * Get time zone informations. + * Get the time zone informations * - * @return + * @return the time zone informations */ TimeZone getTimeZone(); /** + * Get the output format * - * @return + * @return the output format */ String getOutputFormat(); /** - * get the render options used to render the report. + * Get the render options used to render the report. * - * @return + * @return the render options used to render the report. */ IRenderOption getRenderOption(); /** * Get the application context + * + * @return the application context */ Map getAppContext(); /** - * Get the http servlet request object + * Get the HTTP servlet request object + * + * @return the HTTP servlet request object * */ Object getHttpServletRequest(); @@ -111,37 +121,65 @@ public interface IReportContext { /** * Add the object to runtime scope. This object can only be retrieved in the * same phase, i.e. it is not persisted between generation and presentation. + * + * @param name name of the global variable + * @param obj object value */ void setGlobalVariable(String name, Object obj); /** * Remove an object from runtime scope. + * + * @param name variable name */ void deleteGlobalVariable(String name); /** - * Retireve an object from runtime scope. + * Get the value of the global variable + * + * @param name variable name + * @return the value of the global variable */ Object getGlobalVariable(String name); /** * Add the object to report document scope. This object can be retrieved later. * It is persisted between phases, i.e. between generation and presentation. + * + * @param name variable name + * @param obj object value */ void setPersistentGlobalVariable(String name, Serializable obj); /** * Remove an object from report document scope. + * + * @param name variable name */ void deletePersistentGlobalVariable(String name); /** - * Retireve an object from report document scope. + * Retrieve an object from report document scope. + * + * @param name variable name + * @return the global variable value */ Object getPersistentGlobalVariable(String name); + /** + * Get the page variable + * + * @param name variable name + * @return the page variable + */ Object getPageVariable(String name); + /** + * Set the page variable + * + * @param name variable name + * @param value object value + */ void setPageVariable(String name, Object value); /** @@ -235,20 +273,20 @@ public interface IReportContext { String getResourceRenderURL(String resourceName); /** - * evaluate the script with default script language. + * Evaluate the script with default script language. * - * @param script - * @return + * @param script script to be evaluated + * @return the evaluated script * @throws BirtException */ Object evaluate(String script) throws BirtException; /** - * evaluate the script with specified script language. + * Evaluate the script with specified script language. * * @param language - * @param script - * @return + * @param script script to be evaluated + * @return the evaluated script * @throws BirtException */ Object evaluate(String language, String script) throws BirtException; @@ -256,14 +294,14 @@ public interface IReportContext { /** * Evaluate the script. * - * @param script - * @return + * @param script script to be evaluated + * @return the evaluated script * @throws BirtException */ Object evaluate(Expression script) throws BirtException; /** - * get the application classLoader of the current report context + * Get the application classLoader of the current report context * * @return application classLoader */ @@ -275,15 +313,17 @@ public interface IReportContext { void cancel(); /** - * cancel the current engine task + * Cancel the current engine task + * + * @param reason cancellation reason */ void cancel(String reason); /** - * check if the report document generation is finished. It should be used at + * Check if the report document generation is finished. It should be used at * render time. The default value is false * - * @return + * @return true, if the report document is finished */ boolean isReportDocumentFinished(); } diff --git a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/BulletFrame.java b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/BulletFrame.java index 879e906ad36..4ce568f9087 100644 --- a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/BulletFrame.java +++ b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/BulletFrame.java @@ -16,56 +16,107 @@ import java.util.HashMap; import java.util.Map; +/** + * Bullet frame + * + * @since 3.3 + * + */ public class BulletFrame { // list style string + /** property: list style type, disc */ public static String CSS_LISTSTYLETYPE_DISC_VALUE = "disc"; + /** property: list style type, circle */ public static String CSS_LISTSTYLETYPE_CIRCLE_VALUE = "circle"; + /** property: list style type, square */ public static String CSS_LISTSTYLETYPE_SQUARE_VALUE = "square"; + /** property: list style type, decimal with leading zero */ public static String CSS_LISTSTYLETYPE_DECIMALLEADINGZERO_VALUE = "decimal-leading-zero"; + /** property: list style type, lower Roman */ public static String CSS_LISTSTYLETYPE_LOWERROMAN_VALUE = "lower-roman"; + /** property: list style type, upper Roman */ public static String CSS_LISTSTYLETYPE_UPPERROMAN_VALUE = "upper-roman"; + /** property: list style type, lower Greek */ public static String CSS_LISTSTYLETYPE_LOWERGREEK_VALUE = "lower-greek"; + /** property: list style type, lower Latin */ public static String CSS_LISTSTYLETYPE_LOWERLATINC_VALUE = "lower-latin"; + /** property: list style type, upper Latin */ public static String CSS_LISTSTYLETYPE_UPPERLATIN_VALUE = "upper-latin"; + /** property: list style type, Armenian */ public static String CSS_LISTSTYLETYPE_ARMENIAN_VALUE = "armenian"; + /** property: list style type, Georgian */ public static String CSS_LISTSTYLETYPE_GEORGIAN_VALUE = "georgian"; + /** property: list style type, lower alpha */ public static String CSS_LISTSTYLETYPE_LOWERALPHA_VALUE = "lower-alpha"; + /** property: list style type, upper alpha */ public static String CSS_LISTSTYLETYPE_UPPERALPHA_VALUE = "upper-alpha"; + /** property: list style type, no style */ public static String CSS_LISTSTYLETYPE_NONE_VALUE = "none"; + /** property: list style type, inherited */ public static String CSS_LISTSTYLETYPE_INHERIT_VALUE = "inherit"; + /** property: list style type, decimal */ public static String CSS_LISTSTYLETYPE_DECIMAL = "decimal"; - // list style type: + // list style type: + /** property: list style type, numeric, disc */ public static final int LIST_DISC_VALUE = 0; + /** property: list style type, numeric, circle */ public static final int LIST_STYLE_CIRCLE = 1; + /** property: list style type, numeric, square */ public static final int LIST_STYLE_SQUARE = 2; + /** property: list style type, numeric, decimal with leading zero */ public static final int LIST_STYLE_DECIMALLEADINGZERO = 3; + /** property: list style type, numeric, lower Roman */ public static final int LIST_STYLE_LOWERROMAN = 4; + /** property: list style type, numeric, upper Roman */ public static final int LIST_STYLE_UPPERROMAN = 5; + /** property: list style type, numeric, lower Greek */ public static final int LIST_STYLE_LOWERGREEK = 6; + /** property: list style type, numeric, upper Latin */ public static final int LIST_STYLE_UPPERLATIN = 7; + /** property: list style type, numeric, upper Latin */ public static final int LIST_STYLE_LOWERLATIN = 8; + /** property: list style type, numeric, Armenian */ public static final int LIST_STYLE_ARMENIAN = 9; + /** property: list style type, numeric, Georgian */ public static final int LIST_STYLE_GEORGIAN = 10; + /** property: list style type, numeric, lower alpha */ public static final int LIST_STYLE_LOWERALPHA = 11; + /** property: list style type, numeric, upper alpha */ public static final int LIST_STYLE_UPPERALPHA = 12; + /** property: list style type, numeric, no style */ public static final int LIST_STYLE_NONE = 13; + /** property: list style type, numeric, inherited */ public static final int LIST_STYLE_INHERIT = 14; + /** property: list style type, numeric, decimal */ public static final int LIST_STYLE_DECIMAL = 15; + /** property: mapping of types, string to numeric */ public static final Map TYPES = new HashMap<>();// mapping // the // types + /** property: empty string */ public static final String EMPTYSTRING = ""; + + /** property: disc sign */ public static final char DISC_CHAR = 0x2022; + + /** property: circle sign */ public static final char CIRCLE_CHAR = 0x25E6; + + /** property: square sign */ public static final char SQUARE_CHAR = 0x25AA; + + /** property: zero char */ public static final char ZERO_CHAR = '0'; // char table // ALPHA table + /** property: alpha size */ public static final int ALPHA_SIZE = 26; + + /** property: lower alpha chars */ public static final char LOWER_ALPHA_CHARS[] = { 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, // a // b // c @@ -78,6 +129,7 @@ public class BulletFrame { 0x007A // z }; + /** property: upper alpha chars */ public static final char UPPER_ALPHA_CHARS[] = { 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, // A // B // C @@ -90,8 +142,11 @@ public class BulletFrame { 0x005A // Z }; + /** property: lower Greek char size */ public static final int LOWER_GREEK_CHARS_SIZE = 24; + // Note: 0x03C2 GREEK FINAL SIGMA is not used in here.... + /** property: lower Greek chars */ public static final char LOWER_GREEK_CHARS[] = { 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, // alpha // beta // gamma @@ -103,11 +158,19 @@ public class BulletFrame { 0x03C6, 0x03C7, 0x03C8, 0x03C9 // phi chi psi omega }; + /** property: lower Roman chars a */ public static final char LOWER_ROMAN_CHARSA[] = { 'i', 'x', 'c', 'm' };// "ixcm"; + + /** property: upper Roman chars a */ public static final char UPPER_ROMAN_CHARSA[] = { 'I', 'X', 'C', 'M' };// "IXCM"; + + /** property: lower Roman chars b */ public static final char LOWER_ROMAN_CHARSB[] = { 'v', 'l', 'd' };// "vld"; + + /** property: upper Roman chars b */ public static final char UPPER_ROMAN_CHARSB[] = { 'V', 'L', 'D' };// "VLD"; + /** property: Georgian value */ public static char GEORGIAN_VALUE[] = { // 4 * 9 + 1 = 37 // 1 2 3 4 5 6 7 8 9 0x10D0, 0x10D1, 0x10D2, 0x10D3, 0x10D4, 0x10D5, 0x10D6, 0x10F1, 0x10D7, @@ -142,6 +205,11 @@ public class BulletFrame { private int type; + /** + * Constructor + * + * @param styleType style type + */ public BulletFrame(String styleType) { initial(styleType); @@ -156,6 +224,12 @@ private void initial(String styleType) { } + /** + * Paint a bullet list + * + * @param ordinal list type + * @return a bullet list + */ public String paintBullet(int ordinal) { StringBuffer buffer = new StringBuffer(); switch (type) { diff --git a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/HTML2Content.java b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/HTML2Content.java index 79eb813d90b..1ded314f17e 100644 --- a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/HTML2Content.java +++ b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/HTML2Content.java @@ -908,22 +908,22 @@ protected static void formalizeInlineContainer(List parentChildren, IC if (CSSValueConstants.INLINE_VALUE.equals(display)) { Iterator iter = content.getChildren().iterator(); - ArrayList contentChildren = new ArrayList(); + ArrayList contentChildren = new ArrayList(); IContainerContent clonedBlock = null; while (iter.hasNext()) { - IContent child = (IContent) iter.next(); + IContent child = iter.next(); boolean isContainer = child.getChildren().size() > 0; if (isContainer) { formalizeInlineContainer(contentChildren, content, child); } if (clonedBlock == null) { - CSSValue childDisplay = child.getStyle().getProperty(IStyle.STYLE_DISPLAY); + CSSValue childDisplay = child.getStyle().getProperty(StyleConstants.STYLE_DISPLAY); if (CSSValueConstants.BLOCK_VALUE.equals(childDisplay)) { IReportContent report = content.getReportContent(); clonedBlock = report.createContainerContent(); IStyle clonedStyle = report.createStyle(); clonedStyle.setProperties(content.getStyle()); - clonedStyle.setProperty(IStyle.STYLE_DISPLAY, CSSValueConstants.BLOCK_VALUE); + clonedStyle.setProperty(StyleConstants.STYLE_DISPLAY, CSSValueConstants.BLOCK_VALUE); clonedBlock.setInlineStyle(clonedStyle); clonedBlock.getChildren().add(child); } else if (!isContainer) { @@ -947,10 +947,10 @@ protected static void formalizeInlineContainer(List parentChildren, IC parentChildren.add(clonedBlock); } } else { - Iterator iter = content.getChildren().iterator(); - ArrayList newChildren = new ArrayList(); + Iterator iter = content.getChildren().iterator(); + ArrayList newChildren = new ArrayList(); while (iter.hasNext()) { - IContent child = (IContent) iter.next(); + IContent child = iter.next(); boolean isContainer = child.getChildren().size() > 0; if (isContainer) { formalizeInlineContainer(newChildren, content, child); @@ -968,6 +968,11 @@ protected static void formalizeInlineContainer(List parentChildren, IC } } + /** + * Main method + * + * @param args arguments + */ public static void main(String[] args) { /* * ReportContent report = new ReportContent( ); IContent root = @@ -1006,25 +1011,24 @@ public static void main(String[] args) { IContent inlineContent = createInlineContent(report); inline.getChildren().add(inlineContent); inline.getChildren().add(createBlockContent(report)); - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList(); formalizeInlineContainer(list, root, inline); root.getChildren().clear(); if (list.size() > 0) { root.getChildren().addAll(list); } - int i = 0; } protected static IContent createInlineContent(ReportContent report) { IContent content = report.createContainerContent(); - content.getStyle().setProperty(IStyle.STYLE_DISPLAY, CSSValueConstants.INLINE_VALUE); + content.getStyle().setProperty(StyleConstants.STYLE_DISPLAY, CSSValueConstants.INLINE_VALUE); return content; } protected static IContent createBlockContent(ReportContent report) { IContent content = report.createContainerContent(); - content.getStyle().setProperty(IStyle.STYLE_DISPLAY, CSSValueConstants.BLOCK_VALUE); + content.getStyle().setProperty(StyleConstants.STYLE_DISPLAY, CSSValueConstants.BLOCK_VALUE); return content; } diff --git a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/HTMLConstants.java b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/HTMLConstants.java index 5938961f227..65d3dff6cb6 100644 --- a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/HTMLConstants.java +++ b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/HTMLConstants.java @@ -13,81 +13,225 @@ package org.eclipse.birt.report.engine.layout.pdf.util; +/** + * HTML constants + * + * @since 3.3 + * + */ public interface HTMLConstants { // html tag + /** property, html-tag: italic */ String TAG_I = "i"; + + /** property, html-tag: font */ String TAG_FONT = "font"; + + /** property, html-tag: bold */ String TAG_B = "b"; + + /** property, html-tag: link */ String TAG_A = "a"; + + /** property, html-tag: code */ String TAG_CODE = "code"; + + /** property, html-tag: em */ String TAG_EM = "em"; + + /** property, html-tag: object */ String TAG_OBJECT = "object"; + + /** property, html-tag: image */ String TAG_IMG = "img"; + + /** property, html-tag: ins */ String TAG_INS = "ins"; + + /** property, html-tag: span */ String TAG_SPAN = "span"; + + /** property, html-tag: strong */ String TAG_STRONG = "strong"; + + /** property, html-tag: sub */ String TAG_SUB = "sub"; + + /** property, html-tag: sup */ String TAG_SUP = "sup"; + + /** property, html-tag: teletype text */ String TAG_TT = "tt"; + + /** property, html-tag: underline */ String TAG_U = "u"; + + /** property, html-tag: delete */ String TAG_DEL = "del"; + + /** property, html-tag: strike */ String TAG_STRIKE = "strike"; + + /** property, html-tag: invalid text */ String TAG_S = "s"; + + /** property, html-tag: big */ String TAG_BIG = "big"; + + /** property, html-tag: small */ String TAG_SMALL = "small"; + /** property, html-tag: dd */ String TAG_DD = "dd"; //$NON-NLS-1$ + + /** property, html-tag: div */ String TAG_DIV = "div"; //$NON-NLS-1$ + + /** property, html-tag: dl */ String TAG_DL = "dl"; //$NON-NLS-1$ + + /** property, html-tag: dt */ String TAG_DT = "dt"; //$NON-NLS-1$ + + /** property, html-tag: h1 */ String TAG_H1 = "h1"; //$NON-NLS-1$ + + /** property, html-tag: h2 */ String TAG_H2 = "h2"; //$NON-NLS-1$ + + /** property, html-tag: h3 */ String TAG_H3 = "h3"; //$NON-NLS-1$ + + /** property, html-tag: h4 */ String TAG_H4 = "h4"; //$NON-NLS-1$ + + /** property, html-tag: h5 */ String TAG_H5 = "h5"; //$NON-NLS-1$ + + /** property, html-tag: h6 */ String TAG_H6 = "h6"; //$NON-NLS-1$ + + /** property, html-tag: hr */ String TAG_HR = "hr"; //$NON-NLS-1$ + + /** property, html-tag: ol */ String TAG_OL = "ol"; //$NON-NLS-1$ + + /** property, html-tag: p */ String TAG_P = "p"; //$NON-NLS-1$ + + /** property, html-tag: pre */ String TAG_PRE = "pre"; //$NON-NLS-1$ + + /** property, html-tag: ul */ String TAG_UL = "ul"; //$NON-NLS-1$ + + /** property, html-tag: li */ String TAG_LI = "li"; //$NON-NLS-1$ + + /** property, html-tag: address */ String TAG_ADDRESS = "address"; //$NON-NLS-1$ + + /** property, html-tag: body */ String TAG_BODY = "body"; //$NON-NLS-1$ + + /** property, html-tag: center */ String TAG_CENTER = "center"; //$NON-NLS-1$ + + /** property, html-tag: table */ String TAG_TABLE = "table"; //$NON-NLS-1$ + + /** property, html-tag: td */ String TAG_TD = "td"; //$NON-NLS-1$ + + /** property, html-tag: tr */ String TAG_TR = "tr"; //$NON-NLS-1$ + + /** property, html-tag: th */ String TAG_TH = "th"; //$NON-NLS-1$ + + /** property, html-tag: col */ String TAG_COL = "col"; //$NON-NLS-1$ + /** property, html-tag: br */ String TAG_BR = "br";//$NON-NLS-1$ + + /** property, html-tag: value-of */ String TAG_VALUEOF = "value-of";//$NON-NLS-1$ + + /** property, html-tag: image */ String TAG_IMAGE = "image";//$NON-NLS-1$ + + /** property, html-tag: script */ String TAG_SCRIPT = "script";//$NON-NLS-1$ + /** property, property: color */ String PROPERTY_COLOR = "color";//$NON-NLS-1$ + + /** property, property: face */ String PROPERTY_FACE = "face";//$NON-NLS-1$ + + /** property, property: size */ String PROPERTY_SIZE = "size";//$NON-NLS-1$ + + /** property, property: align */ String PROPERTY_ALIGN = "align";//$NON-NLS-1$ + + /** property, property: border */ String PROPERTY_BORDER = "border";//$NON-NLS-1$ + + /** property, property: width */ String PROPERTY_WIDTH = "width";//$NON-NLS-1$ + + /** property, property: height */ String PROPERTY_HEIGHT = "height";//$NON-NLS-1$ + + /** property, property: alt */ String PROPERTY_ALT = "alt";//$NON-NLS-1$ + + /** property, property: src */ String PROPERTY_SRC = "src";//$NON-NLS-1$ + + /** property, property: bgcolor */ String PROPERTY_BGCOLOR = "bgcolor";//$NON-NLS-1$ + + /** property, property: background */ String PROPERTY_BACKGROUND = "background";//$NON-NLS-1$ + + /** property, property: text */ String PROPERTY_TEXT = "text";//$NON-NLS-1$ + + /** property, property: rowspan */ String PROPERTY_ROWSPAN = "rowspan";//$NON-NLS-1$ + + /** property, property: cellpadding */ String PROPERTY_CELLPADDING = "cellpadding";//$NON-NLS-1$ + + /** property, property: colspan */ String PROPERTY_COLSPAN = "colspan";//$NON-NLS-1$ + + /** property, property: valign */ String PROPERTY_VALIGN = "valign";//$NON-NLS-1$ + + /** property, property: id */ String PROPERTY_ID = "id";//$NON-NLS-1$ + + /** property, property: name */ String PROPERTY_NAME = "name";//$NON-NLS-1$ + + /** property, property: href */ String PROPERTY_HREF = "href";//$NON-NLS-1$ + + /** property, property: target */ String PROPERTY_TARGET = "target";//$NON-NLS-1$ + + /** property, property: classid */ String PROPERTY_CLASSID = "classid";//$NON-NLS-1$ + + /** property, property: param */ String PROPERTY_PARAM = "param";//$NON-NLS-1$ + + /** property, property: value */ String PROPERTY_VALUE = "value";//$NON-NLS-1$ } diff --git a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/HTMLStyleProcessor.java b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/HTMLStyleProcessor.java index 0450f5a62f0..dd5921ba090 100644 --- a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/HTMLStyleProcessor.java +++ b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/HTMLStyleProcessor.java @@ -59,7 +59,7 @@ public class HTMLStyleProcessor { /** * Constructor * - * @param context the execution context + * @param report report design handle */ public HTMLStyleProcessor(ReportDesignHandle report) { // Takes the zero-length string as parameter just for keeping to the @@ -70,7 +70,7 @@ public HTMLStyleProcessor(ReportDesignHandle report) { protected void processBackgroundImage(IStyle style, Map context) { if (style != null) { - CSSValue value = (CSSValue) style.getProperty(StyleConstants.STYLE_BACKGROUND_IMAGE); + CSSValue value = style.getProperty(StyleConstants.STYLE_BACKGROUND_IMAGE); if (value instanceof URIValue) { String bgi = ((URIValue) value).getStringValue(); if ((null != bgi) && (!"".equals(bgi))) //$NON-NLS-1$ @@ -88,14 +88,8 @@ protected void processBackgroundImage(IStyle style, Map context) { // bgi = "url(" + bgi + ")"; //$NON-NLS-1$//$NON-NLS-2$ } } - if (bgi != null) { - // Puts the modified URI of the resource - style.setBackgroundImage(bgi); - } else { - // If the resource does not exist, then removes this - // item. - style.removeProperty("background-image"); //$NON-NLS-1$ - } + // Puts the modified URI of the resource + style.setBackgroundImage(bgi); } } } @@ -115,8 +109,9 @@ protected StyleProperties getStyleProperties(Element ele, HashMap styles, Map context) { diff --git a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/PropertiesProcessor.java b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/PropertiesProcessor.java index cb2f26c8021..ce36f5ec6aa 100644 --- a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/PropertiesProcessor.java +++ b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/PropertiesProcessor.java @@ -18,9 +18,16 @@ import java.util.Map; import org.eclipse.birt.report.engine.content.IStyle; +import org.eclipse.birt.report.engine.css.engine.StyleConstants; import org.eclipse.birt.report.engine.ir.DimensionType; import org.w3c.dom.Element; +/** + * Property processor + * + * @since 3.3 + * + */ public abstract class PropertiesProcessor implements HTMLConstants { /** the possible values for property SIZE of HTML element FONT */ @@ -33,12 +40,20 @@ public abstract class PropertiesProcessor implements HTMLConstants { "13.8pt", "18pt", //$NON-NLS-1$//$NON-NLS-2$ "23pt", "36pt" }; //$NON-NLS-1$//$NON-NLS-2$ + /** property: tag property map */ public final static HashMap tagPropertiesMap = new HashMap<>(); abstract void process(String value, StyleProperties sp); private static Map properties2Style = new HashMap<>(); + /** + * Process the properties + * + * @param properties properties + * @param ele element + * @param sp style properties + */ public static void process(String[] properties, Element ele, StyleProperties sp) { for (int i = 0; i < properties.length; i++) { PropertiesProcessor p2s = properties2Style.get(properties[i]); @@ -51,6 +66,13 @@ public static void process(String[] properties, Element ele, StyleProperties sp) } } + /** + * Process the property + * + * @param property property + * @param value property value + * @param sp style properties + */ public static void process(String property, String value, StyleProperties sp) { PropertiesProcessor p2s = properties2Style.get(property); if (p2s != null) { @@ -73,16 +95,16 @@ public void process(String value, StyleProperties sp) { if (value != null && value.length() > 0) { if (value.endsWith("%")) { IStyle style = sp.getStyle(); - if (!hasProperty(style, IStyle.STYLE_PADDING_LEFT)) { + if (!hasProperty(style, StyleConstants.STYLE_PADDING_LEFT)) { style.setPaddingLeft(value); } - if (!hasProperty(style, IStyle.STYLE_PADDING_RIGHT)) { + if (!hasProperty(style, StyleConstants.STYLE_PADDING_RIGHT)) { style.setPaddingRight(value); } - if (!hasProperty(style, IStyle.STYLE_PADDING_TOP)) { + if (!hasProperty(style, StyleConstants.STYLE_PADDING_TOP)) { style.setPaddingTop(value); } - if (!hasProperty(style, IStyle.STYLE_PADDING_BOTTOM)) { + if (!hasProperty(style, StyleConstants.STYLE_PADDING_BOTTOM)) { style.setPaddingBottom(value); } } else { @@ -90,16 +112,16 @@ public void process(String value, StyleProperties sp) { int size = Integer.parseInt(value); // $NON-NLS-1$ String padding = size + "px"; IStyle style = sp.getStyle(); - if (!hasProperty(style, IStyle.STYLE_PADDING_LEFT)) { + if (!hasProperty(style, StyleConstants.STYLE_PADDING_LEFT)) { style.setPaddingLeft(padding); } - if (!hasProperty(style, IStyle.STYLE_PADDING_RIGHT)) { + if (!hasProperty(style, StyleConstants.STYLE_PADDING_RIGHT)) { style.setPaddingRight(padding); } - if (!hasProperty(style, IStyle.STYLE_PADDING_TOP)) { + if (!hasProperty(style, StyleConstants.STYLE_PADDING_TOP)) { style.setPaddingTop(padding); } - if (!hasProperty(style, IStyle.STYLE_PADDING_BOTTOM)) { + if (!hasProperty(style, StyleConstants.STYLE_PADDING_BOTTOM)) { style.setPaddingBottom(padding); } } catch (Exception e) { @@ -115,7 +137,7 @@ public void process(String value, StyleProperties sp) { @Override public void process(String value, StyleProperties sp) { IStyle style = sp.getStyle(); - if (!hasProperty(style, IStyle.STYLE_BACKGROUND_COLOR)) { + if (!hasProperty(style, StyleConstants.STYLE_BACKGROUND_COLOR)) { style.setBackgroundColor(value); } } @@ -129,7 +151,7 @@ public void process(String value, StyleProperties sp) { int size = Integer.parseInt(value); // $NON-NLS-1$ size = Math.min(size, 7); IStyle style = sp.getStyle(); - if (!hasProperty(style, IStyle.STYLE_FONT_SIZE)) { + if (!hasProperty(style, StyleConstants.STYLE_FONT_SIZE)) { style.setFontSize(FONT_SIZE[size + 7]); } } catch (Exception e) { @@ -144,7 +166,7 @@ public void process(String value, StyleProperties sp) { @Override public void process(String value, StyleProperties sp) { IStyle style = sp.getStyle(); - if (!hasProperty(style, IStyle.STYLE_COLOR)) { + if (!hasProperty(style, StyleConstants.STYLE_COLOR)) { style.setColor(value); } } @@ -156,7 +178,7 @@ public void process(String value, StyleProperties sp) { @Override public void process(String value, StyleProperties sp) { IStyle style = sp.getStyle(); - if (!hasProperty(style, IStyle.STYLE_COLOR)) { + if (!hasProperty(style, StyleConstants.STYLE_COLOR)) { style.setColor(value); } } @@ -168,7 +190,7 @@ public void process(String value, StyleProperties sp) { @Override public void process(String value, StyleProperties sp) { IStyle style = sp.getStyle(); - if (!hasProperty(style, IStyle.STYLE_BACKGROUND_COLOR)) { + if (!hasProperty(style, StyleConstants.STYLE_BACKGROUND_COLOR)) { style.setBackgroundColor(value); } } @@ -183,28 +205,28 @@ public void process(String value, StyleProperties sp) { int size = Integer.parseInt(value); // $NON-NLS-1$ String width = size + "px"; IStyle style = sp.getStyle(); - if (!hasProperty(style, IStyle.STYLE_BORDER_TOP_WIDTH)) { + if (!hasProperty(style, StyleConstants.STYLE_BORDER_TOP_WIDTH)) { style.setBorderTopWidth(width); } - if (!hasProperty(style, IStyle.STYLE_BORDER_BOTTOM_WIDTH)) { + if (!hasProperty(style, StyleConstants.STYLE_BORDER_BOTTOM_WIDTH)) { style.setBorderBottomWidth(width); } - if (!hasProperty(style, IStyle.STYLE_BORDER_LEFT_WIDTH)) { + if (!hasProperty(style, StyleConstants.STYLE_BORDER_LEFT_WIDTH)) { style.setBorderLeftWidth(width); } - if (!hasProperty(style, IStyle.STYLE_BORDER_RIGHT_WIDTH)) { + if (!hasProperty(style, StyleConstants.STYLE_BORDER_RIGHT_WIDTH)) { style.setBorderRightWidth(width); } - if (!hasProperty(style, IStyle.STYLE_BORDER_TOP_STYLE)) { + if (!hasProperty(style, StyleConstants.STYLE_BORDER_TOP_STYLE)) { style.setBorderTopStyle("solid"); } - if (!hasProperty(style, IStyle.STYLE_BORDER_BOTTOM_STYLE)) { + if (!hasProperty(style, StyleConstants.STYLE_BORDER_BOTTOM_STYLE)) { style.setBorderBottomStyle("solid"); } - if (!hasProperty(style, IStyle.STYLE_BORDER_LEFT_STYLE)) { + if (!hasProperty(style, StyleConstants.STYLE_BORDER_LEFT_STYLE)) { style.setBorderLeftStyle("solid"); } - if (!hasProperty(style, IStyle.STYLE_BORDER_RIGHT_STYLE)) { + if (!hasProperty(style, StyleConstants.STYLE_BORDER_RIGHT_STYLE)) { style.setBorderRightStyle("solid"); } } catch (Exception e) { @@ -218,7 +240,7 @@ public void process(String value, StyleProperties sp) { @Override public void process(String value, StyleProperties sp) { IStyle style = sp.getStyle(); - if (!hasProperty(style, IStyle.STYLE_FONT_FAMILY)) { + if (!hasProperty(style, StyleConstants.STYLE_FONT_FAMILY)) { style.setFontFamily(value); } } @@ -229,7 +251,7 @@ public void process(String value, StyleProperties sp) { @Override public void process(String value, StyleProperties sp) { IStyle style = sp.getStyle(); - if (!hasProperty(style, IStyle.STYLE_TEXT_ALIGN)) { + if (!hasProperty(style, StyleConstants.STYLE_TEXT_ALIGN)) { style.setTextAlign(value); } } @@ -241,7 +263,7 @@ public void process(String value, StyleProperties sp) { @Override public void process(String value, StyleProperties sp) { IStyle style = sp.getStyle(); - if (!hasProperty(style, IStyle.STYLE_VERTICAL_ALIGN)) { + if (!hasProperty(style, StyleConstants.STYLE_VERTICAL_ALIGN)) { style.setVerticalAlign(value); } } diff --git a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/ShortHandProcessor.java b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/ShortHandProcessor.java index 3db9f4064d4..2c1748a98ed 100644 --- a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/ShortHandProcessor.java +++ b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/ShortHandProcessor.java @@ -22,14 +22,21 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.eclipse.birt.report.engine.content.IStyle; import org.eclipse.birt.report.engine.css.engine.CSSEngine; +import org.eclipse.birt.report.engine.css.engine.StyleConstants; import org.eclipse.birt.report.engine.css.engine.value.IdentifierManager; +import org.eclipse.birt.report.engine.css.engine.value.birt.BIRTConstants; import org.eclipse.birt.report.engine.css.engine.value.css.CSSConstants; import org.w3c.css.sac.CSSException; import org.w3c.css.sac.InputSource; import org.w3c.css.sac.LexicalUnit; +/** + * Short hand processor + * + * @since 3.3 + * + */ public abstract class ShortHandProcessor { abstract void process(StringBuffer buffer, String value, CSSEngine engine); @@ -49,11 +56,11 @@ public void process(StringBuffer buffer, String value, CSSEngine engine) { String[] vs = value.split(" "); for (int i = 0; i < vs.length; i++) { if (CSSConstants.CSS_UNDERLINE_VALUE.equals(vs[i])) { - appendStyle(buffer, IStyle.BIRT_TEXT_UNDERLINE_PROPERTY, "true"); + appendStyle(buffer, BIRTConstants.BIRT_TEXT_UNDERLINE_PROPERTY, "true"); } else if (CSSConstants.CSS_LINE_THROUGH_VALUE.equals(vs[i])) { - appendStyle(buffer, IStyle.BIRT_TEXT_LINETHROUGH_PROPERTY, "true"); + appendStyle(buffer, BIRTConstants.BIRT_TEXT_LINETHROUGH_PROPERTY, "true"); } else if (CSSConstants.CSS_OVERLINE_VALUE.equals(vs[i])) { - appendStyle(buffer, IStyle.BIRT_TEXT_OVERLINE_PROPERTY, "true"); + appendStyle(buffer, BIRTConstants.BIRT_TEXT_OVERLINE_PROPERTY, "true"); } } @@ -250,11 +257,11 @@ protected void buildFontStyle(StringBuffer buffer, String[] vs, CSSEngine engine LexicalUnit u = getUnit(vs[i], engine); if (u != null) { if (u.getLexicalUnitType() == LexicalUnit.SAC_IDENT) { - if (isIdentifier(vs[i], IStyle.STYLE_FONT_STYLE, engine)) { + if (isIdentifier(vs[i], StyleConstants.STYLE_FONT_STYLE, engine)) { appendStyle(buffer, CSSConstants.CSS_FONT_STYLE_PROPERTY, vs[i]); continue; } - if (isIdentifier(vs[i], IStyle.STYLE_FONT_WEIGHT, engine)) { + if (isIdentifier(vs[i], StyleConstants.STYLE_FONT_WEIGHT, engine)) { appendStyle(buffer, CSSConstants.CSS_FONT_WEIGHT_PROPERTY, vs[i]); } } else if (u.getLexicalUnitType() == LexicalUnit.SAC_INTEGER) { @@ -271,6 +278,7 @@ protected void buildFontStyle(StringBuffer buffer, String[] vs, CSSEngine engine } } + @SuppressWarnings("unused") protected void buildFontSize(StringBuffer buffer, String value, CSSEngine engine) { if (value != null && value.length() > 0) { String[] ss = value.split("/"); @@ -300,7 +308,7 @@ protected String getBackgroundColor(String[] values, CSSEngine engine) { if (u.getLexicalUnitType() == LexicalUnit.SAC_RGBCOLOR) { return values[i]; } else if (u.getLexicalUnitType() == LexicalUnit.SAC_IDENT) { - if (isIdentifier(values[i], IStyle.STYLE_COLOR, engine)) { + if (isIdentifier(values[i], StyleConstants.STYLE_COLOR, engine)) { return values[i]; } } @@ -314,12 +322,12 @@ protected String[] getBackgroundRepeat(String[] values, CSSEngine engine) { for (int i = 0; i < values.length; i++) { LexicalUnit u = getUnit(values[i], engine); if (u != null && u.getLexicalUnitType() == LexicalUnit.SAC_IDENT) { - if (isIdentifier(values[i], IStyle.STYLE_BACKGROUND_REPEAT, engine)) { + if (isIdentifier(values[i], StyleConstants.STYLE_BACKGROUND_REPEAT, engine)) { result[0] = values[i]; if (i < values.length - 1) { u = getUnit(values[i + 1], engine); if (u != null && u.getLexicalUnitType() == LexicalUnit.SAC_IDENT) { - if (isIdentifier(values[i + 1], IStyle.STYLE_BACKGROUND_REPEAT, engine)) { + if (isIdentifier(values[i + 1], StyleConstants.STYLE_BACKGROUND_REPEAT, engine)) { result[1] = values[i + 1]; return result; } @@ -358,7 +366,7 @@ protected String getBorderStyle(String[] values, CSSEngine engine) { LexicalUnit u = getUnit(values[i], engine); if (u != null && u.getLexicalUnitType() == LexicalUnit.SAC_IDENT) { - if (isIdentifier(values[i], IStyle.STYLE_BORDER_TOP_STYLE, engine)) { + if (isIdentifier(values[i], StyleConstants.STYLE_BORDER_TOP_STYLE, engine)) { return values[i]; } } @@ -373,7 +381,7 @@ protected String getBorderColor(String[] values, CSSEngine engine) { if (u.getLexicalUnitType() == LexicalUnit.SAC_RGBCOLOR) { return values[i]; } else if (u.getLexicalUnitType() == LexicalUnit.SAC_IDENT) { - if (isIdentifier(values[i], IStyle.STYLE_COLOR, engine)) { + if (isIdentifier(values[i], StyleConstants.STYLE_COLOR, engine)) { return values[i]; } } @@ -401,6 +409,12 @@ protected String getBorderWidth(String[] values, CSSEngine engine) { return CSSConstants.CSS_MEDIUM_VALUE; } + /** + * Get the processor + * + * @param name processor name + * @return the processor + */ public ShortHandProcessor getProcessor(String name) { return processorMap.get(name); } @@ -471,6 +485,14 @@ protected void buildBorder(StringBuffer buffer, String width, String color, Stri buildRightBorder(buffer, width, color, style); } + /** + * Process of styles + * + * @param buffer content buffer + * @param name style name + * @param value style value + * @param engine CSS engine + */ public static void process(StringBuffer buffer, String name, String value, CSSEngine engine) { ShortHandProcessor p = processorMap.get(name); if (p != null) { diff --git a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/StyleProperties.java b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/StyleProperties.java index 20c0618f3c3..e3d15306a91 100644 --- a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/StyleProperties.java +++ b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/StyleProperties.java @@ -20,41 +20,81 @@ import org.eclipse.birt.report.engine.content.IStyle; import org.eclipse.birt.report.engine.ir.DimensionType; +/** + * Style property class + * + * @since 3.3 + * + */ public class StyleProperties { + /** property: width */ public static final String WIDTH = "width"; + + /** property: height */ public static final String HEIGHT = "height"; IStyle style; HashMap properties = new HashMap<>(); + /** + * Constructor + * + * @param style style + */ public StyleProperties(IStyle style) { this.style = style; } + /** + * Is empty + * + * @return true, when the property is empty + */ public boolean isEmpty() { if (style == null) { return properties.isEmpty(); - } else { - if (style.isEmpty()) { - return properties.isEmpty(); - } - return false; } + if (style.isEmpty()) { + return properties.isEmpty(); + } + return false; } + /** + * Get the style + * + * @return the style + */ public IStyle getStyle() { return style; } + /** + * Add the property + * + * @param name property name + * @param value property value + */ public void addProperty(String name, Object value) { properties.put(name, value); } + /** + * Get the property + * + * @param name property name + * @return the property + */ public Object getProperty(String name) { return properties.get(name); } + /** + * Set the property to content + * + * @param content content element + */ public void setProperties(IContent content) { Object w = properties.get(WIDTH); if (w != null) { @@ -66,6 +106,11 @@ public void setProperties(IContent content) { } } + /** + * Set the properties of width and height + * + * @param buffer content buffer + */ public void setProperties(StringBuffer buffer) { Object w = properties.get(WIDTH); if (w != null) { diff --git a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/Tag2Style.java b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/Tag2Style.java index 3f7c3c219b3..fdadbd0cbf5 100644 --- a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/Tag2Style.java +++ b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/util/Tag2Style.java @@ -18,13 +18,21 @@ import java.util.Map; import org.eclipse.birt.report.engine.content.IStyle; +import org.eclipse.birt.report.engine.css.engine.StyleConstants; import org.eclipse.birt.report.engine.css.engine.value.FloatValue; import org.eclipse.birt.report.engine.css.engine.value.ListValue; import org.eclipse.birt.report.engine.css.engine.value.Value; +import org.eclipse.birt.report.engine.css.engine.value.css.CSSValueConstants; import org.w3c.dom.Element; import org.w3c.dom.css.CSSPrimitiveValue; import org.w3c.dom.css.CSSValue; +/** + * Converting HTML tag to style + * + * @since 3.3 + * + */ public abstract class Tag2Style implements HTMLConstants { abstract void process(Element ele, StyleProperties sp); @@ -40,36 +48,36 @@ protected void setProperty(IStyle style, int index, CSSValue value) { protected void setHStyle(IStyle style, float fontSize, float margin) { setMarginTopAndBottom(style, margin); - setProperty(style, IStyle.STYLE_FONT_SIZE, createEmValue(fontSize)); - setProperty(style, IStyle.STYLE_FONT_WEIGHT, IStyle.BOLD_VALUE); - setProperty(style, IStyle.STYLE_PAGE_BREAK_AFTER, IStyle.AVOID_VALUE); + setProperty(style, StyleConstants.STYLE_FONT_SIZE, createEmValue(fontSize)); + setProperty(style, StyleConstants.STYLE_FONT_WEIGHT, CSSValueConstants.BOLD_VALUE); + setProperty(style, StyleConstants.STYLE_PAGE_BREAK_AFTER, CSSValueConstants.AVOID_VALUE); } protected void setMarginTopAndBottom(IStyle style, float margin) { - setProperty(style, IStyle.STYLE_MARGIN_TOP, createEmValue(margin)); - setProperty(style, IStyle.STYLE_MARGIN_BOTTOM, createEmValue(margin)); + setProperty(style, StyleConstants.STYLE_MARGIN_TOP, createEmValue(margin)); + setProperty(style, StyleConstants.STYLE_MARGIN_BOTTOM, createEmValue(margin)); } protected void setFontFamily(IStyle style, Value font) { ListValue fonts = new ListValue(); fonts.append(font); - setProperty(style, IStyle.STYLE_FONT_FAMILY, fonts); + setProperty(style, StyleConstants.STYLE_FONT_FAMILY, fonts); } protected void setFontStyle(IStyle style, Value fontStyle) { - setProperty(style, IStyle.STYLE_FONT_STYLE, fontStyle); + setProperty(style, StyleConstants.STYLE_FONT_STYLE, fontStyle); } protected void setFontWeight(IStyle style, Value fontWeight) { - setProperty(style, IStyle.STYLE_FONT_WEIGHT, fontWeight); + setProperty(style, StyleConstants.STYLE_FONT_WEIGHT, fontWeight); } protected void setInlineDisplay(IStyle style) { - setProperty(style, IStyle.STYLE_DISPLAY, IStyle.INLINE_VALUE); + setProperty(style, StyleConstants.STYLE_DISPLAY, CSSValueConstants.INLINE_VALUE); } protected void setBlockDisplay(IStyle style) { - setProperty(style, IStyle.STYLE_DISPLAY, IStyle.BLOCK_VALUE); + setProperty(style, StyleConstants.STYLE_DISPLAY, CSSValueConstants.BLOCK_VALUE); } protected void processProperites(String[] properties, Element ele, StyleProperties sp) { @@ -81,7 +89,7 @@ protected void processProperites(String[] properties, Element ele, StyleProperti @Override public void process(Element ele, StyleProperties sp) { - setFontStyle(sp.getStyle(), IStyle.ITALIC_VALUE); + setFontStyle(sp.getStyle(), CSSValueConstants.ITALIC_VALUE); setInlineDisplay(sp.getStyle()); } }); @@ -101,7 +109,7 @@ public void process(Element ele, StyleProperties sp) { @Override public void process(Element ele, StyleProperties sp) { - setFontWeight(sp.getStyle(), IStyle.BOLD_VALUE); + setFontWeight(sp.getStyle(), CSSValueConstants.BOLD_VALUE); setInlineDisplay(sp.getStyle()); } }); @@ -118,7 +126,7 @@ public void process(Element ele, StyleProperties sp) { @Override public void process(Element ele, StyleProperties sp) { - setFontFamily(sp.getStyle(), IStyle.MONOSPACE_VALUE); + setFontFamily(sp.getStyle(), CSSValueConstants.MONOSPACE_VALUE); setInlineDisplay(sp.getStyle()); } }); @@ -126,7 +134,7 @@ public void process(Element ele, StyleProperties sp) { @Override public void process(Element ele, StyleProperties sp) { - setFontStyle(sp.getStyle(), IStyle.ITALIC_VALUE); + setFontStyle(sp.getStyle(), CSSValueConstants.ITALIC_VALUE); setInlineDisplay(sp.getStyle()); } }); @@ -158,7 +166,7 @@ public void process(Element ele, StyleProperties sp) { @Override public void process(Element ele, StyleProperties sp) { - setProperty(sp.getStyle(), IStyle.STYLE_TEXT_UNDERLINE, IStyle.UNDERLINE_VALUE); + setProperty(sp.getStyle(), StyleConstants.STYLE_TEXT_UNDERLINE, CSSValueConstants.UNDERLINE_VALUE); setInlineDisplay(sp.getStyle()); } }); @@ -179,7 +187,7 @@ public void process(Element ele, StyleProperties sp) { @Override public void process(Element ele, StyleProperties sp) { - setFontWeight(sp.getStyle(), IStyle.BOLD_VALUE); + setFontWeight(sp.getStyle(), CSSValueConstants.BOLD_VALUE); setInlineDisplay(sp.getStyle()); } }); @@ -188,8 +196,8 @@ public void process(Element ele, StyleProperties sp) { @Override public void process(Element ele, StyleProperties sp) { - setProperty(sp.getStyle(), IStyle.STYLE_VERTICAL_ALIGN, IStyle.BOTTOM_VALUE); - setProperty(sp.getStyle(), IStyle.STYLE_FONT_SIZE, createPercentageValue(75)); + setProperty(sp.getStyle(), StyleConstants.STYLE_VERTICAL_ALIGN, CSSValueConstants.BOTTOM_VALUE); + setProperty(sp.getStyle(), StyleConstants.STYLE_FONT_SIZE, createPercentageValue(75)); setInlineDisplay(sp.getStyle()); } }); @@ -198,8 +206,8 @@ public void process(Element ele, StyleProperties sp) { @Override public void process(Element ele, StyleProperties sp) { - setProperty(sp.getStyle(), IStyle.STYLE_VERTICAL_ALIGN, IStyle.TOP_VALUE); - setProperty(sp.getStyle(), IStyle.STYLE_FONT_SIZE, createPercentageValue(75)); + setProperty(sp.getStyle(), StyleConstants.STYLE_VERTICAL_ALIGN, CSSValueConstants.TOP_VALUE); + setProperty(sp.getStyle(), StyleConstants.STYLE_FONT_SIZE, createPercentageValue(75)); setInlineDisplay(sp.getStyle()); } }); @@ -208,7 +216,7 @@ public void process(Element ele, StyleProperties sp) { @Override public void process(Element ele, StyleProperties sp) { - setFontFamily(sp.getStyle(), IStyle.MONOSPACE_VALUE); + setFontFamily(sp.getStyle(), CSSValueConstants.MONOSPACE_VALUE); setInlineDisplay(sp.getStyle()); } }); @@ -217,7 +225,7 @@ public void process(Element ele, StyleProperties sp) { @Override public void process(Element ele, StyleProperties sp) { - setProperty(sp.getStyle(), IStyle.STYLE_TEXT_UNDERLINE, IStyle.UNDERLINE_VALUE); + setProperty(sp.getStyle(), StyleConstants.STYLE_TEXT_UNDERLINE, CSSValueConstants.UNDERLINE_VALUE); setInlineDisplay(sp.getStyle()); } }); @@ -225,7 +233,7 @@ public void process(Element ele, StyleProperties sp) { @Override public void process(Element ele, StyleProperties sp) { - setProperty(sp.getStyle(), IStyle.STYLE_TEXT_LINETHROUGH, IStyle.LINE_THROUGH_VALUE); + setProperty(sp.getStyle(), StyleConstants.STYLE_TEXT_LINETHROUGH, CSSValueConstants.LINE_THROUGH_VALUE); setInlineDisplay(sp.getStyle()); } }); @@ -234,7 +242,7 @@ public void process(Element ele, StyleProperties sp) { @Override public void process(Element ele, StyleProperties sp) { - setProperty(sp.getStyle(), IStyle.STYLE_TEXT_LINETHROUGH, IStyle.LINE_THROUGH_VALUE); + setProperty(sp.getStyle(), StyleConstants.STYLE_TEXT_LINETHROUGH, CSSValueConstants.LINE_THROUGH_VALUE); setInlineDisplay(sp.getStyle()); } }); @@ -242,7 +250,7 @@ public void process(Element ele, StyleProperties sp) { @Override public void process(Element ele, StyleProperties sp) { - setProperty(sp.getStyle(), IStyle.STYLE_TEXT_LINETHROUGH, IStyle.LINE_THROUGH_VALUE); + setProperty(sp.getStyle(), StyleConstants.STYLE_TEXT_LINETHROUGH, CSSValueConstants.LINE_THROUGH_VALUE); setInlineDisplay(sp.getStyle()); } }); @@ -251,7 +259,7 @@ public void process(Element ele, StyleProperties sp) { @Override public void process(Element ele, StyleProperties sp) { - setProperty(sp.getStyle(), IStyle.STYLE_FONT_SIZE, createPercentageValue(200)); + setProperty(sp.getStyle(), StyleConstants.STYLE_FONT_SIZE, createPercentageValue(200)); setInlineDisplay(sp.getStyle()); } }); @@ -260,7 +268,7 @@ public void process(Element ele, StyleProperties sp) { @Override public void process(Element ele, StyleProperties sp) { - setProperty(sp.getStyle(), IStyle.STYLE_FONT_SIZE, createPercentageValue(50)); + setProperty(sp.getStyle(), StyleConstants.STYLE_FONT_SIZE, createPercentageValue(50)); setInlineDisplay(sp.getStyle()); } }); @@ -403,7 +411,7 @@ public void process(Element ele, StyleProperties sp) { @Override public void process(Element ele, StyleProperties sp) { - setFontFamily(sp.getStyle(), IStyle.MONOSPACE_VALUE); + setFontFamily(sp.getStyle(), CSSValueConstants.MONOSPACE_VALUE); setBlockDisplay(sp.getStyle()); } }); @@ -428,7 +436,7 @@ public void process(Element ele, StyleProperties sp) { @Override public void process(Element ele, StyleProperties sp) { - setFontStyle(sp.getStyle(), IStyle.ITALIC_VALUE); + setFontStyle(sp.getStyle(), CSSValueConstants.ITALIC_VALUE); setBlockDisplay(sp.getStyle()); } }); @@ -445,7 +453,7 @@ public void process(Element ele, StyleProperties sp) { @Override public void process(Element ele, StyleProperties sp) { - setProperty(sp.getStyle(), IStyle.STYLE_TEXT_ALIGN, IStyle.CENTER_VALUE); + setProperty(sp.getStyle(), StyleConstants.STYLE_TEXT_ALIGN, CSSValueConstants.CENTER_VALUE); setBlockDisplay(sp.getStyle()); } }); @@ -499,14 +507,32 @@ public void process(Element ele, StyleProperties sp) { } + /** + * Get the style + * + * @param tagName tag name + * @return the style + */ public static Tag2Style getStyleProcess(String tagName) { - return (Tag2Style) tag2Style.get(tagName); + return tag2Style.get(tagName); } + /** + * Create an EM value + * + * @param value the EM value + * @return the EM value + */ public static FloatValue createEmValue(float value) { return createFloatValue(CSSPrimitiveValue.CSS_EMS, value); } + /** + * Create a percentage value + * + * @param value percentage value + * @return the percentage value + */ public static FloatValue createPercentageValue(float value) { return createFloatValue(CSSPrimitiveValue.CSS_PERCENTAGE, value); }