summaryrefslogtreecommitdiff
path: root/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt
diff options
context:
space:
mode:
Diffstat (limited to 'reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt')
-rw-r--r--reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/ConditionalPrintExpressionReadHandler.java71
-rw-r--r--reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/DetailRootTableReadHandler.java29
-rw-r--r--reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/FixedContentReadHandler.java88
-rw-r--r--reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/FormatConditionReadHandler.java90
-rw-r--r--reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/FormattedTextReadHandler.java108
-rw-r--r--reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/FunctionReadHandler.java106
-rw-r--r--reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/GroupReadHandler.java172
-rw-r--r--reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/GroupSectionReadHandler.java29
-rw-r--r--reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/ImageReadHandler.java131
-rw-r--r--reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/MasterDetailReadHandler.java96
-rw-r--r--reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/ReportElementReadHandler.java100
-rw-r--r--reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/ReportReadHandler.java232
-rw-r--r--reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/RootTableReadHandler.java96
-rw-r--r--reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/SubDocumentReadHandler.java124
14 files changed, 1472 insertions, 0 deletions
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/ConditionalPrintExpressionReadHandler.java b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/ConditionalPrintExpressionReadHandler.java
new file mode 100644
index 000000000000..a15f1610e770
--- /dev/null
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/ConditionalPrintExpressionReadHandler.java
@@ -0,0 +1,71 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+package org.libreoffice.report.pentaho.parser.rpt;
+
+import org.libreoffice.report.pentaho.OfficeNamespaces;
+
+import org.jfree.report.expressions.FormulaFunction;
+import org.jfree.report.structure.Element;
+
+import org.pentaho.reporting.libraries.xmlns.parser.AbstractXmlReadHandler;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * Handles the 'report:conditional-print-expression' element that can appear
+ * in all report elements and all root-level sections.
+ *
+ * @since 02.03.2007
+ */
+public class ConditionalPrintExpressionReadHandler
+ extends AbstractXmlReadHandler
+{
+
+ private final Element element;
+
+ public ConditionalPrintExpressionReadHandler(final Element element)
+ {
+ this.element = element;
+ }
+
+ protected void startParsing(final Attributes attrs) throws SAXException
+ {
+ super.startParsing(attrs);
+ final String formula = attrs.getValue(OfficeNamespaces.OOREPORT_NS, "formula");
+ if (formula != null)
+ {
+ final FormulaFunction valueExpression = new FormulaFunction();
+ valueExpression.setFormula(formula);
+ element.setDisplayCondition(valueExpression);
+ }
+
+ }
+
+ /**
+ * 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 element;
+ }
+}
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/DetailRootTableReadHandler.java b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/DetailRootTableReadHandler.java
new file mode 100644
index 000000000000..2a0677065ecc
--- /dev/null
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/DetailRootTableReadHandler.java
@@ -0,0 +1,29 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+package org.libreoffice.report.pentaho.parser.rpt;
+
+import org.libreoffice.report.pentaho.model.OfficeDetailSection;
+
+public class DetailRootTableReadHandler extends RootTableReadHandler
+{
+
+ public DetailRootTableReadHandler()
+ {
+ super(new OfficeDetailSection());
+ }
+}
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/FixedContentReadHandler.java b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/FixedContentReadHandler.java
new file mode 100644
index 000000000000..ab0fc52b1fee
--- /dev/null
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/FixedContentReadHandler.java
@@ -0,0 +1,88 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+package org.libreoffice.report.pentaho.parser.rpt;
+
+import org.libreoffice.report.OfficeToken;
+import org.libreoffice.report.pentaho.OfficeNamespaces;
+import org.libreoffice.report.pentaho.model.FixedTextElement;
+import org.libreoffice.report.pentaho.parser.ElementReadHandler;
+import org.libreoffice.report.pentaho.parser.text.TextContentReadHandler;
+
+import org.jfree.report.structure.Element;
+
+import org.pentaho.reporting.libraries.xmlns.parser.IgnoreAnyChildReadHandler;
+import org.pentaho.reporting.libraries.xmlns.parser.XmlReadHandler;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * Creation-Date: 01.10.2006, 18:48:11
+ *
+ */
+public class FixedContentReadHandler extends ElementReadHandler
+{
+
+ private final FixedTextElement element;
+
+ public FixedContentReadHandler()
+ {
+ element = new FixedTextElement();
+ }
+
+ /**
+ * Returns the handler for a child element.
+ *
+ * @param tagName the tag name.
+ * @param atts the attributes.
+ * @return the handler or null, if the tagname is invalid.
+ * @throws org.xml.sax.SAXException if there is a parsing error.
+ */
+ protected XmlReadHandler getHandlerForChild(final String uri,
+ final String tagName,
+ final Attributes atts)
+ throws SAXException
+ {
+ if (OfficeNamespaces.TEXT_NS.equals(uri) && OfficeToken.P.equals(tagName))
+ {
+ // expect a paragraph (which will be ignored; it is a structural
+ // component that needs not to be printed at all.
+ return new TextContentReadHandler(element.getContent());
+ }
+
+ if (OfficeNamespaces.OOREPORT_NS.equals(uri))
+ {
+ // expect a report control. The control will modifiy the current
+ // element (as we do not separate the elements that strictly ..)
+ if ("report-control".equals(tagName))
+ {
+ return new IgnoreAnyChildReadHandler();
+ }
+ if ("report-element".equals(tagName))
+ {
+ return new ReportElementReadHandler(element);
+ }
+ }
+ return null;
+ }
+
+ public Element getElement()
+ {
+ return element;
+ }
+}
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/FormatConditionReadHandler.java b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/FormatConditionReadHandler.java
new file mode 100644
index 000000000000..cb3fa0a96039
--- /dev/null
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/FormatConditionReadHandler.java
@@ -0,0 +1,90 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+package org.libreoffice.report.pentaho.parser.rpt;
+
+import org.libreoffice.report.OfficeToken;
+import org.libreoffice.report.pentaho.OfficeNamespaces;
+import org.libreoffice.report.pentaho.model.FormatCondition;
+import org.libreoffice.report.pentaho.model.ReportElement;
+
+import org.jfree.report.expressions.FormulaExpression;
+
+import org.pentaho.reporting.libraries.xmlns.parser.AbstractXmlReadHandler;
+import org.pentaho.reporting.libraries.xmlns.parser.ParseException;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * I'm quite sure I should parse something here. But what?
+ *
+ */
+public class FormatConditionReadHandler extends AbstractXmlReadHandler
+{
+
+ private final ReportElement element;
+
+ public FormatConditionReadHandler(final ReportElement element)
+ {
+ if (element == null)
+ {
+ throw new NullPointerException();
+ }
+ this.element = element;
+ }
+
+ protected void startParsing(final Attributes attrs) throws SAXException
+ {
+ super.startParsing(attrs);
+
+
+ final String formula =
+ attrs.getValue(OfficeNamespaces.OOREPORT_NS, "formula");
+ if (formula == null)
+ {
+ throw new ParseException("Required attribute 'formula' is missing.", getLocator());
+ }
+ final String stylename =
+ attrs.getValue(OfficeNamespaces.OOREPORT_NS, OfficeToken.STYLE_NAME);
+ if (stylename == null)
+ {
+ throw new ParseException("Required attribute 'style-name' is missing.", getLocator());
+ }
+ final FormulaExpression valueExpression = new FormulaExpression();
+ valueExpression.setFormula(formula);
+
+ final String enabledText = attrs.getValue(OfficeNamespaces.OOREPORT_NS, "enabled");
+ final boolean enabled = (enabledText == null || OfficeToken.TRUE.equals(enabledText));
+ final FormatCondition formatCondition =
+ new FormatCondition(valueExpression, stylename, enabled);
+ element.addFormatCondition(formatCondition);
+
+ }
+
+ /**
+ * 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 element;
+ }
+}
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/FormattedTextReadHandler.java b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/FormattedTextReadHandler.java
new file mode 100644
index 000000000000..a1408d20dd52
--- /dev/null
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/FormattedTextReadHandler.java
@@ -0,0 +1,108 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+package org.libreoffice.report.pentaho.parser.rpt;
+
+import org.libreoffice.report.pentaho.OfficeNamespaces;
+import org.libreoffice.report.pentaho.model.FormattedTextElement;
+import org.libreoffice.report.pentaho.parser.ElementReadHandler;
+
+import org.jfree.report.expressions.FormulaExpression;
+import org.jfree.report.structure.Element;
+
+import org.pentaho.reporting.libraries.xmlns.parser.IgnoreAnyChildReadHandler;
+import org.pentaho.reporting.libraries.xmlns.parser.XmlReadHandler;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * Creation-Date: 01.10.2006, 19:06:45
+ *
+ */
+public class FormattedTextReadHandler extends ElementReadHandler
+{
+
+ private final FormattedTextElement element;
+
+ public FormattedTextReadHandler()
+ {
+ element = new FormattedTextElement();
+ }
+
+ /**
+ * 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
+ {
+ super.startParsing(attrs);
+
+ final String formula = attrs.getValue(OfficeNamespaces.OOREPORT_NS, "formula");
+ if (formula != null)
+ {
+ final FormulaExpression valueExpression = new FormulaExpression();
+ valueExpression.setFormula(formula);
+ element.setValueExpression(valueExpression);
+ }
+
+ // * Print-Repeated-Values
+ // * Print-In-First-New-Section
+ // * Print-When-Group-Change
+
+ // * Print-When-Section-Overflows
+ // That property cannot be evaluated yet, as this would require us to
+ // have a clue about pagebreaking. We dont have that - not yet and never
+ // in the future, as pagebreaks are computed by OpenOffice instead
+ }
+
+ /**
+ * Returns the handler for a child element.
+ *
+ * @param tagName the tag name.
+ * @param atts the attributes.
+ * @return the handler or null, if the tagname is invalid.
+ * @throws org.xml.sax.SAXException if there is a parsing error.
+ */
+ protected XmlReadHandler getHandlerForChild(final String uri,
+ final String tagName,
+ final Attributes atts)
+ throws SAXException
+ {
+ if (OfficeNamespaces.OOREPORT_NS.equals(uri))
+ {
+ // expect a report control. The control will modifiy the current
+ // element (as we do not separate the elements that strictly ..)
+ if ("report-control".equals(tagName))
+ {
+ return new IgnoreAnyChildReadHandler();
+ }
+ if ("report-element".equals(tagName))
+ {
+ return new ReportElementReadHandler(element);
+ }
+ }
+ return null;
+ }
+
+ public Element getElement()
+ {
+ return element;
+ }
+}
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/FunctionReadHandler.java b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/FunctionReadHandler.java
new file mode 100644
index 000000000000..b1352d20c909
--- /dev/null
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/FunctionReadHandler.java
@@ -0,0 +1,106 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+package org.libreoffice.report.pentaho.parser.rpt;
+
+import org.libreoffice.report.OfficeToken;
+import org.libreoffice.report.pentaho.OfficeNamespaces;
+
+import org.jfree.report.expressions.Expression;
+import org.jfree.report.expressions.FormulaExpression;
+import org.jfree.report.expressions.FormulaFunction;
+
+import org.pentaho.reporting.libraries.xmlns.parser.AbstractXmlReadHandler;
+import org.pentaho.reporting.libraries.xmlns.parser.ParseException;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * Parses a named expression. These expressions are encountered on reports and
+ * groups and compute global values. Expressions must have an unique name.
+ *
+ */
+public class FunctionReadHandler extends AbstractXmlReadHandler
+{
+
+ private Expression expression;
+
+ public FunctionReadHandler()
+ {
+ }
+
+ /**
+ * 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 formula = attrs.getValue(OfficeNamespaces.OOREPORT_NS, "formula");
+ if (formula == null)
+ {
+ throw new ParseException("Required attribute 'formula' is missing", getLocator());
+ }
+
+ final String name = attrs.getValue(OfficeNamespaces.OOREPORT_NS, "name");
+ if (name == null)
+ {
+ throw new ParseException("Required attribute 'name' is missing", getLocator());
+ }
+ final String initialFormula = attrs.getValue(OfficeNamespaces.OOREPORT_NS, "initial-formula");
+ final String deepTraversing = attrs.getValue(OfficeNamespaces.OOREPORT_NS, "deep-traversing");
+
+ if (initialFormula != null)
+ {
+ final FormulaFunction function = new FormulaFunction();
+ function.setInitial(initialFormula);
+ function.setFormula(formula);
+ this.expression = function;
+ }
+ else
+ {
+ final FormulaExpression expression = new FormulaExpression();
+ expression.setFormula(formula);
+ this.expression = expression;
+ }
+
+ expression.setName(name);
+ expression.setDeepTraversing(OfficeToken.TRUE.equals(deepTraversing));
+ final String preEvaluated = attrs.getValue(OfficeNamespaces.OOREPORT_NS, "pre-evaluated");
+ expression.setPrecompute(OfficeToken.TRUE.equals(preEvaluated));
+ }
+
+ /**
+ * 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 getExpression();
+ }
+
+ public Expression getExpression()
+ {
+ return expression;
+ }
+}
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/GroupReadHandler.java b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/GroupReadHandler.java
new file mode 100644
index 000000000000..22def36e179b
--- /dev/null
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/GroupReadHandler.java
@@ -0,0 +1,172 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+package org.libreoffice.report.pentaho.parser.rpt;
+
+import org.libreoffice.report.OfficeToken;
+import org.libreoffice.report.pentaho.OfficeNamespaces;
+import org.libreoffice.report.pentaho.model.OfficeGroup;
+import org.libreoffice.report.pentaho.model.OfficeGroupInstanceSection;
+import org.libreoffice.report.pentaho.parser.ElementReadHandler;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jfree.report.JFreeReportInfo;
+import org.jfree.report.expressions.FormulaExpression;
+import org.jfree.report.structure.Element;
+import org.jfree.report.structure.Section;
+
+import org.pentaho.reporting.libraries.xmlns.parser.XmlReadHandler;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+
+public class GroupReadHandler extends ElementReadHandler
+{
+
+ private GroupSectionReadHandler groupHeader;
+ private GroupSectionReadHandler groupFooter;
+ private GroupReadHandler childGroup;
+ private RootTableReadHandler detailSection;
+ private final OfficeGroup group;
+ private final OfficeGroupInstanceSection groupInstanceSection;
+ private final List<FunctionReadHandler> functionHandlers;
+ private final ReportReadHandler rh;
+
+ public GroupReadHandler(final ReportReadHandler _rh)
+ {
+ rh = _rh;
+ group = new OfficeGroup();
+ groupInstanceSection = new OfficeGroupInstanceSection();
+ groupInstanceSection.setNamespace(JFreeReportInfo.REPORT_NAMESPACE);
+ groupInstanceSection.setType("group-instance");
+ group.addNode(groupInstanceSection);
+ functionHandlers = new ArrayList<FunctionReadHandler>();
+ }
+
+ /**
+ * 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
+ {
+ super.startParsing(attrs);
+
+ final String groupExpr = attrs.getValue(OfficeNamespaces.OOREPORT_NS, "group-expression");
+ if (groupExpr != null && !"".equals(groupExpr))
+ {
+ final FormulaExpression function = new FormulaExpression();
+ function.setFormula(groupExpr);
+ groupInstanceSection.setGroupingExpression(function);
+ }
+ }
+
+ /**
+ * Returns the handler for a child element.
+ *
+ * @param tagName the tag name.
+ * @param atts the attributes.
+ * @return the handler or null, if the tagname is invalid.
+ * @throws org.xml.sax.SAXException if there is a parsing error.
+ */
+ protected XmlReadHandler getHandlerForChild(final String uri,
+ final String tagName,
+ final Attributes atts)
+ throws SAXException
+ {
+ if (!OfficeNamespaces.OOREPORT_NS.equals(uri))
+ {
+ return null;
+ }
+ if ("function".equals(tagName))
+ {
+ final FunctionReadHandler erh = new FunctionReadHandler();
+ functionHandlers.add(erh);
+ return erh;
+ }
+ if ("group-header".equals(tagName))
+ {
+ groupHeader = new GroupSectionReadHandler();
+ return groupHeader;
+ }
+ if ("group".equals(tagName))
+ {
+ childGroup = new GroupReadHandler(rh);
+ return childGroup;
+ }
+ if ("detail".equals(tagName))
+ {
+ detailSection = new DetailRootTableReadHandler();
+ rh.setDetail(detailSection);
+ return detailSection;
+ }
+ if ("group-footer".equals(tagName))
+ {
+ ((Element) ((Section) rh.getDetail().getElement()).getNode(0)).setAttribute(JFreeReportInfo.REPORT_NAMESPACE, "has-group-footer", OfficeToken.TRUE);
+ groupFooter = new GroupSectionReadHandler();
+ return groupFooter;
+ }
+ return null;
+ }
+
+ /**
+ * Done parsing.
+ *
+ * @throws org.xml.sax.SAXException if there is a parsing error.
+ */
+ protected void doneParsing() throws SAXException
+ {
+ for (int i = 0; i < functionHandlers.size(); i++)
+ {
+ final FunctionReadHandler handler = functionHandlers.get(i);
+ groupInstanceSection.addExpression(handler.getExpression());
+ }
+
+ if (groupHeader != null)
+ {
+ groupInstanceSection.addNode(groupHeader.getElement());
+ }
+
+ final Section groupBody = new Section();
+ groupBody.setNamespace(JFreeReportInfo.REPORT_NAMESPACE);
+ groupBody.setType("group-body");
+ groupInstanceSection.addNode(groupBody);
+ // XOR: Either the detail or the group section can be set ..
+ if (detailSection != null)
+ {
+ groupBody.addNode(detailSection.getElement());
+ }
+ else if (childGroup != null)
+ {
+ groupBody.addNode(childGroup.getElement());
+ }
+
+ if (groupFooter != null)
+ {
+ groupInstanceSection.addNode(groupFooter.getElement());
+ }
+ }
+
+ public Element getElement()
+ {
+ return group;
+ }
+}
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/GroupSectionReadHandler.java b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/GroupSectionReadHandler.java
new file mode 100644
index 000000000000..461cf67840f0
--- /dev/null
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/GroupSectionReadHandler.java
@@ -0,0 +1,29 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+package org.libreoffice.report.pentaho.parser.rpt;
+
+import org.libreoffice.report.pentaho.model.OfficeGroupSection;
+
+public class GroupSectionReadHandler extends RootTableReadHandler
+{
+
+ public GroupSectionReadHandler()
+ {
+ super(new OfficeGroupSection());
+ }
+}
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/ImageReadHandler.java b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/ImageReadHandler.java
new file mode 100644
index 000000000000..39f0d82326e6
--- /dev/null
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/ImageReadHandler.java
@@ -0,0 +1,131 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+package org.libreoffice.report.pentaho.parser.rpt;
+
+import org.libreoffice.report.OfficeToken;
+import org.libreoffice.report.pentaho.OfficeNamespaces;
+import org.libreoffice.report.pentaho.model.ImageElement;
+import org.libreoffice.report.pentaho.parser.ElementReadHandler;
+import org.libreoffice.report.pentaho.parser.xlink.XLinkReadHandler;
+
+import org.jfree.report.expressions.FormulaExpression;
+import org.jfree.report.structure.Element;
+
+import org.pentaho.reporting.libraries.xmlns.parser.IgnoreAnyChildReadHandler;
+import org.pentaho.reporting.libraries.xmlns.parser.XmlReadHandler;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * Deals with Image-content. There are two ways to specify the image;
+ * as formula or as static image data.
+ *
+ */
+public class ImageReadHandler extends ElementReadHandler
+{
+
+ private final ImageElement contentElement;
+ private XLinkReadHandler xLinkReadHandler;
+
+ public ImageReadHandler()
+ {
+ contentElement = new ImageElement();
+ }
+
+ /**
+ * 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
+ {
+ super.startParsing(attrs);
+ final String formula = attrs.getValue(OfficeNamespaces.OOREPORT_NS, "formula");
+// final String preserveIRI = attrs.getValue(OfficeNamespaces.OOREPORT_NS, OfficeToken.PRESERVE_IRI);
+ if (formula != null && formula.length() != 0)
+ {
+ // now, the evaulated content ends up in the 'content' attribute of the
+ // element.
+ final FormulaExpression valueExpression = new FormulaExpression();
+ valueExpression.setFormula(formula);
+ contentElement.setFormula(valueExpression);
+ }
+
+ contentElement.setNamespace(OfficeNamespaces.FORM_NS);
+ contentElement.setType(OfficeToken.IMAGE);
+ }
+
+ /**
+ * Returns the handler for a child element.
+ *
+ * @param tagName the tag name.
+ * @param atts the attributes.
+ * @return the handler or null, if the tagname is invalid.
+ * @throws org.xml.sax.SAXException if there is a parsing error.
+ */
+ protected XmlReadHandler getHandlerForChild(final String uri,
+ final String tagName,
+ final Attributes atts)
+ throws SAXException
+ {
+ if (OfficeNamespaces.DRAWING_NS.equals(uri) && OfficeToken.IMAGE_DATA.equals(tagName))
+ {
+ xLinkReadHandler = new XLinkReadHandler();
+ return xLinkReadHandler;
+ }
+
+ if (OfficeNamespaces.OOREPORT_NS.equals(uri))
+ {
+ // expect a report control. The control will modifiy the current
+ // element (as we do not separate the elements that strictly ..)
+ if ("report-control".equals(tagName))
+ {
+ return new IgnoreAnyChildReadHandler();
+ }
+ if ("report-element".equals(tagName))
+ {
+ return new ReportElementReadHandler(contentElement);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Done parsing.
+ *
+ * @throws org.xml.sax.SAXException if there is a parsing error.
+ */
+ protected void doneParsing() throws SAXException
+ {
+ // if we have static content (as well or only), that one goes into the
+ // alternate-content attribute right now. It is part of the output target
+ // and style rules to deal with them properly ..
+ if (xLinkReadHandler != null)
+ {
+ contentElement.setAttribute(OfficeNamespaces.OOREPORT_NS,
+ "alternate-content", xLinkReadHandler.getUri());
+ }
+ }
+
+ public Element getElement()
+ {
+ return contentElement;
+ }
+}
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/MasterDetailReadHandler.java b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/MasterDetailReadHandler.java
new file mode 100644
index 000000000000..7fe32ecc5d70
--- /dev/null
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/MasterDetailReadHandler.java
@@ -0,0 +1,96 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+package org.libreoffice.report.pentaho.parser.rpt;
+
+import org.libreoffice.report.pentaho.OfficeNamespaces;
+import org.libreoffice.report.pentaho.model.ObjectOleElement;
+import org.libreoffice.report.pentaho.parser.ElementReadHandler;
+
+import org.jfree.report.structure.Element;
+
+import org.pentaho.reporting.libraries.xmlns.parser.XmlReadHandler;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+public class MasterDetailReadHandler extends ElementReadHandler
+{
+
+ private final ObjectOleElement element;
+ private final boolean parseMasterDetail;
+
+ public MasterDetailReadHandler(final ObjectOleElement element)
+ {
+ this.element = element;
+ parseMasterDetail = false;
+ }
+
+ public MasterDetailReadHandler(final ObjectOleElement element, final boolean parseMasterDetail)
+ {
+ this.element = element;
+ this.parseMasterDetail = parseMasterDetail;
+ }
+
+ /**
+ * 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
+ {
+ super.startParsing(attrs);
+ if (parseMasterDetail)
+ {
+ final String master = attrs.getValue(OfficeNamespaces.OOREPORT_NS, "master");
+ if (master != null && master.length() > 0)
+ {
+ final String detail = attrs.getValue(OfficeNamespaces.OOREPORT_NS, "detail");
+ element.addMasterDetailFields(master, detail);
+ }
+ }
+ }
+
+ /**
+ * Returns the handler for a child element.
+ *
+ * @param tagName the tag name.
+ * @param atts the attributes.
+ * @return the handler or null, if the tagname is invalid.
+ * @throws org.xml.sax.SAXException if there is a parsing error.
+ */
+ protected XmlReadHandler getHandlerForChild(final String uri,
+ final String tagName,
+ final Attributes atts)
+ throws SAXException
+ {
+ if (OfficeNamespaces.OOREPORT_NS.equals(uri) && "master-detail-field".equals(tagName))
+ {
+ // expect a report control. The control will modifiy the current
+ // element (as we do not separate the elements that strictly ..)
+ return new MasterDetailReadHandler(element, true);
+ }
+
+ return null;
+ }
+
+ public Element getElement()
+ {
+ return element;
+ }
+}
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/ReportElementReadHandler.java b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/ReportElementReadHandler.java
new file mode 100644
index 000000000000..c29488435fa3
--- /dev/null
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/ReportElementReadHandler.java
@@ -0,0 +1,100 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+package org.libreoffice.report.pentaho.parser.rpt;
+
+import org.libreoffice.report.OfficeToken;
+import org.libreoffice.report.pentaho.OfficeNamespaces;
+import org.libreoffice.report.pentaho.model.ReportElement;
+import org.libreoffice.report.pentaho.parser.ElementReadHandler;
+
+import org.jfree.report.structure.Element;
+
+import org.pentaho.reporting.libraries.xmlns.parser.IgnoreAnyChildReadHandler;
+import org.pentaho.reporting.libraries.xmlns.parser.XmlReadHandler;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+public class ReportElementReadHandler extends ElementReadHandler
+{
+
+ private final ReportElement element;
+
+ public ReportElementReadHandler(final ReportElement element)
+ {
+ if (element == null)
+ {
+ throw new NullPointerException();
+ }
+
+ this.element = element;
+ }
+
+ public Element getElement()
+ {
+ return element;
+ }
+
+ /**
+ * 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
+ {
+ super.startParsing(attrs);
+ 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));
+ }
+
+ /**
+ * Returns the handler for a child element.
+ *
+ * @param tagName the tag name.
+ * @param atts the attributes.
+ * @return the handler or null, if the tagname is invalid.
+ * @throws org.xml.sax.SAXException if there is a parsing error.
+ */
+ protected XmlReadHandler getHandlerForChild(final String uri,
+ final String tagName,
+ final Attributes atts)
+ throws SAXException
+ {
+ if (!OfficeNamespaces.OOREPORT_NS.equals(uri))
+ {
+ return null;
+ }
+ if ("conditional-print-expression".equals(tagName))
+ {
+ return new ConditionalPrintExpressionReadHandler(element);
+ }
+ if ("format-condition".equals(tagName))
+ {
+ return new FormatConditionReadHandler(element);
+ }
+ if ("report-component".equals(tagName))
+ {
+ return new IgnoreAnyChildReadHandler();
+ }
+ return null;
+ }
+}
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/ReportReadHandler.java b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/ReportReadHandler.java
new file mode 100644
index 000000000000..ec270543b904
--- /dev/null
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/ReportReadHandler.java
@@ -0,0 +1,232 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+package org.libreoffice.report.pentaho.parser.rpt;
+
+import org.libreoffice.report.pentaho.OfficeNamespaces;
+import org.libreoffice.report.pentaho.model.OfficeReport;
+import org.libreoffice.report.pentaho.parser.ElementReadHandler;
+import org.libreoffice.report.pentaho.parser.chart.ChartReadHandler;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jfree.report.JFreeReportInfo;
+import org.jfree.report.structure.Element;
+import org.jfree.report.structure.Section;
+
+import org.pentaho.reporting.libraries.xmlns.parser.XmlReadHandler;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+
+public class ReportReadHandler extends ElementReadHandler
+{
+
+ private RootTableReadHandler pageHeader;
+ private RootTableReadHandler pageFooter;
+ private RootTableReadHandler reportHeader;
+ private RootTableReadHandler reportFooter;
+ private RootTableReadHandler detail;
+ private GroupReadHandler groups;
+ private final OfficeReport rootSection;
+ private final List<FunctionReadHandler> functionHandlers;
+ private final List<ElementReadHandler> preBodyHandlers;
+ private final List<ElementReadHandler> postBodyHandlers;
+ private boolean pre = true;
+
+ public ReportReadHandler()
+ {
+ rootSection = new OfficeReport();
+ rootSection.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, "simple-report-structure", Boolean.TRUE);
+ functionHandlers = new ArrayList<FunctionReadHandler>();
+ preBodyHandlers = new ArrayList<ElementReadHandler>();
+ postBodyHandlers = new ArrayList<ElementReadHandler>();
+ }
+
+ /**
+ * Returns the handler for a child element.
+ *
+ * @param tagName the tag name.
+ * @param atts the attributes.
+ * @return the handler or null, if the tagname is invalid.
+ * @throws org.xml.sax.SAXException if there is a parsing error.
+ */
+ protected XmlReadHandler getHandlerForChild(final String uri,
+ final String tagName,
+ final Attributes atts)
+ throws SAXException
+ {
+ final XmlReadHandler erh;
+ if (OfficeNamespaces.CHART_NS.equals(uri))
+ {
+ ChartReadHandler crh = new ChartReadHandler(this);
+ if (pre)
+ {
+ preBodyHandlers.add(crh);
+ }
+ else
+ {
+ postBodyHandlers.add(crh);
+ }
+ erh = crh;
+ }
+ else if (OfficeNamespaces.OOREPORT_NS.equals(uri))
+ {
+ if ("function".equals(tagName))
+ {
+ FunctionReadHandler frh = new FunctionReadHandler();
+ functionHandlers.add(frh);
+ erh = frh;
+ }
+ else if ("page-header".equals(tagName))
+ {
+ pageHeader = new RootTableReadHandler();
+ erh = pageHeader;
+ }
+ else if ("report-header".equals(tagName))
+ {
+ reportHeader = new RootTableReadHandler();
+ erh = reportHeader;
+ }
+ else if ("report-footer".equals(tagName))
+ {
+ reportFooter = new RootTableReadHandler();
+ erh = reportFooter;
+ }
+ else if ("page-footer".equals(tagName))
+ {
+ pageFooter = new RootTableReadHandler();
+ erh = pageFooter;
+ }
+ else if ("detail".equals(tagName))
+ {
+ pre = false;
+ detail = new DetailRootTableReadHandler();
+ erh = detail;
+ }
+ else if ("group".equals(tagName))
+ {
+ groups = new GroupReadHandler(this);
+ erh = groups;
+ }
+ else
+ {
+ erh = null;
+ }
+ }
+ else
+ {
+ erh = null;
+ }
+ return erh;
+ }
+
+ /**
+ * Done parsing.
+ *
+ * @throws org.xml.sax.SAXException if there is a parsing error.
+ */
+ protected void doneParsing() throws SAXException
+ {
+ if (pageHeader != null)
+ {
+ rootSection.setPageHeader(pageHeader.getElement());
+ }
+ if (pageFooter != null)
+ {
+ rootSection.setPageFooter(pageFooter.getElement());
+ }
+ if (reportHeader != null)
+ {
+ rootSection.setReportHeader(reportHeader.getElement());
+ }
+
+ final Section preBody = createSection("report-pre-body", preBodyHandlers);
+ if (preBody != null)
+ {
+ rootSection.setPreBodySection(preBody);
+ }
+
+ final Section groupBody = new Section();
+ groupBody.setNamespace(JFreeReportInfo.REPORT_NAMESPACE);
+ groupBody.setType("report-body");
+ rootSection.setBodySection(groupBody);
+
+ // XOR: Either the detail or the group section can be set ..
+ if (groups != null)
+ {
+ groupBody.addNode(groups.getElement());
+ }
+ else if (detail != null)
+ {
+ groupBody.addNode(detail.getElement());
+ }
+
+ final Section postBody = createSection("report-post-body", postBodyHandlers);
+ if (postBody != null)
+ {
+ rootSection.setPostBodySection(postBody);
+ }
+
+ if (reportFooter != null)
+ {
+ rootSection.setReportFooter(reportFooter.getElement());
+ }
+
+ for (int i = 0; i < functionHandlers.size(); i++)
+ {
+ final FunctionReadHandler handler = functionHandlers.get(i);
+ rootSection.addExpression(handler.getExpression());
+ }
+ }
+
+ public Element getElement()
+ {
+ return rootSection;
+ }
+
+ private final Section createSection(final String name, final List<ElementReadHandler> handler)
+ {
+ if (!handler.isEmpty())
+ {
+ final Section section = new Section();
+ section.setNamespace(JFreeReportInfo.REPORT_NAMESPACE);
+ section.setType(name);
+
+ for (int i = 0; i < handler.size(); i++)
+ {
+ final ElementReadHandler erh = handler.get(i);
+ section.addNode(erh.getElement());
+ }
+ return section;
+ }
+ return null;
+ }
+
+ public void setDetail(final RootTableReadHandler detail)
+ {
+ this.detail = detail;
+ }
+
+ public final RootTableReadHandler getDetail()
+ {
+ return detail;
+ }
+
+}
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/RootTableReadHandler.java b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/RootTableReadHandler.java
new file mode 100644
index 000000000000..54b753b8f630
--- /dev/null
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/RootTableReadHandler.java
@@ -0,0 +1,96 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+package org.libreoffice.report.pentaho.parser.rpt;
+
+import org.libreoffice.report.pentaho.OfficeNamespaces;
+import org.libreoffice.report.pentaho.parser.ElementReadHandler;
+import org.libreoffice.report.pentaho.parser.table.TableReadHandler;
+
+import org.jfree.report.structure.Element;
+import org.jfree.report.structure.Section;
+
+import org.pentaho.reporting.libraries.xmlns.parser.XmlReadHandler;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+public class RootTableReadHandler extends ElementReadHandler
+{
+
+ private TableReadHandler sectionTableReadHandler;
+ private final Section section;
+
+ public RootTableReadHandler()
+ {
+ section = new Section();
+ }
+
+ protected RootTableReadHandler(final Section section)
+ {
+ if (section == null)
+ {
+ throw new NullPointerException();
+ }
+ this.section = section;
+ }
+
+ /**
+ * Returns the handler for a child element.
+ *
+ * @param tagName the tag name.
+ * @param atts the attributes.
+ * @return the handler or null, if the tagname is invalid.
+ *
+ * @throws org.xml.sax.SAXException if there is a parsing error.
+ */
+ protected XmlReadHandler getHandlerForChild(final String uri,
+ final String tagName,
+ final Attributes atts)
+ throws SAXException
+ {
+ if (OfficeNamespaces.TABLE_NS.equals(uri) && "table".equals(tagName))
+ {
+ sectionTableReadHandler = new TableReadHandler();
+ return sectionTableReadHandler;
+ }
+ if (OfficeNamespaces.OOREPORT_NS.equals(uri) && "conditional-print-expression".equals(tagName))
+ {
+ return new ConditionalPrintExpressionReadHandler(section);
+ }
+ return null;
+ }
+
+ /**
+ * Done parsing.
+ *
+ * @throws org.xml.sax.SAXException if there is a parsing error.
+ */
+ protected void doneParsing()
+ throws SAXException
+ {
+ if (sectionTableReadHandler != null)
+ {
+ section.addNode(sectionTableReadHandler.getElement());
+ }
+ }
+
+ public Element getElement()
+ {
+ return section;
+ }
+}
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/SubDocumentReadHandler.java b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/SubDocumentReadHandler.java
new file mode 100644
index 000000000000..c815a69ba7ae
--- /dev/null
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/parser/rpt/SubDocumentReadHandler.java
@@ -0,0 +1,124 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+package org.libreoffice.report.pentaho.parser.rpt;
+
+import org.libreoffice.report.OfficeToken;
+import org.libreoffice.report.pentaho.OfficeNamespaces;
+import org.libreoffice.report.pentaho.model.ObjectOleElement;
+import org.libreoffice.report.pentaho.parser.draw.ObjectOleReadHandler;
+import org.libreoffice.report.pentaho.parser.text.NoCDATATextContentReadHandler;
+
+import org.jfree.report.structure.Section;
+
+import org.pentaho.reporting.libraries.xmlns.parser.IgnoreAnyChildReadHandler;
+import org.pentaho.reporting.libraries.xmlns.parser.XmlReadHandler;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+public class SubDocumentReadHandler extends NoCDATATextContentReadHandler
+{
+
+ private final ObjectOleElement element;
+ private boolean ignore = false;
+
+ public SubDocumentReadHandler(final ObjectOleElement element)
+ {
+ this.element = element;
+ }
+
+ public SubDocumentReadHandler(final Section section, final ObjectOleElement element)
+ {
+ super(section);
+ this.element = element;
+ }
+
+ public SubDocumentReadHandler(final Section section)
+ {
+ this(section, new ObjectOleElement());
+ ignore = true;
+ }
+
+ /**
+ * 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
+ {
+ if (!ignore)
+ {
+ super.startParsing(attrs);
+ }
+ }
+
+ /**
+ * Returns the handler for a child element.
+ *
+ * @param tagName the tag name.
+ * @param atts the attributes.
+ * @return the handler or null, if the tagname is invalid.
+ * @throws org.xml.sax.SAXException if there is a parsing error.
+ */
+ protected XmlReadHandler getHandlerForChild(final String uri,
+ final String tagName,
+ final Attributes atts)
+ throws SAXException
+ {
+ if (OfficeNamespaces.OOREPORT_NS.equals(uri))
+ {
+ // expect a report control. The control will modifiy the current
+ // element (as we do not separate the elements that strictly ..)
+ if ("report-control".equals(tagName))
+ {
+ return new IgnoreAnyChildReadHandler();
+ }
+ if ("report-element".equals(tagName))
+ {
+ return new ReportElementReadHandler(element);
+ }
+ if ("master-detail-fields".equals(tagName))
+ {
+ return new MasterDetailReadHandler(element);
+ }
+ }
+ if (OfficeNamespaces.DRAWING_NS.equals(uri))
+ {
+ final XmlReadHandler readHandler;
+ if (OfficeToken.OBJECT_OLE.equals(tagName))
+ {
+ readHandler = new ObjectOleReadHandler(element);
+ }
+ else if ("frame".equals(tagName))
+ {
+ readHandler = new SubDocumentReadHandler(new Section(), element);
+ }
+ else
+ {
+ readHandler = null;
+ }
+ if (readHandler != null)
+ {
+ getChildren().add(readHandler);
+ return readHandler;
+ }
+ }
+ return super.getHandlerForChild(uri, tagName, atts);
+ }
+}