Tag: cws_dev300_rptchart02 User: oj Date: 2008-04-21 12:53:40+0000 Modified: dba/reportdesign/java/com/sun/star/report/OfficeToken.java dba/reportdesign/java/com/sun/star/report/SDBCReportDataFactory.java dba/reportdesign/java/com/sun/star/report/pentaho/output/spreadsheet/SpreadsheetRawReportTarget.java dba/reportdesign/java/com/sun/star/report/pentaho/output/text/TextRawReportTarget.java
Log: export chart for spreadsheet and set default command type as command File Changes: Directory: /dba/reportdesign/java/com/sun/star/report/ ====================================================== File [changed]: OfficeToken.java Url: http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/OfficeToken.java?r1=1.1.2.4&r2=1.1.2.5 Delta lines: +3 -2 ------------------- --- OfficeToken.java 2008-04-16 07:01:25+0000 1.1.2.4 +++ OfficeToken.java 2008-04-21 12:53:36+0000 1.1.2.5 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: OfficeToken.java,v $ - * $Revision: 1.1.2.4 $ + * $Revision: 1.1.2.5 $ * * This file is part of OpenOffice.org. * @@ -60,4 +60,5 @@ public static final String PRESERVE_IRI = "preserve-IRI"; public static final String SCALE = "scale"; public static final String NAME = "name"; + public static final String SHAPES = "shapes"; } File [changed]: SDBCReportDataFactory.java Url: http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/SDBCReportDataFactory.java?r1=1.3.4.2&r2=1.3.4.3 Delta lines: +16 -14 --------------------- --- SDBCReportDataFactory.java 2008-04-16 06:20:48+0000 1.3.4.2 +++ SDBCReportDataFactory.java 2008-04-21 12:53:37+0000 1.3.4.3 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: SDBCReportDataFactory.java,v $ - * $Revision: 1.3.4.2 $ + * $Revision: 1.3.4.3 $ * * This file is part of OpenOffice.org. * @@ -38,7 +38,6 @@ import com.sun.star.sdbc.XConnection; import com.sun.star.container.XNameAccess; import com.sun.star.lang.XComponent; -import com.sun.star.report.OfficeToken; import com.sun.star.sdb.CommandType; import com.sun.star.sdb.XCompletedExecution; import com.sun.star.sdb.XParametersSupplier; @@ -85,19 +84,22 @@ { try { - final int commandType; + int commandType = CommandType.COMMAND; final String commandTypeValue = (String) parameters.get(COMMAND_TYPE); + if (commandTypeValue != null) + { if (commandTypeValue.equals("query")) { commandType = CommandType.QUERY; } - else if (commandTypeValue.equals("command")) + else if (commandTypeValue.equals("table")) { - commandType = CommandType.COMMAND; + commandType = CommandType.TABLE; } else { - commandType = CommandType.TABLE; + commandType = CommandType.COMMAND; + } } final XRowSet rowSet = createRowSet(command, commandType, parameters); final XPropertySet rowSetProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, rowSet); Directory: /dba/reportdesign/java/com/sun/star/report/pentaho/output/spreadsheet/ ================================================================================= File [changed]: SpreadsheetRawReportTarget.java Url: http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/output/spreadsheet/SpreadsheetRawReportTarget.java?r1=1.5.4.3&r2=1.5.4.4 Delta lines: +102 -4 --------------------- --- SpreadsheetRawReportTarget.java 2008-04-16 06:23:50+0000 1.5.4.3 +++ SpreadsheetRawReportTarget.java 2008-04-21 12:53:37+0000 1.5.4.4 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: SpreadsheetRawReportTarget.java,v $ - * $Revision: 1.5.4.3 $ + * $Revision: 1.5.4.4 $ * * This file is part of OpenOffice.org. * @@ -51,6 +51,7 @@ import com.sun.star.report.pentaho.output.OfficeDocumentReportTarget; import com.sun.star.report.pentaho.output.StyleUtilities; import com.sun.star.report.pentaho.output.text.MasterPageFactory; +import com.sun.star.report.pentaho.styles.LengthCalculator; import java.util.Set; import org.jfree.layouting.util.AttributeMap; import org.jfree.layouting.input.style.values.CSSNumericValue; @@ -149,6 +150,7 @@ private String tableBackgroundColor; // null means transparent ... private static final ColumnBoundary[] EMPTY_COLBOUNDS = new ColumnBoundary[0]; private boolean elementBoundaryCollectionPass; + private boolean oleHandled; private final List columnBoundaryList; private float currentRowBoundaryMarker; private ColumnBoundary[] sortedBoundaryArray; @@ -157,6 +159,9 @@ private int columnCounter; private int columnSpanCounter; private String unitsOfMeasure; + private ArrayList shapes; + private ArrayList ole; + private ArrayList rowHeights; public SpreadsheetRawReportTarget(final ReportJob reportJob, final ResourceManager resourceManager, @@ -171,16 +176,21 @@ super(reportJob, resourceManager, baseResource, inputRepository, outputRepository, target, imageService, dataSourceFactory); columnBoundaryList = new ArrayList(); elementBoundaryCollectionPass = true; + rowHeights = new ArrayList(); + shapes = new ArrayList(); + ole = new ArrayList(); + oleHandled = false; } public void startOther(final AttributeMap attrs) throws DataSourceException, ReportProcessingException { if (ReportTargetUtil.isElementOfType(OfficeNamespaces.INTERNAL_NS, OfficeToken.OBJECT_OLE, attrs)) { - if (!isElementBoundaryCollectionPass() && getCurrentRole() != ROLE_TEMPLATE ) + if (isElementBoundaryCollectionPass() && getCurrentRole() != ROLE_TEMPLATE) { - startChartProcessing(attrs); + ole.add(attrs); } + oleHandled = true; return; } final String namespace = ReportTargetUtil.getNamespaceFromAttribute(attrs); @@ -195,6 +205,43 @@ paragraphFound = true; return; } + + if (OfficeNamespaces.DRAWING_NS.equals(namespace) && OfficeToken.FRAME.equals(elementType)) + { + if (isElementBoundaryCollectionPass() && getCurrentRole() != ROLE_TEMPLATE) + { + final LengthCalculator len = new LengthCalculator(); + double val = 0.0; + for (int i = 0; i < rowHeights.size(); i++) + { + len.add((CSSNumericValue) rowHeights.get(i)); + // val += ((CSSNumericValue)rowHeights.get(i)).getValue(); + } + + rowHeights.clear(); + final CSSNumericValue currentRowHeight = len.getResult(); + rowHeights.add(currentRowHeight); + attrs.setAttribute(OfficeNamespaces.DRAWING_NS, "z-index", String.valueOf(shapes.size())); + final String y = (String) attrs.getAttribute(OfficeNamespaces.SVG_NS, "y"); + if (y != null) + { + len.add(parseLength(y)); + final CSSNumericValue currentY = len.getResult(); + attrs.setAttribute(OfficeNamespaces.SVG_NS, "y", currentY.getValue() + currentY.getType().getType()); + } + shapes.add(attrs); + } + return; + } + if (oleHandled) + { + if (isElementBoundaryCollectionPass() && getCurrentRole() != ROLE_TEMPLATE) + { + ole.add(attrs); + } + return; + } + // if this is the report namespace, write out a table definition .. if (OfficeNamespaces.TABLE_NS.equals(namespace) && OfficeToken.TABLE.equals(elementType)) { @@ -474,6 +521,37 @@ return unitsOfMeasure; } + private void createTableShapes() throws ReportProcessingException + { + try + { + final XmlWriter xmlWriter = getXmlWriter(); + // at this point we need to generate the table-columns section based on our boundary table + // <table:shapes> + // <draw:frame /> + // .. + // </table:shapes> + xmlWriter.writeTag(OfficeNamespaces.TABLE_NS, OfficeToken.SHAPES, null, XmlWriterSupport.OPEN); + + + for (int i = 0; i < shapes.size(); i++) + { + final AttributeMap attrs = (AttributeMap) shapes.get(i); + final AttributeList attrList = buildAttributeList(attrs); + attrList.removeAttribute(OfficeNamespaces.DRAWING_NS, OfficeToken.STYLE_NAME); + xmlWriter.writeTag(OfficeNamespaces.DRAWING_NS, OfficeToken.FRAME, attrList, XmlWriterSupport.OPEN); + startChartProcessing((AttributeMap) ole.get(i)); + + xmlWriter.writeCloseTag(); + } + xmlWriter.writeCloseTag(); + } + catch (IOException e) + { + throw new ReportProcessingException("Failed", e); + } + } + private void createTableColumns() throws ReportProcessingException { try @@ -519,6 +597,19 @@ protected void endOther(final AttributeMap attrs) throws DataSourceException, ReportProcessingException { + if (ReportTargetUtil.isElementOfType(OfficeNamespaces.INTERNAL_NS, OfficeToken.OBJECT_OLE, attrs) || oleHandled) + { + oleHandled = false; + return; + } + + if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, OfficeToken.TABLE_ROW, attrs) + && isElementBoundaryCollectionPass() && getCurrentRole() != ROLE_TEMPLATE ) + { + final String styleName = (String) attrs.getAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME); + rowHeights.add(computeRowHeight(styleName)); + } + if (isRepeatingSection() || isElementBoundaryCollectionPass()) { return; @@ -530,6 +621,11 @@ return; } final String elementType = ReportTargetUtil.getElemenTypeFromAttribute(attrs); + if (OfficeNamespaces.DRAWING_NS.equals(namespace) && OfficeToken.FRAME.equals(elementType)) + { + return; + } + // if this is the report namespace, write out a table definition .. if (OfficeNamespaces.TABLE_NS.equals(namespace) && (OfficeToken.TABLE.equals(elementType) || OfficeToken.COVERED_TABLE_CELL.equals(elementType) || @@ -543,6 +639,7 @@ { return; } + paragraphHandled = false; try { @@ -621,6 +718,7 @@ performStyleProcessing(tableAttributes); xmlWriter.writeTag(OfficeNamespaces.TABLE_NS, OfficeToken.TABLE, buildAttributeList(tableAttributes), XmlWriterSupport.OPEN); + createTableShapes(); createTableColumns(); } } Directory: /dba/reportdesign/java/com/sun/star/report/pentaho/output/text/ ========================================================================== File [changed]: TextRawReportTarget.java Url: http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/output/text/TextRawReportTarget.java?r1=1.5.4.4&r2=1.5.4.5 Delta lines: +18 -13 --------------------- --- TextRawReportTarget.java 2008-04-16 06:24:08+0000 1.5.4.4 +++ TextRawReportTarget.java 2008-04-21 12:53:37+0000 1.5.4.5 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: TextRawReportTarget.java,v $ - * $Revision: 1.5.4.4 $ + * $Revision: 1.5.4.5 $ * * This file is part of OpenOffice.org. * @@ -52,7 +52,6 @@ import com.sun.star.report.pentaho.output.OfficeDocumentReportTarget; import com.sun.star.report.pentaho.output.StyleUtilities; import com.sun.star.report.pentaho.styles.LengthCalculator; -import java.util.HashSet; import org.jfree.layouting.input.style.values.CSSNumericValue; import org.jfree.layouting.util.AttributeMap; import org.jfree.report.DataSourceException; @@ -712,20 +711,26 @@ attrs.setAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME, style.getStyleName()); } } -/* + if ( ObjectUtilities.equal(OfficeNamespaces.DRAWING_NS, namespace) && ObjectUtilities.equal(OfficeToken.FRAME, elementType) ) { final String styleName = (String) attrs.getAttribute(OfficeNamespaces.DRAWING_NS, OfficeToken.STYLE_NAME); - final Object raw = StyleUtilities.queryStyle(getPredefinedStylesCollection(), OfficeToken.GRAPHIC, styleName, - OfficeToken.GRAPHIC_PROPERTIES, OfficeNamespaces.STYLE_NS, VERTICAL_POS); - - final OfficeStyle style = deriveStyle(OfficeToken.GRAPHIC, styleName); - Element graphicProperties = style.getGraphicProperties(); + final OfficeStyle predefAutoStyle = getPredefinedStylesCollection().getAutomaticStyles().getStyle(OfficeToken.GRAPHIC, styleName); + if (predefAutoStyle != null) + { + // special ole handling + Element graphicProperties = predefAutoStyle.getGraphicProperties(); graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, VERTICAL_POS, "from-top"); graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, HORIZONTAL_POS, "from-left"); - attrs.setAttribute(OfficeNamespaces.DRAWING_NS, OfficeToken.STYLE_NAME, style.getStyleName()); + graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, "vertical-rel", "paragraph-content"); + graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, "horizontal-rel", "paragraph"); + graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, "flow-with-text", "false"); + graphicProperties.setAttribute(OfficeNamespaces.DRAWING_NS, "ole-draw-aspect", "1"); + + // attrs.setAttribute(OfficeNamespaces.DRAWING_NS, OfficeToken.STYLE_NAME, predefAutoStyle.getStyleName()); + } } -*/ + // process the styles as usual performStyleProcessing(attrs); final XmlWriter xmlWriter = getXmlWriter(); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
