User: kz      
Date: 2008-05-05 13:52:07+0000
Modified:
   
dba/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/ImageElementLayoutController.java

Log:
 INTEGRATION: CWS dba30beta (1.6.6); FILE MERGED
 2008/04/22 10:30:26 oj 1.6.6.1: #i88503# merge changes from rptchart02

File Changes:

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

File [changed]: ImageElementLayoutController.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/ImageElementLayoutController.java?r1=1.6&r2=1.7
Delta lines:  +228 -226
-----------------------
--- ImageElementLayoutController.java   2008-04-10 17:23:52+0000        1.6
+++ ImageElementLayoutController.java   2008-05-05 13:52:04+0000        1.7
@@ -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;
@@ -67,14 +66,14 @@
 public class ImageElementLayoutController
     extends AbstractReportElementLayoutController
 {
+
   private ImageElementContext context;
 
   public ImageElementLayoutController()
   {
   }
 
-  protected LayoutController delegateContentGeneration
-      (final ReportTarget target)
+    protected LayoutController delegateContentGeneration(final ReportTarget 
target)
       throws ReportProcessingException, ReportDataFactoryException,
       DataSourceException
   {
@@ -109,11 +108,11 @@
 
     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(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, "image-data", linkTarget);
+        image.setAttribute(OfficeNamespaces.INTERNAL_NS, 
OfficeToken.IMAGE_DATA, linkTarget);
     target.startElement(image);
     target.endElement(image);
   }
@@ -131,10 +130,8 @@
         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);
+            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.");
@@ -151,7 +148,7 @@
       // 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");
+            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.");
@@ -167,7 +164,7 @@
 
       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");
+            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.
@@ -177,65 +174,16 @@
       }
 
       final ImageElementContext context = new ImageElementContext(colSpan, 
rowSpan);
-
-      final Node[] columnDefs = columns.getNodeArray();
-      int columnCounter = 0;
-      for (int i = 0; i < columnDefs.length; i++)
-      {
-        final Element column = (Element) columnDefs[i];
-
-        if (ObjectUtilities.equal(column.getNamespace(), 
OfficeNamespaces.TABLE_NS) == false ||
-            ObjectUtilities.equal(column.getType(), "table-column") == false)
-        {
-          continue;
-        }
-        if (columnCounter >= columnPos)
-        {
-          final String colStyle = (String) 
column.getAttribute(OfficeNamespaces.TABLE_NS, "style-name");
-          context.setColStyle(columnCounter - columnPos, colStyle);
-        }
-
-        columnCounter += 1;
-
-        if (columnCounter >= (columnPos + colSpan))
-        {
-          break;
-        }
-
-      }
-
+            addColumnStyles(context, columns, columnPos, colSpan);
       // finally search the styles for the row now.
-      final int rowPos = findNodeInSection(table, tableRow,null);
+            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)
-        {
-          continue;
-        }
-        if (rowCounter >= rowPos)
-        {
-          final String rowStyle = (String) 
row.getAttribute(OfficeNamespaces.TABLE_NS, "style-name");
-          context.setRowStyle(rowCounter - rowPos, rowStyle);
-        }
-
-        rowCounter += 1;
-
-        if (rowCounter >= (rowPos + rowSpan))
-        {
-          break;
-        }
-      }
+            addRowStyles(context, table,rowPos,rowSpan);
       this.context = context;
     }
     return this.context;
@@ -252,19 +200,18 @@
     for (int i = 0; i < nodes.length; i++)
     {
       final Node node = nodes[i];
-      if (node instanceof Element == false)
+            if (!(node instanceof Element))
       {
         continue;
       }
       final Element child = (Element) node;
-/*
-      if (! "covered-table-cell".equals(child.getType()) &&
+            /*
+            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) == false ||
-          (ObjectUtilities.equal(child.getType(), type) == false 
-              && (secondType == null || ObjectUtilities.equal(child.getType(), 
secondType) == false)) )
+             */
+            if (!ObjectUtilities.equal(child.getNamespace(), namespace) ||
+                    (!ObjectUtilities.equal(child.getType(), type) && 
(secondType == null || !ObjectUtilities.equal(child.getType(), secondType))))
       {
         continue;
       }
@@ -325,5 +272,60 @@
     }
   }
 
+    void addColumnStyles(final ImageElementContext context, final Section 
columns, final int columnPos, final int colSpan)
+    {
+        final Node[] columnDefs = columns.getNodeArray();
+        int columnCounter = 0;
+        for (int i = 0; i < columnDefs.length; i++)
+        {
+            final Element column = (Element) columnDefs[i];
+
+            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;
+            }
+
+        }
+    }
+
+    void addRowStyles(final ImageElementContext context, final Section table, 
final int rowPos, final int rowSpan)
+    {
+        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) ||
+                    !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;
+            }
+        }
+    }
 }




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

Reply via email to