Tag: cws_src680_oj14
User: fs      
Date: 2007-06-19 11:55:11+0000
Modified:
   dba/reportdesign/java/com/sun/star/report/SOImageService.java
   dba/reportdesign/java/com/sun/star/report/pentaho/OfficeNamespaces.java
   dba/reportdesign/java/com/sun/star/report/pentaho/output/ImageProducer.java
   
dba/reportdesign/java/com/sun/star/report/pentaho/output/OfficeDocumentReportTarget.java
   
dba/reportdesign/java/com/sun/star/report/pentaho/output/spreadsheet/SpreadsheetRawReportTarget.java
   
dba/reportdesign/java/com/sun/star/report/pentaho/output/text/TextRawReportTarget.java

Log:
 provided by [EMAIL PROTECTED]: fixes for #i78370# #i78371# #i78373# #i78405#

File Changes:

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

File [changed]: SOImageService.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/SOImageService.java?r1=1.1.2.3&r2=1.1.2.4
Delta lines:  +3 -4
-------------------
--- SOImageService.java 2007-06-12 11:54:32+0000        1.1.2.3
+++ SOImageService.java 2007-06-19 11:55:07+0000        1.1.2.4
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: SOImageService.java,v $
  *
- *  $Revision: 1.1.2.3 $
+ *  $Revision: 1.1.2.4 $
  *
- *  last change: $Author: fs $ $Date: 2007/06/12 11:54:32 $
+ *  last change: $Author: fs $ $Date: 2007/06/19 11:55:07 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -153,8 +153,7 @@
     String mimeType = null;
     try
     {
-      final PropertyValue[] value = new PropertyValue[4];
-      value[0] = new PropertyValue();
+      final PropertyValue[] value = new PropertyValue[] { new PropertyValue() 
};
       value[0].Name = "InputStream";
       value[0].Value = image;
 

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

File [changed]: OfficeNamespaces.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/OfficeNamespaces.java?r1=1.1.2.1&r2=1.1.2.2
Delta lines:  +4 -3
-------------------
--- OfficeNamespaces.java       2007-05-09 12:11:29+0000        1.1.2.1
+++ OfficeNamespaces.java       2007-06-19 11:55:07+0000        1.1.2.2
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: OfficeNamespaces.java,v $
  *
- *  $Revision: 1.1.2.1 $
+ *  $Revision: 1.1.2.2 $
  *
- *  last change: $Author: oj $ $Date: 2007/05/09 12:11:29 $
+ *  last change: $Author: fs $ $Date: 2007/06/19 11:55:07 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -73,6 +73,7 @@
   public static final String OOREPORT_NS = "http://openoffice.org/2005/report";;
   public static final String CONFIG = 
"urn:oasis:names:tc:opendocument:xmlns:config:1.0";
   public static final String INTERNAL_NS = 
"http://reporting.pentaho.org/namespaces/engine";;
+  public static final String MANIFEST_NS = 
"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0";
   /**
    * @deprecated
    */

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

File [changed]: ImageProducer.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/output/ImageProducer.java?r1=1.1.2.4&r2=1.1.2.5
Delta lines:  +39 -66
---------------------
--- ImageProducer.java  2007-06-11 19:29:07+0000        1.1.2.4
+++ ImageProducer.java  2007-06-19 11:55:07+0000        1.1.2.5
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: ImageProducer.java,v $
  *
- *  $Revision: 1.1.2.4 $
+ *  $Revision: 1.1.2.5 $
  *
- *  last change: $Author: fs $ $Date: 2007/06/11 19:29:07 $
+ *  last change: $Author: fs $ $Date: 2007/06/19 11:55:07 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -162,11 +162,17 @@
   private OutputRepository outputRepository;
   private ImageService imageService;
   private DefaultNameGenerator nameGenerator;
+  private OfficeManifest manifest;
 
   public ImageProducer(final InputRepository inputRepository,
                        final OutputRepository outputRepository,
-                       final ImageService imageService)
+                       final ImageService imageService,
+                       final OfficeManifest manifest)
   {
+    if (manifest == null)
+    {
+      throw new NullPointerException();
+    }
     if (inputRepository == null)
     {
       throw new NullPointerException();
@@ -184,6 +190,7 @@
     this.outputRepository = outputRepository;
     this.imageService = imageService;
     this.imageCache = new HashMap();
+    this.manifest = manifest;
     this.nameGenerator = new DefaultNameGenerator(outputRepository);
   }
 
@@ -300,6 +307,7 @@
       final CSSNumericValue heightVal = 
CSSNumericValue.createValue(CSSNumericType.MM, dims.getHeight() / 100.0);
       final OfficeImage officeImage = new OfficeImage(name, widthVal, 
heightVal);
       imageCache.put(imageKey, officeImage);
+      manifest.addEntry(name, mimeType);
       return officeImage;
     }
     catch (IOException e)
