: eval 'exec perl -wS $0 ${1+"$@"}' if 0; # ************************************************************* # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # # ************************************************************* use IO::File; use Cwd; use File::Spec; use File::Spec::Functions; use File::Temp; use File::Path; $TempDir = ""; # all the XML package generation is a blatant rip from AF's # write-calc-doc.pl ############################################################################### # Open a file with the given name. # First it is checked if the temporary directory, in which all files for # the document are gathered, is already present and create it if it is not. # Then create the path to the file inside the temporary directory. # Finally open the file and return a file handle to it. # sub open_file { my $filename = pop @_; # Create base directory of temporary directory tree if not alreay # present. if ($TempDir eq "") { $TempDir = File::Temp::tempdir (CLEANUP => 1); } # Create the path to the file. my $fullname = File::Spec->catfile ($TempDir, $filename); my ($volume,$directories,$file) = File::Spec->splitpath ($fullname); mkpath (File::Spec->catpath ($volume,$directories,"")); # Open the file and return a file handle to it. return new IO::File ($fullname, "w"); } ############################################################################### # Zip the files in the directory tree into the given file. # sub zip_dirtree { my $filename = pop @_; my $cwd = getcwd; my $zip_name = $filename; # We are about to change the directory. # Therefore create an absolute pathname for the zip archive. # First transfer the drive from $cwd to $zip_name. This is a # workaround for a bug in file_name_is_absolute which thinks # the the path \bla is an absolute path under DOS. my ($volume,$directories,$file) = File::Spec->splitpath ($zip_name); my ($volume_cwd,$directories_cwd,$file_cwd) = File::Spec->splitpath ($cwd); $volume = $volume_cwd if ($volume eq ""); $zip_name = File::Spec->catpath ($volume,$directories,$file); # Add the current working directory to a relative path. if ( ! file_name_is_absolute ($zip_name)) { $zip_name = File::Spec->catfile ($cwd, $zip_name); # Try everything to clean up the name. $zip_name = File::Spec->rel2abs ($filename); $zip_name = File::Spec->canonpath ($zip_name); # Remove .. directories from the middle of the path. while ($zip_name =~ /\/[^\/][^\.\/][^\/]*\/\.\.\//) { $zip_name = $` . "/" . $'; } } # Just in case the zip program gets confused by an existing file with the # same name as the one to be written that file is removed first. if ( -e $filename) { if (unlink ($filename) == 0) { print "Existing file $filename could not be deleted.\n"; print "Please close the application that uses it, then try again.\n"; return; } } # Finally create the zip file. First change into the temporary directory # so that the resulting zip file contains only paths relative to it. print "zipping [$ZipCmd $ZipFlags $zip_name *]\n"; chdir ($TempDir); system ("$ZipCmd $ZipFlags $zip_name *"); chdir ($cwd); } sub writeHeader { print $OUT qq~ ~; } sub writeSlideStyles { my $mode = pop @_; my $direction = pop @_; my $transitionSubType = pop @_; my $transitionType = pop @_; my $slideNum = pop @_; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; } sub writeIntermediate { print $OUT qq~ ~; } sub writeSlide { my $mode = pop @_; my $direction = pop @_; my $transitionSubtype = pop @_; my $transitionType = pop @_; my $slideNum = pop @_; print $OUT " "; print $OUT " \n"; print $OUT " \n"; print $OUT " Transition “",$slideNum-1,"”\n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " Transition: ",$transitionType,"\n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " Subtype: ",$transitionSubtype,"\n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " Direction: ",$direction == 0 ? "forward" : "reverse","\n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " Mode: ",$mode == 0 ? "in" : "out","\n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; print $OUT " \n"; } sub writeFooter { print $OUT qq~ ~; } sub writeManifest { my $outFile = open_file("META-INF/manifest.xml"); print $outFile qq~ ~; $outFile->close; } $transitionsRef = [ ["barWipe", ["leftToRight", "topToBottom"]], ["blindsWipe", ["vertical", "horizontal"]], ["boxWipe", ["topLeft", "topRight", "bottomRight", "bottomLeft", "topCenter", "rightCenter", "bottomCenter", "leftCenter"]], ["fourBoxWipe", ["cornersIn", "cornersOut"]], ["barnDoorWipe", ["vertical", "horizontal", "diagonalBottomLeft", "diagonalTopLeft"]], ["bowTieWipe", ["vertical", "horizontal"]], ["miscDiagonalWipe", ["doubleBarnDoor", "doubleDiamond"]], ["veeWipe", ["down", "left", "up", "right"]], ["barnVeeWipe", ["top", "left", "up", "right"]], ["zigZagWipe", ["leftToRight", "topToBottom"]], ["barnZigZagWipe", ["vertical", "horizontal"]], ["irisWipe", ["rectangle", "diamond"]], ["triangleWipe", ["up", "right", "down", "left"]], ["arrowHeadWipe", ["up", "right", "down", "left"]], ["pentagonWipe", ["up", "down"]], ["hexagonWipe", ["horizontal", "vertical"]], ["ellipseWipe", ["circle", "horizontal", "vertical"]], ["eyeWipe", ["vertical", "horizontal"]], ["roundRectWipe", ["horizontal", "vertical"]], ["starWipe", ["fourPoint", "fivePoint", "sixPoint"]], ["miscShapeWipe", ["heart", "keyhole"]], ["clockWipe", ["clockwiseTwelve", "clockwiseThree", "clockwiseSix", "clockwiseNine"]], ["pinWheelWipe", ["oneBlade", "twoBladeVertical", "twoBladeHorizontal", "threeBlade", "fourBlade", "eightBlade"]], ["singleSweepWipe", ["clockwiseTop", "clockwiseRight", "clockwiseBottom", "clockwiseLeft", "clockwiseTopLeft", "counterClockwiseBottomLeft", "clockwiseBottomRight", "counterClockwiseTopRight"]], ["fanWipe", ["centerTop", "centerRight", "top", "right", "bottom", "left"]], ["doubleFanWipe", ["fanOutVertical", "fanOutHorizontal", "fanInVertical", "fanInHorizontal"]], ["doubleSweepWipe", ["parallelVertical", "parallelDiagonal", "oppositeVertical", "oppositeHorizontal", "parallelDiagonalTopLeft", "parallelDiagonalBottomLeft"]], ["saloonDoorWipe", ["top", "left", "bottom", "right"]], ["windshieldWipe", ["right", "up", "vertical", "horizontal"]], ["snakeWipe", ["topLeftHorizontal", "topLeftVertical", "topLeftDiagonal", "topRightDiagonal", "bottomRightDiagonal", "bottomLeftDiagonal"]], ["spiralWipe", ["topLeftClockwise", "topRightClockwise", "bottomRightClockwise", "bottomLeftClockwise", "topLeftCounterClockwise", "topRightCounterClockwise", "bottomRightCounterClockwise", "bottomLeftCounterClockwise"]], ["parallelSnakesWipe", ["verticalTopSame", "verticalBottomSame", "verticalTopLeftOpposite", "verticalBottomLeftOpposite", "horizontalLeftSame", "horizontalRightSame", "horizontalTopLeftOpposite", "horizontalTopRightOpposite", "diagonalBottomLeftOpposite", "diagonalTopLeftOpposite"]], ["boxSnakesWipe", ["twoBoxTop", "twoBoxLeft", "twoBoxRight", "fourBoxVertical", "fourBoxHorizontal"]], ["waterfallWipe", ["verticalLeft", "verticalRight", "horizontalLeft", "horizontalRight"]], ["pushWipe", ["fromLeft", "fromTop", "fromRight", "fromBottom", "fromBottomRight", "fromBottomLeft", "fromTopRight", "fromTopLeft", "combHorizontal", "combVertical"]], ["slideWipe", ["fromLeft", "fromTop", "fromRight", "fromBottom", "fromBottomRight", "fromBottomLeft", "fromTopRight", "fromTopLeft"]], ["fade", ["crossfade", "fadeToColor", "fadeFromColor", "fadeOverColor"]], ["randomBarWipe", ["vertical", "horizontal"]], ["checkerBoardWipe", ["down", "across"]], ["dissolve", ["default"]] ]; ############################################################################### # Print usage information. # sub usage () { print <* [] output-file-name defaults to alltransitions.odp. options: -a Generate _all_ combinations of type, subtype, direction, and mode -h Print this usage information. END_OF_USAGE } ############################################################################### # Process the command line. # sub process_command_line { foreach (@ARGV) { if (/^-h/) { usage; exit 0; } } $global_gen_all=0; $global_output_name = "alltransitions.odp"; my $j = 0; for (my $i=0; $i<=$#ARGV; $i++) { if ($ARGV[$i] eq "-a") { $global_gen_all=1; } elsif ($ARGV[$i] =~ /^-/) { print "Unknown option $ARGV[$i]\n"; usage; exit 1; } elsif ($#ARGV == $i ) { $global_output_name = $ARGV[$i]; } } print "output to $global_output_name\n"; } ############################################################################### # Main ############################################################################### $ZipCmd = $ENV{LOG_FILE_ZIP_CMD}; $ZipFlags = $ENV{LOG_FILE_ZIP_FLAGS}; # Provide default values for the zip command and it's flags. if ( ! defined $ZipCmd) { $ZipCmd = "zip" unless defined $ZipCmd; $ZipFlags = "-r -q" unless defined $ZipFlags; } process_command_line(); writeManifest(); $OUT = open_file( "content.xml" ); writeHeader(); $slideNum=1; foreach $transitionRef (@$transitionsRef) { $transitionType = @$transitionRef[0]; foreach $subtype (@{$transitionRef->[1]}) { if( $global_gen_all != 0 ) { writeSlideStyles($slideNum++, $transitionType, $subtype, 0, 0); writeSlideStyles($slideNum++, $transitionType, $subtype, 1, 0); writeSlideStyles($slideNum++, $transitionType, $subtype, 0, 1); writeSlideStyles($slideNum++, $transitionType, $subtype, 1, 1); } else { writeSlideStyles($slideNum++, $transitionType, $subtype, 0, 0); } } } writeIntermediate(); $slideNum=1; foreach $transitionRef (@$transitionsRef) { $transitionType = @$transitionRef[0]; foreach $subtype (@{$transitionRef->[1]}) { if( $global_gen_all != 0 ) { writeSlide($slideNum++, $transitionType, $subtype, 0, 0); writeSlide($slideNum++, $transitionType, $subtype, 1, 0); writeSlide($slideNum++, $transitionType, $subtype, 0, 1); writeSlide($slideNum++, $transitionType, $subtype, 1, 1); } else { writeSlide($slideNum++, $transitionType, $subtype, 0, 0); } } } writeFooter(); $OUT->close; zip_dirtree ($global_output_name);