Tag: cws_src680_rpt23fix02
User: tmorgner
Date: 2007-07-24 17:19:30+0000
Added:
   dba/reportdesign/java/com/sun/star/report/util/ManifestWriter.java

Modified:
   dba/reportdesign/java/com/sun/star/report/StorageRepository.java
   
dba/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/FormattedTextLayoutController.java
   dba/reportdesign/java/com/sun/star/report/util/FileRepository.java

Log:
 Issue number:  #78502, #77039
 
 The formatted-text-layout controller did not look for the correct node,
 and therefore never found the expected 'office:value-type' attribute. 
 This now fixes the #78502 bug, and possibly addresses the #77039 bug as
 well (although this bug might be connected to a writer-bug).
 
 Fixed the repositories so that the StorageRepository does no longer log
 exceptions whenever we test for an non-existing file. We expect the
 exception and can safely swallow it here.
 
 The FileRepository now maintains its own manifest for all files that
 are written. This class is needed for all test-runs outside of OpenOffice.
 
 

File Changes:

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

File [changed]: StorageRepository.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/StorageRepository.java?r1=1.2&r2=1.2.4.1
Delta lines:  +3 -3
-------------------
--- StorageRepository.java      2007-07-09 11:56:04+0000        1.2
+++ StorageRepository.java      2007-07-24 17:19:27+0000        1.2.4.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: StorageRepository.java,v $
  *
- *  $Revision: 1.2 $
+ *  $Revision: 1.2.4.1 $
  *
- *  last change: $Author: rt $ $Date: 2007/07/09 11:56:04 $
+ *  last change: $Author: tmorgner $ $Date: 2007/07/24 17:19:27 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -113,7 +113,7 @@
         } catch (com.sun.star.lang.IllegalArgumentException ex) {
             ex.printStackTrace();
         } catch (NoSuchElementException ex) {
-            ex.printStackTrace();
+            // We expect this exception, no need to log it.
         }
         return false;
     }

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

File [changed]: FormattedTextLayoutController.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/layoutprocessor/FormattedTextLayoutController.java?r1=1.2&r2=1.2.4.1
Delta lines:  +6 -38
--------------------
--- FormattedTextLayoutController.java  2007-07-09 11:56:05+0000        1.2
+++ FormattedTextLayoutController.java  2007-07-24 17:19:27+0000        1.2.4.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: FormattedTextLayoutController.java,v $
  *
- *  $Revision: 1.2 $
+ *  $Revision: 1.2.4.1 $
  *
