Tag: cws_src680_rpt23fix02
User: tmorgner
Date: 2007-07-31 09:34:18+0000
Added:
   
dba/reportdesign/java/com/sun/star/report/pentaho/parser/text/NoCDATATextContentReadHandler.java

Modified:
   
dba/reportdesign/java/com/sun/star/report/pentaho/output/text/TextRawReportTarget.java
   
dba/reportdesign/java/com/sun/star/report/pentaho/parser/table/TableCellReadHandler.java
   
dba/reportdesign/java/com/sun/star/report/pentaho/parser/text/TextContentReadHandler.java

Log:
 Fixed the non-display of shapes that was caused by some unnecessary CDATA
 copied from the original XML file. We now ignore all CDATA from <draw:*>
 elements.
 
 

File Changes:

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.2.4.5&r2=1.2.4.6
Delta lines:  +64 -24
---------------------
--- TextRawReportTarget.java    2007-07-30 13:08:49+0000        1.2.4.5
+++ TextRawReportTarget.java    2007-07-31 09:34:15+0000        1.2.4.6
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: TextRawReportTarget.java,v $
  *
- *  $Revision: 1.2.4.5 $
+ *  $Revision: 1.2.4.6 $
  *
- *  last change: $Author: tmorgner $ $Date: 2007/07/30 13:08:49 $
+ *  last change: $Author: tmorgner $ $Date: 2007/07/31 09:34:15 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -638,6 +638,10 @@
       cellEmpty = true;
     }
 
+    boolean keepTogetherOnParagraph = true;
+
+    if (keepTogetherOnParagraph)
+    {
     if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TEXT_NS, "p", attrs))
     {
       cellEmpty = false;
@@ -668,6 +672,40 @@
         attrs.setAttribute(OfficeNamespaces.TEXT_NS, "style-name", 
style.getStyleName());
       }
     }
+    }
+    else
+    {
+      if (ReportTargetUtil.isElementOfType(OfficeNamespaces.TABLE_NS, 
"table-cell", attrs))
+      {
+        cellEmpty = false;
+        if (firstCellSeen == false && sectionKeepTogether)
+        {
+          final String styleName = (String) 
attrs.getAttribute(OfficeNamespaces.TABLE_NS, "style-name");
+          final OfficeStyle style = deriveStyle("table-cell", styleName);
+          // Lets set the 'keep-together' flag..
+
+          Element paragraphProps = style.getParagraphProperties();
+          if (paragraphProps == null)
+          {
+            paragraphProps = new Section();
+            paragraphProps.setNamespace(OfficeNamespaces.STYLE_NS);
+            paragraphProps.setType("paragraph-properties");
+            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)
+          {
+            paragraphProps.setAttribute(OfficeNamespaces.FO_NS, 
"keep-with-next", "always");
+          }
+
+          attrs.setAttribute(OfficeNamespaces.TABLE_NS, "style-name", 
style.getStyleName());
+        }
+      }
+    }
 
     // process the styles as usual
     performStyleProcessing(attrs);
@@ -1230,9 +1268,11 @@
       final AttributeList rootAttributes = new AttributeList();
       rootAttributes.addNamespaceDeclaration("office", 
OfficeNamespaces.OFFICE_NS);
       rootAttributes.addNamespaceDeclaration("config", 
OfficeNamespaces.CONFIG);
+      rootAttributes.addNamespaceDeclaration("ooo", 
OfficeNamespaces.OO2004_NS);
       rootAttributes.setAttribute(OfficeNamespaces.OFFICE_NS, "version", 
"1.0");
       final OutputStream outputStream = 
getOutputRepository().createOutputStream("settings.xml","text/xml");
       final XmlWriter xmlWriter = new XmlWriter(new 
OutputStreamWriter(outputStream, "UTF-8"), createTagDescription());
+      xmlWriter.setAlwaysAddNamespace(true);
       xmlWriter.writeXmlDeclaration("UTF-8");
       xmlWriter.writeTag(OfficeNamespaces.OFFICE_NS, "document-settings", 
rootAttributes, XmlWriterSupport.OPEN);
       xmlWriter.writeTag(OfficeNamespaces.OFFICE_NS, "settings", 
XmlWriterSupport.OPEN);

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

File [changed]: TableCellReadHandler.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/parser/table/TableCellReadHandler.java?r1=1.2&r2=1.2.4.1
Delta lines:  +4 -4
-------------------
--- TableCellReadHandler.java   2007-07-09 11:56:11+0000        1.2
+++ TableCellReadHandler.java   2007-07-31 09:34:15+0000        1.2.4.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: TableCellReadHandler.java,v $
  *
- *  $Revision: 1.2 $
+ *  $Revision: 1.2.4.1 $
  *
- *  last change: $Author: rt $ $Date: 2007/07/09 11:56:11 $
+ *  last change: $Author: tmorgner $ $Date: 2007/07/31 09:34:15 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -38,7 +38,7 @@
 package com.sun.star.report.pentaho.parser.table;
 
 import com.sun.star.report.pentaho.model.TableCellElement;
