Tag: cws_src680_oj14 User: fs Date: 2007-06-15 11:39:49+0000 Modified: dba/reportdesign/java/com/sun/star/report/pentaho/output/OfficeDocumentReportTarget.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: supplied by [EMAIL PROTECTED], fixing #i78370#,#i78371#,#i77504#i#i78405# File Changes: Directory: /dba/reportdesign/java/com/sun/star/report/pentaho/output/ ===================================================================== File [changed]: OfficeDocumentReportTarget.java Url: http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/output/OfficeDocumentReportTarget.java?r1=1.1.2.8&r2=1.1.2.9 Delta lines: +5 -4 ------------------- --- OfficeDocumentReportTarget.java 2007-06-13 12:23:38+0000 1.1.2.8 +++ OfficeDocumentReportTarget.java 2007-06-15 11:39:46+0000 1.1.2.9 @@ -4,9 +4,9 @@ * * $RCSfile: OfficeDocumentReportTarget.java,v $ * - * $Revision: 1.1.2.8 $ + * $Revision: 1.1.2.9 $ * - * last change: $Author: fs $ $Date: 2007/06/13 12:23:38 $ + * last change: $Author: fs $ $Date: 2007/06/15 11:39:46 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -556,6 +556,7 @@ } catch (IOException ioe) { + ioe.printStackTrace(); throw new ReportProcessingException("Failed to write content", ioe); } // finally @@ -575,6 +576,7 @@ { final OfficeStylesCollection stylesCollection = getStylesCollection(); final OfficeStylesCollection predefCollection = getPredefinedStylesCollection(); + final OfficeStylesCollection globalStylesCollection = getGlobalStylesCollection(); final String elementNamespace = ReportTargetUtil.getNamespaceFromAttribute(attrs); @@ -615,8 +617,7 @@ } // Copy styles is only called once per style. - StyleUtilities.copyStyle(styleFamily, attrValue, stylesCollection, - getGlobalStylesCollection(), predefCollection); + StyleUtilities.copyStyle(styleFamily, attrValue, stylesCollection, globalStylesCollection, predefCollection); } } } 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.1.2.2&r2=1.1.2.3 Delta lines: +83 -8 -------------------- --- SpreadsheetRawReportTarget.java 2007-06-06 07:00:01+0000 1.1.2.2 +++ SpreadsheetRawReportTarget.java 2007-06-15 11:39:46+0000 1.1.2.3 @@ -4,9 +4,9 @@ * * $RCSfile: SpreadsheetRawReportTarget.java,v $ * - * $Revision: 1.1.2.2 $ + * $Revision: 1.1.2.3 $ * - * last change: $Author: oj $ $Date: 2007/06/06 07:00:01 $ + * last change: $Author: fs $ $Date: 2007/06/15 11:39:46 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -48,11 +48,19 @@ import com.sun.star.report.pentaho.OfficeNamespaces; import com.sun.star.report.pentaho.PentahoReportEngineMetaData; import com.sun.star.report.pentaho.model.OfficeStyle; +import com.sun.star.report.pentaho.model.OfficeStyles; +import com.sun.star.report.pentaho.model.OfficeStylesCollection; +import com.sun.star.report.pentaho.model.OfficeMasterPage; +import com.sun.star.report.pentaho.model.OfficeMasterStyles; import com.sun.star.report.pentaho.output.OfficeDocumentReportTarget; +import com.sun.star.report.pentaho.output.text.MasterPageFactory; import org.jfree.layouting.util.AttributeMap; +import org.jfree.layouting.input.style.values.CSSNumericValue; +import org.jfree.layouting.input.style.values.CSSNumericType; import org.jfree.report.DataFlags; import org.jfree.report.DataSourceException; import org.jfree.report.ReportProcessingException; +import org.jfree.report.JFreeReportInfo; import org.jfree.report.flow.ReportJob; import org.jfree.report.flow.ReportStructureRoot; import org.jfree.report.flow.ReportTargetUtil; @@ -426,13 +434,80 @@ protected void startContent(final AttributeMap attrs) throws IOException, DataSourceException, ReportProcessingException { - if (isElementBoundaryCollectionPass() == false) + if (isElementBoundaryCollectionPass()) { + return; + } + final XmlWriter xmlWriter = getXmlWriter(); xmlWriter.writeTag(OfficeNamespaces.OFFICE_NS, "spreadsheet", null, XmlWriterSupport.OPEN); - xmlWriter.writeTag(OfficeNamespaces.TABLE_NS, "table", null, XmlWriterSupport.OPEN); + + final AttributeMap tableAttributes = new AttributeMap(); + tableAttributes.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, Element.NAMESPACE_ATTRIBUTE, OfficeNamespaces.TABLE_NS); + tableAttributes.setAttribute(JFreeReportInfo.REPORT_NAMESPACE, Element.TYPE_ATTRIBUTE, "table"); + tableAttributes.setAttribute(OfficeNamespaces.TABLE_NS, "style-name", generateInitialTableStyle()); + tableAttributes.setAttribute(OfficeNamespaces.TABLE_NS, "name", "Report"); + + performStyleProcessing(tableAttributes); + + xmlWriter.writeTag(OfficeNamespaces.TABLE_NS, "table", buildAttributeList(tableAttributes), XmlWriterSupport.OPEN); createTableColumns(); } + + private String generateInitialTableStyle () throws ReportProcessingException + { + final OfficeStylesCollection predefStyles = getPredefinedStylesCollection(); + final OfficeStyles commonStyles = predefStyles.getAutomaticStyles(); + if (commonStyles.containsStyle("table", "Initial_Table") == false) + { + final String masterPageName = createMasterPage(); + + final OfficeStyle tableStyle = new OfficeStyle(); + tableStyle.setStyleFamily("table"); + tableStyle.setStyleName("Initial_Table"); + tableStyle.setAttribute(OfficeNamespaces.STYLE_NS, "master-page-name", masterPageName); + final Element tableProperties = produceFirstChild(tableStyle, OfficeNamespaces.STYLE_NS, "table-properties"); + tableProperties.setAttribute(OfficeNamespaces.FO_NS, "background-color", "transparent"); + commonStyles.addStyle(tableStyle); + } + return "Initial_Table"; + } + + private String createMasterPage() throws ReportProcessingException + { + final OfficeStylesCollection predefStyles = getPredefinedStylesCollection(); + final MasterPageFactory masterPageFactory = new MasterPageFactory(predefStyles.getMasterStyles()); + final OfficeMasterPage masterPage; + if (masterPageFactory.containsMasterPage("Standard", null, null) == false) + { + masterPage = masterPageFactory.createMasterPage("Standard", null, null); + + final CSSNumericValue zeroLength = CSSNumericValue.createValue(CSSNumericType.CM, 0); + final String pageLayoutTemplate = masterPage.getPageLayout(); + if (pageLayoutTemplate == null) + { + // there is no pagelayout. Create one .. + final String derivedLayout = masterPageFactory.createPageStyle + (getGlobalStylesCollection().getAutomaticStyles(), zeroLength, zeroLength); + masterPage.setPageLayout(derivedLayout); + } + else + { + final String derivedLayout = masterPageFactory.derivePageStyle(pageLayoutTemplate, + getPredefinedStylesCollection().getAutomaticStyles(), + getGlobalStylesCollection().getAutomaticStyles(), zeroLength, zeroLength); + masterPage.setPageLayout(derivedLayout); + } + + final OfficeStylesCollection officeStylesCollection = getGlobalStylesCollection(); + final OfficeMasterStyles officeMasterStyles = officeStylesCollection.getMasterStyles(); + officeMasterStyles.addMasterPage(masterPage); + } + else + { + masterPage = masterPageFactory.getMasterPage("Standard", null, null); + } + return masterPage.getStyleName(); } protected void endContent(final AttributeMap attrs) throws IOException, DataSourceException, @@ -539,7 +614,7 @@ if (initialColumnSpan > 1) { // ok we've got some additional spanning specified on the input - int index = (col - 1) + (initialColumnSpan - 1); + final int index = (col - 1) + (initialColumnSpan - 1); cellWidth += tableBoundaries[index].getBoundary() - tableBoundaries[col - 1].getBoundary(); cellBoundary = tableBoundaries[index].getBoundary(); } 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.1.2.5&r2=1.1.2.6 Delta lines: +90 -22 --------------------- --- TextRawReportTarget.java 2007-06-11 19:29:07+0000 1.1.2.5 +++ TextRawReportTarget.java 2007-06-15 11:39:47+0000 1.1.2.6 @@ -4,9 +4,9 @@ * * $RCSfile: TextRawReportTarget.java,v $ * - * $Revision: 1.1.2.5 $ + * $Revision: 1.1.2.6 $ * - * last change: $Author: fs $ $Date: 2007/06/11 19:29:07 $ + * last change: $Author: fs $ $Date: 2007/06/15 11:39:47 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -70,6 +70,8 @@ import org.jfree.resourceloader.ResourceKey; import org.jfree.resourceloader.ResourceManager; import org.jfree.util.FastStack; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.Log; import org.jfree.xmlns.common.AttributeList; import org.jfree.xmlns.writer.XmlWriter; import org.jfree.xmlns.writer.XmlWriterSupport; @@ -259,6 +261,7 @@ activePageHeader = context.getPageHeaderContent(); } + final String masterPageName; if (currentMasterPage == null || masterPageFactory.containsMasterPage("Standard", activePageHeader, activePageFooter) == false) { @@ -294,11 +297,21 @@ currentMasterPage.setPageLayout(derivedLayout); } officeMasterStyles.addMasterPage(currentMasterPage); + masterPageName = currentMasterPage.getStyleName(); } else { // retrieve the master-page. - currentMasterPage = masterPageFactory.getMasterPage("Standard", activePageHeader, activePageFooter); + final OfficeMasterPage masterPage = masterPageFactory.getMasterPage("Standard", activePageHeader, activePageFooter); + if (ObjectUtilities.equal(masterPage.getStyleName(), currentMasterPage.getStyleName())) + { + // They are the same, + masterPageName = null; + } + else + { + masterPageName = currentMasterPage.getStyleName(); + } } // if either the pageheader or footer are *not* printed with the @@ -311,7 +324,7 @@ setPagebreakDefinition(new PageBreakDefinition(isResetPageNumber())); } - return currentMasterPage.getStyleName(); + return masterPageName; } private boolean isColumnBreakPending() @@ -575,15 +588,11 @@ final XmlWriter xmlWriter = getXmlWriter(); if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, "table-row", attrs)) { - firstCellSeen = false; - expectedTableRowCount -= 1; - final String rowStyle = (String) - attrs.getAttribute(OfficeNamespaces.TABLE_NS, "style-name"); - final CSSNumericValue rowHeight = computeRowHeight(rowStyle); - // Log.debug("Adding row-Style: " + rowStyle + " " + rowHeight); - sectionHeight.add(rowHeight); + startRow(attrs); + return; } - else if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TEXT_NS, "variable-set", attrs)) + + if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TEXT_NS, "variable-set", attrs)) { // update the variables-declaration thingie .. final String varName = (String) attrs.getAttribute(OfficeNamespaces.TEXT_NS, "name"); @@ -639,10 +648,37 @@ } + private void startRow(final AttributeMap attrs) + throws IOException, ReportProcessingException + { + firstCellSeen = false; + expectedTableRowCount -= 1; + final String rowStyle = (String) attrs.getAttribute(OfficeNamespaces.TABLE_NS, "style-name"); + final CSSNumericValue rowHeight = computeRowHeight(rowStyle); + // Log.debug("Adding row-Style: " + rowStyle + " " + rowHeight); + sectionHeight.add(rowHeight); + + if (expectedTableRowCount > 0) + { + // Some other row. Create a keep-together + + } + else + { + // This is the last row before the section will end. + // or (in some weird cases) There is no information when the row will end. + // Anyway, if we are here, we do not create a keep-together style on the table-row .. + } + // process the styles as usual + performStyleProcessing(attrs); + + final AttributeList attrList = buildAttributeList(attrs); + getXmlWriter().writeTag(OfficeNamespaces.TABLE_NS, "table-row", attrList, XmlWriterSupport.OPEN); + } + private void startTable(final AttributeMap attrs) throws ReportProcessingException, IOException { - final Integer trc = (Integer) attrs.getAttribute(OfficeNamespaces.INTERNAL_NS, "table-row-count"); if (trc == null) { @@ -670,23 +706,31 @@ if (getCurrentRole() == OfficeDocumentReportTarget.ROLE_REPORT_HEADER) { breakDefinition = new PageBreakDefinition(isResetPageNumber()); - masterPageName = createMasterPage - (pageHeaderOnReportHeader, pageFooterOnReportHeader); + masterPageName = createMasterPage(pageHeaderOnReportHeader, pageFooterOnReportHeader); + if (masterPageName == null) + { + // we should always have a master-page ... + masterPageName = currentMasterPage.getStyleName(); + } } - else if (getCurrentRole() == - OfficeDocumentReportTarget.ROLE_REPORT_FOOTER) + else if (getCurrentRole() == OfficeDocumentReportTarget.ROLE_REPORT_FOOTER) { breakDefinition = new PageBreakDefinition(isResetPageNumber()); masterPageName = createMasterPage (pageHeaderOnReportFooter, pageFooterOnReportFooter); + if (masterPageName == null || isSectionPagebreakBefore(attrs)) + { + // If we have a manual pagebreak, then activate the current master-page again. + masterPageName = currentMasterPage.getStyleName(); } - else if (getCurrentRole() == - OfficeDocumentReportTarget.ROLE_REPEATING_GROUP_HEADER) + // But we skip this (and therefore the resulting pagebreak) if there is no manual break + // and no other condition that would force an break. + } + else if (getCurrentRole() == OfficeDocumentReportTarget.ROLE_REPEATING_GROUP_HEADER) { // no pagebreaks .. } - else if (getCurrentRole() == - OfficeDocumentReportTarget.ROLE_REPEATING_GROUP_FOOTER) + else if (getCurrentRole() == OfficeDocumentReportTarget.ROLE_REPEATING_GROUP_FOOTER) { // no pagebreaks .. } @@ -694,6 +738,11 @@ { // Must be the first table, as we have no master-page yet. masterPageName = createMasterPage(true, true); + if (masterPageName == null) + { + // we should always have a master-page ... + masterPageName = currentMasterPage.getStyleName(); + } breakDefinition = new PageBreakDefinition(isResetPageNumber()); } else if (isPagebreakPending()) @@ -703,6 +752,11 @@ breakDefinition = getPagebreakDefinition(); setPagebreakDefinition(null); masterPageName = createMasterPage(true, true); + if (masterPageName == null) + { + // we should always have a master-page ... + masterPageName = currentMasterPage.getStyleName(); + } } } else if (isPagebreakPending() && @@ -714,10 +768,21 @@ breakDefinition = getPagebreakDefinition(); setPagebreakDefinition(null); masterPageName = createMasterPage(true, true); + if (masterPageName == null || isSectionPagebreakBefore(attrs)) + { + // If we have a manual pagebreak, then activate the current master-page again. + masterPageName = currentMasterPage.getStyleName(); + } } - final XmlWriter xmlWriter = getXmlWriter(); + if (detailBandProcessingState == DETAIL_SECTION_OTHER_PRINTED && + masterPageName != null) + { + // close the last table-tag, we will open a new one + xmlWriter.writeCloseTag(); + } + if (tableLayoutConfig == TABLE_LAYOUT_VARIABLES_PARAGRAPH && variables != null) { if (masterPageName != null) @@ -842,6 +907,8 @@ { final Element tableProps = produceFirstChild(style, OfficeNamespaces.STYLE_NS, "table-properties"); tableProps.setAttribute(OfficeNamespaces.FO_NS, "keep-with-next", "always"); + // A keep-with-next does not work, if the may-break-betweek rows is not set to false .. + tableProps.setAttribute(OfficeNamespaces.STYLE_NS, "may-break-between-rows", "false"); } attrs.setAttribute(OfficeNamespaces.TABLE_NS, "style-name", style.getStyleName()); // no need to copy the styles, this was done while deriving the @@ -1262,6 +1329,7 @@ { if (detailBandProcessingState == DETAIL_SECTION_OTHER_PRINTED) { + // closes the table .. final XmlWriter xmlWriter = getXmlWriter(); xmlWriter.writeCloseTag(); detailBandProcessingState = DETAIL_SECTION_WAIT; --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
