diff options
author | Kurt Zenker <kz@openoffice.org> | 2008-05-05 12:52:04 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2008-05-05 12:52:04 +0000 |
commit | a00cdc7dd780af8e4f337e5fd28da1c15e6fb050 (patch) | |
tree | 8135b7d5420b9ddd6e3e7e16cd099cd90c913d25 /reportdesign | |
parent | 32636ab0a3fea3624feef3f8ebbc1637e5187a51 (diff) |
INTEGRATION: CWS dba30beta (1.6.6); FILE MERGED
2008/04/22 10:30:26 oj 1.6.6.1: #i88503# merge changes from rptchart02
Diffstat (limited to 'reportdesign')
2 files changed, 355 insertions, 354 deletions
diff --git a/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/FormattedTextLayoutController.java b/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/FormattedTextLayoutController.java index bfd4e86bd99e..04e8fe474e2b 100644 --- a/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/FormattedTextLayoutController.java +++ b/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/FormattedTextLayoutController.java @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: FormattedTextLayoutController.java,v $ - * $Revision: 1.6 $ + * $Revision: 1.7 $ * * This file is part of OpenOffice.org. * @@ -27,11 +27,10 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ - - package com.sun.star.report.pentaho.layoutprocessor; import com.sun.star.report.pentaho.OfficeNamespaces; +import com.sun.star.report.OfficeToken; import com.sun.star.report.pentaho.model.FormattedTextElement; import com.sun.star.report.pentaho.model.OfficeDocument; import com.sun.star.report.pentaho.model.OfficeStyle; @@ -57,161 +56,161 @@ import org.jfree.util.Log; * @since 05.03.2007 */ public class FormattedTextLayoutController - extends AbstractReportElementLayoutController + extends AbstractReportElementLayoutController { - public FormattedTextLayoutController() - { - } - - private VariablesCollection getVariablesCollection() - { - LayoutController parent = getParent(); - while (parent != null) - { - if (parent instanceof OfficeRepeatingStructureLayoutController) - { - final OfficeRepeatingStructureLayoutController orslc = - (OfficeRepeatingStructureLayoutController) parent; - if (orslc.isNormalFlowProcessing()) - { - return null; - } - return orslc.getVariablesCollection(); - } - parent = parent.getParent(); - } - return null; - } - - protected boolean isValueChanged() - { - try - { - final FormattedTextElement element = (FormattedTextElement) getNode(); - final FormulaExpression formulaExpression = element.getValueExpression(); - final Formula formula = formulaExpression.getCompiledFormula(); - final LValue lValue = formula.getRootReference(); - return isReferenceChanged(lValue); - } - catch (final ParseException e) + public FormattedTextLayoutController() { - Log.debug("Parse Exception", e); - return false; } - } - - protected LayoutController delegateContentGeneration(final ReportTarget target) - throws ReportProcessingException, ReportDataFactoryException, - DataSourceException - { - final FormattedTextElement element = (FormattedTextElement) getNode(); - final VariablesCollection vc = getVariablesCollection(); - if (vc != null) + + private VariablesCollection getVariablesCollection() { - final String name = vc.addVariable(element); - final AttributeMap variablesGet = new AttributeMap(); - variablesGet.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, - Element.TYPE_ATTRIBUTE, "variable-get"); - variablesGet.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, - Element.NAMESPACE_ATTRIBUTE, OfficeNamespaces.TEXT_NS); - variablesGet.setAttribute(OfficeNamespaces.TEXT_NS, "name", name); - //variablesGet.setAttribute(OfficeNamespaces.TEXT_NS, "display", "value"); - - final String dataStyleName = computeValueStyle(); - if (dataStyleName != null) - { - variablesGet.setAttribute(OfficeNamespaces.STYLE_NS, "data-style-name", dataStyleName); - } - - final String valueType = computeValueType(); - variablesGet.setAttribute(OfficeNamespaces.OFFICE_NS, "value-type", valueType); - target.startElement(variablesGet); - - target.endElement(variablesGet); + LayoutController parent = getParent(); + while (parent != null) + { + if (parent instanceof OfficeRepeatingStructureLayoutController) + { + final OfficeRepeatingStructureLayoutController orslc = + (OfficeRepeatingStructureLayoutController) parent; + if (orslc.isNormalFlowProcessing()) + { + return null; + } + + return orslc.getVariablesCollection(); + } + parent = parent.getParent(); + } + return null; } - else - { - final DataFlags df = FormatValueUtility.computeDataFlag(element, getFlowController()); - if (df != null) - { - target.processContent(df); - } + protected boolean isValueChanged() + { + try + { + final FormattedTextElement element = (FormattedTextElement) getNode(); + final FormulaExpression formulaExpression = element.getValueExpression(); + final Formula formula = formulaExpression.getCompiledFormula(); + final LValue lValue = formula.getRootReference(); + return isReferenceChanged(lValue); + } + catch (final ParseException e) + { + Log.debug("Parse Exception", e); + return false; + } } - return join(getFlowController()); - } + protected LayoutController delegateContentGeneration(final ReportTarget target) + throws ReportProcessingException, ReportDataFactoryException, + DataSourceException + { + final FormattedTextElement element = (FormattedTextElement) getNode(); + final VariablesCollection vc = getVariablesCollection(); + if (vc != null) + { + final String name = vc.addVariable(element); + final AttributeMap variablesGet = new AttributeMap(); + variablesGet.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, + Element.TYPE_ATTRIBUTE, "variable-get"); + variablesGet.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, + Element.NAMESPACE_ATTRIBUTE, OfficeNamespaces.TEXT_NS); + variablesGet.setAttribute(OfficeNamespaces.TEXT_NS, "name", name); + //variablesGet.setAttribute(OfficeNamespaces.TEXT_NS, "display", "value"); + + final String dataStyleName = computeValueStyle(); + if (dataStyleName != null) + { + variablesGet.setAttribute(OfficeNamespaces.STYLE_NS, "data-style-name", dataStyleName); + } + + final String valueType = computeValueType(); + variablesGet.setAttribute(OfficeNamespaces.OFFICE_NS, FormatValueUtility.VALUE_TYPE, valueType); + target.startElement(variablesGet); + + target.endElement(variablesGet); + } + else + { + final DataFlags df = FormatValueUtility.computeDataFlag(element, getFlowController()); + if (df != null) + { + target.processContent(df); + } + } - private OfficeDocument getDocument() - { - LayoutController parent = getParent(); - while (parent != null) - { - final Object node = parent.getNode(); - if (node instanceof OfficeDocument) - { - return (OfficeDocument) node; - } - parent = parent.getParent(); + return join(getFlowController()); } - return null; - } - private Element getParentTableCell() - { - LayoutController parent = getParent(); - while (parent != null) + private OfficeDocument getDocument() { - if (parent instanceof TableCellLayoutController) - { - final TableCellLayoutController cellController = (TableCellLayoutController) parent; - return cellController.getElement(); - } - parent = parent.getParent(); + LayoutController parent = getParent(); + while (parent != null) + { + final Object node = parent.getNode(); + if (node instanceof OfficeDocument) + { + return (OfficeDocument) node; + } + parent = parent.getParent(); + } + return null; } - return null; - } - private String computeValueStyle() - { - final Element tce = getParentTableCell(); - if (tce == null) + private Element getParentTableCell() { - return null; + LayoutController parent = getParent(); + while (parent != null) + { + if (parent instanceof TableCellLayoutController) + { + final TableCellLayoutController cellController = (TableCellLayoutController) parent; + return cellController.getElement(); + } + parent = parent.getParent(); + } + return null; } - final String cellStyleName = (String) tce.getAttribute(OfficeNamespaces.TABLE_NS, "style-name"); - if (cellStyleName == null) + private String computeValueStyle() { - return null; - } - final OfficeDocument document = getDocument(); - if (document == null) - { - return null; - } + final Element tce = getParentTableCell(); + if (tce == null) + { + return null; + } - final OfficeStyle style = document.getStylesCollection().getStyle("table-cell", cellStyleName); - return (String) style.getAttribute(OfficeNamespaces.STYLE_NS, "data-style-name"); - } + final String cellStyleName = (String) tce.getAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME); + if (cellStyleName == null) + { + return null; + } + final OfficeDocument document = getDocument(); + if (document == null) + { + return null; + } - private String computeValueType() - { - final Element tce = getParentTableCell(); - if (tce == null) - { - // NO particular format means: Fallback to string and hope and pray .. - throw new IllegalStateException("A formatted text element must be a child of a Table-Cell."); + final OfficeStyle style = document.getStylesCollection().getStyle("table-cell", cellStyleName); + return (String) style.getAttribute(OfficeNamespaces.STYLE_NS, "data-style-name"); } - final String type = (String) tce.getAttribute(OfficeNamespaces.OFFICE_NS, "value-type"); - if (type == null) + private String computeValueType() { - Log.error("The Table-Cell does not have a office:value attribute defined. Your content will be messed up."); - return "string"; + final Element tce = getParentTableCell(); + if (tce == null) + { + // NO particular format means: Fallback to string and hope and pray .. + throw new IllegalStateException("A formatted text element must be a child of a Table-Cell."); + } + + final String type = (String) tce.getAttribute(OfficeNamespaces.OFFICE_NS, FormatValueUtility.VALUE_TYPE); + if (type == null) + { + Log.error("The Table-Cell does not have a office:value attribute defined. Your content will be messed up."); + return "string"; + } + return type; } - return type; - } } diff --git a/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/ImageElementLayoutController.java b/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/ImageElementLayoutController.java index 9eb2bb202fb2..9e4fbc6eb1a1 100644 --- a/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/ImageElementLayoutController.java +++ b/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/ImageElementLayoutController.java @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: ImageElementLayoutController.java,v $ - * $Revision: 1.6 $ + * $Revision: 1.7 $ * * This file is part of OpenOffice.org. * @@ -27,11 +27,10 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ - - package com.sun.star.report.pentaho.layoutprocessor; import com.sun.star.report.pentaho.OfficeNamespaces; +import com.sun.star.report.OfficeToken; import com.sun.star.report.pentaho.model.ImageElement; import org.jfree.formula.Formula; import org.jfree.formula.lvalues.LValue; @@ -65,265 +64,268 @@ import org.jfree.util.ObjectUtilities; * @since 05.03.2007 */ public class ImageElementLayoutController - extends AbstractReportElementLayoutController + extends AbstractReportElementLayoutController { - private ImageElementContext context; - public ImageElementLayoutController() - { - } + private ImageElementContext context; - protected LayoutController delegateContentGeneration - (final ReportTarget target) - throws ReportProcessingException, ReportDataFactoryException, - DataSourceException - { - final ImageElement imageElement = (ImageElement) getNode(); - final FormulaExpression formulaExpression = imageElement.getFormula(); - if (formulaExpression == null) + public ImageElementLayoutController() { - // A static image is easy. At least at this level. Dont ask about the weird things we have to do in the - // output targets ... - final String linkTarget = imageElement.getImageData(); - generateImage(target, linkTarget, imageElement.isScale(), imageElement.isPreserveIRI()); } - else + + protected LayoutController delegateContentGeneration(final ReportTarget target) + throws ReportProcessingException, ReportDataFactoryException, + DataSourceException { - final Object value = - LayoutControllerUtil.evaluateExpression(getFlowController(), imageElement, formulaExpression); - generateImage(target, value, imageElement.isScale(), imageElement.isPreserveIRI()); + final ImageElement imageElement = (ImageElement) getNode(); + final FormulaExpression formulaExpression = imageElement.getFormula(); + if (formulaExpression == null) + { + // A static image is easy. At least at this level. Dont ask about the weird things we have to do in the + // output targets ... + final String linkTarget = imageElement.getImageData(); + generateImage(target, linkTarget, imageElement.isScale(), imageElement.isPreserveIRI()); + } + else + { + final Object value = + LayoutControllerUtil.evaluateExpression(getFlowController(), imageElement, formulaExpression); + generateImage(target, value, imageElement.isScale(), imageElement.isPreserveIRI()); + } + return join(getFlowController()); } - return join(getFlowController()); - } - private void generateImage(final ReportTarget target, - final Object linkTarget, - final boolean scale, - final boolean preserveIri) - throws ReportProcessingException, DataSourceException - { - if (linkTarget == null) + private void generateImage(final ReportTarget target, + final Object linkTarget, + final boolean scale, + final boolean preserveIri) + throws ReportProcessingException, DataSourceException { - return; - } + if (linkTarget == null) + { + return; + } - final AttributeMap image = new AttributeMap(); - image.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, Element.NAMESPACE_ATTRIBUTE, OfficeNamespaces.INTERNAL_NS); - image.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, Element.TYPE_ATTRIBUTE, "image"); - image.setAttribute(OfficeNamespaces.INTERNAL_NS, "scale", String.valueOf(scale)); - image.setAttribute(OfficeNamespaces.INTERNAL_NS, "preserve-IRI", String.valueOf(preserveIri)); - image.setAttribute(OfficeNamespaces.INTERNAL_NS, "image-context", createContext()); - image.setAttribute(OfficeNamespaces.INTERNAL_NS, "image-data", linkTarget); - target.startElement(image); - target.endElement(image); - } + final AttributeMap image = new AttributeMap(); + image.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, Element.NAMESPACE_ATTRIBUTE, OfficeNamespaces.INTERNAL_NS); + image.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, Element.TYPE_ATTRIBUTE, OfficeToken.IMAGE); + image.setAttribute(OfficeNamespaces.INTERNAL_NS, OfficeToken.SCALE, String.valueOf(scale)); + image.setAttribute(OfficeNamespaces.INTERNAL_NS, OfficeToken.PRESERVE_IRI, String.valueOf(preserveIri)); + image.setAttribute(OfficeNamespaces.INTERNAL_NS, "image-context", createContext()); + image.setAttribute(OfficeNamespaces.INTERNAL_NS, OfficeToken.IMAGE_DATA, linkTarget); + target.startElement(image); + target.endElement(image); + } - protected ImageElementContext createContext() - { - if (context == null) + protected ImageElementContext createContext() { + if (context == null) + { - // Step 1: Find the parent cell. - final LayoutController cellController = findParentCell(); - if (cellController == null) - { - Log.warn("Image is not contained in a table. Unable to calculate the image-size."); - return null; - } - final Element tableCell = (Element) cellController.getNode(); - final int rowSpan = TextUtilities.parseInt - ((String) tableCell.getAttribute(OfficeNamespaces.TABLE_NS, "number-rows-spanned"), 1); - final int colSpan = TextUtilities.parseInt - ((String) tableCell.getAttribute(OfficeNamespaces.TABLE_NS, "number-columns-spanned"), 1); - if (rowSpan < 1 || colSpan < 1) - { - Log.warn("Rowspan or colspan for image-size calculation was invalid."); - return null; - } - - final LayoutController rowController = cellController.getParent(); - if (rowController == null) - { - Log.warn("Table-Cell has no parent. Unable to calculate the image-size."); - return null; - } - final Section tableRow = (Section) rowController.getNode(); - // we are now making the assumption, that the row is a section, that contains the table-cell. - // This breaks the ability to return nodes or to construct reports on the fly, but the OO-report format - // is weird anyway and wont support such advanced techniques for the next few centuries .. - final int columnPos = findNodeInSection(tableRow, tableCell,"covered-table-cell"); - if (columnPos == -1) - { - Log.warn("Table-Cell is not a direct child of the table-row. Unable to calculate the image-size."); - return null; - } + // Step 1: Find the parent cell. + final LayoutController cellController = findParentCell(); + if (cellController == null) + { + Log.warn("Image is not contained in a table. Unable to calculate the image-size."); + return null; + } + final Element tableCell = (Element) cellController.getNode(); + final int rowSpan = TextUtilities.parseInt((String) tableCell.getAttribute(OfficeNamespaces.TABLE_NS, "number-rows-spanned"), 1); + final int colSpan = TextUtilities.parseInt((String) tableCell.getAttribute(OfficeNamespaces.TABLE_NS, "number-columns-spanned"), 1); + if (rowSpan < 1 || colSpan < 1) + { + Log.warn("Rowspan or colspan for image-size calculation was invalid."); + return null; + } - final LayoutController tableController = rowController.getParent(); - if (tableController == null) - { - Log.warn("Table-Row has no Table. Unable to calculate the image-size."); - return null; - } + final LayoutController rowController = cellController.getParent(); + if (rowController == null) + { + Log.warn("Table-Cell has no parent. Unable to calculate the image-size."); + return null; + } + final Section tableRow = (Section) rowController.getNode(); + // we are now making the assumption, that the row is a section, that contains the table-cell. + // This breaks the ability to return nodes or to construct reports on the fly, but the OO-report format + // is weird anyway and wont support such advanced techniques for the next few centuries .. + final int columnPos = findNodeInSection(tableRow, tableCell, OfficeToken.COVERED_TABLE_CELL); + if (columnPos == -1) + { + Log.warn("Table-Cell is not a direct child of the table-row. Unable to calculate the image-size."); + return null; + } - final Section table = (Section) tableController.getNode(); - // ok, we got a table, so as next we have to search for the columns now. - final Section columns = (Section) table.findFirstChild(OfficeNamespaces.TABLE_NS, "table-columns"); - if (columns.getNodeCount() <= columnPos + colSpan) - { - // the colspan is to large. The table definition is therefore invalid. We do not try to fix this. - Log.warn( - "The Table's defined columns do not match the col-span or col-position. Unable to calculate the image-size."); - return null; - } + final LayoutController tableController = rowController.getParent(); + if (tableController == null) + { + Log.warn("Table-Row has no Table. Unable to calculate the image-size."); + return null; + } - final ImageElementContext context = new ImageElementContext(colSpan, rowSpan); + final Section table = (Section) tableController.getNode(); + // ok, we got a table, so as next we have to search for the columns now. + final Section columns = (Section) table.findFirstChild(OfficeNamespaces.TABLE_NS, OfficeToken.TABLE_COLUMNS); + if (columns.getNodeCount() <= columnPos + colSpan) + { + // the colspan is to large. The table definition is therefore invalid. We do not try to fix this. + Log.warn( + "The Table's defined columns do not match the col-span or col-position. Unable to calculate the image-size."); + return null; + } - final Node[] columnDefs = columns.getNodeArray(); - int columnCounter = 0; - for (int i = 0; i < columnDefs.length; i++) - { - final Element column = (Element) columnDefs[i]; + final ImageElementContext context = new ImageElementContext(colSpan, rowSpan); + addColumnStyles(context, columns, columnPos, colSpan); + // finally search the styles for the row now. + final int rowPos = findNodeInSection(table, tableRow, null); + if (rowPos == -1) + { + Log.warn("Table-Cell is not a direct child of the table-row. Unable to calculate the image-size."); + return null; + } - if (ObjectUtilities.equal(column.getNamespace(), OfficeNamespaces.TABLE_NS) == false || - ObjectUtilities.equal(column.getType(), "table-column") == false) - { - continue; + addRowStyles(context, table,rowPos,rowSpan); + this.context = context; } - if (columnCounter >= columnPos) + return this.context; + } + + private int findNodeInSection(final Section tableRow, + final Element tableCell, + final String secondType) + { + int retval = 0; + final Node[] nodes = tableRow.getNodeArray(); + final String namespace = tableCell.getNamespace(); + final String type = tableCell.getType(); + for (int i = 0; i < nodes.length; i++) { - final String colStyle = (String) column.getAttribute(OfficeNamespaces.TABLE_NS, "style-name"); - context.setColStyle(columnCounter - columnPos, colStyle); - } + final Node node = nodes[i]; + if (!(node instanceof Element)) + { + continue; + } + final Element child = (Element) node; + /* + if (! OfficeToken.COVERED_TABLE_CELL.equals(child.getType()) && + (ObjectUtilities.equal(child.getNamespace(), namespace) == false || + ObjectUtilities.equal(child.getType(), type) == false)) + */ + if (!ObjectUtilities.equal(child.getNamespace(), namespace) || + (!ObjectUtilities.equal(child.getType(), type) && (secondType == null || !ObjectUtilities.equal(child.getType(), secondType)))) + { + continue; + } - columnCounter += 1; + if (node == tableCell) + { + return retval; + } + retval += 1; + } + return -1; + } - if (columnCounter >= (columnPos + colSpan)) + private LayoutController findParentCell() + { + LayoutController parent = getParent(); + while (parent != null) { - break; + final Object node = parent.getNode(); + if (node instanceof Element) + { + final Element element = (Element) node; + if (OfficeNamespaces.TABLE_NS.equals(element.getNamespace()) && "table-cell".equals(element.getType())) + { + return parent; + } + } + parent = parent.getParent(); } - - } - - // finally search the styles for the row now. - final int rowPos = findNodeInSection(table, tableRow,null); - if (rowPos == -1) - { - Log.warn("Table-Cell is not a direct child of the table-row. Unable to calculate the image-size."); return null; - } - - final Node[] rows = table.getNodeArray(); - int rowCounter = 0; - for (int i = 0; i < rows.length; i++) - { - final Element row = (Element) rows[i]; + } - if (ObjectUtilities.equal(row.getNamespace(), OfficeNamespaces.TABLE_NS) == false || - ObjectUtilities.equal(row.getType(), "table-row") == false) + protected boolean isValueChanged() + { + final ImageElement imageElement = (ImageElement) getNode(); + final FormulaExpression formulaExpression = imageElement.getFormula(); + if (formulaExpression == null) { - continue; + final FlowController controller = getFlowController(); + final GlobalMasterRow masterRow = controller.getMasterRow(); + final ReportDataRow reportDataRow = masterRow.getReportDataRow(); + if (reportDataRow.getCursor() == 0) + { + return true; + } + return false; } - if (rowCounter >= rowPos) + + try { - final String rowStyle = (String) row.getAttribute(OfficeNamespaces.TABLE_NS, "style-name"); - context.setRowStyle(rowCounter - rowPos, rowStyle); + final Formula formula = formulaExpression.getCompiledFormula(); + final LValue lValue = formula.getRootReference(); + return isReferenceChanged(lValue); } - - rowCounter += 1; - - if (rowCounter >= (rowPos + rowSpan)) + catch (ParseException e) { - break; + return false; } - } - this.context = context; } - return this.context; - } - private int findNodeInSection(final Section tableRow, - final Element tableCell, - final String secondType) - { - int retval = 0; - final Node[] nodes = tableRow.getNodeArray(); - final String namespace = tableCell.getNamespace(); - final String type = tableCell.getType(); - for (int i = 0; i < nodes.length; i++) + void addColumnStyles(final ImageElementContext context, final Section columns, final int columnPos, final int colSpan) { - final Node node = nodes[i]; - if (node instanceof Element == false) - { - continue; - } - final Element child = (Element) node; -/* - if (! "covered-table-cell".equals(child.getType()) && - (ObjectUtilities.equal(child.getNamespace(), namespace) == false || - ObjectUtilities.equal(child.getType(), type) == false)) -*/ - if (ObjectUtilities.equal(child.getNamespace(), namespace) == false || - (ObjectUtilities.equal(child.getType(), type) == false - && (secondType == null || ObjectUtilities.equal(child.getType(), secondType) == false)) ) - { - continue; - } + final Node[] columnDefs = columns.getNodeArray(); + int columnCounter = 0; + for (int i = 0; i < columnDefs.length; i++) + { + final Element column = (Element) columnDefs[i]; - if (node == tableCell) - { - return retval; - } - retval += 1; - } - return -1; - } + if (!ObjectUtilities.equal(column.getNamespace(), OfficeNamespaces.TABLE_NS) || + !ObjectUtilities.equal(column.getType(), OfficeToken.TABLE_COLUMN)) + { + continue; + } + if (columnCounter >= columnPos) + { + final String colStyle = (String) column.getAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME); + context.setColStyle(columnCounter - columnPos, colStyle); + } + + columnCounter += 1; + + if (columnCounter >= (columnPos + colSpan)) + { + break; + } - private LayoutController findParentCell() - { - LayoutController parent = getParent(); - while (parent != null) - { - final Object node = parent.getNode(); - if (node instanceof Element) - { - final Element element = (Element) node; - if (OfficeNamespaces.TABLE_NS.equals(element.getNamespace()) && "table-cell".equals(element.getType())) - { - return parent; } - } - parent = parent.getParent(); } - return null; - } - protected boolean isValueChanged() - { - final ImageElement imageElement = (ImageElement) getNode(); - final FormulaExpression formulaExpression = imageElement.getFormula(); - if (formulaExpression == null) + void addRowStyles(final ImageElementContext context, final Section table, final int rowPos, final int rowSpan) { - final FlowController controller = getFlowController(); - final GlobalMasterRow masterRow = controller.getMasterRow(); - final ReportDataRow reportDataRow = masterRow.getReportDataRow(); - if (reportDataRow.getCursor() == 0) - { - return true; - } - return false; - } + final Node[] rows = table.getNodeArray(); + int rowCounter = 0; + for (int i = 0; i < rows.length; i++) + { + final Element row = (Element) rows[i]; - try - { - final Formula formula = formulaExpression.getCompiledFormula(); - final LValue lValue = formula.getRootReference(); - return isReferenceChanged(lValue); - } - catch (ParseException e) - { - return false; - } - } + if (!ObjectUtilities.equal(row.getNamespace(), OfficeNamespaces.TABLE_NS) || + !ObjectUtilities.equal(row.getType(), OfficeToken.TABLE_ROW)) + { + continue; + } + if (rowCounter >= rowPos) + { + final String rowStyle = (String) row.getAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME); + context.setRowStyle(rowCounter - rowPos, rowStyle); + } + rowCounter += 1; + if (rowCounter >= (rowPos + rowSpan)) + { + break; + } + } + } } |