qadevOOo/runner/convwatch/DB.java                        |   78 -
 qadevOOo/runner/convwatch/DBHelper.java                  |   18 
 qadevOOo/runner/convwatch/FileHelper.java                |   30 
 qadevOOo/runner/convwatch/MSOfficePrint.java             |  710 +++++++--------
 qadevOOo/runner/convwatch/OfficePrint.java               |   66 -
 qadevOOo/runner/graphical/MSOfficePostscriptCreator.java |  476 +++++-----
 qadevOOo/runner/helper/FileTools.java                    |   28 
 qadevOOo/runner/stats/FileLogWriter.java                 |   13 
 qadevOOo/runner/stats/SQLExecution.java                  |   86 -
 qadevOOo/runner/stats/SimpleFileOutProducer.java         |   64 -
 qadevOOo/runner/util/DBTools.java                        |   32 
 11 files changed, 873 insertions(+), 728 deletions(-)

New commits:
commit a2c481457cd2d03263054a5fefe80da316e09a44
Author: Robert Antoni Buj i Gelonch <robert....@gmail.com>
Date:   Mon Oct 13 13:20:47 2014 +0200

    runner: finally block to ensure that a resource is closed (Prior to Java SE 
7)
    
    
http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html
    
    Change-Id: I5ecefd3e5bf84fea2a8735a44236ed4c86b440c4
    Reviewed-on: https://gerrit.libreoffice.org/11950
    Reviewed-by: Noel Grandin <noelgran...@gmail.com>
    Tested-by: Noel Grandin <noelgran...@gmail.com>

