Tag: cws_dev300_rptchart02
User: oj      
Date: 2008-05-27 08:06:20+0000
Modified:
   dba/reportdesign/java/com/sun/star/report/SDBCReportDataFactory.java
   
dba/reportdesign/java/com/sun/star/report/pentaho/output/OfficeDocumentReportTarget.java
   dba/reportdesign/java/com/sun/star/report/pentaho/output/StyleUtilities.java
   
dba/reportdesign/java/com/sun/star/report/pentaho/output/text/TextRawReportTarget.java
   
dba/reportdesign/java/com/sun/star/report/pentaho/parser/rpt/GroupReadHandler.java
   
dba/reportdesign/java/com/sun/star/report/pentaho/parser/rpt/ReportReadHandler.java

Log:
 #i77610# handle keep-with-next and may-break-between-rows and keep-together

File Changes:

Directory: /dba/reportdesign/java/com/sun/star/report/
======================================================

File [changed]: SDBCReportDataFactory.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/SDBCReportDataFactory.java?r1=1.3.4.7&r2=1.3.4.8
Delta lines:  +1 -7
-------------------
--- SDBCReportDataFactory.java  2008-05-22 08:04:52+0000        1.3.4.7
+++ SDBCReportDataFactory.java  2008-05-27 08:06:15+0000        1.3.4.8
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: SDBCReportDataFactory.java,v $
- * $Revision: 1.3.4.7 $
+ * $Revision: 1.3.4.8 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -399,14 +399,8 @@
             final XParametersSupplier paraSup = (XParametersSupplier) 
