diff options
Diffstat (limited to 'reportbuilder/java/com/sun/star/report/pentaho/styles')
8 files changed, 224 insertions, 248 deletions
diff --git a/reportbuilder/java/com/sun/star/report/pentaho/styles/LengthCalculator.java b/reportbuilder/java/com/sun/star/report/pentaho/styles/LengthCalculator.java index 9a0a330dbc15..1e041d6bce8d 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/styles/LengthCalculator.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/styles/LengthCalculator.java @@ -27,8 +27,6 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ - - package com.sun.star.report.pentaho.styles; import org.jfree.layouting.input.style.values.CSSNumericType; @@ -44,73 +42,72 @@ import org.jfree.layouting.input.style.values.CSSNumericValue; */ public class LengthCalculator { - // and centimeter (x10) - private double millimeter; - - // and pica (x12) and inch(x72). Px is assumed to be in 96dpi. - private double point; + // and centimeter (x10) - private double pixel; + private double millimeter; + // and pica (x12) and inch(x72). Px is assumed to be in 96dpi. + private double point; + private double pixel; - public LengthCalculator() - { - } - - public void add (final CSSNumericValue value) - { - if (value == null) + public LengthCalculator() { - return; } - final CSSNumericType numericType = value.getType(); - if (numericType == CSSNumericType.CM) - { - millimeter += value.getValue() * 10; - } - else if (numericType == CSSNumericType.MM) + public void add(final CSSNumericValue value) { - millimeter += value.getValue(); - } - else if (numericType == CSSNumericType.PT) - { - point += value.getValue(); - } - else if (numericType == CSSNumericType.PC) - { - point += 12 * value.getValue(); - } - else if (numericType == CSSNumericType.INCH) - { - point += 72 * value.getValue(); - } - else if (numericType == CSSNumericType.PX) - { - pixel += value.getValue(); - } - // LOGGER.debug ("Adding " + value + " [mm: " + millimeter + "] [pt: " + point + "] px: [" + pixel + "]"); - } + if (value == null) + { + return; + } - public CSSNumericValue getResult () - { - if (pixel == 0 && point == 0) - { - return CSSNumericValue.createValue(CSSNumericType.MM, millimeter); + final CSSNumericType numericType = value.getType(); + if (numericType == CSSNumericType.CM) + { + millimeter += value.getValue() * 10; + } + else if (numericType == CSSNumericType.MM) + { + millimeter += value.getValue(); + } + else if (numericType == CSSNumericType.PT) + { + point += value.getValue(); + } + else if (numericType == CSSNumericType.PC) + { + point += 12 * value.getValue(); + } + else if (numericType == CSSNumericType.INCH) + { + point += 72 * value.getValue(); + } + else if (numericType == CSSNumericType.PX) + { + pixel += value.getValue(); + } + // LOGGER.debug ("Adding " + value + " [mm: " + millimeter + "] [pt: " + point + "] px: [" + pixel + "]"); } - if (pixel == 0 && millimeter == 0) - { - return CSSNumericValue.createValue(CSSNumericType.PT, point); - } - if (point == 0 && millimeter == 0) + + public CSSNumericValue getResult() { - return CSSNumericValue.createValue(CSSNumericType.PX, pixel); - } - // else convert it. + if (pixel == 0 && point == 0) + { + return CSSNumericValue.createValue(CSSNumericType.MM, millimeter); + } + if (pixel == 0 && millimeter == 0) + { + return CSSNumericValue.createValue(CSSNumericType.PT, point); + } + if (point == 0 && millimeter == 0) + { + return CSSNumericValue.createValue(CSSNumericType.PX, pixel); + } + // else convert it. - double result = point; - result += (millimeter * 10 * 72 / 254); - result += pixel * 72 / 96; + double result = point; + result += (millimeter * 10 * 72 / 254); + result += pixel * 72 / 96; - return CSSNumericValue.createValue(CSSNumericType.PT, result); - } + return CSSNumericValue.createValue(CSSNumericType.PT, result); + } } diff --git a/reportbuilder/java/com/sun/star/report/pentaho/styles/StyleMapper.java b/reportbuilder/java/com/sun/star/report/pentaho/styles/StyleMapper.java index 1424d0becad6..6cb6add68697 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/styles/StyleMapper.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/styles/StyleMapper.java @@ -27,8 +27,6 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ - - package com.sun.star.report.pentaho.styles; import java.util.HashMap; @@ -54,53 +52,47 @@ import org.pentaho.reporting.libraries.resourceloader.ResourceManager; */ public class StyleMapper { - private final Map backend; - public StyleMapper() - { - this.backend = new HashMap(); - } + private final Map backend; - public void addMapping(final StyleMappingRule rule) - { - backend.put(rule.getKey(), rule); - } + public StyleMapper() + { + this.backend = new HashMap(); + } - public boolean isListOfStyles(final String elementNamespace, - final String elementTagName, - final String attributeNamespace, - final String attributeName) - { - final StyleMapperKey key = new StyleMapperKey - (elementNamespace, elementTagName, attributeNamespace, attributeName); - final StyleMappingRule rule = (StyleMappingRule) backend.get(key); - if (rule == null) + public void addMapping(final StyleMappingRule rule) { - return false; + backend.put(rule.getKey(), rule); } - return rule.isListOfValues(); - } - public String getStyleFamilyFor(final String elementNamespace, - final String elementTagName, - final String attributeNamespace, - final String attributeName) - { - final StyleMapperKey key = new StyleMapperKey - (elementNamespace, elementTagName, attributeNamespace, attributeName); - final StyleMappingRule rule = (StyleMappingRule) backend.get(key); - if (rule == null) + public boolean isListOfStyles(final String elementNamespace, + final String elementTagName, + final String attributeNamespace, + final String attributeName) { - return null; + final StyleMapperKey key = new StyleMapperKey(elementNamespace, elementTagName, attributeNamespace, attributeName); + final StyleMappingRule rule = (StyleMappingRule) backend.get(key); + return rule != null && rule.isListOfValues(); } - return rule.getFamily(); - } - public static StyleMapper loadInstance (final ResourceManager resourceManager) - throws ResourceException - { - final Resource resource = resourceManager.createDirectly - ("res://com/sun/star/report/pentaho/styles/stylemapper.xml", StyleMapper.class); - return (StyleMapper) resource.getResource(); - } + public String getStyleFamilyFor(final String elementNamespace, + final String elementTagName, + final String attributeNamespace, + final String attributeName) + { + final StyleMapperKey key = new StyleMapperKey(elementNamespace, elementTagName, attributeNamespace, attributeName); + final StyleMappingRule rule = (StyleMappingRule) backend.get(key); + if (rule == null) + { + return null; + } + return rule.getFamily(); + } + + public static StyleMapper loadInstance(final ResourceManager resourceManager) + throws ResourceException + { + final Resource resource = resourceManager.createDirectly("res://com/sun/star/report/pentaho/styles/stylemapper.xml", StyleMapper.class); + return (StyleMapper) resource.getResource(); + } } diff --git a/reportbuilder/java/com/sun/star/report/pentaho/styles/StyleMapperKey.java b/reportbuilder/java/com/sun/star/report/pentaho/styles/StyleMapperKey.java index 64b50cba1197..496bfd23387f 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/styles/StyleMapperKey.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/styles/StyleMapperKey.java @@ -96,9 +96,7 @@ public final class StyleMapperKey final StyleMapperKey that = (StyleMapperKey) o; - if ((attributeName != null ? !attributeName.equals(that.attributeName) : that.attributeName != null) || - (attributeNamespace != null ? !attributeNamespace.equals(that.attributeNamespace) : that.attributeNamespace != null) || - !elementName.equals(that.elementName) || !elementNamespace.equals(that.elementNamespace)) + if ((attributeName != null ? !attributeName.equals(that.attributeName) : that.attributeName != null) || (attributeNamespace != null ? !attributeNamespace.equals(that.attributeNamespace) : that.attributeNamespace != null) || !elementName.equals(that.elementName) || !elementNamespace.equals(that.elementNamespace)) { return false; } diff --git a/reportbuilder/java/com/sun/star/report/pentaho/styles/StyleMapperXmlFactoryModule.java b/reportbuilder/java/com/sun/star/report/pentaho/styles/StyleMapperXmlFactoryModule.java index 0b6319af3848..09802517e0a2 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/styles/StyleMapperXmlFactoryModule.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/styles/StyleMapperXmlFactoryModule.java @@ -57,8 +57,7 @@ public class StyleMapperXmlFactoryModule implements XmlFactoryModule public int getDocumentSupport(final XmlDocumentInfo documentInfo) { final String rootNamespace = documentInfo.getRootElementNameSpace(); - if (StyleMapperXmlFactoryModule.NAMESPACE.equals(rootNamespace) && - "style-mapper-definition".equals(documentInfo.getRootElement())) + if (StyleMapperXmlFactoryModule.NAMESPACE.equals(rootNamespace) && "style-mapper-definition".equals(documentInfo.getRootElement())) { return XmlFactoryModule.RECOGNIZED_BY_NAMESPACE; diff --git a/reportbuilder/java/com/sun/star/report/pentaho/styles/StyleMapperXmlResourceFactory.java b/reportbuilder/java/com/sun/star/report/pentaho/styles/StyleMapperXmlResourceFactory.java index 4d9646303b38..5574bf022353 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/styles/StyleMapperXmlResourceFactory.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/styles/StyleMapperXmlResourceFactory.java @@ -27,8 +27,6 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ - - package com.sun.star.report.pentaho.styles; import org.pentaho.reporting.libraries.xmlns.parser.AbstractXmlResourceFactory; @@ -43,17 +41,18 @@ import org.pentaho.reporting.libraries.base.config.Configuration; */ public class StyleMapperXmlResourceFactory extends AbstractXmlResourceFactory { - public StyleMapperXmlResourceFactory() - { - } - protected Configuration getConfiguration() - { - return JFreeReportBoot.getInstance().getGlobalConfig(); - } + public StyleMapperXmlResourceFactory() + { + } + + protected Configuration getConfiguration() + { + return JFreeReportBoot.getInstance().getGlobalConfig(); + } - public Class getFactoryType() - { - return StyleMapper.class; - } + public Class getFactoryType() + { + return StyleMapper.class; + } } diff --git a/reportbuilder/java/com/sun/star/report/pentaho/styles/StyleMappingReadHandler.java b/reportbuilder/java/com/sun/star/report/pentaho/styles/StyleMappingReadHandler.java index 21101d847e44..7db04ffc5d93 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/styles/StyleMappingReadHandler.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/styles/StyleMappingReadHandler.java @@ -27,8 +27,6 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ - - package com.sun.star.report.pentaho.styles; import org.pentaho.reporting.libraries.xmlns.parser.AbstractXmlReadHandler; @@ -44,66 +42,62 @@ import org.xml.sax.SAXException; */ public class StyleMappingReadHandler extends AbstractXmlReadHandler { - private StyleMappingRule rule; - - public StyleMappingReadHandler() - { - } + private StyleMappingRule rule; - /** - * Starts parsing. - * - * @param attrs the attributes. - * @throws org.xml.sax.SAXException if there is a parsing error. - */ - protected void startParsing(final Attributes attrs) - throws SAXException - { - final String elementNamespace = attrs.getValue(getUri(), - "element-namespace"); - if (elementNamespace == null) + public StyleMappingReadHandler() { - throw new ParseException - ("Required attribute 'element-namespace' is missing", getLocator()); } - final String elementName = attrs.getValue(getUri(), "element-name"); - - if (elementName == null) + /** + * Starts parsing. + * + * @param attrs the attributes. + * @throws org.xml.sax.SAXException if there is a parsing error. + */ + protected void startParsing(final Attributes attrs) + throws SAXException { - throw new ParseException - ("Required attribute 'element-name' is missing", getLocator()); - } + final String elementNamespace = attrs.getValue(getUri(), + "element-namespace"); + if (elementNamespace == null) + { + throw new ParseException("Required attribute 'element-namespace' is missing", getLocator()); + } - final String attributeNamespace = attrs.getValue(getUri(), - "attribute-namespace"); - final String attributeName = attrs.getValue(getUri(), "attribute-name"); + final String elementName = attrs.getValue(getUri(), "element-name"); - final boolean listOfValues = - "styleNameRefs".equals(attrs.getValue(getUri(), "type")); + if (elementName == null) + { + throw new ParseException("Required attribute 'element-name' is missing", getLocator()); + } - final String family = attrs.getValue(getUri(), "style-family"); - final StyleMapperKey key = new StyleMapperKey - (elementNamespace, elementName, attributeNamespace, attributeName); - rule = new StyleMappingRule(key, family, listOfValues); - } + final String attributeNamespace = attrs.getValue(getUri(), + "attribute-namespace"); + final String attributeName = attrs.getValue(getUri(), "attribute-name"); + final boolean listOfValues = + "styleNameRefs".equals(attrs.getValue(getUri(), "type")); - public StyleMappingRule getRule() - { - return rule; - } + final String family = attrs.getValue(getUri(), "style-family"); + final StyleMapperKey key = new StyleMapperKey(elementNamespace, elementName, attributeNamespace, attributeName); + rule = new StyleMappingRule(key, family, listOfValues); + } - /** - * Returns the object for this element or null, if this element does not - * create an object. - * - * @return the object. - */ - public Object getObject() - throws SAXException - { - return rule; - } + public StyleMappingRule getRule() + { + return rule; + } + + /** + * Returns the object for this element or null, if this element does not + * create an object. + * + * @return the object. + */ + public Object getObject() + throws SAXException + { + return rule; + } } diff --git a/reportbuilder/java/com/sun/star/report/pentaho/styles/StyleMappingRule.java b/reportbuilder/java/com/sun/star/report/pentaho/styles/StyleMappingRule.java index 742daf8ba6e5..e0fbd62a77d8 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/styles/StyleMappingRule.java +++ b/reportbuilder/java/com/sun/star/report/pentaho/styles/StyleMappingRule.java @@ -27,8 +27,6 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ - - package com.sun.star.report.pentaho.styles; /** @@ -39,32 +37,31 @@ package com.sun.star.report.pentaho.styles; */ public class StyleMappingRule { - private final StyleMapperKey key; - private final String family; - private final boolean listOfValues; - - public StyleMappingRule(final StyleMapperKey key, final String family, - final boolean listOfValues) - { - this.key = key; - this.family = family; - this.listOfValues = listOfValues; - } + private final StyleMapperKey key; + private final String family; + private final boolean listOfValues; + public StyleMappingRule(final StyleMapperKey key, final String family, + final boolean listOfValues) + { + this.key = key; + this.family = family; + this.listOfValues = listOfValues; + } - public StyleMapperKey getKey() - { - return key; - } + public StyleMapperKey getKey() + { + return key; + } - public String getFamily() - { - return family; - } + public String getFamily() + { + return family; + } - public boolean isListOfValues() - { - return listOfValues; - } + public boolean isListOfValues() + { + return listOfValues; + } } diff --git a/reportbuilder/java/com/sun/star/report/pentaho/styles/stylemapper.xsd b/reportbuilder/java/com/sun/star/report/pentaho/styles/stylemapper.xsd index 905dbc8464d6..93392a6f0ea1 100644 --- a/reportbuilder/java/com/sun/star/report/pentaho/styles/stylemapper.xsd +++ b/reportbuilder/java/com/sun/star/report/pentaho/styles/stylemapper.xsd @@ -34,62 +34,62 @@ xmlns="http://jfreereport.sourceforge.net/namespaces/engine/openoffice/stylemapper" targetNamespace="http://jfreereport.sourceforge.net/namespaces/engine/openoffice/stylemapper" attributeFormDefault="unqualified"> - <xsd:annotation> - <xsd:documentation> + <xsd:annotation> + <xsd:documentation> This schema describes the format of the stylemapper definition file. The stylemapper declares what style-families are referenced by an element. - </xsd:documentation> - </xsd:annotation> + </xsd:documentation> + </xsd:annotation> - <xsd:simpleType name="styleNameRefType"> - <xsd:restriction base="xsd:NMTOKEN"> - <xsd:enumeration value="styleNameRef"/> - <xsd:enumeration value="styleNameRefs"/> - </xsd:restriction> - </xsd:simpleType> + <xsd:simpleType name="styleNameRefType"> + <xsd:restriction base="xsd:NMTOKEN"> + <xsd:enumeration value="styleNameRef"/> + <xsd:enumeration value="styleNameRefs"/> + </xsd:restriction> + </xsd:simpleType> - <xsd:simpleType name="styleFamilyType"> - <xsd:restriction base="xsd:NMTOKEN"> - <xsd:enumeration value="paragraph"/> - <xsd:enumeration value="text"/> - <xsd:enumeration value="section"/> - <xsd:enumeration value="table"/> - <xsd:enumeration value="table-column"/> - <xsd:enumeration value="table-row"/> - <xsd:enumeration value="table-cell"/> - <xsd:enumeration value="table-page"/> - <xsd:enumeration value="chart"/> - <xsd:enumeration value="default"/> - <xsd:enumeration value="drawing-page"/> - <xsd:enumeration value="graphic"/> - <xsd:enumeration value="presentation"/> - <xsd:enumeration value="control"/> - <xsd:enumeration value="ruby"/> - <xsd:enumeration value="custom-shape"/> - </xsd:restriction> - </xsd:simpleType> + <xsd:simpleType name="styleFamilyType"> + <xsd:restriction base="xsd:NMTOKEN"> + <xsd:enumeration value="paragraph"/> + <xsd:enumeration value="text"/> + <xsd:enumeration value="section"/> + <xsd:enumeration value="table"/> + <xsd:enumeration value="table-column"/> + <xsd:enumeration value="table-row"/> + <xsd:enumeration value="table-cell"/> + <xsd:enumeration value="table-page"/> + <xsd:enumeration value="chart"/> + <xsd:enumeration value="default"/> + <xsd:enumeration value="drawing-page"/> + <xsd:enumeration value="graphic"/> + <xsd:enumeration value="presentation"/> + <xsd:enumeration value="control"/> + <xsd:enumeration value="ruby"/> + <xsd:enumeration value="custom-shape"/> + </xsd:restriction> + </xsd:simpleType> - <xsd:element name="mapping"> - <xsd:complexType> - <xsd:attribute name="element-namespace" use="required" type="xsd:anyURI"/> - <xsd:attribute name="element-name" use="required" type="xsd:NCName"/> - <xsd:attribute name="attribute-namespace" use="required" type="xsd:anyURI"/> - <xsd:attribute name="attribute-name" use="required" type="xsd:NCName"/> - <xsd:attribute name="type" use="required" type="styleNameRefType"/> - <xsd:attribute name="style-family" use="required" type="styleFamilyType"/> - </xsd:complexType> - </xsd:element> + <xsd:element name="mapping"> + <xsd:complexType> + <xsd:attribute name="element-namespace" use="required" type="xsd:anyURI"/> + <xsd:attribute name="element-name" use="required" type="xsd:NCName"/> + <xsd:attribute name="attribute-namespace" use="required" type="xsd:anyURI"/> + <xsd:attribute name="attribute-name" use="required" type="xsd:NCName"/> + <xsd:attribute name="type" use="required" type="styleNameRefType"/> + <xsd:attribute name="style-family" use="required" type="styleFamilyType"/> + </xsd:complexType> + </xsd:element> - <xsd:element name="style-mapper-definition"> - <xsd:complexType> - <xsd:complexContent> - <xsd:restriction base="xsd:anyType"> - <xsd:sequence> - <xsd:element ref="mapping" minOccurs="0" maxOccurs="unbounded"/> - </xsd:sequence> - </xsd:restriction> - </xsd:complexContent> - </xsd:complexType> - </xsd:element> + <xsd:element name="style-mapper-definition"> + <xsd:complexType> + <xsd:complexContent> + <xsd:restriction base="xsd:anyType"> + <xsd:sequence> + <xsd:element ref="mapping" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:restriction> + </xsd:complexContent> + </xsd:complexType> + </xsd:element> </xsd:schema> |