summaryrefslogtreecommitdiffstats
path: root/reportbuilder/java/org/libreoffice/report/pentaho/parser/table
diff options
context:
space:
mode:
Diffstat (limited to 'reportbuilder/java/org/libreoffice/report/pentaho/parser/table')
-rw-r--r--reportbuilder/java/org/libreoffice/report/pentaho/parser/table/CoveredCellReadHandler.java45
-rw-r--r--reportbuilder/java/org/libreoffice/report/pentaho/parser/table/TableCellReadHandler.java36
-rw-r--r--reportbuilder/java/org/libreoffice/report/pentaho/parser/table/TableColumnReadHandler.java44
-rw-r--r--reportbuilder/java/org/libreoffice/report/pentaho/parser/table/TableColumnsReadHandler.java96
-rw-r--r--reportbuilder/java/org/libreoffice/report/pentaho/parser/table/TableReadHandler.java139
-rw-r--r--reportbuilder/java/org/libreoffice/report/pentaho/parser/table/TableRowReadHandler.java119
-rw-r--r--reportbuilder/java/org/libreoffice/report/pentaho/parser/table/TableRowsReadHandler.java92
7 files changed, 571 insertions, 0 deletions
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/parser/table/CoveredCellReadHandler.java b/reportbuilder/java/org/libreoffice/report/pentaho/parser/table/CoveredCellReadHandler.java
new file mode 100644
index 000000000..5adb6d596
--- /dev/null
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/parser/table/CoveredCellReadHandler.java
@@ -0,0 +1,45 @@
+/*
+ * 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.table;
+
+import org.libreoffice.report.pentaho.parser.ElementReadHandler;
+
+import org.jfree.report.structure.Element;
+import org.jfree.report.structure.Section;
+
+/**
+ * Todo: Document me!
+ *
+ * @since 14.03.2007
+ */
+public class CoveredCellReadHandler extends ElementReadHandler
+{
+
+ private final Element coveredCell;
+
+ public CoveredCellReadHandler()
+ {
+ coveredCell = new Section();
+ }
+
+ @Override
+ public Element getElement()
+ {
+ return coveredCell;
+ }
+}
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/parser/table/TableCellReadHandler.java b/reportbuilder/java/org/libreoffice/report/pentaho/parser/table/TableCellReadHandler.java
new file mode 100644
index 000000000..f37ac00f7
--- /dev/null
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/parser/table/TableCellReadHandler.java
@@ -0,0 +1,36 @@
+/*
+ * 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.table;
+
+import org.libreoffice.report.pentaho.model.TableCellElement;
+import org.libreoffice.report.pentaho.parser.text.NoCDATATextContentReadHandler;
+
+/**
+ * A read handler for table-cell contents. This is basically a text-content
+ * read handler; we may extend this implementation later.
+ *
+ * @since 05.03.2007
+ */
+public class TableCellReadHandler extends NoCDATATextContentReadHandler
+{
+
+ public TableCellReadHandler()
+ {
+ super(new TableCellElement(), true);
+ }
+}
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/parser/table/TableColumnReadHandler.java b/reportbuilder/java/org/libreoffice/report/pentaho/parser/table/TableColumnReadHandler.java
new file mode 100644
index 000000000..adfc956da
--- /dev/null
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/parser/table/TableColumnReadHandler.java
@@ -0,0 +1,44 @@
+/*
+ * 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.table;
+
+import org.libreoffice.report.pentaho.parser.ElementReadHandler;
+
+import org.jfree.report.structure.Element;
+import org.jfree.report.structure.Section;
+
+/**
+ * Creation-Date: 03.07.2006, 14:26:55
+ *
+ */
+public class TableColumnReadHandler extends ElementReadHandler
+{
+
+ private final Section tableColumn;
+
+ public TableColumnReadHandler()
+ {
+ tableColumn = new Section();
+ }
+
+ @Override
+ public Element getElement()
+ {
+ return tableColumn;
+ }
+}
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/parser/table/TableColumnsReadHandler.java b/reportbuilder/java/org/libreoffice/report/pentaho/parser/table/TableColumnsReadHandler.java
new file mode 100644
index 000000000..35da849ce
--- /dev/null
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/parser/table/TableColumnsReadHandler.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.table;
+
+import org.libreoffice.report.OfficeToken;
+import org.libreoffice.report.pentaho.OfficeNamespaces;
+import org.libreoffice.report.pentaho.parser.ElementReadHandler;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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;
+
+
+/**
+ * Creation-Date: 03.07.2006, 13:50:41
+ *
+ */
+public class TableColumnsReadHandler extends ElementReadHandler
+{
+
+ private final List<TableColumnReadHandler> columns;
+ private final Section tableColumns;
+
+ public TableColumnsReadHandler()
+ {
+ columns = new ArrayList<TableColumnReadHandler>();
+ tableColumns = new 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.
+ */
+ @Override
+ protected XmlReadHandler getHandlerForChild(final String uri,
+ final String tagName,
+ final Attributes atts)
+ throws SAXException
+ {
+ if (OfficeNamespaces.TABLE_NS.equals(uri) && OfficeToken.TABLE_COLUMN.equals(tagName))
+ {
+ final TableColumnReadHandler readHandler = new TableColumnReadHandler();
+ columns.add(readHandler);
+ return readHandler;
+ }
+
+ return null;
+ }
+
+ /**
+ * Done parsing.
+ *
+ * @throws org.xml.sax.SAXException if there is a parsing error.
+ */
+ @Override
+ protected void doneParsing() throws SAXException
+ {
+ for (int i = 0; i < columns.size(); i++)
+ {
+ final TableColumnReadHandler handler = columns.get(i);
+ tableColumns.addNode(handler.getElement());
+ }
+ }
+
+ @Override
+ public Element getElement()
+ {
+ return tableColumns;
+ }
+}
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/parser/table/TableReadHandler.java b/reportbuilder/java/org/libreoffice/report/pentaho/parser/table/TableReadHandler.java
new file mode 100644
index 000000000..3c8e90f20
--- /dev/null
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/parser/table/TableReadHandler.java
@@ -0,0 +1,139 @@
+/*
+ * 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.table;
+
+import org.libreoffice.report.OfficeToken;
+import org.libreoffice.report.pentaho.OfficeNamespaces;
+import org.libreoffice.report.pentaho.model.OfficeTableSection;
+import org.libreoffice.report.pentaho.parser.ElementReadHandler;
+import org.libreoffice.report.pentaho.parser.rpt.ConditionalPrintExpressionReadHandler;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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;
+
+
+/**
+ * Creation-Date: 03.07.2006, 13:47:47
+ *
+ */
+public class TableReadHandler extends ElementReadHandler
+{
+
+ private final List<ElementReadHandler> children;
+ private final Section table;
+
+ public TableReadHandler()
+ {
+ children = new ArrayList<ElementReadHandler>();
+ table = new OfficeTableSection();
+ }
+
+ /**
+ * Starts parsing.
+ *
+ * @param attrs the attributes.
+ * @throws org.xml.sax.SAXException if there is a parsing error.
+ */
+ @Override
+ protected void startParsing(final Attributes attrs)
+ throws SAXException
+ {
+ super.startParsing(attrs);
+ final String enabled = attrs.getValue(OfficeNamespaces.OOREPORT_NS, "visible");
+ if (enabled == null || OfficeToken.TRUE.equals(enabled))
+ {
+ table.setEnabled(true);
+ }
+ else
+ {
+ table.setEnabled(false);
+ }
+
+ }
+
+ /**
+ * 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.
+ */
+ @Override
+ protected XmlReadHandler getHandlerForChild(final String uri,
+ final String tagName,
+ final Attributes atts)
+ throws SAXException
+ {
+ if (OfficeNamespaces.OOREPORT_NS.equals(uri) && "conditional-print-expression".equals(tagName))
+ {
+ return new ConditionalPrintExpressionReadHandler(table);
+ }
+ else if (OfficeNamespaces.TABLE_NS.equals(uri))
+ {
+ if (OfficeToken.TABLE_COLUMNS.equals(tagName) || OfficeToken.TABLE_HEADER_COLUMNS.equals(tagName))
+ {
+ final TableColumnsReadHandler columns = new TableColumnsReadHandler();
+ children.add(columns);
+ return columns;
+ }
+ else if (OfficeToken.TABLE_ROW.equals(tagName))
+ {
+ final TableRowReadHandler rowHandler = new TableRowReadHandler();
+ children.add(rowHandler);
+ return rowHandler;
+ }
+ else if (OfficeToken.TABLE_ROWS.equals(tagName) || OfficeToken.TABLE_HEADER_ROWS.equals(tagName))
+ {
+ final TableRowsReadHandler rowsHandler = new TableRowsReadHandler();
+ children.add(rowsHandler);
+ return rowsHandler;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Done parsing.
+ *
+ * @throws org.xml.sax.SAXException if there is a parsing error.
+ */
+ @Override
+ protected void doneParsing() throws SAXException
+ {
+ for (int i = 0; i < children.size(); i++)
+ {
+ final ElementReadHandler handler = children.get(i);
+ table.addNode(handler.getElement());
+ }
+ }
+
+ @Override
+ public Element getElement()
+ {
+ return table;
+ }
+}
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/parser/table/TableRowReadHandler.java b/reportbuilder/java/org/libreoffice/report/pentaho/parser/table/TableRowReadHandler.java
new file mode 100644
index 000000000..2f4bad5a4
--- /dev/null
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/parser/table/TableRowReadHandler.java
@@ -0,0 +1,119 @@
+/*
+ * 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.table;
+
+import org.libreoffice.report.OfficeToken;
+import org.libreoffice.report.pentaho.OfficeNamespaces;
+import org.libreoffice.report.pentaho.parser.ElementReadHandler;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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;
+
+
+/**
+ * Creation-Date: 03.07.2006, 13:51:47
+ *
+ */
+public class TableRowReadHandler extends ElementReadHandler
+{
+
+ private final List<ElementReadHandler> tableCells;
+ private final Section tableRow;
+
+ public TableRowReadHandler()
+ {
+ tableCells = new ArrayList<ElementReadHandler>();
+ tableRow = new 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.
+ */
+ @Override
+ protected XmlReadHandler getHandlerForChild(final String uri,
+ final String tagName,
+ final Attributes atts)
+ throws SAXException
+ {
+ final ElementReadHandler rh;
+ if (OfficeNamespaces.TABLE_NS.equals(uri))
+ {
+ if (OfficeToken.TABLE_CELL.equals(tagName))
+ {
+ rh = new TableCellReadHandler();
+ }
+ else if (OfficeToken.COVERED_TABLE_CELL.equals(tagName))
+ {
+ rh = new CoveredCellReadHandler();
+ }
+ else
+ {
+ rh = null;
+ }
+ if (rh != null)
+ {
+ tableCells.add(rh);
+ }
+ }
+ else
+ {
+ rh = null;
+ }
+ return rh;
+ }
+
+ /**
+ * Done parsing.
+ *
+ * @throws org.xml.sax.SAXException if there is a parsing error.
+ */
+ @Override
+ protected void doneParsing() throws SAXException
+ {
+ for (int i = 0; i < tableCells.size(); i++)
+ {
+ final ElementReadHandler handler = tableCells.get(i);
+ tableRow.addNode(handler.getElement());
+ }
+ }
+
+ /**
+ * Returns the object for this element or null, if this element does not
+ * create an object.
+ *
+ * @return the object.
+ */
+ @Override
+ public Element getElement()
+ {
+ return tableRow;
+ }
+}
diff --git a/reportbuilder/java/org/libreoffice/report/pentaho/parser/table/TableRowsReadHandler.java b/reportbuilder/java/org/libreoffice/report/pentaho/parser/table/TableRowsReadHandler.java
new file mode 100644
index 000000000..33e253f24
--- /dev/null
+++ b/reportbuilder/java/org/libreoffice/report/pentaho/parser/table/TableRowsReadHandler.java
@@ -0,0 +1,92 @@
+/*
+ * 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.table;
+
+import org.libreoffice.report.OfficeToken;
+import org.libreoffice.report.pentaho.OfficeNamespaces;
+import org.libreoffice.report.pentaho.parser.ElementReadHandler;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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 TableRowsReadHandler extends ElementReadHandler
+{
+
+ private final List<TableRowReadHandler> rows;
+ private final Section tableRows;
+
+ public TableRowsReadHandler()
+ {
+ rows = new ArrayList<TableRowReadHandler>();
+ tableRows = new 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.
+ */
+ @Override
+ protected XmlReadHandler getHandlerForChild(final String uri,
+ final String tagName,
+ final Attributes atts)
+ throws SAXException
+ {
+ if (OfficeNamespaces.TABLE_NS.equals(uri) && OfficeToken.TABLE_ROW.equals(tagName))
+ {
+ final TableRowReadHandler readHandler = new TableRowReadHandler();
+ rows.add(readHandler);
+ return readHandler;
+ }
+
+ return null;
+ }
+
+ /**
+ * Done parsing.
+ *
+ * @throws org.xml.sax.SAXException if there is a parsing error.
+ */
+ @Override
+ protected void doneParsing() throws SAXException
+ {
+ for (int i = 0; i < rows.size(); i++)
+ {
+ final TableRowReadHandler handler = rows.get(i);
+ tableRows.addNode(handler.getElement());
+ }
+ }
+
+ @Override
+ public Element getElement()
+ {
+ return tableRows;
+ }
+}