Tag: cws_src680_rpt23fix02
User: tmorgner
Date: 2007-07-26 14:10:52+0000
Modified:
   dba/reportdesign/java/com/sun/star/report/pentaho/output/StyleUtilities.java
   
dba/reportdesign/java/com/sun/star/report/pentaho/output/spreadsheet/SpreadsheetRawReportTarget.java

Log:
 Issue number:  77494
 
 The engine now creates a derived style if the section-table has a
 defined background that is not transparent. However, if the row
 has an own background that is not transparent, then the row's 
 defined background will be preserved.
 
 

File Changes:

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

File [changed]: StyleUtilities.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/output/StyleUtilities.java?r1=1.2&r2=1.2.4.1
Delta lines:  +51 -2
--------------------
--- StyleUtilities.java 2007-07-09 11:56:07+0000        1.2
+++ StyleUtilities.java 2007-07-26 14:10:49+0000        1.2.4.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: StyleUtilities.java,v $
  *
- *  $Revision: 1.2 $
+ *  $Revision: 1.2.4.1 $
  *
- *  last change: $Author: rt $ $Date: 2007/07/09 11:56:07 $
+ *  last change: $Author: tmorgner $ $Date: 2007/07/26 14:10:49 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -510,4 +510,53 @@
           "Deriving the style failed. Clone error: ", e);
     }
   }
+
+  public static String queryStyle (final OfficeStylesCollection 
predefCollection,
+                                   final String styleFamily,
+                                   final String styleName,
+                                   final String sectionName,
+                                   final String propertyNamespace,
+                                   final String propertyName)
+  {
+    return queryStyle(predefCollection, styleFamily,
+        styleName, sectionName, propertyNamespace, propertyName, new 
HashSet());
+  }
+
+  private static String queryStyle (final OfficeStylesCollection 
predefCollection,
+                                   final String styleFamily,
+                                   final String styleName,
+                                   final String sectionName,
+                                   final String propertyNamespace,
+                                   final String propertyName,
+                                   final HashSet seenStyles)
+  {
+    if (seenStyles.contains(styleName))
+    {
+      return null;
+    }
+    seenStyles.add(styleName);
+
+    final OfficeStyle style = predefCollection.getStyle(styleFamily, 
styleName);
+    if (style == null)
+    {
+      return null; // no such style
+    }
+    final Element section = style.findFirstChild(OfficeNamespaces.STYLE_NS, 
sectionName);
+    if (section != null)
+    {
+      final Object attribute = section.getAttribute(propertyNamespace, 
propertyName);
+      if (attribute != null)
+      {
+        return String.valueOf(attribute);
+      }
+    }
+    final String parent = style.getStyleParent();
+    if (parent == null)
+    {
+      return null;
+    }
+    return queryStyle(predefCollection, styleFamily, parent, sectionName, 
propertyNamespace, propertyName, seenStyles);
+  }
+
+
 }

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.2&r2=1.2.4.1
Delta lines:  +50 -8
--------------------
--- SpreadsheetRawReportTarget.java     2007-07-09 11:56:07+0000        1.2
+++ SpreadsheetRawReportTarget.java     2007-07-26 14:10:49+0000        1.2.4.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: SpreadsheetRawReportTarget.java,v $
  *
- *  $Revision: 1.2 $
+ *  $Revision: 1.2.4.1 $
  *
- *  last change: $Author: rt $ $Date: 2007/07/09 11:56:07 $
+ *  last change: $Author: tmorgner $ $Date: 2007/07/26 14:10:49 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -53,6 +53,7 @@
 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.StyleUtilities;
 import com.sun.star.report.pentaho.output.text.MasterPageFactory;
 import org.jfree.layouting.util.AttributeMap;
 import org.jfree.layouting.input.style.values.CSSNumericValue;
@@ -81,24 +82,20 @@
  */
 public class SpreadsheetRawReportTarget extends OfficeDocumentReportTarget
 {
+  private String tableBackgroundColor; // null means transparent ...
+
   private static final ColumnBoundary[] EMPTY_COLBOUNDS = new 
ColumnBoundary[0];
 
   private boolean elementBoundaryCollectionPass;
-
   private List columnBoundaryList;
-
   private float currentRowBoundaryMarker;
 
   private ColumnBoundary[] sortedBoundaryArray;
-
   private ColumnBoundary[] boundariesForTableArray;
 
   private int tableCounter;
-
   private int columnCounter;
-
   private int columnSpanCounter;
-
   private String unitsOfMeasure;
 
   public SpreadsheetRawReportTarget(final ReportJob reportJob,
@@ -122,6 +119,7 @@
     {
       return;
     }
+
     final String elementType = 
ReportTargetUtil.getElemenTypeFromAttribute(attrs);
     // if this is the report namespace, write out a table definition ..
     if (OfficeNamespaces.TABLE_NS.equals(namespace) && 
"table".equals(elementType))
@@ -130,6 +128,7 @@
       // this is used to keep tracked of the boundary conditions per table
       tableCounter++;
     }
+
     if (isElementBoundaryCollectionPass())
     {
       collectBoundaryForElement(attrs);
@@ -157,6 +156,25 @@
     {
       // a new table means we must clear our "calculated" table boundary array 
cache
       boundariesForTableArray = null;
+
+      final String tableStyle = (String) 
attrs.getAttribute(OfficeNamespaces.TABLE_NS, "style-name");
+      if (tableStyle == null)
+      {
+        tableBackgroundColor = null;
+      }
+      else
+      {
+        final Object raw = 
StyleUtilities.queryStyle(getPredefinedStylesCollection(), "table", tableStyle,
+            "table-properties", OfficeNamespaces.FO_NS, "background-color");
+        if (raw == null || "transparent".equals(raw))
+        {
+          tableBackgroundColor = null;
+        }
+        else
+        {
+          tableBackgroundColor = String.valueOf(raw);
+        }
+      }
       return;
     }
 
@@ -194,6 +212,30 @@
     {
       // a new row means our column counter gets reset
       columnCounter = 0;
+      // Lets make sure the color of the table is ok ..
+      if (tableBackgroundColor != null)
+      {
+        final String styleName = (String) 
attrs.getAttribute(OfficeNamespaces.TABLE_NS, "style-name");
+        final OfficeStyle style = deriveStyle("table-row", styleName);
+        Element tableRowProperties = style.getTableRowProperties();
+        if (tableRowProperties == null)
+        {
+          tableRowProperties = new Section();
+          tableRowProperties.setNamespace(OfficeNamespaces.STYLE_NS);
+          tableRowProperties.setType("table-row-properties");
+          tableRowProperties.setAttribute(OfficeNamespaces.FO_NS, 
"background-color", tableBackgroundColor);
+          style.addNode(tableRowProperties);
+        }
+        else
+        {
+          final Object oldValue = 
tableRowProperties.getAttribute(OfficeNamespaces.FO_NS, "background-color");
+          if (oldValue == null || "transparent".equals(oldValue))
+          {
+            tableRowProperties.setAttribute(OfficeNamespaces.FO_NS, 
"background-color", tableBackgroundColor);
+          }
+        }
+        attrs.setAttribute(OfficeNamespaces.TABLE_NS, "style-name", 
style.getStyleName());
+      }
     }
     else if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, 
"table-cell", attrs))
     {




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

Reply via email to