- *  last change: $Author: rt $ $Date: 2007/07/09 11:56:05 $
+ *  last change: $Author: tmorgner $ $Date: 2007/07/24 17:19:27 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -64,43 +64,10 @@
 public class FormattedTextLayoutController
     extends AbstractReportElementLayoutController
 {
-//  private Boolean inRepeatingSection;
-
   public FormattedTextLayoutController()
   {
   }
 
-//  private boolean isInRepeatingSection ()
-//  {
-//    if (inRepeatingSection == null)
-//    {
-//      LayoutController parent = getParent();
-//      while (parent != null && inRepeatingSection == null)
-//      {
-//        if (parent instanceof OfficeRepeatingStructureLayoutController)
-//        {
-//          final OfficeRepeatingStructureLayoutController orslc =
-//              (OfficeRepeatingStructureLayoutController) parent;
-//          if (orslc.isNormalFlowProcessing())
-//          {
-//            inRepeatingSection = Boolean.FALSE;
-//          }
-//          else
-//          {
-//            inRepeatingSection = Boolean.TRUE;
-//          }
-//        }
-//        parent = parent.getParent();
-//      }
-//
-//      if (inRepeatingSection == null)
-//      {
-//        inRepeatingSection = Boolean.FALSE;
-//      }
-//    }
-//    return inRepeatingSection.booleanValue();
-//  }
-
   private VariablesCollection getVariablesCollection()
   {
     LayoutController parent = getParent();
@@ -179,9 +146,9 @@
     LayoutController parent = getParent();
     while (parent != null)
     {
-      if (parent instanceof ElementLayoutController)
+      if (parent instanceof TableCellLayoutController)
       {
-        final ElementLayoutController cellController = 
(ElementLayoutController) parent;
+        final TableCellLayoutController cellController = 
(TableCellLayoutController) parent;
         return cellController.getElement();
       }
       parent = parent.getParent();
@@ -195,12 +162,13 @@
     if (tce == null)
     {
       // NO particular format means: Fallback to string and hope and pray ..
-      return "string";
+      throw new IllegalStateException("A formatted text element must be a 
child of a Table-Cell.");
     }
 
     final String type = (String) tce.getAttribute(OfficeNamespaces.OFFICE_NS, 
"value-type");
     if (type == null)
     {
+      Log.error ("The Table-Cell does not have a office:value attribute 
defined. Your content will be messed up.");
       return "string";
     }
     return type;

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

File [changed]: FileRepository.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/util/FileRepository.java?r1=1.2&r2=1.2.4.1
Delta lines:  +48 -26
---------------------
--- FileRepository.java 2007-07-09 11:56:13+0000        1.2
+++ FileRepository.java 2007-07-24 17:19:27+0000        1.2.4.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: FileRepository.java,v $
  *
- *  $Revision: 1.2 $
+ *  $Revision: 1.2.4.1 $
  *
- *  last change: $Author: rt $ $Date: 2007/07/09 11:56:13 $
+ *  last change: $Author: tmorgner $ $Date: 2007/07/24 17:19:27 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -37,12 +37,12 @@
 
 package com.sun.star.report.util;
 
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.OutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 
 import com.sun.star.report.InputRepository;
 import com.sun.star.report.OutputRepository;
@@ -50,73 +50,95 @@
 public class FileRepository implements InputRepository, OutputRepository
 {
   private File baseDirectory;
+  private ManifestWriter manifestWriter;
+  private boolean manifestDirty;
 
-  public FileRepository (final File baseDirectory)
+  public FileRepository(final File baseDirectory)
+  {
+    if (baseDirectory == null)
   {
-    if (baseDirectory == null) throw new NullPointerException();
+      throw new NullPointerException();
+    }
     this.baseDirectory = baseDirectory;
+    this.manifestWriter = new ManifestWriter();
   }
 
-  public InputStream createInputStream (String name)
+  public InputStream createInputStream(final String name)
           throws IOException
   {
-    return new FileInputStream (new File(baseDirectory, name));
+    return new FileInputStream(new File(baseDirectory, name));
   }
 
   /**
-   * Returns a unique identifier for this repository. Two repositories 
accessing the same
-   * location should return the same id. The identifier must never be null.
+   * Returns a unique identifier for this repository. Two repositories 
accessing the same location should return the
+   * same id. The identifier must never be null.
    *
    * @return the repository id
    */
-  public Object getId ()
+  public Object getId()
   {
     return baseDirectory;
   }
 
   /**
-   * This returns an version number for the given resource. Return zero, if 
the resource
-   * is not versionable, else return a unique number for each version. As rule 
of thumb:
-   * Increase the version number by at least one for each change made to the 
resource.
+   * This returns an version number for the given resource. Return zero, if 
the resource is not versionable, else return
+   * a unique number for each version. As rule of thumb: Increase the version 
number by at least one for each change
+   * made to the resource.
    *
    * @param name the name of the resource
    * @return the version number
    */
-  public long getVersion (String name)
+  public long getVersion(final String name)
   {
     return new File(baseDirectory, name).lastModified();
   }
 
   /**
-   * Creates an output stream for writing the data. If there is an entry with 
that name
-   * already contained in the repository, try to overwrite it.
+   * Creates an output stream for writing the data. If there is an entry with 
that name already contained in the
+   * repository, try to overwrite it.
    *
    * @param name
    * @return the outputstream
-   *
    * @throws java.io.IOException if opening the stream fails
    */
-  public synchronized OutputStream createOutputStream (final String name, 
final String mimeType)
+  public synchronized OutputStream createOutputStream(final String name, final 
String mimeType)
           throws IOException
   {
     final File file = new File(baseDirectory, name);
     final File parentFile = file.getParentFile();
     parentFile.mkdirs();
-    return new FileOutputStream (file);
+    manifestWriter.addEntry(name, mimeType);
+    manifestDirty = true;
+    return new FileOutputStream(file);
   }
 
-  public synchronized boolean exists (String name)
+  public synchronized boolean exists(final String name)
   {
     return new File(baseDirectory, name).exists();
   }
 
-  public boolean isWritable (String name)
+  public boolean isWritable(final String name)
   {
     return new File(baseDirectory, name).canWrite();
   }
 
-  public boolean isReadable (String name)
+  public boolean isReadable(final String name)
   {
     return new File(baseDirectory, name).canRead();
   }
+
+  public void initialize (final String contentType)
+  {
+    manifestWriter.addEntry("/", contentType);
+  }
+
+  public void close() throws IOException
+  {
+    // Write the manifest ...
+    if (manifestDirty)
+    {
+      manifestWriter.write(this);
+      manifestDirty = false;
+    }
+  }
 }

File [added]: ManifestWriter.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/util/ManifestWriter.java?rev=1.1.2.1&content-type=text/vnd.viewcvs-markup
Added lines: 0
--------------




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

Reply via email to