@@ -324,7 +332,7 @@
     }
     catch (MalformedURLException e)
     {
-      // ignore ..
+      // ignore .. but we had to try this ..
     }
 
     final OfficeImage o = (OfficeImage) imageCache.get(source);
@@ -351,12 +359,15 @@
         }
         final byte[] data = bout.toByteArray();
         final Dimension dims = imageService.getImageSize(data);
+        final String mimeType = imageService.getMimeType(data);
 
         final CSSNumericValue widthVal = 
CSSNumericValue.createValue(CSSNumericType.MM, dims.getWidth() / 100.0);
         final CSSNumericValue heightVal = 
CSSNumericValue.createValue(CSSNumericType.MM, dims.getHeight() / 100.0);
 
-        final OfficeImage officeImage = new OfficeImage(source, widthVal, 
heightVal);
+        final String filename = copyToOutputRepository(mimeType, source, data);
+        final OfficeImage officeImage = new OfficeImage(filename, widthVal, 
heightVal);
         imageCache.put(source, officeImage);
+        manifest.addEntry(filename, mimeType);
         return officeImage;
       }
       catch (IOException e)
@@ -388,7 +399,6 @@
     {
       final ByteArrayOutputStream bout = new ByteArrayOutputStream(8192);
       final URLConnection urlConnection = url.openConnection();
-      final String urlMimeType = urlConnection.getHeaderField("Content-Type");
       final InputStream inputStream = new 
BufferedInputStream(urlConnection.getInputStream());
       try
       {
@@ -401,43 +411,21 @@
       final byte[] data = bout.toByteArray();
 
       final Dimension dims = imageService.getImageSize(data);
-
+      final String mimeType = imageService.getMimeType(data);
       final CSSNumericValue widthVal = 
CSSNumericValue.createValue(CSSNumericType.MM, dims.getWidth() / 100.0);
       final CSSNumericValue heightVal = 
CSSNumericValue.createValue(CSSNumericType.MM, dims.getHeight() / 100.0);
 
       if (preserveIRI == false)
       {
-        final OfficeImage retval = new OfficeImage(url.toString(), null, null);
-
+        final OfficeImage retval = new OfficeImage(url.toString(), widthVal, 
heightVal);
         imageCache.put(url, retval);
         return retval;
       }
 
       final String file = url.getFile();
-      final String mimeType;
-      if (urlMimeType == null)
-      {
-        mimeType = getMimeType(file);
-      }
-      else
-      {
-        mimeType = urlMimeType;
-      }
-
-      // copy the image into the local output-storage
-      final String name = nameGenerator.generateName("Pictures/image", 
mimeType);
-      final OutputStream outputStream = 
outputRepository.createOutputStream(name);
-      final ByteArrayInputStream bin = new ByteArrayInputStream(data);
-
-      try
-      {
-        IOUtils.getInstance().copyStreams(bin, outputStream);
-      }
-      finally
-      {
-        outputStream.close();
-      }
+      final String name = copyToOutputRepository(mimeType, file, data);
       final OfficeImage officeImage = new OfficeImage(name, widthVal, 
heightVal);
+      manifest.addEntry(name, mimeType);
       imageCache.put(url, officeImage);
       return officeImage;
     }
@@ -461,49 +449,34 @@
     return null;
   }
 
