Tag: cws_dev300_rptfix02 User: oj Date: 2008-07-03 11:12:37+0000 Modified: dba/reportdesign/java/com/sun/star/report/pentaho/output/StyleUtilities.java
Log: #i91016# also export style referenced by apply-style-name File Changes: Directory: /dba/reportdesign/java/com/sun/star/report/pentaho/output/ ===================================================================== File [changed]: StyleUtilities.java Url: http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/output/StyleUtilities.java?r1=1.8&r2=1.8.18.1 Delta lines: +77 -47 --------------------- --- StyleUtilities.java 2008-06-16 13:14:32+0000 1.8 +++ StyleUtilities.java 2008-07-03 11:12:34+0000 1.8.18.1 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: StyleUtilities.java,v $ - * $Revision: 1.8 $ + * $Revision: 1.8.18.1 $ * * This file is part of OpenOffice.org. * @@ -42,6 +42,7 @@ import java.util.Set; import org.jfree.report.ReportProcessingException; import org.jfree.report.structure.Element; +import org.jfree.report.structure.Section; import org.jfree.report.util.AttributeNameGenerator; import org.jfree.util.Log; @@ -191,8 +192,7 @@ Log.warn("Inconsistent styles: " + styleFamily + ":" + styleParent + " does not exist."); } return preStyle; - } - catch (CloneNotSupportedException e) + } catch (CloneNotSupportedException e) { throw new ReportProcessingException("Failed to derive a stylesheet", e); } @@ -247,8 +247,7 @@ currentFonts.addFontFace((FontFaceElement) element.clone()); } } - } - catch (CloneNotSupportedException e) + } catch (CloneNotSupportedException e) { throw new ReportProcessingException("Failed to clone font-face element"); } @@ -259,50 +258,76 @@ final OfficeStylesCollection predefCollection) throws ReportProcessingException { - final Object attribute = style.getAttribute(OfficeNamespaces.STYLE_NS, "data-style-name"); - if (attribute == null) + final Section derivedStyle = performDataStyleProcessing(style, stylesCollection, predefCollection, "data-style-name"); + if (derivedStyle != null) { - // the easy case: It has no number style at all. - return; - } - - final String styleName = String.valueOf(attribute); - if (stylesCollection.getAutomaticStyles().containsDataStyle(styleName)) + try { - return; + final Section styleMap = (Section) derivedStyle.findFirstChild(OfficeNamespaces.STYLE_NS,"map"); + if (styleMap != null) + { + performDataStyleProcessing(styleMap, stylesCollection, predefCollection, "apply-style-name"); } - if (stylesCollection.getCommonStyles().containsDataStyle(styleName)) + } catch (Exception e) { - return; + } + } } - + private static Section performDataStyleProcessing(final Section style, + final OfficeStylesCollection stylesCollection, + final OfficeStylesCollection predefCollection, + final String attributeName) + throws ReportProcessingException + { + final Object attribute = style.getAttribute(OfficeNamespaces.STYLE_NS, attributeName); + final DataStyle derivedStyle; + if (attribute != null) + { + final String styleName = String.valueOf(attribute); + if (!stylesCollection.getAutomaticStyles().containsDataStyle(styleName) && + !stylesCollection.getCommonStyles().containsDataStyle(styleName)) + { try { final OfficeStyles automaticStyles = predefCollection.getAutomaticStyles(); final DataStyle autoDataStyle = automaticStyles.getDataStyle(styleName); if (autoDataStyle != null) { - final DataStyle derivedStyle = (DataStyle) autoDataStyle.clone(); + derivedStyle = (DataStyle) autoDataStyle.clone(); stylesCollection.getAutomaticStyles().addDataStyle(derivedStyle); - return; } + else + { final OfficeStyles commonStyles = predefCollection.getCommonStyles(); final DataStyle commonDataStyle = commonStyles.getDataStyle(styleName); if (commonDataStyle != null) { - final DataStyle derivedStyle = (DataStyle) commonDataStyle.clone(); + derivedStyle = (DataStyle) commonDataStyle.clone(); stylesCollection.getCommonStyles().addDataStyle(derivedStyle); - return; } - + else + { Log.warn("Dangling data style: " + styleName); + derivedStyle = null; + } } - catch (CloneNotSupportedException e) + } catch (CloneNotSupportedException e) { throw new ReportProcessingException("Failed to copy style. This should not have happened."); } } + else + { + derivedStyle = null; + } + } + else + { + derivedStyle = null; + } + return derivedStyle; + } /** * Derives the named style. If the style is a common style, a new automatic style is generated and inserted into the @@ -482,8 +507,7 @@ predefCollection); } return autostyle; - } - catch (CloneNotSupportedException e) + } catch (CloneNotSupportedException e) { throw new ReportProcessingException( "Deriving the style failed. Clone error: ", e); @@ -508,13 +532,15 @@ final ArrayList propertyName, final ArrayList propertyValues) { - if ( propertyNamespace.size() != propertyName.size()) + if (propertyNamespace.size() != propertyName.size()) + { return null; + } final OfficeStyle[] styles = predefCollection.getAutomaticStyles().getAllStyles(); for (int i = 0; i < styles.length; i++) { final OfficeStyle officeStyle = styles[i]; - if ( officeStyle.getStyleFamily().equals(styleFamily) ) + if (officeStyle.getStyleFamily().equals(styleFamily)) { final Element section = officeStyle.findFirstChild(OfficeNamespaces.STYLE_NS, sectionName); if (section != null) @@ -522,16 +548,20 @@ int j = 0; for (; j < propertyNamespace.size(); j++) { - final String ns = (String)propertyNamespace.get(j); - final String prop = (String)propertyName.get(j); + final String ns = (String) propertyNamespace.get(j); + final String prop = (String) propertyName.get(j); final Object obj = section.getAttribute(ns, prop); final Object value = propertyValues.get(j); - if ( obj == null && value == null) + if (obj == null && value == null) + { continue; + } if (!propertyValues.get(j).equals(obj)) + { break; } - if ( j == propertyName.size() ) + } + if (j == propertyName.size()) { return officeStyle; } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