UnoRuntime.queryInterface(XParametersSupplier.class, composer);
             if (paraSup != null)
             {
-<<<<<<< SDBCReportDataFactory.java
                 final XIndexAccess params = paraSup.getParameters();
                 if (params != null)
-=======
-                // get old parameter count
-                final XParametersSupplier paraSup = (XParametersSupplier) 
UnoRuntime.queryInterface(XParametersSupplier.class, composer);
-                if (paraSup != null)
->>>>>>> 1.3.4.6
                 {
                     oldParameterCount = params.getCount();
                 }

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.5.4.4&r2=1.5.4.5
Delta lines:  +33 -35
---------------------
--- OfficeDocumentReportTarget.java     2008-04-16 06:23:32+0000        1.5.4.4
+++ OfficeDocumentReportTarget.java     2008-05-27 08:06:15+0000        1.5.4.5
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: OfficeDocumentReportTarget.java,v $
- * $Revision: 1.5.4.4 $
+ * $Revision: 1.5.4.5 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -100,8 +100,8 @@
  */
 public abstract class OfficeDocumentReportTarget extends AbstractReportTarget
 {
-    public static final String HORIZONTAL_POS = "horizontal-pos";
 
+    public static final String HORIZONTAL_POS = "horizontal-pos";
     public static final String TAG_DEF_PREFIX = 
"com.sun.star.report.pentaho.output.";
     public static final int ROLE_NONE = 0;
     public static final int ROLE_REPORT_HEADER = 1;
@@ -117,7 +117,6 @@
     public static final int ROLE_TEMPLATE = 11;
     public static final int ROLE_SPREADSHEET_PAGE_HEADER = 12;
     public static final int ROLE_SPREADSHEET_PAGE_FOOTER = 13;
-    
     public static final int STATE_IN_DOCUMENT = 0;
     public static final int STATE_IN_BODY = 1;
     public static final int STATE_IN_CONTENT = 2;
@@ -130,7 +129,6 @@
     public static final String VERTICAL_POS = "vertical-pos";
     private static final String ZERO_CM = "0cm";
     
-
     protected static class BufferState
     {
 
@@ -379,22 +377,24 @@
             predefinedStylesCollection = reportDoc.getStylesCollection();
 
             final OfficeStyles commonStyles = 
predefinedStylesCollection.getCommonStyles();
-            if 
(!commonStyles.containsStyle(OfficeToken.GRAPHIC,OfficeToken.GRAPHICS))
+            if (!commonStyles.containsStyle(OfficeToken.GRAPHIC, 
OfficeToken.GRAPHICS))
             {
                 final OfficeStyle graphicsDefaultStyle = new OfficeStyle();
                 graphicsDefaultStyle.setStyleFamily(OfficeToken.GRAPHIC);
                 graphicsDefaultStyle.setStyleName(OfficeToken.GRAPHICS);
-                final Element graphicProperties = 
produceFirstChild(graphicsDefaultStyle, 
OfficeNamespaces.STYLE_NS,OfficeToken.GRAPHIC_PROPERTIES);
-                graphicProperties.setAttribute(OfficeNamespaces.TEXT_NS, 
"anchor-type",OfficeToken.PARAGRAPH);
-                graphicProperties.setAttribute(OfficeNamespaces.SVG_NS, 
"x",ZERO_CM);
-                graphicProperties.setAttribute(OfficeNamespaces.SVG_NS, 
"y",ZERO_CM);
+                final Element graphicProperties = 
produceFirstChild(graphicsDefaultStyle, OfficeNamespaces.STYLE_NS, 
OfficeToken.GRAPHIC_PROPERTIES);
+                graphicProperties.setAttribute(OfficeNamespaces.TEXT_NS, 
"anchor-type", OfficeToken.PARAGRAPH);
+                graphicProperties.setAttribute(OfficeNamespaces.SVG_NS, "x", 
ZERO_CM);
+                graphicProperties.setAttribute(OfficeNamespaces.SVG_NS, "y", 
ZERO_CM);
                 graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, 
"wrap", "dynamic");
                 graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, 
"number-wrapped-paragraphs", "no-limit");
                 graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, 
"wrap-contour", OfficeToken.FALSE);
                 graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, 
VERTICAL_POS, "from-top"); // changed for chart
-                graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, 
"vertical-rel",OfficeToken.PARAGRAPH);
-                
graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS,HORIZONTAL_POS, 
"from-left"); // changed for chart
-                graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, 
"horizontal-rel",OfficeToken.PARAGRAPH);
+
+                graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, 
"vertical-rel", OfficeToken.PARAGRAPH);
+                graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, 
HORIZONTAL_POS, "from-left"); // changed for chart
+
+                graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, 
"horizontal-rel", OfficeToken.PARAGRAPH);
                 commonStyles.addStyle(graphicsDefaultStyle);
             }
 
@@ -408,7 +408,7 @@
         }
         catch (IOException e)
         {
-            throw new ReportProcessingException( FAILED,e);
+            throw new ReportProcessingException(FAILED, e);
         }
     }
 
@@ -813,7 +813,6 @@
     protected void startGroupInstance(final AttributeMap attrs)
             throws IOException, DataSourceException, ReportProcessingException
     {
-
     }
 
     protected void startGroupBody(final AttributeMap attrs)
@@ -844,7 +843,7 @@
         }
         catch (IOException e)
         {
-            throw new ReportProcessingException( FAILED,e);
+            throw new ReportProcessingException(FAILED, e);
         }
     }
 
@@ -907,7 +906,7 @@
         }
         catch (IOException e)
         {
-            throw new ReportProcessingException( FAILED,e);
+            throw new ReportProcessingException(FAILED, e);
         }
     }
 
@@ -988,13 +987,11 @@
     protected void endGroupBody(final AttributeMap attrs)
             throws IOException, DataSourceException, ReportProcessingException
     {
-
     }
 
     protected void endGroupInstance(final AttributeMap attrs)
             throws IOException, DataSourceException, ReportProcessingException
     {
-
     }
 
     public int getCurrentRole()
@@ -1058,7 +1055,7 @@
         }
         catch (IOException e)
         {
-            throw new ReportProcessingException( FAILED,e);
+            throw new ReportProcessingException(FAILED, e);
         }
     }
 
