summaryrefslogtreecommitdiff
path: root/reportbuilder
diff options
context:
space:
mode:
Diffstat (limited to 'reportbuilder')
-rw-r--r--reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/AbstractReportElementLayoutController.java132
-rw-r--r--reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FixedTextLayoutController.java2
-rw-r--r--reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FormatValueUtility.java132
-rw-r--r--reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FormattedTextLayoutController.java4
-rw-r--r--reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ImageElementLayoutController.java4
-rw-r--r--reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ObjectOleLayoutController.java2
-rw-r--r--reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/TableCellLayoutController.java38
-rw-r--r--reportbuilder/java/com/sun/star/report/pentaho/model/ReportElement.java10
-rw-r--r--reportbuilder/java/com/sun/star/report/pentaho/parser/rpt-schema-v1.0-os.xsd2
-rw-r--r--reportbuilder/java/com/sun/star/report/pentaho/parser/rpt/FormattedTextReadHandler.java2
-rw-r--r--reportbuilder/java/com/sun/star/report/pentaho/parser/rpt/ReportElementReadHandler.java4
11 files changed, 182 insertions, 150 deletions
diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/AbstractReportElementLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/AbstractReportElementLayoutController.java
index dfa7f16863a6..83c572a2591b 100644
--- a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/AbstractReportElementLayoutController.java
+++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/AbstractReportElementLayoutController.java
@@ -78,106 +78,19 @@ public abstract class AbstractReportElementLayoutController
throw new IllegalStateException();
}
- boolean isPrintableContent = true;
- final ReportElement text = (ReportElement) getNode();
- // Tests we have to perform:
- // 1. Print when group changes. We can know whether a group changed by
- // looking at the newly introduced iteration counter.
- //
- // Whether we use the next one or the one after that depends on whether
- // this element is a child of a group-header or group-footer.
-
- // 2. Print repeated values. This never applies to static text or static
- // elements.
- if ((text.isPrintWhenGroupChanges() && !isGroupChanged()) || (!text.isPrintRepeatedValues() && !isValueChanged()))
- {
- // if this is set to true, then we print the element only if this is the
- // first occurrence in this group.
- // or
- // If this is set to true, we evaluate the formula of the element and
- // try to derive whether there was a change.
- isPrintableContent = false;
- }
-
- // 3. Evaluate the Display Condition
- final Expression dc = text.getDisplayCondition();
- if (dc != null)
- {
- final Object o = LayoutControllerUtil.evaluateExpression(getFlowController(), text, dc);
- if (Boolean.FALSE.equals(o))
- {
-// LOGGER.debug ("DISPLAY Condition forbids printing");
- isPrintableContent = false;
- }
- }
-
- if (!isPrintableContent)
- {
- // There is no printable content at all. Set the state to FINISHED
- return join(getFlowController());
- }
- else
+ if (FormatValueUtility.shouldPrint(this, (ReportElement)getNode()))
{
// delegate to the handler ..
return delegateContentGeneration(target);
}
-
- }
-
- protected abstract boolean isValueChanged();
-
- protected boolean isGroupChanged()
- {
- // search the group.
- final SectionLayoutController slc = findGroup();
- if (slc == null)
+ else
{
- // Always print the content of the report header and footer and
- // the page header and footer.
- return true;
+ // There is no printable content at all. Set the state to FINISHED
+ return join(getFlowController());
}
-
- // we are in the first iteration, so yes, the group has changed recently.
- return slc.getIterationCount() == 0;
}
- private SectionLayoutController findGroup()
- {
- LayoutController parent = getParent();
- boolean skipNext = false;
- while (parent != null)
- {
- if (!(parent instanceof SectionLayoutController))
- {
- parent = parent.getParent();
- }
- else
- {
- final SectionLayoutController slc = (SectionLayoutController) parent;
- final Element element = slc.getElement();
- if (element instanceof OfficeGroupSection)
- {
- // This is a header or footer. So we take the next group instead.
- skipNext = true;
- parent = parent.getParent();
- }
- else if (!(element instanceof Group))
- {
- parent = parent.getParent();
- }
- else if (skipNext)
- {
- skipNext = false;
- parent = parent.getParent();
- }
- else
- {
- return (SectionLayoutController) parent;
- }
- }
- }
- return null;
- }
+ public abstract boolean isValueChanged();
/**
* Joins with a delegated process flow. This is generally called from a child
@@ -213,41 +126,6 @@ public abstract class AbstractReportElementLayoutController
return state != AbstractReportElementLayoutController.FINISHED;
}
- protected boolean isReferenceChanged(final LValue lValue)
- {
- if (lValue instanceof ContextLookup)
- {
- final ContextLookup rval = (ContextLookup) lValue;
- final String s = rval.getName();
- final DataRow view = getFlowController().getMasterRow().getGlobalView();
- try
- {
- final DataFlags flags = view.getFlags(s);
- if (flags != null && flags.isChanged())
- {
-// LOGGER.debug ("Reference " + s + " is changed");
- return true;
- }
-// LOGGER.debug ("Reference " + s + " is unchanged");
- }
- catch (DataSourceException e)
- {
- // ignore .. assume that the reference has not changed.
- }
- }
- final LValue[] childValues = lValue.getChildValues();
- for (int i = 0; i < childValues.length; i++)
- {
- final LValue value = childValues[i];
- if (isReferenceChanged(value))
- {
- return true;
- }
- }
-// LOGGER.debug ("Unchanged.");
- return false;
- }
-
public int getState()
{
return state;
diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FixedTextLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FixedTextLayoutController.java
index 07070164de3e..2dd554e0543e 100644
--- a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FixedTextLayoutController.java
+++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FixedTextLayoutController.java
@@ -49,7 +49,7 @@ public class FixedTextLayoutController
{
}
- protected boolean isValueChanged()
+ public boolean isValueChanged()
{
final FlowController controller = getFlowController();
final GlobalMasterRow masterRow = controller.getMasterRow();
diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FormatValueUtility.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FormatValueUtility.java
index ddb3b04fb7d1..99ff3e5fcf27 100644
--- a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FormatValueUtility.java
+++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FormatValueUtility.java
@@ -21,6 +21,8 @@ package com.sun.star.report.pentaho.layoutprocessor;
import com.sun.star.report.OfficeToken;
import com.sun.star.report.pentaho.OfficeNamespaces;
import com.sun.star.report.pentaho.model.FormattedTextElement;
+import com.sun.star.report.pentaho.model.OfficeGroupSection;
+import com.sun.star.report.pentaho.model.ReportElement;
import java.math.BigDecimal;
import java.sql.Time;
@@ -31,12 +33,20 @@ import java.util.Date;
import org.jfree.layouting.util.AttributeMap;
import org.jfree.report.DataFlags;
+import org.jfree.report.DataRow;
import org.jfree.report.DataSourceException;
import org.jfree.report.data.DefaultDataFlags;
+import org.jfree.report.expressions.Expression;
import org.jfree.report.expressions.FormulaExpression;
import org.jfree.report.flow.FlowController;
+import org.jfree.report.flow.layoutprocessor.LayoutController;
import org.jfree.report.flow.layoutprocessor.LayoutControllerUtil;
+import org.jfree.report.flow.layoutprocessor.SectionLayoutController;
+import org.jfree.report.structure.Element;
+import org.jfree.report.structure.Group;
+import org.pentaho.reporting.libraries.formula.lvalues.ContextLookup;
+import org.pentaho.reporting.libraries.formula.lvalues.LValue;
import org.pentaho.reporting.libraries.formula.util.HSSFDateUtil;
/**
@@ -228,4 +238,126 @@ public class FormatValueUtility
return new DefaultDataFlags(null, result, true);
}
}
+
+ public static boolean shouldPrint(final LayoutController ref, final ReportElement text)
+ throws DataSourceException
+ {
+ final boolean isValueChanged;
+ if (ref instanceof AbstractReportElementLayoutController)
+ isValueChanged=((AbstractReportElementLayoutController)ref).isValueChanged();
+ else if (ref instanceof TableCellLayoutController)
+ isValueChanged=((TableCellLayoutController)ref).isValueChanged();
+ else
+ throw new AssertionError("com.sun.star.report.pentaho.layoutprocessor.FormatValueUtility.shouldPrint expects an implementor of isValueChanged as first argument");
+
+ // Tests we have to perform:
+ // 1. If repeated values are supposed to be printed, then print.
+ // (this is always the case for static text and static elements)
+ // 2. If value changed, then print.
+ // 3. If (printing should be forced on group change AND group changed), then print
+ if ( !( isValueChanged
+ || text.isPrintRepeatedValues()
+ || ( text.isPrintWhenGroupChange() && isGroupChanged(ref) )))
+ {
+ return false;
+ }
+
+ final Expression dc = text.getDisplayCondition();
+ if (dc != null)
+ {
+ final Object o = LayoutControllerUtil.evaluateExpression(ref.getFlowController(), text, dc);
+ if (Boolean.FALSE.equals(o))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public static boolean isGroupChanged(LayoutController ref)
+ {
+ // search the group.
+ final SectionLayoutController slc = findGroup(ref);
+ if (slc == null)
+ {
+ // Always print the content of the report header and footer and
+ // the page header and footer.
+ return true;
+ }
+
+ // we are in the first iteration, so yes, the group has changed recently.
+ return slc.getIterationCount() == 0;
+ }
+
+ public static SectionLayoutController findGroup(LayoutController ref)
+ {
+ LayoutController parent = ref.getParent();
+ boolean skipNext = false;
+ while (parent != null)
+ {
+ if (!(parent instanceof SectionLayoutController))
+ {
+ parent = parent.getParent();
+ }
+ else
+ {
+ final SectionLayoutController slc = (SectionLayoutController) parent;
+ final Element element = slc.getElement();
+ if (element instanceof OfficeGroupSection)
+ {
+ // This is a header or footer. So we take the next group instead.
+ skipNext = true;
+ parent = parent.getParent();
+ }
+ else if (!(element instanceof Group))
+ {
+ parent = parent.getParent();
+ }
+ else if (skipNext)
+ {
+ skipNext = false;
+ parent = parent.getParent();
+ }
+ else
+ {
+ return (SectionLayoutController) parent;
+ }
+ }
+ }
+ return null;
+ }
+
+ public static boolean isReferenceChanged(LayoutController ref, final LValue lValue)
+ {
+ if (lValue instanceof ContextLookup)
+ {
+ final ContextLookup rval = (ContextLookup) lValue;
+ final String s = rval.getName();
+ final DataRow view = ref.getFlowController().getMasterRow().getGlobalView();
+ try
+ {
+ final DataFlags flags = view.getFlags(s);
+ if (flags != null && flags.isChanged())
+ {
+ return true;
+ }
+ }
+ catch (DataSourceException e)
+ {
+ // ignore .. assume that the reference has not changed.
+ }
+ }
+ final LValue[] childValues = lValue.getChildValues();
+ for (int i = 0; i < childValues.length; i++)
+ {
+ final LValue value = childValues[i];
+ if (isReferenceChanged(ref, value))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
}
diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FormattedTextLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FormattedTextLayoutController.java
index db8c1ffeff15..ea3d22bc169c 100644
--- a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FormattedTextLayoutController.java
+++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/FormattedTextLayoutController.java
@@ -78,7 +78,7 @@ public class FormattedTextLayoutController
return null;
}
- protected boolean isValueChanged()
+ public boolean isValueChanged()
{
try
{
@@ -86,7 +86,7 @@ public class FormattedTextLayoutController
final FormulaExpression formulaExpression = element.getValueExpression();
final Formula formula = formulaExpression.getCompiledFormula();
final LValue lValue = formula.getRootReference();
- return isReferenceChanged(lValue);
+ return FormatValueUtility.isReferenceChanged(this, lValue);
}
catch (final ParseException e)
{
diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ImageElementLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ImageElementLayoutController.java
index e164bb367b60..a32073e13224 100644
--- a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ImageElementLayoutController.java
+++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ImageElementLayoutController.java
@@ -230,7 +230,7 @@ public class ImageElementLayoutController
return null;
}
- protected boolean isValueChanged()
+ public boolean isValueChanged()
{
final ImageElement imageElement = (ImageElement) getNode();
final FormulaExpression formulaExpression = imageElement.getFormula();
@@ -246,7 +246,7 @@ public class ImageElementLayoutController
{
final Formula formula = formulaExpression.getCompiledFormula();
final LValue lValue = formula.getRootReference();
- return isReferenceChanged(lValue);
+ return FormatValueUtility.isReferenceChanged(this, lValue);
}
catch (ParseException e)
{
diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ObjectOleLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ObjectOleLayoutController.java
index a762ee1667fe..4dbac0fae730 100644
--- a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ObjectOleLayoutController.java
+++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/ObjectOleLayoutController.java
@@ -44,7 +44,7 @@ public class ObjectOleLayoutController extends AbstractReportElementLayoutContro
{
}
- protected boolean isValueChanged()
+ public boolean isValueChanged()
{
final ObjectOleElement element = (ObjectOleElement) getNode();
final List masterfields = element.getMasterfields();
diff --git a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/TableCellLayoutController.java b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/TableCellLayoutController.java
index bb1af2f6644f..148909876471 100644
--- a/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/TableCellLayoutController.java
+++ b/reportbuilder/java/com/sun/star/report/pentaho/layoutprocessor/TableCellLayoutController.java
@@ -27,6 +27,7 @@ import org.jfree.layouting.util.AttributeMap;
import org.jfree.report.DataFlags;
import org.jfree.report.DataSourceException;
import org.jfree.report.expressions.Expression;
+import org.jfree.report.expressions.FormulaExpression;
import org.jfree.report.flow.FlowController;
import org.jfree.report.flow.ReportTarget;
import org.jfree.report.flow.layoutprocessor.LayoutControllerUtil;
@@ -34,6 +35,9 @@ import org.jfree.report.flow.layoutprocessor.SectionLayoutController;
import org.jfree.report.structure.Element;
import org.jfree.report.structure.Node;
import org.jfree.report.structure.Section;
+import org.pentaho.reporting.libraries.formula.Formula;
+import org.pentaho.reporting.libraries.formula.lvalues.LValue;
+import org.pentaho.reporting.libraries.formula.parser.ParseException;
import org.pentaho.reporting.libraries.base.util.ObjectUtilities;
@@ -99,18 +103,36 @@ public class TableCellLayoutController extends SectionLayoutController
{
return null;
}
- final Expression dc = element.getDisplayCondition();
- if (dc != null)
+ if (!FormatValueUtility.shouldPrint(this, element))
{
- final Object o = LayoutControllerUtil.evaluateExpression(getFlowController(), element, dc);
- if (Boolean.FALSE.equals(o))
+ attributeMap.setAttribute(OfficeNamespaces.OFFICE_NS,
+ FormatValueUtility.VALUE_TYPE, "string");
+ return null;
+ }
+ return FormatValueUtility.computeDataFlag(element, getFlowController());
+ }
+
+ public boolean isValueChanged()
+ {
+ try
+ {
+ final Section cell = (Section) getElement();
+ final FormattedTextElement element = findFormattedTextElement(cell);
+ if (element == null)
+ return false;
+ else
{
- attributeMap.setAttribute(OfficeNamespaces.OFFICE_NS,
- FormatValueUtility.VALUE_TYPE, "string");
- return null;
+ final FormulaExpression formulaExpression = element.getValueExpression();
+ final Formula formula = formulaExpression.getCompiledFormula();
+ final LValue lValue = formula.getRootReference();
+ return FormatValueUtility.isReferenceChanged(this, lValue);
}
}
- return FormatValueUtility.computeDataFlag(element, getFlowController());
+ catch (final ParseException e)
+ {
+ //LOGGER.debug("Parse Exception", e);
+ return false;
+ }
}
private FormattedTextElement findFormattedTextElement(final Section section)
diff --git a/reportbuilder/java/com/sun/star/report/pentaho/model/ReportElement.java b/reportbuilder/java/com/sun/star/report/pentaho/model/ReportElement.java
index 74e48229bd84..37e11ffc0637 100644
--- a/reportbuilder/java/com/sun/star/report/pentaho/model/ReportElement.java
+++ b/reportbuilder/java/com/sun/star/report/pentaho/model/ReportElement.java
@@ -49,15 +49,15 @@ public abstract class ReportElement extends Element
* @return true, if the element should only be printed in the first row of the
* current group, false otherwise.
*/
- public boolean isPrintWhenGroupChanges()
+ public boolean isPrintWhenGroupChange()
{
- return OfficeToken.TRUE.equals(getAttribute(OfficeNamespaces.OOREPORT_NS, "print-when-group-changes"));
+ return OfficeToken.TRUE.equals(getAttribute(OfficeNamespaces.OOREPORT_NS, "print-when-group-change"));
}
- public void setPrintWhenGroupChanges(final boolean printWhenGroupChanges)
+ public void setPrintWhenGroupChange(final boolean printWhenGroupChange)
{
- setAttribute(OfficeNamespaces.OOREPORT_NS, "print-when-group-changes",
- String.valueOf(printWhenGroupChanges));
+ setAttribute(OfficeNamespaces.OOREPORT_NS, "print-when-group-change",
+ String.valueOf(printWhenGroupChange));
}
/**
diff --git a/reportbuilder/java/com/sun/star/report/pentaho/parser/rpt-schema-v1.0-os.xsd b/reportbuilder/java/com/sun/star/report/pentaho/parser/rpt-schema-v1.0-os.xsd
index 0acba65c323d..4c296ac7a75f 100644
--- a/reportbuilder/java/com/sun/star/report/pentaho/parser/rpt-schema-v1.0-os.xsd
+++ b/reportbuilder/java/com/sun/star/report/pentaho/parser/rpt-schema-v1.0-os.xsd
@@ -330,7 +330,7 @@
</xs:complexType>
</xs:element>
<xs:attributeGroup name="rpt-report-element-attlist">
- <xs:attribute name="print-when-group-change" default="false" form="qualified">
+ <xs:attribute name="print-when-group-change" default="true" form="qualified">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="true"/>
diff --git a/reportbuilder/java/com/sun/star/report/pentaho/parser/rpt/FormattedTextReadHandler.java b/reportbuilder/java/com/sun/star/report/pentaho/parser/rpt/FormattedTextReadHandler.java
index 94b8f21d60f3..0ed48ca586d9 100644
--- a/reportbuilder/java/com/sun/star/report/pentaho/parser/rpt/FormattedTextReadHandler.java
+++ b/reportbuilder/java/com/sun/star/report/pentaho/parser/rpt/FormattedTextReadHandler.java
@@ -64,7 +64,7 @@ public class FormattedTextReadHandler extends ElementReadHandler
// * Print-Repeated-Values
// * Print-In-First-New-Section
- // * Print-When-Group-Changes
+ // * Print-When-Group-Change
// * Print-When-Section-Overflows
// That property cannot be evaluated yet, as this would require us to
diff --git a/reportbuilder/java/com/sun/star/report/pentaho/parser/rpt/ReportElementReadHandler.java b/reportbuilder/java/com/sun/star/report/pentaho/parser/rpt/ReportElementReadHandler.java
index 7d0e735f4ae2..d7adf8631d9c 100644
--- a/reportbuilder/java/com/sun/star/report/pentaho/parser/rpt/ReportElementReadHandler.java
+++ b/reportbuilder/java/com/sun/star/report/pentaho/parser/rpt/ReportElementReadHandler.java
@@ -60,8 +60,8 @@ public class ReportElementReadHandler extends ElementReadHandler
throws SAXException
{
super.startParsing(attrs);
- final String printWhenGroupChanges = attrs.getValue(OfficeNamespaces.OOREPORT_NS, "print-when-group-changes");
- element.setPrintWhenGroupChanges(OfficeToken.TRUE.equals(printWhenGroupChanges));
+ final String printWhenGroupChange = attrs.getValue(OfficeNamespaces.OOREPORT_NS, "print-when-group-change");
+ element.setPrintWhenGroupChange(OfficeToken.TRUE.equals(printWhenGroupChange));
final String printRepeatingValues = attrs.getValue(OfficeNamespaces.OOREPORT_NS, "print-repeated-values");
element.setPrintRepeatedValues(printRepeatingValues == null || OfficeToken.TRUE.equals(printRepeatingValues));
}