summaryrefslogtreecommitdiff
path: root/reportdesign/java
diff options
context:
space:
mode:
authorRüdiger Timm <rt@openoffice.org>2008-07-10 14:53:52 +0000
committerRüdiger Timm <rt@openoffice.org>2008-07-10 14:53:52 +0000
commitceab8b22190b85d996c053bed5c545a408410160 (patch)
tree79b57f45b293fa5585bab12e214d6979633e7977 /reportdesign/java
parent3bc0e518c6cfab035ca1bb61246c169b20e0038e (diff)
INTEGRATION: CWS rptfix02 (1.8.18); FILE MERGED
2008/07/03 11:12:34 oj 1.8.18.1: #i91016# also export style referenced by apply-style-name
Diffstat (limited to 'reportdesign/java')
-rw-r--r--reportdesign/java/com/sun/star/report/pentaho/output/StyleUtilities.java120
1 files changed, 75 insertions, 45 deletions
diff --git a/reportdesign/java/com/sun/star/report/pentaho/output/StyleUtilities.java b/reportdesign/java/com/sun/star/report/pentaho/output/StyleUtilities.java
index 9ae5e68cb486..1697e3eeee71 100644
--- a/reportdesign/java/com/sun/star/report/pentaho/output/StyleUtilities.java
+++ b/reportdesign/java/com/sun/star/report/pentaho/output/StyleUtilities.java
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: StyleUtilities.java,v $
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
* This file is part of OpenOffice.org.
*
@@ -42,6 +42,7 @@ import java.util.ArrayList;
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 @@ public class StyleUtilities
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 @@ public class StyleUtilities
currentFonts.addFontFace((FontFaceElement) element.clone());
}
}
- }
- catch (CloneNotSupportedException e)
+ } catch (CloneNotSupportedException e)
{
throw new ReportProcessingException("Failed to clone font-face element");
}
@@ -259,49 +258,75 @@ public class StyleUtilities
final OfficeStylesCollection predefCollection)
throws ReportProcessingException
{
- final Object attribute = style.getAttribute(OfficeNamespaces.STYLE_NS, "data-style-name");
- if (attribute == null)
- {
- // the easy case: It has no number style at all.
- return;
- }
-
- final String styleName = String.valueOf(attribute);
- if (stylesCollection.getAutomaticStyles().containsDataStyle(styleName))
- {
- return;
- }
- if (stylesCollection.getCommonStyles().containsDataStyle(styleName))
+ final Section derivedStyle = performDataStyleProcessing(style, stylesCollection, predefCollection, "data-style-name");
+ if (derivedStyle != null)
{
- return;
+ try
+ {
+ final Section styleMap = (Section) derivedStyle.findFirstChild(OfficeNamespaces.STYLE_NS,"map");
+ if (styleMap != null)
+ {
+ performDataStyleProcessing(styleMap, stylesCollection, predefCollection, "apply-style-name");
+ }
+ } catch (Exception e)
+ {
+ }
}
+ }
-
- try
+ 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 OfficeStyles automaticStyles = predefCollection.getAutomaticStyles();
- final DataStyle autoDataStyle = automaticStyles.getDataStyle(styleName);
- if (autoDataStyle != null)
+ final String styleName = String.valueOf(attribute);
+ if (!stylesCollection.getAutomaticStyles().containsDataStyle(styleName) &&
+ !stylesCollection.getCommonStyles().containsDataStyle(styleName))
{
- final DataStyle derivedStyle = (DataStyle) autoDataStyle.clone();
- stylesCollection.getAutomaticStyles().addDataStyle(derivedStyle);
- return;
+ try
+ {
+ final OfficeStyles automaticStyles = predefCollection.getAutomaticStyles();
+ final DataStyle autoDataStyle = automaticStyles.getDataStyle(styleName);
+ if (autoDataStyle != null)
+ {
+ derivedStyle = (DataStyle) autoDataStyle.clone();
+ stylesCollection.getAutomaticStyles().addDataStyle(derivedStyle);
+ }
+ else
+ {
+ final OfficeStyles commonStyles = predefCollection.getCommonStyles();
+ final DataStyle commonDataStyle = commonStyles.getDataStyle(styleName);
+ if (commonDataStyle != null)
+ {
+ derivedStyle = (DataStyle) commonDataStyle.clone();
+ stylesCollection.getCommonStyles().addDataStyle(derivedStyle);
+ }
+ else
+ {
+ Log.warn("Dangling data style: " + styleName);
+ derivedStyle = null;
+ }
+ }
+ } catch (CloneNotSupportedException e)
+ {
+ throw new ReportProcessingException("Failed to copy style. This should not have happened.");
+ }
}
- final OfficeStyles commonStyles = predefCollection.getCommonStyles();
- final DataStyle commonDataStyle = commonStyles.getDataStyle(styleName);
- if (commonDataStyle != null)
+ else
{
- final DataStyle derivedStyle = (DataStyle) commonDataStyle.clone();
- stylesCollection.getCommonStyles().addDataStyle(derivedStyle);
- return;
+ derivedStyle = null;
}
-
- Log.warn("Dangling data style: " + styleName);
}
- catch (CloneNotSupportedException e)
+ else
{
- throw new ReportProcessingException("Failed to copy style. This should not have happened.");
+ derivedStyle = null;
}
+ return derivedStyle;
}
/**
@@ -482,8 +507,7 @@ public class StyleUtilities
predefCollection);
}
return autostyle;
- }
- catch (CloneNotSupportedException e)
+ } catch (CloneNotSupportedException e)
{
throw new ReportProcessingException(
"Deriving the style failed. Clone error: ", e);
@@ -508,13 +532,15 @@ public class StyleUtilities
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 @@ public class StyleUtilities
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;
}