@@ -1264,6 +1261,7 @@
 
             // When scaling, we have to create an image-style.
             final CSSNumericValue width = image.getWidth(); // always in 100th 
of a mm
+
             final CSSNumericValue height = image.getHeight(); // always in 
100th of a mm
 
             Log.debug("Image " + imageData + " Width: " + width + ", Height: " 
+ height);
@@ -1300,8 +1298,8 @@
                         final double clipHeight = 
normalizedImageHeight.getValue() - imageAreaHeightVal.getValue();
                         if (clipWidth > 0 && clipHeight > 0)
                         {
-                            final OfficeStyle imageStyle = 
deriveStyle(OfficeToken.GRAPHIC,OfficeToken.GRAPHICS);
-                            final Element graphProperties = 
produceFirstChild(imageStyle, 
OfficeNamespaces.STYLE_NS,OfficeToken.GRAPHIC_PROPERTIES);
+                            final OfficeStyle imageStyle = 
deriveStyle(OfficeToken.GRAPHIC, OfficeToken.GRAPHICS);
+                            final Element graphProperties = 
produceFirstChild(imageStyle, OfficeNamespaces.STYLE_NS, 
OfficeToken.GRAPHIC_PROPERTIES);
                             final StringBuffer buffer = new StringBuffer();
                             buffer.append("rect(");
                             buffer.append(clipHeight / 2);
@@ -1323,8 +1321,8 @@
                         }
                         else if (clipWidth > 0)
                         {
-                            final OfficeStyle imageStyle = 
deriveStyle(OfficeToken.GRAPHIC,OfficeToken.GRAPHICS);
-                            final Element graphProperties = 
produceFirstChild(imageStyle, 
OfficeNamespaces.STYLE_NS,OfficeToken.GRAPHIC_PROPERTIES);
+                            final OfficeStyle imageStyle = 
deriveStyle(OfficeToken.GRAPHIC, OfficeToken.GRAPHICS);
+                            final Element graphProperties = 
produceFirstChild(imageStyle, OfficeNamespaces.STYLE_NS, 
OfficeToken.GRAPHIC_PROPERTIES);
                             final StringBuffer buffer = new StringBuffer();
                             buffer.append("rect(0cm ");
                             buffer.append(clipWidth / 2);
@@ -1341,8 +1339,8 @@
                         }
                         else if (clipHeight > 0)
                         {
-                            final OfficeStyle imageStyle = 
deriveStyle(OfficeToken.GRAPHIC,OfficeToken.GRAPHICS);
-                            final Element graphProperties = 
produceFirstChild(imageStyle, 
OfficeNamespaces.STYLE_NS,OfficeToken.GRAPHIC_PROPERTIES);
+                            final OfficeStyle imageStyle = 
deriveStyle(OfficeToken.GRAPHIC, OfficeToken.GRAPHICS);
+                            final Element graphProperties = 
produceFirstChild(imageStyle, OfficeNamespaces.STYLE_NS, 
OfficeToken.GRAPHIC_PROPERTIES);
                             final StringBuffer buffer = new StringBuffer();
                             buffer.append("rect(");
                             buffer.append(clipHeight / 2);
@@ -1381,10 +1379,10 @@
             {
                 frameList.setAttribute(OfficeNamespaces.DRAWING_NS, 
OfficeToken.STYLE_NAME, styleName);
             }
-            frameList.setAttribute(OfficeNamespaces.TEXT_NS, 
"anchor-type",OfficeToken.PARAGRAPH);
+            frameList.setAttribute(OfficeNamespaces.TEXT_NS, "anchor-type", 
OfficeToken.PARAGRAPH);
             frameList.setAttribute(OfficeNamespaces.SVG_NS, "z-index", "0");
-            frameList.setAttribute(OfficeNamespaces.SVG_NS, "x",ZERO_CM);
-            frameList.setAttribute(OfficeNamespaces.SVG_NS, "y",ZERO_CM);
+            frameList.setAttribute(OfficeNamespaces.SVG_NS, "x", ZERO_CM);
+            frameList.setAttribute(OfficeNamespaces.SVG_NS, "y", ZERO_CM);
 
             Log.debug("Image " + imageData + " A-Width: " + imageAreaWidthVal 
+ ", A-Height: " + imageAreaHeightVal);
 
@@ -1416,7 +1414,7 @@
             }
             catch (IOException ioe)
             {
-                throw new ReportProcessingException( FAILED,ioe);
+                throw new ReportProcessingException(FAILED, ioe);
             }
         }
     }