-import com.sun.star.report.pentaho.parser.text.TextContentReadHandler;
+import com.sun.star.report.pentaho.parser.text.NoCDATATextContentReadHandler;
 
 /**
  * A read handler for table-cell contents. This is basicly a text-content
@@ -47,7 +47,7 @@
  * @author Thomas Morgner
  * @since 05.03.2007
  */
-public class TableCellReadHandler extends TextContentReadHandler
+public class TableCellReadHandler extends NoCDATATextContentReadHandler
 {
   public TableCellReadHandler()
   {

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

File [added]: NoCDATATextContentReadHandler.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/parser/text/NoCDATATextContentReadHandler.java?rev=1.1.2.1&content-type=text/vnd.viewcvs-markup
Added lines: 153
----------------
/*
 * Copyright (c) 2007, Your Corporation. All Rights Reserved.
 */

package com.sun.star.report.pentaho.parser.text;

import java.util.ArrayList;

import com.sun.star.report.pentaho.parser.ElementReadHandler;
import com.sun.star.report.pentaho.parser.rpt.FixedContentReadHandler;
import com.sun.star.report.pentaho.parser.rpt.FormattedTextReadHandler;
import com.sun.star.report.pentaho.parser.rpt.ImageReadHandler;
import com.sun.star.report.pentaho.OfficeNamespaces;
import org.jfree.report.structure.Section;
import org.jfree.report.structure.Element;
import org.jfree.report.structure.StaticText;
import org.jfree.xmlns.parser.XmlReadHandler;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;

/**
 * This is a generic implementation that accepts all input and adds special
 * handlers for the report-elements.
 *
 * @author Thomas Morgner
 */
public class NoCDATATextContentReadHandler extends ElementReadHandler
{
  private Section section;
  private ArrayList children;
  private boolean copyType;

  public NoCDATATextContentReadHandler(final Section section,
                                       final boolean copyType)
  {
    this.children = new ArrayList();
    this.section = section;
    this.copyType = copyType;
  }

  public NoCDATATextContentReadHandler(final Section section)
  {
    this (section, false);
  }

  public NoCDATATextContentReadHandler()
  {
    this(new Section(), true);
  }


  /**
   * Starts parsing.
   *
   * @param attrs the attributes.
   * @throws org.xml.sax.SAXException if there is a parsing error.
   */
  protected void startParsing(final Attributes attrs) throws SAXException
  {
    super.startParsing(attrs);
    final Element element = getElement();
    if (copyType)
    {
      copyElementType(element);
    }
    copyAttributes(attrs, element);
  }

  /**
   * Returns the handler for a child element.
   *
   * @param tagName the tag name.
   * @param atts    the attributes.
   * @return the handler or null, if the tagname is invalid.
   * @throws org.xml.sax.SAXException if there is a parsing error.
   */
  protected XmlReadHandler getHandlerForChild(final String uri,
                                              final String tagName,
                                              final Attributes atts)
      throws SAXException
  {
    if (OfficeNamespaces.OOREPORT_NS.equals(uri))
    {
      if ("fixed-content".equals(tagName))
      {
        final FixedContentReadHandler fixedContentReadHandler = new 
FixedContentReadHandler();
        children.add(fixedContentReadHandler);
        return fixedContentReadHandler;
      }
      if ("formatted-text".equals(tagName))
      {
        final FormattedTextReadHandler formattedTextReadHandler = new 
FormattedTextReadHandler();
        children.add(formattedTextReadHandler);
        return formattedTextReadHandler;
      }
      if ("image".equals(tagName))
      {
        final ImageReadHandler imageReadHandler = new ImageReadHandler();
        children.add(imageReadHandler);
        return imageReadHandler;
      }
      if ("sub-document".equals(tagName))
      {
        return null;
      }
    }
    if (OfficeNamespaces.DRAWING_NS.equals(uri))
    {
      final NoCDATATextContentReadHandler readHandler = new 
NoCDATATextContentReadHandler();
      children.add(readHandler);
      return readHandler;
    }
    else
    {
      final TextContentReadHandler readHandler = new TextContentReadHandler();
      children.add(readHandler);
      return readHandler;
    }
  }

  public ArrayList getChildren()
  {
    return children;
  }

  /**
   * Done parsing.
   *
   * @throws org.xml.sax.SAXException if there is a parsing error.
   */
  protected void doneParsing() throws SAXException
  {
    for (int i = 0; i < children.size(); i++)
    {
      final Object o = children.get(i);
      if (o instanceof ElementReadHandler)
      {
        final ElementReadHandler handler = (ElementReadHandler) o;
        section.addNode(handler.getElement());
      }
      else if (o instanceof StaticText)
      {
        section.addNode((StaticText) o);
      }
    }
  }


  public Element getElement()
  {
    return section;
  }
}

File [changed]: TextContentReadHandler.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/parser/text/TextContentReadHandler.java?r1=1.2.4.1&r2=1.2.4.2
Delta lines:  +7 -115
---------------------
--- TextContentReadHandler.java 2007-07-30 13:08:50+0000        1.2.4.1
+++ TextContentReadHandler.java 2007-07-31 09:34:16+0000        1.2.4.2
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: TextContentReadHandler.java,v $
  *
- *  $Revision: 1.2.4.1 $
+ *  $Revision: 1.2.4.2 $
  *
- *  last change: $Author: tmorgner $ $Date: 2007/07/30 13:08:50 $
+ *  last change: $Author: tmorgner $ $Date: 2007/07/31 09:34:16 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -36,18 +36,8 @@
 
 package com.sun.star.report.pentaho.parser.text;
 
-import java.util.ArrayList;
-
-import com.sun.star.report.pentaho.OfficeNamespaces;
-import com.sun.star.report.pentaho.parser.ElementReadHandler;
-import com.sun.star.report.pentaho.parser.rpt.FixedContentReadHandler;
-import com.sun.star.report.pentaho.parser.rpt.FormattedTextReadHandler;
-import com.sun.star.report.pentaho.parser.rpt.ImageReadHandler;
-import org.jfree.report.structure.Element;
 import org.jfree.report.structure.Section;
 import org.jfree.report.structure.StaticText;
-import org.jfree.xmlns.parser.XmlReadHandler;
-import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 
 /**
@@ -56,90 +46,20 @@
  *
  * @author Thomas Morgner
  */
-public class TextContentReadHandler extends ElementReadHandler
+public class TextContentReadHandler extends NoCDATATextContentReadHandler
 {
-  private Section section;
-  private ArrayList children;
-  private boolean copyType;
-
-  public TextContentReadHandler(final Section section,
-                                final boolean copyType)
+  public TextContentReadHandler(final Section section, final boolean copyType)
   {
-    this.children = new ArrayList();
-    this.section = section;
-    this.copyType = copyType;
+    super(section, copyType);
   }
 
   public TextContentReadHandler(final Section section)
   {
-    this (section, false);
+    super(section);
   }
 
   public TextContentReadHandler()
   {
-    this(new Section(), true);
-  }
-
-
-  /**
-   * Starts parsing.
-   *
-   * @param attrs the attributes.
-   * @throws org.xml.sax.SAXException if there is a parsing error.
-   */
-  protected void startParsing(final Attributes attrs) throws SAXException
-  {
-    super.startParsing(attrs);
-    final Element element = getElement();
-    if (copyType)
-    {
-      copyElementType(element);
-    }
-    copyAttributes(attrs, element);
-  }
-
-  /**
-   * Returns the handler for a child element.
-   *
-   * @param tagName the tag name.
-   * @param atts    the attributes.
-   * @return the handler or null, if the tagname is invalid.
-   * @throws org.xml.sax.SAXException if there is a parsing error.
-   */
-  protected XmlReadHandler getHandlerForChild(final String uri,
-                                              final String tagName,
-                                              final Attributes atts)
-      throws SAXException
-  {
-    if (OfficeNamespaces.OOREPORT_NS.equals(uri))
-    {
-      if ("fixed-content".equals(tagName))
-      {
-        final FixedContentReadHandler fixedContentReadHandler = new 
FixedContentReadHandler();
-        children.add(fixedContentReadHandler);
-        return fixedContentReadHandler;
-      }
-      if ("formatted-text".equals(tagName))
-      {
-        final FormattedTextReadHandler formattedTextReadHandler = new 
FormattedTextReadHandler();
-        children.add(formattedTextReadHandler);
-        return formattedTextReadHandler;
-      }
-      if ("image".equals(tagName))
-      {
-        final ImageReadHandler imageReadHandler = new ImageReadHandler();
-        children.add(imageReadHandler);
-        return imageReadHandler;
-      }
-      if ("sub-document".equals(tagName))
-      {
-        return null;
-      }
-    }
-
-    final TextContentReadHandler readHandler = new TextContentReadHandler();
-    children.add(readHandler);
-    return readHandler;
   }
 
   /**
@@ -153,34 +73,6 @@
   public void characters(final char[] ch, final int start, final int length)
       throws SAXException
   {
-    children.add(new StaticText(new String(ch, start, length)));
-  }
-
-  /**
-   * Done parsing.
-   *
-   * @throws org.xml.sax.SAXException if there is a parsing error.
-   */
-  protected void doneParsing() throws SAXException
-  {
-    for (int i = 0; i < children.size(); i++)
-    {
-      final Object o = children.get(i);
-      if (o instanceof ElementReadHandler)
-      {
-        final ElementReadHandler handler = (ElementReadHandler) o;
-        section.addNode(handler.getElement());
-      }
-      else if (o instanceof StaticText)
-      {
-        section.addNode((StaticText) o);
-      }
-    }
-  }
-
-
-  public Element getElement()
-  {
-    return section;
+    getChildren().add(new StaticText(new String(ch, start, length)));
   }
 }




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

Reply via email to