diff options
Diffstat (limited to 'qadevOOo/runner/convwatch/MSOfficePrint.java')
-rw-r--r-- | qadevOOo/runner/convwatch/MSOfficePrint.java | 710 |
1 files changed, 374 insertions, 336 deletions
diff --git a/qadevOOo/runner/convwatch/MSOfficePrint.java b/qadevOOo/runner/convwatch/MSOfficePrint.java index 4436d8397cbf..ba65b5bcf80e 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); |