@@ -1623,7 +1621,7 @@
         }
         catch (IOException ioe)
         {
-            throw new ReportProcessingException( FAILED,ioe);
+            throw new ReportProcessingException(FAILED, ioe);
         }
 
 

File [changed]: StyleUtilities.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/output/StyleUtilities.java?r1=1.5.4.2&r2=1.5.4.3
Delta lines:  +45 -3
--------------------
--- StyleUtilities.java 2008-04-16 06:23:38+0000        1.5.4.2
+++ StyleUtilities.java 2008-05-27 08:06:16+0000        1.5.4.3
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: StyleUtilities.java,v $
- * $Revision: 1.5.4.2 $
+ * $Revision: 1.5.4.3 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -38,6 +38,7 @@
 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 java.util.ArrayList;
 import java.util.Set;
 import org.jfree.report.ReportProcessingException;
 import org.jfree.report.structure.Element;
@@ -448,7 +449,7 @@
 
         // now copy the common style ..
         final OfficeStyles commonStyles = commonCollection.getCommonStyles();
-        if (!commonStyles.containsStyle(styleFamily, styleName) )
+        if (!commonStyles.containsStyle(styleFamily, styleName))
         {
             copyStyleInternal(commonStyle, commonStyles,
                     commonCollection, commonCollection, predefCollection,
@@ -500,6 +501,46 @@
                 styleName, sectionName, propertyNamespace, propertyName, new 
HashSet());
     }
 