-  public String getMimeType(final String name)
-  {
-    if (name == null)
-    {
-      return "application/octet-stream";
-    }
-    if (StringUtils.endsWithIgnoreCase(name, ".png"))
-    {
-      return "image/png";
-    }
-    if (StringUtils.endsWithIgnoreCase(name, ".png"))
-    {
-      return "image/png";
-    }
-    if (StringUtils.endsWithIgnoreCase(name, ".jpg"))
-    {
-      return "image/jpeg";
-    }
-    if (StringUtils.endsWithIgnoreCase(name, ".jpeg"))
+  private String copyToOutputRepository(final String urlMimeType, final String 
file, final byte[] data)
+      throws IOException, ReportExecutionException
     {
-      return "image/jpeg";
-    }
-    if (StringUtils.endsWithIgnoreCase(name, ".gif"))
-    {
-      return "image/gif";
-    }
-    if (StringUtils.endsWithIgnoreCase(name, ".pdf"))
+    final String mimeType;
+    if (urlMimeType == null)
     {
-      return "application/pdf";
+      mimeType = imageService.getMimeType(data);
     }
-    if (StringUtils.endsWithIgnoreCase(name, ".txt"))
+    else
     {
-      return "text/plain";
+      mimeType = urlMimeType;
     }
-    if (StringUtils.endsWithIgnoreCase(name, ".html"))
+
+    // copy the image into the local output-storage
+    final String name = nameGenerator.generateName("Pictures/image", mimeType);
+    final OutputStream outputStream = 
outputRepository.createOutputStream(name);
+    final ByteArrayInputStream bin = new ByteArrayInputStream(data);
+
+    try
     {
-      return "text/html";
+      IOUtils.getInstance().copyStreams(bin, outputStream);
     }
-    if (StringUtils.endsWithIgnoreCase(name, ".htm"))
+    finally
     {
-      return "text/html";
+      outputStream.close();
     }
-    return "application/octet-stream";
+    manifest.addEntry("Pictures/", "");
+    return name;
   }
 
 }

File [changed]: OfficeDocumentReportTarget.java
Url: 
http://dba.openoffice.org/source/browse/dba/reportdesign/java/com/sun/star/report/pentaho/output/OfficeDocumentReportTarget.java?r1=1.1.2.9&r2=1.1.2.10
Delta lines:  +22 -4
--------------------
--- OfficeDocumentReportTarget.java     2007-06-15 11:39:46+0000        1.1.2.9
+++ OfficeDocumentReportTarget.java     2007-06-19 11:55:08+0000        1.1.2.10
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: OfficeDocumentReportTarget.java,v $
  *
- *  $Revision: 1.1.2.9 $
+ *  $Revision: 1.1.2.10 $
  *
- *  last change: $Author: fs $ $Date: 2007/06/15 11:39:46 $
+ *  last change: $Author: fs $ $Date: 2007/06/19 11:55:08 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -247,6 +247,7 @@
   private static final boolean DEBUG_ELEMENTS =
       JFreeReportBoot.getInstance().getExtendedConfig().getBoolProperty
       ("com.sun.star.report.pentaho.output.DebugElements");