diff --git a/qadevOOo/runner/convwatch/DB.java 
b/qadevOOo/runner/convwatch/DB.java
index 70a2559..8b4c4ff 100644
--- a/qadevOOo/runner/convwatch/DB.java
+++ b/qadevOOo/runner/convwatch/DB.java
@@ -215,49 +215,65 @@ public class DB extends DBHelper
             ArrayList<String> aResultList = new ArrayList<String>();
             try
             {
-                oStmt = _aCon.createStatement();
-
-                java.sql.ResultSet aResultSet = oStmt.executeQuery(_sSQL);
-                java.sql.ResultSetMetaData aResultSetMetaData = 
aResultSet.getMetaData();
-
-                int nColumnCount = aResultSetMetaData.getColumnCount();        
 // java sql starts with '1'
-
-                while( aResultSet.next() )
+                try
                 {
-                    StringBuffer aResult = new StringBuffer();
+                    oStmt = _aCon.createStatement();
+                    java.sql.ResultSet aResultSet = null;
                     try
                     {
-                        aResult.append("sqlresult: ");
-                        for (int i=1;i<=nColumnCount;i++)
+                        aResultSet = oStmt.executeQuery(_sSQL);
+                        java.sql.ResultSetMetaData aResultSetMetaData = 
aResultSet.getMetaData();
+
+                        int nColumnCount = 
aResultSetMetaData.getColumnCount();         // java sql starts with '1'
+
+                        while( aResultSet.next() )
                         {
-                            String sColumnName = 
aResultSetMetaData.getColumnName(i);
-                            aResult.append(sColumnName).append("=");
-                            String sValue;
-                            int nSQLType = aResultSetMetaData.getColumnType(i);
-                            switch(nSQLType)
+                            StringBuffer aResult = new StringBuffer();
+                            try
                             {
-                            case java.sql.Types.VARCHAR:
-                                sValue = "'" + aResultSet.getString(i)  +  "'";
-                                break;
-                            case java.sql.Types.INTEGER:
-                            {
-                                int nValue = aResultSet.getInt(i);
-                                sValue = String.valueOf(nValue);
-                                break;
+                                aResult.append("sqlresult: ");
+                                for (int i=1;i<=nColumnCount;i++)
+                                {
+                                    String sColumnName = 
aResultSetMetaData.getColumnName(i);
+                                    aResult.append(sColumnName).append("=");
+                                    String sValue;
+                                    int nSQLType = 
aResultSetMetaData.getColumnType(i);
+                                    switch(nSQLType)
+                                    {
+                                    case java.sql.Types.VARCHAR:
+                                        sValue = "'" + aResultSet.getString(i) 
 +  "'";
+                                        break;
+                                    case java.sql.Types.INTEGER:
+                                    {
+                                        int nValue = aResultSet.getInt(i);
+                                        sValue = String.valueOf(nValue);
+                                        break;
+                                    }
+
+                                    default:
+                                        sValue = "UNSUPPORTED TYPE";
+                                    }
+                                    aResult.append(sValue).append(", ");
+                                }
+                                String sResult = aResult.toString();
+                                aResultList.add(sResult);
                             }
-
-                            default:
-                                sValue = "UNSUPPORTED TYPE";
+                            catch (java.sql.SQLException e)
+                            {
                             }
-                            aResult.append(sValue).append(", ");
                         }
-                        String sResult = aResult.toString();
-                        aResultList.add(sResult);
                     }
-                    catch (java.sql.SQLException e)
+                    finally
                     {
+                        if (aResultSet != null)
+                            aResultSet.close();
                     }
                 }
+                finally
+                {
+                    if (oStmt != null)
+                        oStmt.close();
+                }
             }
             catch (java.sql.SQLException e)
             {
diff --git a/qadevOOo/runner/convwatch/DBHelper.java 
b/qadevOOo/runner/convwatch/DBHelper.java
index aaf6497..03128ea 100644
--- a/qadevOOo/runner/convwatch/DBHelper.java
+++ b/qadevOOo/runner/convwatch/DBHelper.java
@@ -69,11 +69,19 @@ class ShareConnection
 
                 try
                 {
-                    oStmt = m_aCon.createStatement();
-
-                    GlobalLogWriter.get().println("DB: " + m_sSQL);
-                    /* ResultSet oResult = */
-                    oStmt.executeUpdate(m_sSQL);
+                    try
+                    {
+                        oStmt = m_aCon.createStatement();
+
+                        GlobalLogWriter.get().println("DB: " + m_sSQL);
+                        /* ResultSet oResult = */
+                        oStmt.executeUpdate(m_sSQL);
+                    }
+                    finally
+                    {
+                        if (oStmt != null)
+                            oStmt.close();
+                    }
                 }
                 catch(Exception e)
                 {
diff --git a/qadevOOo/runner/convwatch/FileHelper.java 
b/qadevOOo/runner/convwatch/FileHelper.java
index ba4e4c3..dab33c3 100644
--- a/qadevOOo/runner/convwatch/FileHelper.java
+++ b/qadevOOo/runner/convwatch/FileHelper.java
@@ -267,15 +267,31 @@ public class FileHelper
                 File inputFile = new File(_sSource);
                 File outputFile = new File(_sDestination);
 
-                java.io.FileReader in = new java.io.FileReader(inputFile);
-                java.io.FileWriter out = new java.io.FileWriter(outputFile);
-                int c;
+                java.io.FileReader in = null;
+                java.io.FileWriter out = null;
+                try
+                {
+                    in = new java.io.FileReader(inputFile);
+                    try
+                    {
+                        out = new java.io.FileWriter(outputFile);
+                        int c;
 
-                while ((c = in.read()) != -1)
-                    out.write(c);
+                        while ((c = in.read()) != -1)
+                            out.write(c);
 
-                in.close();
-                out.close();
+                    }
+                    finally
+                    {
+                        if (out != null)
+                            out.close();
+                    }
+                }
+                finally
+                {
+                    if (in != null)
+                        in.close();
+                }
             }
             catch (java.io.IOException e)
             {
diff --git a/qadevOOo/runner/convwatch/MSOfficePrint.java 
b/qadevOOo/runner/convwatch/MSOfficePrint.java
index 4436d83..ba65b5b 100644
--- a/qadevOOo/runner/convwatch/MSOfficePrint.java
+++ b/qadevOOo/runner/convwatch/MSOfficePrint.java
@@ -275,86 +275,93 @@ public class MSOfficePrint
 
             String sName = sTmpPath + fs + sPrintViaWord;
             File aFile = new File(sName);
-            FileWriter out = new FileWriter(aFile.toString());
-
-
-            out.write( "eval 'exec perl -wS $0 ${1+\"$@\"}'                    
                                      " + ls );
-            out.write( "   if 0;                                               
                                      " + ls );
-            out.write( "use strict;                                            
                                      " + ls );
-            out.write( "use Time::HiRes;                                       
                                      " + ls );
-            out.write( "if ( $^O ne \"MSWin32\")                               
                                      " + ls );
-            out.write( "{                                                      
                                      " + ls );
-            out.write( "   print 'Windows only.\\n';                           
                                       " + ls );
-            out.write( "   print_usage();                                      
                                      " + ls );
-            out.write( "   exit(1);                                            
                                      " + ls );
-            out.write( "}                                                      
                                      " + ls );
-            out.write( "                                                       
                                      " + ls );
-            out.write( "use Win32::OLE;                                        
                                      " + ls );
-            out.write( "use Win32::OLE::Const 'Microsoft Word';                
                                      " + ls );
-            out.write( "                                                       
                                      " + ls );
-            out.write( "# ------ usage ------                                  
                                      " + ls );
-            out.write( "sub print_usage()                                      
                                      " + ls );
-            out.write( "{                                                      
                                      " + ls );
-            out.write( "    print STDERR \"Usage: word_print.pl  <Word file> 
<name of printer> <output file> .\\n     " + ls );
-            out.write( "                  Please use the same string for the 
name of the printer as you can find \\n  " + ls );
-            out.write( "                  under Start-Control Panel-Printer 
and Faxes  \\n                        " + ls );
-            out.write( "                  The name could look like the 
following line: \\n                        " + ls );
-            out.write( "                  Apple LaserWriter II NT v47.0 \\n    
                                       " + ls );
-            out.write( "                  Sample command line: \\n             
                                       " + ls );
-            out.write( "                  execl_print.pl  c:\\book1.doc Apple 
LaserWriter II NT v47.0 c:\\output\\book1.ps \\n\";  " + ls );
-            out.write( "}                                                      
                                      " + ls );
-            out.write( "                                                       
                                      " + ls );
-            out.write( "                                                       
                                      " + ls );
-            out.write( "if ($#ARGV != 2)                                       
                                      " + ls );
-            out.write( "{                                                      
                                      " + ls );
-            out.write( "   print 'Too less arguments.\\n';                     
                                       " + ls );
-            out.write( "   print_usage();                                      
                                      " + ls );
-            out.write( "   exit(1);                                            
                                      " + ls );
-            out.write( "}                                                      
                                      " + ls );
-            out.write( "                                                       
                                      " + ls );
-            out.write( "my $startWordTime = Time::HiRes::time(); " + ls );
-            out.write( "my $Word = Win32::OLE->new('Word.Application');        
                                      " + ls );
-            out.write( "my $stopWordTime = Time::HiRes::time() - 
$startWordTime; " + ls );
-            out.write( "# $Word->{'Visible'} = 1;         # if you want to see 
what's going on                       " + ls );
-            out.write( "# , ReadOnly => 1})" + ls );
-            out.write(ls);
-            out.write( "my $startLoadWordTime = Time::HiRes::time(); " + ls );
-            out.write( "$Word->Documents->Open({Filename => $ARGV[0]})         
                                      " + ls );
-            out.write( "    || die('Unable to open document ', 
Win32::OLE->LastError());                             " + ls );
-            out.write( "my $stopLoadWordTime = Time::HiRes::time() - 
$startLoadWordTime; " + ls );
-            out.write(ls);
-            out.write( "my $startPrintWordTime = Time::HiRes::time(); " + ls);
-            out.write( "my $oldActivePrinte = $Word->{ActivePrinter} ;         
                                      " + ls );
-            out.write( "$Word->{ActivePrinter} = $ARGV[1];                     
                                      " + ls );
-            out.write( "$Word->ActiveDocument->PrintOut({                      
                                      " + ls );
-            out.write( "                                 Background => 0,      
                                      " + ls );
-            out.write( "                                 Append     => 0,      
                                      " + ls );
-            out.write( "                                 Range      => 
wdPrintAllDocument,                           " + ls );
-            out.write( "                                 Item       => 
wdPrintDocumentContent,                       " + ls );
-            out.write( "                                 Copies     => 1,      
                                      " + ls );
-            out.write( "                                 PageType   => 
wdPrintAllPages,                              " + ls );
-            out.write( "                                 PrintToFile => 1,     
                                      " + ls );
-            out.write( "                                 OutputFileName => 
$ARGV[2]                                  " + ls );
-            out.write( "  });                                                  
                                      " + ls );
-            out.write( "$Word->{ActivePrinter} = $oldActivePrinte;             
                                      " + ls );
-            out.write( "my $stopPrintWordTime = Time::HiRes::time() - 
$startPrintWordTime;" + ls);
-
-            out.write( "# 
ActiveDocument.Close(SaveChanges:=WdSaveOptions.wdDoNotSaveChanges)" + ls );
-            out.write( "my $sVersion = $Word->Application->Version();"+ls);
-            out.write( "$Word->ActiveDocument->Close({SaveChanges => 0});      
                                                     " + ls );
-            out.write( "$Word->Quit();                                         
                                      " + ls );
-
-            out.write( "local *FILE;" + ls);
-            out.write( "if (open(FILE, 
\">$ENV{HOME}/msofficeloadtimes.txt\"))" + ls);
-            out.write( "{" + ls);
-            out.write( "   print FILE \"name=$ARGV[0]\\n\";" + ls);
-            out.write( "   print FILE \"WordVersion=$sVersion\\n\";" + ls);
-            out.write( "   print FILE \"WordStartTime=$stopWordTime\\n\";" + 
ls);
-            out.write( "   print FILE \"WordLoadTime=$stopLoadWordTime\\n\";" 
+ ls);
-            out.write( "   print FILE 
\"WordPrintTime=$stopPrintWordTime\\n\";" + ls);
-            out.write( "   close(FILE);" + ls);
-            out.write( "}" + ls);
-            out.close();
+            FileWriter out = null;
+            try
+            {
+                out = new FileWriter(aFile.toString());
+
+                out.write( "eval 'exec perl -wS $0 ${1+\"$@\"}'                
                                          " + ls );
+                out.write( "   if 0;                                           
                                          " + ls );
+                out.write( "use strict;                                        
                                          " + ls );
+                out.write( "use Time::HiRes;                                   
                                          " + ls );
+                out.write( "if ( $^O ne \"MSWin32\")                           
                                          " + ls );
+                out.write( "{                                                  
                                          " + ls );
+                out.write( "   print 'Windows only.\\n';                       
                                           " + ls );
+                out.write( "   print_usage();                                  
                                          " + ls );
+                out.write( "   exit(1);                                        
                                          " + ls );
+                out.write( "}                                                  
                                          " + ls );
+                out.write( "                                                   
                                          " + ls );
+                out.write( "use Win32::OLE;                                    
                                          " + ls );
+                out.write( "use Win32::OLE::Const 'Microsoft Word';            
                                          " + ls );
+                out.write( "                                                   
                                          " + ls );
+                out.write( "# ------ usage ------                              
                                          " + ls );
+                out.write( "sub print_usage()                                  
                                          " + ls );
+                out.write( "{                                                  
                                          " + ls );
+                out.write( "    print STDERR \"Usage: word_print.pl  <Word 
file> <name of printer> <output file> .\\n     " + ls );
+                out.write( "                  Please use the same string for 
the name of the printer as you can find \\n  " + ls );
+                out.write( "                  under Start-Control 
Panel-Printer and Faxes  \\n                        " + ls );
+                out.write( "                  The name could look like the 
following line: \\n                        " + ls );
+                out.write( "                  Apple LaserWriter II NT v47.0 
\\n                                           " + ls );
+                out.write( "                  Sample command line: \\n         
                                           " + ls );
+                out.write( "                  execl_print.pl  c:\\book1.doc 
Apple LaserWriter II NT v47.0 c:\\output\\book1.ps \\n\";  " + ls );
+                out.write( "}                                                  
                                          " + ls );
+                out.write( "                                                   
                                          " + ls );
+                out.write( "                                                   
                                          " + ls );
+                out.write( "if ($#ARGV != 2)                                   
                                          " + ls );
+                out.write( "{                                                  
                                          " + ls );
+                out.write( "   print 'Too less arguments.\\n';                 
                                           " + ls );
+                out.write( "   print_usage();                                  
                                          " + ls );
+                out.write( "   exit(1);                                        
                                          " + ls );
+                out.write( "}                                                  
                                          " + ls );
+                out.write( "                                                   
                                          " + ls );
+                out.write( "my $startWordTime = Time::HiRes::time(); " + ls );
+                out.write( "my $Word = Win32::OLE->new('Word.Application');    
                                          " + ls );
+                out.write( "my $stopWordTime = Time::HiRes::time() - 
$startWordTime; " + ls );
+                out.write( "# $Word->{'Visible'} = 1;         # if you want to 
see what's going on                       " + ls );
+                out.write( "# , ReadOnly => 1})" + ls );
+                out.write(ls);
+                out.write( "my $startLoadWordTime = Time::HiRes::time(); " + 
ls );
+                out.write( "$Word->Documents->Open({Filename => $ARGV[0]})     
                                          " + ls );
+                out.write( "    || die('Unable to open document ', 
Win32::OLE->LastError());                             " + ls );
+                out.write( "my $stopLoadWordTime = Time::HiRes::time() - 
$startLoadWordTime; " + ls );
+                out.write(ls);
+                out.write( "my $startPrintWordTime = Time::HiRes::time(); " + 
ls);
+                out.write( "my $oldActivePrinte = $Word->{ActivePrinter} ;     
                                          " + ls );
+                out.write( "$Word->{ActivePrinter} = $ARGV[1];                 
                                          " + ls );
+                out.write( "$Word->ActiveDocument->PrintOut({                  
                                          " + ls );
+                out.write( "                                 Background => 0,  
                                          " + ls );
+                out.write( "                                 Append     => 0,  
                                          " + ls );
+                out.write( "                                 Range      => 
wdPrintAllDocument,                           " + ls );
+                out.write( "                                 Item       => 
wdPrintDocumentContent,                       " + ls );
+                out.write( "                                 Copies     => 1,  
                                          " + ls );
+                out.write( "                                 PageType   => 
wdPrintAllPages,                              " + ls );
+                out.write( "                                 PrintToFile => 1, 
                                          " + ls );
+                out.write( "                                 OutputFileName => 
$ARGV[2]                                  " + ls );
+                out.write( "  });                                              
                                          " + ls );
+                out.write( "$Word->{ActivePrinter} = $oldActivePrinte;         
                                          " + ls );
+                out.write( "my $stopPrintWordTime = Time::HiRes::time() - 
$startPrintWordTime;" + ls);
+
+                out.write( "# 
ActiveDocument.Close(SaveChanges:=WdSaveOptions.wdDoNotSaveChanges)" + ls );
+                out.write( "my $sVersion = $Word->Application->Version();"+ls);
+                out.write( "$Word->ActiveDocument->Close({SaveChanges => 0});  
                                                         " + ls );
+                out.write( "$Word->Quit();                                     
                                          " + ls );
+
+                out.write( "local *FILE;" + ls);
+                out.write( "if (open(FILE, 
\">$ENV{HOME}/msofficeloadtimes.txt\"))" + ls);
+                out.write( "{" + ls);
+                out.write( "   print FILE \"name=$ARGV[0]\\n\";" + ls);
+                out.write( "   print FILE \"WordVersion=$sVersion\\n\";" + ls);
+                out.write( "   print FILE \"WordStartTime=$stopWordTime\\n\";" 
+ ls);
+                out.write( "   print FILE 
\"WordLoadTime=$stopLoadWordTime\\n\";" + ls);
+                out.write( "   print FILE 
\"WordPrintTime=$stopPrintWordTime\\n\";" + ls);
+                out.write( "   close(FILE);" + ls);
+                out.write( "}" + ls);
+            }
+            finally
+            {
+                if (out != null)
+                    out.close();
+            }
 
             aList.add("perl");
             aList.add(sName);
@@ -412,59 +419,67 @@ public class MSOfficePrint
             }
 
             File aFile = new File(sName);
-            FileWriter out = new FileWriter(aFile.toString());
-
-            out.write( "eval 'exec perl -wS $0 ${1+\"$@\"}'                    
                                      " + ls );
-            out.write( "   if 0;                                               
                                      " + ls );
-            out.write( "use strict;                                            
                                      " + ls );
-            out.write( "                                                       
                                      " + ls );
-            out.write( "if ( $^O ne \"MSWin32\")                               
                                      " + ls );
-            out.write( "{                                                      
                                      " + ls );
-            out.write( "   print 'Windows only.\\n';                           
                                       " + ls );
-            out.write( "   print_usage();                                      
                                      " + ls );
-            out.write( "   exit(1);                                            
                                      " + ls );
-            out.write( "}                                                      
                                      " + ls );
-            out.write( "                                                       
                                      " + ls );
-            out.write( "use Win32::OLE;                                        
                                      " + ls );
-            out.write( "use Win32::OLE::Const 'Microsoft Word';                
                                      " + ls );
-            out.write( "                                                       
                                      " + ls );
-            out.write( "# ------ usage ------                                  
                                      " + ls );
-            out.write( "sub print_usage()                                      
                                      " + ls );
-            out.write( "{                                                      
                                      " + ls );
-            out.write( "    print STDERR \"Usage: storeViaWord.pl  <Word file> 
<output filer> <output file> \\n\"     " + ls );
-            out.write( "}                                                      
                                      " + ls );
-            out.write( "                                                       
                                      " + ls );
-            out.write( "                                                       
                                      " + ls );
-            out.write( "if ($#ARGV != 2)                                       
                                      " + ls );
-            out.write( "{                                                      
                                      " + ls );
-            out.write( "   print 'Too less arguments.\\n';                     
                                       " + ls );
-            out.write( "   print_usage();                                      
                                      " + ls );
-            out.write( "   exit(1);                                            
                                      " + ls );
-            out.write( "}                                                      
                                      " + ls );
-            out.write( "                                                       
                                      " + ls );
-            out.write( "                                                       
                                      " + ls );
-            out.write( "my $Word = Win32::OLE->new('Word.Application');        
                                      " + ls );
-            out.write( "# $Word->{'Visible'} = 1;         # if you want to see 
what's going on                       " + ls );
-            out.write( "my $Book = $Word->Documents->Open($ARGV[0])            
                                                 " + ls );
-            out.write( "    || die('Unable to open document ', 
Win32::OLE->LastError());                             " + ls );
-            out.write( "# my $oldActivePrinte = $Word->{ActivePrinter} ;       
                                        " + ls );
-            out.write( "# $Word->{ActivePrinter} = $ARGV[1];                   
                                        " + ls );
-            out.write( "# $Word->ActiveDocument->PrintOut({                    
                                        " + ls );
-            out.write( "#                                  Background => 0,    
                                        " + ls );
-            out.write( "#                                  Append     => 0,    
                                        " + ls );
-            out.write( "#                                  Range      => 
wdPrintAllDocument,                           " + ls );
-            out.write( "#                                  Item       => 
wdPrintDocumentContent,                       " + ls );
-            out.write( "#                                  Copies     => 1,    
                                        " + ls );
-            out.write( "#                                  PageType   => 
wdPrintAllPages,                              " + ls );
-            out.write( "#                                  PrintToFile => 1,   
                                        " + ls );
-            out.write( "#                                  OutputFileName => 
$ARGV[2]                                  " + ls );
-            out.write( "#   });                                                
                                        " + ls );
-            out.write( "# $Word->{ActivePrinter} = $oldActivePrinte;           
                                        " + ls );
-            out.write( "$Book->savaAs($ARGV[2], $ARGV[1]);                     
                                        " + ls );
-            out.write( "# 
ActiveDocument.Close(SaveChanges:=WdSaveOptions.wdDoNotSaveChanges)" + ls );
-            out.write( "$Book->Close({SaveChanges => 0});                      
                                     " + ls );
-            out.write( "$Word->Quit();                                         
                                      " + ls );
-            out.close();
+            FileWriter out = null;
+            try
+            {
+                out = new FileWriter(aFile.toString());
+
+                out.write( "eval 'exec perl -wS $0 ${1+\"$@\"}'                
                                          " + ls );
+                out.write( "   if 0;                                           
                                          " + ls );
+                out.write( "use strict;                                        
                                          " + ls );
+                out.write( "                                                   
                                          " + ls );
+                out.write( "if ( $^O ne \"MSWin32\")                           
                                          " + ls );
+                out.write( "{                                                  
                                          " + ls );
+                out.write( "   print 'Windows only.\\n';                       
                                           " + ls );
+                out.write( "   print_usage();                                  
                                          " + ls );
+                out.write( "   exit(1);                                        
                                          " + ls );
+                out.write( "}                                                  
                                          " + ls );
+                out.write( "                                                   
                                          " + ls );
+                out.write( "use Win32::OLE;                                    
                                          " + ls );
+                out.write( "use Win32::OLE::Const 'Microsoft Word';            
                                          " + ls );
+                out.write( "                                                   
                                          " + ls );
+                out.write( "# ------ usage ------                              
                                          " + ls );
+                out.write( "sub print_usage()                                  
                                          " + ls );
+                out.write( "{                                                  
                                          " + ls );
+                out.write( "    print STDERR \"Usage: storeViaWord.pl  <Word 
file> <output filer> <output file> \\n\"     " + ls );
+                out.write( "}                                                  
                                          " + ls );
+                out.write( "                                                   
                                          " + ls );
+                out.write( "                                                   
                                          " + ls );
+                out.write( "if ($#ARGV != 2)                                   
                                          " + ls );
+                out.write( "{                                                  
                                          " + ls );
+                out.write( "   print 'Too less arguments.\\n';                 
                                           " + ls );
+                out.write( "   print_usage();                                  
                                          " + ls );
+                out.write( "   exit(1);                                        
                                          " + ls );
+                out.write( "}                                                  
                                          " + ls );
+                out.write( "                                                   
                                          " + ls );
+                out.write( "                                                   
                                          " + ls );
+                out.write( "my $Word = Win32::OLE->new('Word.Application');    
                                          " + ls );
+                out.write( "# $Word->{'Visible'} = 1;         # if you want to 
see what's going on                       " + ls );
+                out.write( "my $Book = $Word->Documents->Open($ARGV[0])        
                                                     " + ls );
+                out.write( "    || die('Unable to open document ', 
Win32::OLE->LastError());                             " + ls );
+                out.write( "# my $oldActivePrinte = $Word->{ActivePrinter} ;   
                                            " + ls );
+                out.write( "# $Word->{ActivePrinter} = $ARGV[1];               
                                            " + ls );
+                out.write( "# $Word->ActiveDocument->PrintOut({                
                                            " + ls );
+                out.write( "#                                  Background => 
0,                                            " + ls );
+                out.write( "#                                  Append     => 
0,                                            " + ls );
+                out.write( "#                                  Range      => 
wdPrintAllDocument,                           " + ls );
+                out.write( "#                                  Item       => 
wdPrintDocumentContent,                       " + ls );
+                out.write( "#                                  Copies     => 
1,                                            " + ls );
+                out.write( "#                                  PageType   => 
wdPrintAllPages,                              " + ls );
+                out.write( "#                                  PrintToFile => 
1,                                           " + ls );
+                out.write( "#                                  OutputFileName 
=> $ARGV[2]                                  " + ls );
+                out.write( "#   });                                            
                                            " + ls );
+                out.write( "# $Word->{ActivePrinter} = $oldActivePrinte;       
                                            " + ls );
+                out.write( "$Book->savaAs($ARGV[2], $ARGV[1]);                 
                                            " + ls );
+                out.write( "# 
ActiveDocument.Close(SaveChanges:=WdSaveOptions.wdDoNotSaveChanges)" + ls );
+                out.write( "$Book->Close({SaveChanges => 0});                  
                                         " + ls );
+                out.write( "$Word->Quit();                                     
                                          " + ls );
+            }
+            finally
+            {
+                if (out != null)
+                    out.close();
+            }
 
             aList.add("perl");
             aList.add(sName);
@@ -493,74 +508,82 @@ public class MSOfficePrint
             }
 
             File aFile = new File(sName);
-            FileWriter out = new FileWriter(aFile.toString());
-
-            out.write( "eval 'exec perl -wS $0 ${1+\"$@\"}'                    
                                                            " + ls );
-            out.write( "   if 0;                                               
                                                          " + ls );
-            out.write( "use strict;                                            
                                                          " + ls );
-            out.write( "                                                       
                                                          " + ls );
-            out.write( "if ( $^O ne \"MSWin32\")                               
                                                          " + ls );
-            out.write( "{                                                      
                                                          " + ls );
-            out.write( "   print \"Windows only.\\n\";                         
                                                           " + ls );
-            out.write( "   print_usage();                                      
                                                          " + ls );
-            out.write( "   exit(1);                                            
                                                          " + ls );
-            out.write( "}                                                      
                                                          " + ls );
-            out.write( "                                                       
                                                          " + ls );
-            out.write( "                                                       
                                                          " + ls );
-            out.write( "use Win32::OLE qw(in with);                            
                                                          " + ls );
-            out.write( "use Win32::OLE::Const 'Microsoft Excel';               
                                                          " + ls );
-            out.write( "                                                       
                                                          " + ls );
-            out.write( "# ------ usage ------                                  
                                                          " + ls );
-            out.write( "sub print_usage()                                      
                                                          " + ls );
-            out.write( "{                                                      
                                                          " + ls );
-            out.write( "    print STDERR \"Usage: printViaExcel.pl  <Excel 
file> <name of printer> <output file> .\\n                       " + ls );
-            out.write( "                  Please use the same string for the 
name of the printer as you can find \\n                      " + ls );
-            out.write( "                  under Start-Control Panel-Printer 
and Faxes  \\n                                            " + ls );
-            out.write( "                  The name could look like the 
following line: \\n                                            " + ls );
-            out.write( "                  Apple LaserWriter II NT v47.0 \\n    
                                                           " + ls );
-            out.write( "                  Sample command line: \\n             
                                                           " + ls );
-            out.write( "                  execl_print.pl  c:\\book1.xls Apple 
LaserWriter II NT v47.0 c:\\output\\book1.ps \\n\";     " + ls );
-            out.write( "}                                                      
                                                          " + ls );
-            out.write( "                                                       
                                                          " + ls );
-            out.write( "                                                       
                                                          " + ls );
-            out.write( "                                                       
                                                          " + ls );
-            out.write( "$Win32::OLE::Warn = 3;                                
# die on errors...                                         " + ls );
-            out.write( "                                                       
                                                          " + ls );
-            out.write( "                                                       
                                                          " + ls );
-            out.write( "if ($#ARGV != 2)                                       
                                                          " + ls );
-            out.write( "{                                                      
                                                          " + ls );
-            out.write( "   print STDERR \"Too less arguments.\\n\";            
                                                          " + ls );
-            out.write( "   print STDERR \"ARGV[0] $ARGV[0]\\n\";               
                                                          " + ls );
-            out.write( "   print STDERR \"ARGV[1] $ARGV[1]\\n\";               
                                                          " + ls );
-            out.write( "   print STDERR \"ARGV[2] $ARGV[2]\\n\";               
                                                          " + ls );
-            out.write( "   print_usage();                                      
                                                          " + ls );
-            out.write( "   exit(1);                                            
                                                          " + ls );
-            out.write( "}                                                      
                                                          " + ls );
-            out.write( "                                                       
                                                          " + ls );
-            out.write( "my $Excel = 
Win32::OLE->GetActiveObject('Excel.Application')                                
                     " + ls );
-            out.write( "    || Win32::OLE->new('Excel.Application', 'Quit');  
# get already active Excel                                 " + ls );
-            out.write( "                                                      
# application or open new                                  " + ls );
-            out.write( "                                                       
                                                          " + ls );
-            out.write( "                                                       
                                                          " + ls );
-            out.write( "                                                       
                                                          " + ls );
-            out.write( "my $Book = $Excel->Workbooks->Open( $ARGV[0] );        
                                                          " + ls );
-            out.write( "   $Book->PrintOut({Copies => 1,                       
                                                          " + ls );
-            out.write( "                    ActivePrinter => $ARGV[1],         
                                                          " + ls );
-            out.write( "                    PrToFileName => $ARGV[2],          
                                                          " + ls );
-            out.write( "                    Collate => 1                       
                                                          " + ls );
-            out.write( "                    });                                
                                                          " + ls );
-            out.write( "# Close worksheets without store changes" + ls );
-            out.write( "# $Book->Close({SaveChanges => 0});                    
                                       " + ls );
-            out.write( "my $sVersion = $Excel->Application->Version();"+ls);
-            out.write( "$Excel->Quit();                                        
                                                             " + ls );
-            out.write( "local *FILE;" + ls);
-            out.write( "if (open(FILE, 
\">$ENV{HOME}/msofficeloadtimes.txt\"))" + ls);
-            out.write( "{" + ls);
-            out.write( "   print FILE \"name=$ARGV[0]\\n\";" + ls);
-            out.write( "   print FILE \"ExcelVersion=$sVersion\\n\";" + ls);
-            out.write( "   close(FILE);" + ls);
-            out.write( "}" + ls);
-            out.close();
+            FileWriter out = null;
+            try
+            {
+                out = new FileWriter(aFile.toString());
+
+                out.write( "eval 'exec perl -wS $0 ${1+\"$@\"}'                
                                                                " + ls );
+                out.write( "   if 0;                                           
                                                              " + ls );
+                out.write( "use strict;                                        
                                                              " + ls );
+                out.write( "                                                   
                                                              " + ls );
+                out.write( "if ( $^O ne \"MSWin32\")                           
                                                              " + ls );
+                out.write( "{                                                  
                                                              " + ls );
+                out.write( "   print \"Windows only.\\n\";                     
                                                               " + ls );
+                out.write( "   print_usage();                                  
                                                              " + ls );
+                out.write( "   exit(1);                                        
                                                              " + ls );
+                out.write( "}                                                  
                                                              " + ls );
+                out.write( "                                                   
                                                              " + ls );
+                out.write( "                                                   
                                                              " + ls );
+                out.write( "use Win32::OLE qw(in with);                        
                                                              " + ls );
+                out.write( "use Win32::OLE::Const 'Microsoft Excel';           
                                                              " + ls );
+                out.write( "                                                   
                                                              " + ls );
+                out.write( "# ------ usage ------                              
                                                              " + ls );
+                out.write( "sub print_usage()                                  
                                                              " + ls );
+                out.write( "{                                                  
                                                              " + ls );
+                out.write( "    print STDERR \"Usage: printViaExcel.pl  <Excel 
file> <name of printer> <output file> .\\n                       " + ls );
+                out.write( "                  Please use the same string for 
the name of the printer as you can find \\n                      " + ls );
+                out.write( "                  under Start-Control 
Panel-Printer and Faxes  \\n                                            " + ls 
);
+                out.write( "                  The name could look like the 
following line: \\n                                            " + ls );
+                out.write( "                  Apple LaserWriter II NT v47.0 
\\n                                                               " + ls );
+                out.write( "                  Sample command line: \\n         
                                                               " + ls );
+                out.write( "                  execl_print.pl  c:\\book1.xls 
Apple LaserWriter II NT v47.0 c:\\output\\book1.ps \\n\";     " + ls );
+                out.write( "}                                                  
                                                              " + ls );
+                out.write( "                                                   
                                                              " + ls );
+                out.write( "                                                   
                                                              " + ls );
+                out.write( "                                                   
                                                              " + ls );
+                out.write( "$Win32::OLE::Warn = 3;                             
   # die on errors...                                         " + ls );
+                out.write( "                                                   
                                                              " + ls );
+                out.write( "                                                   
                                                              " + ls );
+                out.write( "if ($#ARGV != 2)                                   
                                                              " + ls );
+                out.write( "{                                                  
                                                              " + ls );
+                out.write( "   print STDERR \"Too less arguments.\\n\";        
                                                              " + ls );
+                out.write( "   print STDERR \"ARGV[0] $ARGV[0]\\n\";           
                                                              " + ls );
+                out.write( "   print STDERR \"ARGV[1] $ARGV[1]\\n\";           
                                                              " + ls );
+                out.write( "   print STDERR \"ARGV[2] $ARGV[2]\\n\";           
                                                              " + ls );
+                out.write( "   print_usage();                                  
                                                              " + ls );
+                out.write( "   exit(1);                                        
                                                              " + ls );
+                out.write( "}                                                  
                                                              " + ls );
+                out.write( "                                                   
                                                              " + ls );
+                out.write( "my $Excel = 
Win32::OLE->GetActiveObject('Excel.Application')                                
                     " + ls );
+                out.write( "    || Win32::OLE->new('Excel.Application', 
'Quit');  # get already active Excel                                 " + ls );
+                out.write( "                                                   
   # application or open new                                  " + ls );
+                out.write( "                                                   
                                                              " + ls );
+                out.write( "                                                   
                                                              " + ls );
+                out.write( "                                                   
                                                              " + ls );
+                out.write( "my $Book = $Excel->Workbooks->Open( $ARGV[0] );    
                                                              " + ls );
+                out.write( "   $Book->PrintOut({Copies => 1,                   
                                                              " + ls );
+                out.write( "                    ActivePrinter => $ARGV[1],     
                                                              " + ls );
+                out.write( "                    PrToFileName => $ARGV[2],      
                                                              " + ls );
+                out.write( "                    Collate => 1                   
                                                              " + ls );
+                out.write( "                    });                            
                                                              " + ls );
+                out.write( "# Close worksheets without store changes" + ls );
+                out.write( "# $Book->Close({SaveChanges => 0});                
                                           " + ls );
+                out.write( "my $sVersion = 
$Excel->Application->Version();"+ls);
+                out.write( "$Excel->Quit();                                    
                                                                 " + ls );
+                out.write( "local *FILE;" + ls);
+                out.write( "if (open(FILE, 
\">$ENV{HOME}/msofficeloadtimes.txt\"))" + ls);
+                out.write( "{" + ls);
+                out.write( "   print FILE \"name=$ARGV[0]\\n\";" + ls);
+                out.write( "   print FILE \"ExcelVersion=$sVersion\\n\";" + 
ls);
+                out.write( "   close(FILE);" + ls);
+                out.write( "}" + ls);
+            }
+            finally
+            {
+                if (out != null)
+                    out.close();
+            }
 
             aList.add("perl");
             aList.add(sName);
@@ -588,69 +611,77 @@ public class MSOfficePrint
             }
 
             File aFile = new File(sName);
-            FileWriter out = new FileWriter(aFile.toString());
-
-            out.write( "eval 'exec perl -wS $0 ${1+\"$@\"}'                    
                                                            " + ls );
-            out.write( "   if 0;                                               
                                                          " + ls );
-            out.write( "use strict;                                            
                                                          " + ls );
-            out.write( "# This script is automatically created.                
                                                          " + ls );
-            out.write( "                                                       
                                                          " + ls );
-            out.write( "use Win32::OLE qw(in with);                            
                                                          " + ls );
-            out.write( "use Win32::OLE::Const 'Microsoft Excel';               
                                                          " + ls );
-            out.write( "                                                       
                                                          " + ls );
-            out.write( "# ------ usage ------                                  
                                                          " + ls );
-            out.write( "sub print_usage()                                      
                                                          " + ls );
-            out.write( "{                                                      
                                                          " + ls );
-            out.write( "    print STDERR \"Usage: savaViaExcel.pl  <Excel 
file> <filefilter> <output file> .\\n                       " + ls );
-            out.write( "                  execl_print.pl  c:\\book1.xls Apple 
LaserWriter II NT v47.0 c:\\output\\book1.ps \\n\";     " + ls );
-            out.write( "}                                                      
                                                          " + ls );
-            out.write( "                                                       
                                                          " + ls );
-            out.write( "                                                       
                                                          " + ls );
-            out.write( "                                                       
                                                          " + ls );
-            out.write( "$Win32::OLE::Warn = 3;                                
# die on errors...                                         " + ls );
-            out.write( "                                                       
                                                          " + ls );
-            out.write( "                                                       
                                                          " + ls );
-            out.write( "if ($#ARGV != 2)                                       
                                                          " + ls );
-            out.write( "{                                                      
                                                          " + ls );
-            out.write( "   print \"Too less arguments.\\n\";                   
                                                           " + ls );
-            out.write( "   print_usage();                                      
                                                          " + ls );
-            out.write( "   exit(1);                                            
                                                          " + ls );
-            out.write( "}                                                      
                                                          " + ls );
-            out.write( "                                                       
                                                          " + ls );
-            out.write( "my $Excel = 
Win32::OLE->GetActiveObject('Excel.Application')                                
                     " + ls );
-            out.write( "    || Win32::OLE->new('Excel.Application', 'Quit');  
# get already active Excel                                 " + ls );
-            out.write( "                                                      
# application or open new                                  " + ls );
-            out.write( "my $sFilterParameter = $ARGV[1];                       
                                                                                
          " + ls );
-            out.write( "my $sFilterName = xlHTML;                              
                                                                                
   " + ls );
-            out.write( "if ($sFilterParameter eq 'xlXMLSpreadsheet')           
                                                                                
                      " + ls );
-            out.write( "{                                                      
                                                           " + ls );
-            out.write( "    $sFilterName = xlXMLSpreadsheet;                   
                                                                                
             " + ls );
-            out.write( "}                                                      
                                                           " + ls );
-            out.write( "elsif ($sFilterParameter eq 'xlHTML')                  
                                                                                
               " + ls );
-            out.write( "{                                                      
                                                           " + ls );
-            out.write( "    $sFilterName = xlHTML;                             
                                                                                
    " + ls );
-            out.write( "}                                                      
                                                           " + ls );
-            out.write( "else                                                   
                                                              " + ls );
-            out.write( "{                                                      
                                                           " + ls );
-            out.write( "    my $undefined;                                     
                                                           " + ls);
-            out.write( "    $sFilterName = $undefined;                         
                                                                                
     " + ls );
-            out.write( "}                                                      
                                                           " + ls );
-            out.write( "                                                       
                                                          " + ls );
-            out.write( "my $Book = $Excel->Workbooks->Open( $ARGV[0] );        
                                                          " + ls );
-            out.write( "$Excel->{DisplayAlerts} = 0;                           
                                                          " + ls );
-            out.write( "$Book->saveAs($ARGV[2],                                
                                                          " + ls );
-            out.write( "              $sFilterName,                            
                                                       " + ls );
-            out.write( "              '',                                      
                                                          " + ls );
-            out.write( "              '',                                      
                                                          " + ls );
-            out.write( "              0,                                       
                                                          " + ls );
-            out.write( "              0,                                       
                                                          " + ls );
-            out.write( "              xlNoChange,                              
                                                          " + ls );
-            out.write( "              xlLocalSessionChanges,                   
                                                          " + ls );
-            out.write( "              1);                                      
                                                          " + ls );
-            out.write( "# Close worksheets without store changes" + ls );
-            out.write( "# $Book->Close({SaveChanges => 0}); " + ls );
-            out.write( "$Excel->Quit();                                        
                                                             " + ls );
-            out.close();
+            FileWriter out = null;
+            try
+            {
+                out = new FileWriter(aFile.toString());
+
+                out.write( "eval 'exec perl -wS $0 ${1+\"$@\"}'                
                                                                " + ls );
+                out.write( "   if 0;                                           
                                                              " + ls );
+                out.write( "use strict;                                        
                                                              " + ls );
+                out.write( "# This script is automatically created.            
                                                              " + ls );
+                out.write( "                                                   
                                                              " + ls );
+                out.write( "use Win32::OLE qw(in with);                        
                                                              " + ls );
+                out.write( "use Win32::OLE::Const 'Microsoft Excel';           
                                                              " + ls );
+                out.write( "                                                   
                                                              " + ls );
+                out.write( "# ------ usage ------                              
                                                              " + ls );
+                out.write( "sub print_usage()                                  
                                                              " + ls );
+                out.write( "{                                                  
                                                              " + ls );
+                out.write( "    print STDERR \"Usage: savaViaExcel.pl  <Excel 
file> <filefilter> <output file> .\\n                       " + ls );
+                out.write( "                  execl_print.pl  c:\\book1.xls 
Apple LaserWriter II NT v47.0 c:\\output\\book1.ps \\n\";     " + ls );
+                out.write( "}                                                  
                                                              " + ls );
+                out.write( "                                                   
                                                              " + ls );
+                out.write( "                                                   
                                                              " + ls );
+                out.write( "                                                   
                                                              " + ls );
+                out.write( "$Win32::OLE::Warn = 3;                             
   # die on errors...                                         " + ls );
+                out.write( "                                                   
                                                              " + ls );
+                out.write( "                                                   
                                                              " + ls );
+                out.write( "if ($#ARGV != 2)                                   
                                                              " + ls );
+                out.write( "{                                                  
                                                              " + ls );
+                out.write( "   print \"Too less arguments.\\n\";               
                                                               " + ls );
+                out.write( "   print_usage();                                  
                                                              " + ls );
+                out.write( "   exit(1);                                        
                                                              " + ls );
+                out.write( "}                                                  
                                                              " + ls );
+                out.write( "                                                   
                                                              " + ls );
+                out.write( "my $Excel = 
Win32::OLE->GetActiveObject('Excel.Application')                                
                     " + ls );
+                out.write( "    || Win32::OLE->new('Excel.Application', 
'Quit');  # get already active Excel                                 " + ls );
+                out.write( "                                                   
   # application or open new                                  " + ls );
+                out.write( "my $sFilterParameter = $ARGV[1];                   
                                                                                
              " + ls );
+                out.write( "my $sFilterName = xlHTML;                          
                                                                                
       " + ls );
+                out.write( "if ($sFilterParameter eq 'xlXMLSpreadsheet')       
                                                                                
                          " + ls );
+                out.write( "{                                                  
                                                               " + ls );
+                out.write( "    $sFilterName = xlXMLSpreadsheet;               
                                                                                
                 " + ls );
+                out.write( "}                                                  
                                                               " + ls );
+                out.write( "elsif ($sFilterParameter eq 'xlHTML')              
                                                                                
                   " + ls );
+                out.write( "{                                                  
                                                               " + ls );
+                out.write( "    $sFilterName = xlHTML;                         
                                                                                
        " + ls );
+                out.write( "}                                                  
                                                               " + ls );
+                out.write( "else                                               
                                                                  " + ls );
+                out.write( "{                                                  
                                                               " + ls );
+                out.write( "    my $undefined;                                 
                                                               " + ls);
+                out.write( "    $sFilterName = $undefined;                     
                                                                                
         " + ls );
+                out.write( "}                                                  
                                                               " + ls );
+                out.write( "                                                   
                                                              " + ls );
+                out.write( "my $Book = $Excel->Workbooks->Open( $ARGV[0] );    
                                                              " + ls );
+                out.write( "$Excel->{DisplayAlerts} = 0;                       
                                                              " + ls );
+                out.write( "$Book->saveAs($ARGV[2],                            
                                                              " + ls );
+                out.write( "              $sFilterName,                        
                                                           " + ls );
+                out.write( "              '',                                  
                                                              " + ls );
+                out.write( "              '',                                  
                                                              " + ls );
+                out.write( "              0,                                   
                                                              " + ls );
+                out.write( "              0,                                   
                                                              " + ls );
+                out.write( "              xlNoChange,                          
                                                              " + ls );
+                out.write( "              xlLocalSessionChanges,               
                                                              " + ls );
+                out.write( "              1);                                  
                                                              " + ls );
+                out.write( "# Close worksheets without store changes" + ls );
+                out.write( "# $Book->Close({SaveChanges => 0}); " + ls );
+                out.write( "$Excel->Quit();                                    
                                                                 " + ls );
+            }
+            finally
+            {
+                if (out != null)
+                    out.close();
+            }
 
             aList.add("perl");
             aList.add(sName);
@@ -678,78 +709,85 @@ public class MSOfficePrint
             }
 
             File aFile = new File(sName);
-            FileWriter out = new FileWriter(aFile.toString());
-
-
-            out.write( "eval 'exec perl -wS $0 $1 $2 '                         
                                                                " + ls );
-            out.write( "   if 0;                                               
                                                                " + ls );
-            out.write( "use strict;                                            
                                                                " + ls );
-            out.write( "                                                       
                                                                " + ls );
-            out.write( "if ( $^O ne \"MSWin32\")                               
                                                                  " + ls );
-            out.write( "{                                                      
                                                                " + ls );
-            out.write( "   print \"Windows only.\\n\";                         
                                                                   " + ls );
-            out.write( "   print_usage();                                      
                                                                " + ls );
-            out.write( "   exit(1);                                            
                                                                " + ls );
-            out.write( "}                                                      
                                                                " + ls );
-            out.write( "                                                       
                                                                " + ls );
-            out.write( "                                                       
                                                                " + ls );
-            out.write( "use Win32::OLE qw(in with);                            
                                                                " + ls );
-            out.write( "use Win32::OLE::Const 'Microsoft PowerPoint';          
                                                                " + ls );
-            out.write( "                                                       
                                                                " + ls );
-            out.write( "# ------ usage ------                                  
                                                                " + ls );
-            out.write( "sub print_usage()                                      
                                                                " + ls );
-            out.write( "{                                                      
                                                                " + ls );
-            out.write( "    print STDERR \"Usage: powerpoint_print.pl  
<PowerPoint file> <name of printer> <output file> .\\n                    " + 
ls );
-            out.write( "                  Please use the same string for the 
name of the printer as you can find \\n                            " + ls );
-            out.write( "                  under Start-Control Panel-Printer 
and Faxes  \\n                                                  " + ls );
-            out.write( "                  The name could look like the 
following line: \\n                                                  " + ls );
-            out.write( "                  Apple LaserWriter II NT v47.0 \\n    
                                                                 " + ls );
-            out.write( "                  Sample command line: \\n             
                                                                 " + ls );
-            out.write( "                  powerpoint_print.pl  c:\\book.ppt 
Apple LaserWriter II NT v47.0 c:\\output\\book.ps \\n\";         " + ls );
-            out.write( "}                                                      
                                                                " + ls );
-            out.write( "                                                       
                                                                " + ls );
-            out.write( "                                                       
                                                                " + ls );
-            out.write( "                                                       
                                                                " + ls );
-            out.write( "$Win32::OLE::Warn = 3;                                
# die on errors...                                               " + ls );
-            out.write( "                                                       
                                                                " + ls );
-            out.write( "                                                       
                                                                " + ls );
-            out.write( "if ($#ARGV < 2)                                        
                                                                " + ls );
-            out.write( "{                                                      
                                                                " + ls );
-            out.write( "   print \"Too less arguments.\\n\";                   
                                                                   " + ls );
-            out.write( "   print_usage();                                      
                                                                " + ls );
-            out.write( "   exit(1);                                            
                                                                " + ls );
-            out.write( "}                                                      
                                                                " + ls );
-            out.write( "                                                       
                                                                " + ls );
-            out.write( "my $PowerPoint = 
Win32::OLE->GetActiveObject('PowerPoint.Application')                           
                      " + ls );
-            out.write( "    || Win32::OLE->new('PowerPoint.Application', 
'Quit');  # get already active Excel                                  " + ls );
-            out.write( "                                                      
# application or open new                                        " + ls );
-            out.write( "                                                       
                                                                " + ls );
-            out.write( "                                                       
                                                                " + ls );
-            out.write( "                                                       
                                                                " + ls );
-            out.write( "   $PowerPoint->{'Visible'} = 1;                       
                                                                " + ls );
-            out.write( "   my $Presentation = $PowerPoint->Presentations->Add; 
                                                                " + ls );
-            out.write( "   my $Presentation = 
$PowerPoint->Presentations->Open( $ARGV[0] );                                   
                 " + ls );
-            out.write( "# we can't change active printer in powerpoint         
                                                   " + ls );
-            out.write( "#   $Presentation->PrintOptions->{ActivePrinter} = 
$ARGV[1]; " + ls );
-            out.write( "   print \"Active printer is: \" . 
$Presentation->PrintOptions->{ActivePrinter} . \"\\n\"; " + ls );
-            out.write( "   $Presentation->PrintOptions->{PrintInBackground} = 
0;                                                               " + ls );
-            out.write( "   # PrintColorType = 1 means print in color and 
PrintColorType = 2 means print in gray                                " + ls );
-            out.write( "   $Presentation->PrintOptions->{PrintColorType} = 1;  
                                                                " + ls );
-            out.write( "                                                       
                                                                " + ls );
-            out.write( "   $Presentation->PrintOut({PrintToFile => $ARGV[2]}); 
                                                                " + ls );
-            out.write( "   sleep 5;                                            
                                                                " + ls );
-            out.write( "   print \"Presentation has been printed\\n\";         
                                                                   " + ls );
-            out.write( "my $sVersion = 
$Presentation->Application->Version();"+ls);
-            out.write( "   $PowerPoint->Quit(); " + ls );
-
-            out.write( "local *FILE;" + ls);
-            out.write( "if (open(FILE, 
\">$ENV{HOME}/msofficeloadtimes.txt\"))" + ls);
-            out.write( "{" + ls);
-            out.write( "   print FILE \"name=$ARGV[0]\\n\";" + ls);
-            out.write( "   print FILE \"PowerPointVersion=$sVersion\\n\";" + 
ls);
-            out.write( "   close(FILE);" + ls);
-            out.write( "}" + ls);
-            out.close();
+            FileWriter out = null;
+            try
+            {
+                out = new FileWriter(aFile.toString());
+
+                out.write( "eval 'exec perl -wS $0 $1 $2 '                     
                                                                    " + ls );
+                out.write( "   if 0;                                           
                                                                    " + ls );
+                out.write( "use strict;                                        
                                                                    " + ls );
+                out.write( "                                                   
                                                                    " + ls );
+                out.write( "if ( $^O ne \"MSWin32\")                           
                                                                      " + ls );
+                out.write( "{                                                  
                                                                    " + ls );
+                out.write( "   print \"Windows only.\\n\";                     
                                                                       " + ls );
+                out.write( "   print_usage();                                  
                                                                    " + ls );
+                out.write( "   exit(1);                                        
                                                                    " + ls );
+                out.write( "}                                                  
                                                                    " + ls );
+                out.write( "                                                   
                                                                    " + ls );
+                out.write( "                                                   
                                                                    " + ls );
+                out.write( "use Win32::OLE qw(in with);                        
                                                                    " + ls );
+                out.write( "use Win32::OLE::Const 'Microsoft PowerPoint';      
                                                                    " + ls );
+                out.write( "                                                   
                                                                    " + ls );
+                out.write( "# ------ usage ------                              
                                                                    " + ls );
+                out.write( "sub print_usage()                                  
                                                                    " + ls );
+                out.write( "{                                                  
                                                                    " + ls );
+                out.write( "    print STDERR \"Usage: powerpoint_print.pl  
<PowerPoint file> <name of printer> <output file> .\\n                    " + 
ls );
+                out.write( "                  Please use the same string for 
the name of the printer as you can find \\n                            " + ls );
+                out.write( "                  under Start-Control 
Panel-Printer and Faxes  \\n                                                  " 
+ ls );
+                out.write( "                  The name could look like the 
following line: \\n                                                  " + ls );
+                out.write( "                  Apple LaserWriter II NT v47.0 
\\n                                                                     " + ls 
);
+                out.write( "                  Sample command line: \\n         
                                                                     " + ls );
+                out.write( "                  powerpoint_print.pl  
c:\\book.ppt Apple LaserWriter II NT v47.0 c:\\output\\book.ps \\n\";         " 
+ ls );
+                out.write( "}                                                  
                                                                    " + ls );
+                out.write( "                                                   
                                                                    " + ls );
+                out.write( "                                                   
                                                                    " + ls );
+                out.write( "                                                   
                                                                    " + ls );
+                out.write( "$Win32::OLE::Warn = 3;                             
   # die on errors...                                               " + ls );
+                out.write( "                                                   
                                                                    " + ls );
+                out.write( "                                                   
                                                                    " + ls );
+                out.write( "if ($#ARGV < 2)                                    
                                                                    " + ls );
+                out.write( "{                                                  
                                                                    " + ls );
+                out.write( "   print \"Too less arguments.\\n\";               
                                                                       " + ls );
+                out.write( "   print_usage();                                  
                                                                    " + ls );
+                out.write( "   exit(1);                                        
                                                                    " + ls );
+                out.write( "}                                                  
                                                                    " + ls );
+                out.write( "                                                   
                                                                    " + ls );
+                out.write( "my $PowerPoint = 
Win32::OLE->GetActiveObject('PowerPoint.Application')                           
                      " + ls );
+                out.write( "    || Win32::OLE->new('PowerPoint.Application', 
'Quit');  # get already active Excel                                  " + ls );
+                out.write( "                                                   
   # application or open new                                        " + ls );
+                out.write( "                                                   
                                                                    " + ls );
+                out.write( "                                                   
                                                                    " + ls );
+                out.write( "                                                   
                                                                    " + ls );
+                out.write( "   $PowerPoint->{'Visible'} = 1;                   
                                                                    " + ls );
+                out.write( "   my $Presentation = 
$PowerPoint->Presentations->Add;                                                
                 " + ls );
+                out.write( "   my $Presentation = 
$PowerPoint->Presentations->Open( $ARGV[0] );                                   
                 " + ls );
+                out.write( "# we can't change active printer in powerpoint     
                                                       " + ls );
+                out.write( "#   $Presentation->PrintOptions->{ActivePrinter} = 
$ARGV[1]; " + ls );
+                out.write( "   print \"Active printer is: \" . 
$Presentation->PrintOptions->{ActivePrinter} . \"\\n\"; " + ls );
+                out.write( "   
$Presentation->PrintOptions->{PrintInBackground} = 0;                           
                                    " + ls );
+                out.write( "   # PrintColorType = 1 means print in color and 
PrintColorType = 2 means print in gray                                " + ls );
+                out.write( "   $Presentation->PrintOptions->{PrintColorType} = 
1;                                                                  " + ls );
+                out.write( "                                                   
                                                                    " + ls );
+                out.write( "   $Presentation->PrintOut({PrintToFile => 
$ARGV[2]});                                                                 " + 
ls );
+                out.write( "   sleep 5;                                        
                                                                    " + ls );
+                out.write( "   print \"Presentation has been printed\\n\";     
                                                                       " + ls );
+                out.write( "my $sVersion = 
$Presentation->Application->Version();"+ls);
+                out.write( "   $PowerPoint->Quit(); " + ls );
+
+                out.write( "local *FILE;" + ls);
+                out.write( "if (open(FILE, 
\">$ENV{HOME}/msofficeloadtimes.txt\"))" + ls);
+                out.write( "{" + ls);
+                out.write( "   print FILE \"name=$ARGV[0]\\n\";" + ls);
+                out.write( "   print FILE \"PowerPointVersion=$sVersion\\n\";" 
+ ls);
+                out.write( "   close(FILE);" + ls);
+                out.write( "}" + ls);
+            }
+            finally
+            {
+                if (out != null)
+                    out.close();
+            }
 
             aList.add("perl");
             aList.add(sName);
diff --git a/qadevOOo/runner/convwatch/OfficePrint.java 
b/qadevOOo/runner/convwatch/OfficePrint.java
index 24eb0b0..cc7867d 100644
--- a/qadevOOo/runner/convwatch/OfficePrint.java
+++ b/qadevOOo/runner/convwatch/OfficePrint.java
@@ -362,48 +362,56 @@ public class OfficePrint {
 
             String sBuildID = "";
 
+            FileWriter out = null;
             try
             {
-                FileWriter out = new FileWriter(aInfoFile.toString());
-                out.write("# automatically created file by graphical compare" 
+ ls);
-                if (_aGTA != null)
+                try
                 {
-                    if (_sSpecial != null && _sSpecial.equals("msoffice"))
+                    out = new FileWriter(aInfoFile.toString());
+                    out.write("# automatically created file by graphical 
compare" + ls);
+                    if (_aGTA != null)
                     {
-                        out.write("# buildid from wordloadfile" + ls);
-                        sBuildID = _aGTA.getPerformance().getMSOfficeVersion();
-                        out.write("buildid=" + sBuildID + ls);
+                        if (_sSpecial != null && _sSpecial.equals("msoffice"))
+                        {
+                            out.write("# buildid from wordloadfile" + ls);
+                            sBuildID = 
_aGTA.getPerformance().getMSOfficeVersion();
+                            out.write("buildid=" + sBuildID + ls);
+                        }
+                        else
+                        {
+                            out.write("# buildid is read out of the bootstrap 
file" + ls);
+                            sBuildID = _aGTA.getBuildID();
+                            out.write("buildid=" + sBuildID + ls);
+                        }
+                        out.write(ls);
+                        out.write("# resolution given in DPI" + ls);
+                        out.write("resolution=" + _aGTA.getResolutionInDPI() + 
ls);
                     }
                     else
                     {
-                        out.write("# buildid is read out of the bootstrap 
file" + ls);
-                        sBuildID = _aGTA.getBuildID();
-                        out.write("buildid=" + sBuildID + ls);
+                        out.write("buildid=" + _sSpecial + ls);
                     }
+
                     out.write(ls);
-                    out.write("# resolution given in DPI" + ls);
-                    out.write("resolution=" + _aGTA.getResolutionInDPI() + ls);
-                }
-                else
-                {
-                    out.write("buildid=" + _sSpecial + ls);
-                }
+                    out.write("# Values out of System.getProperty(...)" + ls);
+                    out.write("os.name=" + System.getProperty("os.name") + ls);
+                    out.write("os.arch=" + System.getProperty("os.arch") + ls);
+                    out.write("os.version=" + System.getProperty("os.version") 
+ ls);
 
-                out.write(ls);
-                out.write("# Values out of System.getProperty(...)" + ls);
-                out.write("os.name=" + System.getProperty("os.name") + ls);
-                out.write("os.arch=" + System.getProperty("os.arch") + ls);
-                out.write("os.version=" + System.getProperty("os.version") + 
ls);
+                    if (_aGTA != null)
+                    {
+                        out.write(ls);
+                        out.write("# Performance output, values are given in 
milli sec." + ls);
+                        _aGTA.getPerformance().print(out);
+                    }
 
-                if (_aGTA != null)
+                    out.flush();
+                }
+                finally
                 {
-                    out.write(ls);
-                    out.write("# Performance output, values are given in milli 
sec." + ls);
-                    _aGTA.getPerformance().print(out);
+                    if (out != null)

... etc. - the rest is truncated
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to