+    public static OfficeStyle queryStyleByProperties(final 
OfficeStylesCollection predefCollection,
+            final String styleFamily,
+            final String sectionName,
+            final ArrayList propertyNamespace,
+            final ArrayList propertyName,
+            final ArrayList propertyValues)
+    {
+        if ( propertyNamespace.size() != propertyName.size())
+            return null;
+        final OfficeStyle[] styles = 
predefCollection.getAutomaticStyles().getAllStyles();
+        for (int i = 0; i < styles.length; i++)
+        {
+            final OfficeStyle officeStyle = styles[i];
+            if ( officeStyle.getStyleFamily().equals(styleFamily) )
+            {
+                final Element section = 
officeStyle.findFirstChild(OfficeNamespaces.STYLE_NS, sectionName);
+                if (section != null)
+                {
+                    int j = 0;
+                    for (; j < propertyNamespace.size(); j++)
+                    {
+                        final String ns = (String)propertyNamespace.get(j);
+                        final String prop = (String)propertyName.get(j);
+                        final Object obj = section.getAttribute(ns, prop);
+                        final Object value = propertyValues.get(j);
+                        if ( obj == null && value == null)
+                            continue;
+                        if (!propertyValues.get(j).equals(obj))
+                            break;
+                    }
+                    if ( j == propertyName.size() )
+                    {
+                        return officeStyle;
+                    }
+                }
+            }
+        }
+        return null;
+    }
+
     private static String queryStyle(final OfficeStylesCollection 
predefCollection,
             final String styleFamily,
             final String styleName,
@@ -518,6 +559,7 @@
         if (style == null)
         {
             return null; // no such style
+
         }
         final Element section = 
style.findFirstChild(OfficeNamespaces.STYLE_NS, sectionName);
         if (section != null)

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.5&r2=1.5.4.6
Delta lines:  +114 -71
----------------------
--- TextRawReportTarget.java    2008-04-21 12:53:37+0000        1.5.4.5
+++ TextRawReportTarget.java    2008-05-27 08:06:16+0000        1.5.4.6
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: TextRawReportTarget.java,v $
- * $Revision: 1.5.4.5 $
+ * $Revision: 1.5.4.6 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -52,6 +52,7 @@
 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.ArrayList;
 import org.jfree.layouting.input.style.values.CSSNumericValue;
 import org.jfree.layouting.util.AttributeMap;
 import org.jfree.report.DataSourceException;
@@ -60,6 +61,7 @@
 import org.jfree.report.flow.ReportStructureRoot;
 import org.jfree.report.flow.ReportTargetUtil;
 import org.jfree.report.structure.Element;
+import org.jfree.report.structure.Node;
 import org.jfree.report.structure.Section;
 import org.jfree.report.util.AttributeNameGenerator;
 import org.jfree.report.util.IntegerCache;
@@ -83,11 +85,13 @@
     private static final String ALWAYS = "always";
     private static final String KEEP_TOGETHER = "keep-together";
     private static final String KEEP_WITH_NEXT = "keep-with-next";
+    private static final String MAY_BREAK_BETWEEN_ROWS = 
"may-break-between-rows";
     private static final String NAME = "name";
     private static final String NONE = "none";
     private static final String NORMAL = "normal";
     private static final String PARAGRAPH_PROPERTIES = "paragraph-properties";
     private static final String STANDARD = "Standard";
+    private static final String TABLE_PROPERTIES = "table-properties";
     private static final String VARIABLES_HIDDEN_STYLE_WITH_KEEPWNEXT = 
"variables_paragraph_with_next";
     private static final String VARIABLES_HIDDEN_STYLE_WITHOUT_KEEPWNEXT = 
"variables_paragraph_without_next";
     private static final int TABLE_LAYOUT_VARIABLES_PARAGRAPH = 0;
@@ -564,7 +568,7 @@
             {
                 startImageProcessing(attrs);
             }
-            else if (ObjectUtilities.equal(OfficeToken.OBJECT_OLE, 
elementType) && getCurrentRole() != ROLE_TEMPLATE )
+            else if (ObjectUtilities.equal(OfficeToken.OBJECT_OLE, 
elementType) && getCurrentRole() != ROLE_TEMPLATE)
             {
                 startChartProcessing(attrs);
             }
@@ -652,42 +656,38 @@
             {
                 if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TEXT_NS, 
OfficeToken.P, attrs))
                 {
+                    final int keepTogetherState = 
getCurrentContext().getKeepTogether();
                     cellEmpty = false;
-                    if (!firstCellSeen && sectionKeepTogether)
+                    if (!firstCellSeen && (sectionKeepTogether || 
keepTogetherState == PageContext.KEEP_TOGETHER_GROUP))
                     {
+                        OfficeStyle style = null;
                         final String styleName = (String) 
attrs.getAttribute(OfficeNamespaces.TEXT_NS, OfficeToken.STYLE_NAME);
-                        final OfficeStyle style = 
deriveStyle(OfficeToken.PARAGRAPH, styleName);
-                        // Lets set the 'keep-together' flag..
+                        if (styleName == null)
+                        {
+                            final boolean keep = (keepTogetherState == 
PageContext.KEEP_TOGETHER_GROUP || expectedTableRowCount > 0) && 
isParentKeepTogether();
+                            final ArrayList propertyNameSpaces = new 
ArrayList();
+                            final ArrayList propertyNames = new ArrayList();
+                            final ArrayList propertyValues = new ArrayList();
 
-                        Element paragraphProps = 
style.getParagraphProperties();
-                        if (paragraphProps == null)
+                            propertyNameSpaces.add(OfficeNamespaces.FO_NS);
+                            propertyNameSpaces.add(OfficeNamespaces.FO_NS);
+                            propertyNames.add(KEEP_TOGETHER);
+                            propertyValues.add(ALWAYS);
+                            if (keep)
                         {
-                            paragraphProps = new Section();
-                            
paragraphProps.setNamespace(OfficeNamespaces.STYLE_NS);
-                            paragraphProps.setType(PARAGRAPH_PROPERTIES);
-                            style.addNode(paragraphProps);
+                                propertyNames.add(KEEP_WITH_NEXT);
+                                propertyValues.add(ALWAYS);
                         }
-                        paragraphProps.setAttribute(OfficeNamespaces.FO_NS, 
KEEP_TOGETHER, ALWAYS);
-                        final int keepTogetherState = 
getCurrentContext().getKeepTogether();
-                        // We prevent pagebreaks within the two adjacent rows 
(this one and the next one) if
-                        // either a group-wide keep-together is defined or if 
we haven't reached the end of the
-                        // current section yet.
-                        if (keepTogetherState == 
PageContext.KEEP_TOGETHER_GROUP || expectedTableRowCount > 0)
+                            else
                         {
-                            
paragraphProps.setAttribute(OfficeNamespaces.FO_NS, KEEP_WITH_NEXT, ALWAYS);
+                                propertyNames.add(KEEP_WITH_NEXT);
+                                propertyValues.add(null);
                         }
-
-                        attrs.setAttribute(OfficeNamespaces.TEXT_NS, 
OfficeToken.STYLE_NAME, style.getStyleName());
+                            style = 
StyleUtilities.queryStyleByProperties(getStylesCollection(), 
OfficeToken.PARAGRAPH, PARAGRAPH_PROPERTIES, propertyNameSpaces, propertyNames, 
propertyValues);
                     }
-                }
-            }
-            else if (isTableNS && 
ObjectUtilities.equal(OfficeToken.TABLE_CELL, elementType))
-            {
-                cellEmpty = false;
-                if (!firstCellSeen && sectionKeepTogether)
+                        if (style == null)
                 {
-                    final String styleName = (String) 
attrs.getAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME);
-                    final OfficeStyle style = 
deriveStyle(OfficeToken.TABLE_CELL, styleName);
+                            style = deriveStyle(OfficeToken.PARAGRAPH, 
styleName);
                     // Lets set the 'keep-together' flag..
 
                     Element paragraphProps = style.getParagraphProperties();
@@ -699,20 +699,22 @@
                         style.addNode(paragraphProps);
                     }
                     paragraphProps.setAttribute(OfficeNamespaces.FO_NS, 
KEEP_TOGETHER, ALWAYS);
-                    final int keepTogetherState = 
getCurrentContext().getKeepTogether();
+
                     // We prevent pagebreaks within the two adjacent rows 