+  private OfficeManifest manifest;
 
   protected OfficeDocumentReportTarget(final ReportJob reportJob,
                                        final ResourceManager resourceManager,
@@ -276,7 +277,20 @@
     this.xmlWriters = new FastStack();
     this.imageNames = new AttributeNameGenerator();
 
-    this.imageProducer = new ImageProducer(inputRepository, outputRepository, 
imageService);
+    this.manifest = new OfficeManifest();
+    this.manifest.addEntry("/", getTargetMimeType());
+    this.manifest.addEntry("content.xml", "text/xml");
+
+    if (outputRepository.exists("settings.xml"))
+    {
+      manifest.addEntry("settings.xml", "text/xml");
+    }
+    if (outputRepository.exists("meta.xml"))
+    {
+      manifest.addEntry("meta.xml", "text/xml");
+    }
+
+    this.imageProducer = new ImageProducer(inputRepository, outputRepository, 
imageService, manifest);
 
     try
     {
@@ -287,9 +301,10 @@
     {
       throw new ReportProcessingException("Failed to load style-mapper", e);
     }
-
   }
 
+  protected abstract String getTargetMimeType();
+
   protected OutputRepository getOutputRepository()
   {
     return outputRepository;
@@ -922,6 +937,7 @@
       final BufferState state = finishBuffering();
       this.rootXmlWriter.writeStream(state.getXmlAsReader());
 
+      manifest.addEntry("styles.xml", "text/xml");
       final OutputStream stylesOutStream =
           outputRepository.createOutputStream("styles.xml");
       final OutputStreamWriter osw =
@@ -933,6 +949,8 @@
 
       this.rootXmlWriter.writeCloseTag();
       this.rootXmlWriter.close();
+
+      manifest.write(outputRepository);
     }
     catch (IOException e)
     {

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.1.2.3&r2=1.1.2.4
Delta lines:  +7 -2
-------------------
--- SpreadsheetRawReportTarget.java     2007-06-15 11:39:46+0000        1.1.2.3
+++ SpreadsheetRawReportTarget.java     2007-06-19 11:55:08+0000        1.1.2.4
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: SpreadsheetRawReportTarget.java,v $
  *
- *  $Revision: 1.1.2.3 $
+ *  $Revision: 1.1.2.4 $
  *
- *  last change: $Author: fs $ $Date: 2007/06/15 11:39:46 $
+ *  last change: $Author: fs $ $Date: 2007/06/19 11:55:08 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -644,6 +644,11 @@
     return span;
   }
 
+  protected String getTargetMimeType()
+  {
+    return "application/vnd.oasis.opendocument.spreadsheet";
+  }
+
   /**
    * This class represents a column boundary, not in width, but it's actual 
boundary location. One of the motivations
    * for creating this class was to be able to record the boundaries for each 
incoming table while consuming as few

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.1.2.6&r2=1.1.2.7
Delta lines:  +8 -6
-------------------
--- TextRawReportTarget.java    2007-06-15 11:39:47+0000        1.1.2.6
+++ TextRawReportTarget.java    2007-06-19 11:55:08+0000        1.1.2.7
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: TextRawReportTarget.java,v $
  *
- *  $Revision: 1.1.2.6 $
+ *  $Revision: 1.1.2.7 $
  *
- *  last change: $Author: fs $ $Date: 2007/06/15 11:39:47 $
+ *  last change: $Author: fs $ $Date: 2007/06/19 11:55:08 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -71,7 +71,6 @@
 import org.jfree.resourceloader.ResourceManager;
 import org.jfree.util.FastStack;
 import org.jfree.util.ObjectUtilities;
-import org.jfree.util.Log;
 import org.jfree.xmlns.common.AttributeList;
 import org.jfree.xmlns.writer.XmlWriter;
 import org.jfree.xmlns.writer.XmlWriterSupport;
@@ -146,6 +145,10 @@
     this.tableLayoutConfig = TABLE_LAYOUT_SINGLE_DETAIL_TABLE;
   }
 
+  protected String getTargetMimeType()
+  {
+    return "application/vnd.oasis.opendocument.text";
+  }
 
   /**
    * Checks, whether a manual page break should be inserted at the next 
possible location.
@@ -716,9 +719,8 @@
       else if (getCurrentRole() == 
OfficeDocumentReportTarget.ROLE_REPORT_FOOTER)
       {
         breakDefinition = new PageBreakDefinition(isResetPageNumber());
-        masterPageName = createMasterPage
-            (pageHeaderOnReportFooter, pageFooterOnReportFooter);
-        if (masterPageName == null || isSectionPagebreakBefore(attrs))
+        masterPageName = createMasterPage (pageHeaderOnReportFooter, 
pageFooterOnReportFooter);
+        if (masterPageName == null && isSectionPagebreakBefore(attrs))
         {
           // If we have a manual pagebreak, then activate the current 
master-page again.
           masterPageName = currentMasterPage.getStyleName();




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

Reply via email to