(this one and the next one) if
                     // either a group-wide keep-together is defined or if we 
haven't reached the end of the
                     // current section yet.
-                    if (keepTogetherState == PageContext.KEEP_TOGETHER_GROUP 
|| expectedTableRowCount > 0)
+                            if ((keepTogetherState == 
PageContext.KEEP_TOGETHER_GROUP || expectedTableRowCount > 0) && 
isParentKeepTogether())
                     {
                         paragraphProps.setAttribute(OfficeNamespaces.FO_NS, 
KEEP_WITH_NEXT, ALWAYS);
                     }
+                        }
 
-                    attrs.setAttribute(OfficeNamespaces.TABLE_NS, 
OfficeToken.STYLE_NAME, style.getStyleName());
+                        attrs.setAttribute(OfficeNamespaces.TEXT_NS, 
OfficeToken.STYLE_NAME, style.getStyleName());
+                    }
                 }
             }
 
-            if ( ObjectUtilities.equal(OfficeNamespaces.DRAWING_NS, namespace) 
&& ObjectUtilities.equal(OfficeToken.FRAME, elementType) )
+            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 OfficeStyle predefAutoStyle = 
getPredefinedStylesCollection().getAutomaticStyles().getStyle(OfficeToken.GRAPHIC,
 styleName);
@@ -980,8 +982,8 @@
             {
                 if (localKeepTogether)
                 {
-                    final Element tableProps = produceFirstChild(style, 
OfficeNamespaces.STYLE_NS, "table-properties");
-                    tableProps.setAttribute(OfficeNamespaces.STYLE_NS, 
"may-break-between-rows", OfficeToken.FALSE);
+                    final Element tableProps = produceFirstChild(style, 
OfficeNamespaces.STYLE_NS, TABLE_PROPERTIES);
+                    tableProps.setAttribute(OfficeNamespaces.STYLE_NS, 
MAY_BREAK_BETWEEN_ROWS, OfficeToken.FALSE);
                 }
             }
             else
@@ -997,10 +999,19 @@
             }
             if (keepWithNext)
             {
-                final Element tableProps = produceFirstChild(style, 
OfficeNamespaces.STYLE_NS, "table-properties");
+                boolean addKeepWithNext = true;
+                if (currentRole == ROLE_GROUP_FOOTER)
+                {
+                    addKeepWithNext = isParentKeepTogether();
+                }
+
+                final Element tableProps = produceFirstChild(style, 
OfficeNamespaces.STYLE_NS, TABLE_PROPERTIES);
+                tableProps.setAttribute(OfficeNamespaces.STYLE_NS, 
MAY_BREAK_BETWEEN_ROWS, OfficeToken.FALSE);
+                if (addKeepWithNext)
+                {
                 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", OfficeToken.FALSE);
+                }
             }
             attrs.setAttribute(OfficeNamespaces.TABLE_NS, 
OfficeToken.STYLE_NAME, style.getStyleName());
         // no need to copy the styles, this was done while deriving the
@@ -1018,6 +1029,22 @@
                 }
                 else if (detailBandProcessingState == DETAIL_SECTION_WAIT)
                 {
+                    if (keepWithNext)
+                    {
+                        final String styleName = (String) 
attrs.getAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME);
+
+                        final OfficeStyle style = 
deriveStyle(OfficeToken.TABLE, styleName);
+                        final Element tableProps = produceFirstChild(style, 
OfficeNamespaces.STYLE_NS, TABLE_PROPERTIES);
+                        // 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, OfficeToken.FALSE);
+                        final String hasGroupFooter = (String) 
attrs.getAttribute(OfficeNamespaces.INTERNAL_NS, "has-group-footer");
+                        if (hasGroupFooter != null && 
hasGroupFooter.equals(OfficeToken.TRUE))
+                        {
+                            tableProps.setAttribute(OfficeNamespaces.FO_NS, 
KEEP_WITH_NEXT, ALWAYS);
+                        }
+
+                        attrs.setAttribute(OfficeNamespaces.TABLE_NS, 
OfficeToken.STYLE_NAME, style.getStyleName());
+                    }
                     detailBandProcessingState = DETAIL_SECTION_FIRST_STARTED;
                 }
                 else if (detailBandProcessingState == 
DETAIL_SECTION_FIRST_PRINTED)
@@ -1036,6 +1063,20 @@
         xmlWriter.writeTag(namespace, elementType, attrList, 
XmlWriterSupport.OPEN);
     }
 
+    private boolean isParentKeepTogether()
+    {
+        PageContext context = getCurrentContext();
+        if (context != null)
+        {
+            context = context.getParent();
+            if (context != null)
+            {
+                return context.getKeepTogether() == 
PageContext.KEEP_TOGETHER_GROUP;
+            }
+        }
+        return false;
+    }
+
     private boolean isTableMergeActive()
     {
         return getCurrentRole() == ROLE_DETAIL &&
@@ -1351,6 +1392,7 @@
                 xmlWriter.writeCloseTag();
                 variables = null;
             }
+        /** 
             // Only generate the empty paragraph, if we have to add the 
keep-together ..
             else if (cellEmpty && expectedTableRowCount > 0 &&
                     sectionKeepTogether && !firstCellSeen)
@@ -1362,6 +1404,7 @@
                 xmlWriter.writeTag(OfficeNamespaces.TEXT_NS, OfficeToken.P, 
OfficeToken.STYLE_NAME,
                         
TextRawReportTarget.VARIABLES_HIDDEN_STYLE_WITH_KEEPWNEXT, 
XmlWriterSupport.CLOSE);
             }
+         */
         }
 
         if (isTableNs && (ObjectUtilities.equal(OfficeToken.TABLE_CELL, 
elementType) || ObjectUtilities.equal(OfficeToken.COVERED_TABLE_CELL, 
elementType)))

Directory: /dba/reportdesign/java/com/sun/star/report/pentaho/parser/rpt/
=========================================================================

File [changed]: GroupReadHandler.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/parser/rpt/GroupReadHandler.java?r1=1.4.4.2&r2=1.4.4.3
Delta lines:  +9 -4
-------------------
--- GroupReadHandler.java       2008-04-16 06:25:11+0000        1.4.4.2
+++ GroupReadHandler.java       2008-05-27 08:06:17+0000        1.4.4.3
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: GroupReadHandler.java,v $
- * $Revision: 1.4.4.2 $
+ * $Revision: 1.4.4.3 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -29,6 +29,7 @@
  ************************************************************************/
 package com.sun.star.report.pentaho.parser.rpt;
 
+import com.sun.star.report.OfficeToken;
 import java.util.ArrayList;
 
 import com.sun.star.report.pentaho.OfficeNamespaces;
@@ -53,9 +54,11 @@
     private final OfficeGroup group;
     private final OfficeGroupInstanceSection groupInstanceSection;
     private final List functionHandlers;
+    private final ReportReadHandler rh;
 
-    public GroupReadHandler()
+    public GroupReadHandler(final ReportReadHandler _rh)
     {
+        rh = _rh;
         group = new OfficeGroup();
         groupInstanceSection = new OfficeGroupInstanceSection();
         groupInstanceSection.setNamespace(OfficeNamespaces.INTERNAL_NS);
@@ -113,16 +116,18 @@
         }
         if ("group".equals(tagName))
         {
-            childGroup = new GroupReadHandler();
+            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(OfficeNamespaces.INTERNAL_NS,"has-group-footer",
 OfficeToken.TRUE);
             groupFooter = new GroupSectionReadHandler();
             return groupFooter;
         }

File [changed]: ReportReadHandler.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/parser/rpt/ReportReadHandler.java?r1=1.3.4.2&r2=1.3.4.3
Delta lines:  +8 -3
-------------------
--- ReportReadHandler.java      2008-04-16 06:25:24+0000        1.3.4.2
+++ ReportReadHandler.java      2008-05-27 08:06:17+0000        1.3.4.3
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: ReportReadHandler.java,v $
- * $Revision: 1.3.4.2 $
+ * $Revision: 1.3.4.3 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -32,6 +32,7 @@
 import java.util.ArrayList;
 
 import com.sun.star.report.pentaho.OfficeNamespaces;
+import com.sun.star.report.pentaho.model.OfficeGroup;
 import com.sun.star.report.pentaho.model.OfficeReport;
 import com.sun.star.report.pentaho.parser.ElementReadHandler;
 import com.sun.star.report.pentaho.parser.chart.ChartReadHandler;
@@ -55,6 +56,10 @@
     {
         this.detail = detail;
     }
+    public final RootTableReadHandler getDetail()
+    {
+        return detail;
+    }
     private GroupReadHandler groups;
     private final OfficeReport rootSection;
     private final List functionHandlers;
@@ -132,7 +137,7 @@
             }
             else if ("group".equals(tagName))
             {
-                groups = new GroupReadHandler();
+                groups = new GroupReadHandler(this);
                 erh = groups;
             }
             else




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to