merge the formfield patch from ooo-build
[ooovba.git] / slideshow / qa / tools / mktransitions.pl
blob4ba63777479821389a107c8bb768c6e4c6c6cc65
2 eval 'exec perl -wS $0 ${1+"$@"}'
3 if 0;
6 use IO::File;
7 use Cwd;
8 use File::Spec;
9 use File::Spec::Functions;
10 use File::Temp;
11 use File::Path;
13 $TempDir = "";
16 # all the XML package generation is a blatant rip from AF's
17 # write-calc-doc.pl
20 ###############################################################################
21 # Open a file with the given name.
22 # First it is checked if the temporary directory, in which all files for
23 # the document are gathered, is already present and create it if it is not.
24 # Then create the path to the file inside the temporary directory.
25 # Finally open the file and return a file handle to it.
27 sub open_file
29 my $filename = pop @_;
31 # Create base directory of temporary directory tree if not alreay
32 # present.
33 if ($TempDir eq "")
35 $TempDir = File::Temp::tempdir (CLEANUP => 1);
38 # Create the path to the file.
39 my $fullname = File::Spec->catfile ($TempDir, $filename);
40 my ($volume,$directories,$file) = File::Spec->splitpath ($fullname);
41 mkpath (File::Spec->catpath ($volume,$directories,""));
43 # Open the file and return a file handle to it.
44 return new IO::File ($fullname, "w");
48 ###############################################################################
49 # Zip the files in the directory tree into the given file.
51 sub zip_dirtree
53 my $filename = pop @_;
55 my $cwd = getcwd;
56 my $zip_name = $filename;
58 # We are about to change the directory.
59 # Therefore create an absolute pathname for the zip archive.
61 # First transfer the drive from $cwd to $zip_name. This is a
62 # workaround for a bug in file_name_is_absolute which thinks
63 # the the path \bla is an absolute path under DOS.
64 my ($volume,$directories,$file) = File::Spec->splitpath ($zip_name);
65 my ($volume_cwd,$directories_cwd,$file_cwd) = File::Spec->splitpath ($cwd);
66 $volume = $volume_cwd if ($volume eq "");
67 $zip_name = File::Spec->catpath ($volume,$directories,$file);
69 # Add the current working directory to a relative path.
70 if ( ! file_name_is_absolute ($zip_name))
72 $zip_name = File::Spec->catfile ($cwd, $zip_name);
74 # Try everything to clean up the name.
75 $zip_name = File::Spec->rel2abs ($filename);
76 $zip_name = File::Spec->canonpath ($zip_name);
78 # Remove .. directories from the middle of the path.
79 while ($zip_name =~ /\/[^\/][^\.\/][^\/]*\/\.\.\//)
81 $zip_name = $` . "/" . $';
85 # Just in case the zip program gets confused by an existing file with the
86 # same name as the one to be written that file is removed first.
87 if ( -e $filename)
89 if (unlink ($filename) == 0)
91 print "Existing file $filename could not be deleted.\n";
92 print "Please close the application that uses it, then try again.\n";
93 return;
97 # Finally create the zip file. First change into the temporary directory
98 # so that the resulting zip file contains only paths relative to it.
99 print "zipping [$ZipCmd $ZipFlags $zip_name *]\n";
100 chdir ($TempDir);
101 system ("$ZipCmd $ZipFlags $zip_name *");
102 chdir ($cwd);
107 sub writeHeader
109 print $OUT qq~<?xml version="1.0" encoding="UTF-8"?>
111 <office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0" xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" office:version="1.0">
112 <office:scripts/>
113 <office:automatic-styles>
118 sub writeSlideStyles
120 my $mode = pop @_;
121 my $direction = pop @_;
122 my $transitionSubType = pop @_;
123 my $transitionType = pop @_;
124 my $slideNum = pop @_;
126 print $OUT " <style:style style:name=\"dp",$slideNum,"\" style:family=\"drawing-page\">\n";
127 print $OUT " <style:drawing-page-properties presentation:transition-type=\"automatic\" presentation:duration=\"PT00H00M01S\" presentation:background-visible=\"true\" presentation:background-objects-visible=\"true\" draw:fill=\"solid\" draw:fill-color=\"#ff",$slideNum % 2 ? "ff99" : "cc99","\" smil:type=\"",$transitionType,"\" smil:subtype=\"",$transitionSubType,"\" ",$direction == 0 ? "" : "smil:direction=\"reverse\" ",$mode == 0 ? "" : "smil:mode=\"out\"","/>\n";
128 print $OUT " </style:style>\n";
131 sub writeIntermediate
133 print $OUT qq~ <style:style style:name="gr1" style:family="graphic">
134 <style:graphic-properties style:protect="size"/>
135 </style:style>
136 <style:style style:name="pr1" style:family="presentation" style:parent-style-name="Default-title">
137 <style:graphic-properties draw:fill-color="#ffffff" draw:auto-grow-height="true" fo:min-height="3.508cm"/>
138 </style:style>
139 <style:style style:name="pr2" style:family="presentation" style:parent-style-name="Default-notes">
140 <style:graphic-properties draw:fill-color="#ffffff" draw:auto-grow-height="true" fo:min-height="13.367cm"/>
141 </style:style>
142 <style:style style:name="P1" style:family="paragraph">
143 <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="0cm"/>
144 </style:style>
145 <style:style style:name="P2" style:family="paragraph">
146 <style:paragraph-properties fo:margin-left="0.6cm" fo:margin-right="0cm" fo:text-indent="-0.6cm"/>
147 </style:style>
148 <text:list-style style:name="L1">
149 <text:list-level-style-bullet text:level="1" text:bullet-char="●">
150 <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/>
151 </text:list-level-style-bullet>
152 <text:list-level-style-bullet text:level="2" text:bullet-char="●">
153 <style:list-level-properties text:space-before="0.6cm" text:min-label-width="0.6cm"/>
154 <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/>
155 </text:list-level-style-bullet>
156 <text:list-level-style-bullet text:level="3" text:bullet-char="●">
157 <style:list-level-properties text:space-before="1.2cm" text:min-label-width="0.6cm"/>
158 <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/>
159 </text:list-level-style-bullet>
160 <text:list-level-style-bullet text:level="4" text:bullet-char="●">
161 <style:list-level-properties text:space-before="1.8cm" text:min-label-width="0.6cm"/>
162 <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/>
163 </text:list-level-style-bullet>
164 <text:list-level-style-bullet text:level="5" text:bullet-char="●">
165 <style:list-level-properties text:space-before="2.4cm" text:min-label-width="0.6cm"/>
166 <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/>
167 </text:list-level-style-bullet>
168 <text:list-level-style-bullet text:level="6" text:bullet-char="●">
169 <style:list-level-properties text:space-before="3cm" text:min-label-width="0.6cm"/>
170 <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/>
171 </text:list-level-style-bullet>
172 <text:list-level-style-bullet text:level="7" text:bullet-char="●">
173 <style:list-level-properties text:space-before="3.6cm" text:min-label-width="0.6cm"/>
174 <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/>
175 </text:list-level-style-bullet>
176 <text:list-level-style-bullet text:level="8" text:bullet-char="●">
177 <style:list-level-properties text:space-before="4.2cm" text:min-label-width="0.6cm"/>
178 <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/>
179 </text:list-level-style-bullet>
180 <text:list-level-style-bullet text:level="9" text:bullet-char="●">
181 <style:list-level-properties text:space-before="4.8cm" text:min-label-width="0.6cm"/>
182 <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/>
183 </text:list-level-style-bullet>
184 </text:list-style>
185 </office:automatic-styles>
186 <office:body>
187 <office:presentation>
192 sub writeSlide
194 my $mode = pop @_;
195 my $direction = pop @_;
196 my $transitionSubtype = pop @_;
197 my $transitionType = pop @_;
198 my $slideNum = pop @_;
200 print $OUT " <draw:page draw:name=\"page",$slideNum,"\" draw:style-name=\"dp",$slideNum,"\" draw:master-page-name=\"Default\" presentation:presentation-page-layout-name=\"AL1T19\">";
202 print $OUT " <draw:frame presentation:style-name=\"pr1\" draw:layer=\"layout\" svg:width=\"25.199cm\" svg:height=\"3.256cm\" svg:x=\"1.4cm\" svg:y=\"0.962cm\" presentation:class=\"title\">\n";
203 print $OUT " <draw:text-box>\n";
204 print $OUT " <text:p text:style-name=\"P1\">Transition “",$slideNum-1,"”</text:p>\n";
205 print $OUT " </draw:text-box>\n";
206 print $OUT " </draw:frame>\n";
207 print $OUT " <draw:frame presentation:style-name=\"pr2\" draw:layer=\"layout\" svg:width=\"25.199cm\" svg:height=\"13.609cm\" svg:x=\"1.4cm\" svg:y=\"4.914cm\" presentation:class=\"outline\">\n";
208 print $OUT " <draw:text-box>\n";
209 print $OUT " <text:list text:style-name=\"L2\">\n";
210 print $OUT " <text:list-item>\n";
211 print $OUT " <text:p text:style-name=\"P2\">Transition: ",$transitionType,"</text:p>\n";
212 print $OUT " </text:list-item>\n";
213 print $OUT " </text:list>\n";
214 print $OUT " <text:list text:style-name=\"L2\">\n";
215 print $OUT " <text:list-item>\n";
216 print $OUT " <text:list>\n";
217 print $OUT " <text:list-item>\n";
218 print $OUT " <text:p text:style-name=\"P3\">Subtype: ",$transitionSubtype,"</text:p>\n";
219 print $OUT " </text:list-item>\n";
220 print $OUT " </text:list>\n";
221 print $OUT " </text:list-item>\n";
222 print $OUT " </text:list>\n";
223 print $OUT " <text:list text:style-name=\"L2\">\n";
224 print $OUT " <text:list-item>\n";
225 print $OUT " <text:list>\n";
226 print $OUT " <text:list-item>\n";
227 print $OUT " <text:p text:style-name=\"P3\">Direction: ",$direction == 0 ? "forward" : "reverse","</text:p>\n";
228 print $OUT " </text:list-item>\n";
229 print $OUT " </text:list>\n";
230 print $OUT " </text:list-item>\n";
231 print $OUT " </text:list>\n";
232 print $OUT " <text:list text:style-name=\"L2\">\n";
233 print $OUT " <text:list-item>\n";
234 print $OUT " <text:list>\n";
235 print $OUT " <text:list-item>\n";
236 print $OUT " <text:p text:style-name=\"P3\">Mode: ",$mode == 0 ? "in" : "out","</text:p>\n";
237 print $OUT " </text:list-item>\n";
238 print $OUT " </text:list>\n";
239 print $OUT " </text:list-item>\n";
240 print $OUT " </text:list>\n";
241 print $OUT " </draw:text-box>\n";
242 print $OUT " </draw:frame>\n";
243 print $OUT " <presentation:notes draw:style-name=\"dp2\">\n";
244 print $OUT " <draw:page-thumbnail draw:style-name=\"gr1\" draw:layer=\"layout\" svg:width=\"14.851cm\" svg:height=\"11.138cm\" svg:x=\"3.068cm\" svg:y=\"2.257cm\" draw:page-number=\"1\" presentation:class=\"page\"/>\n";
245 print $OUT " <draw:frame presentation:style-name=\"pr3\" draw:layer=\"layout\" svg:width=\"16.79cm\" svg:height=\"13.116cm\" svg:x=\"2.098cm\" svg:y=\"14.109cm\" presentation:class=\"notes\" presentation:placeholder=\"true\">\n";
246 print $OUT " <draw:text-box/>\n";
247 print $OUT " </draw:frame>\n";
248 print $OUT " </presentation:notes>\n";
249 print $OUT " </draw:page>\n";
253 sub writeFooter
255 print $OUT qq~ <presentation:settings presentation:full-screen="false"/>
256 </office:presentation>
257 </office:body>
258 </office:document-content>
263 sub writeManifest
265 my $outFile = open_file("META-INF/manifest.xml");
267 print $outFile qq~<?xml version="1.0" encoding="UTF-8"?>
268 <!DOCTYPE manifest:manifest PUBLIC "-//OpenOffice.org//DTD Manifest 1.0//EN" "Manifest.dtd">
269 <manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0">
270 <manifest:file-entry manifest:media-type="application/vnd.oasis.opendocument.presentation" manifest:full-path="/"/>
271 <manifest:file-entry manifest:media-type="text/xml" manifest:full-path="content.xml"/>
272 </manifest:manifest>
275 $outFile->close;
279 $transitionsRef = [
281 ["barWipe",
282 ["leftToRight",
283 "topToBottom"]],
285 ["blindsWipe",
286 ["vertical",
287 "horizontal"]],
289 ["boxWipe",
290 ["topLeft",
291 "topRight",
292 "bottomRight",
293 "bottomLeft",
294 "topCenter",
295 "rightCenter",
296 "bottomCenter",
297 "leftCenter"]],
299 ["fourBoxWipe",
300 ["cornersIn",
301 "cornersOut"]],
303 ["barnDoorWipe",
304 ["vertical",
305 "horizontal",
306 "diagonalBottomLeft",
307 "diagonalTopLeft"]],
309 ["bowTieWipe",
310 ["vertical",
311 "horizontal"]],
313 ["miscDiagonalWipe",
314 ["doubleBarnDoor",
315 "doubleDiamond"]],
317 ["veeWipe",
318 ["down",
319 "left",
320 "up",
321 "right"]],
323 ["barnVeeWipe",
324 ["top",
325 "left",
326 "up",
327 "right"]],
329 ["zigZagWipe",
330 ["leftToRight",
331 "topToBottom"]],
333 ["barnZigZagWipe",
334 ["vertical",
335 "horizontal"]],
337 ["irisWipe",
338 ["rectangle",
339 "diamond"]],
341 ["triangleWipe",
342 ["up",
343 "right",
344 "down",
345 "left"]],
347 ["arrowHeadWipe",
348 ["up",
349 "right",
350 "down",
351 "left"]],
353 ["pentagonWipe",
354 ["up",
355 "down"]],
357 ["hexagonWipe",
358 ["horizontal",
359 "vertical"]],
361 ["ellipseWipe",
362 ["circle",
363 "horizontal",
364 "vertical"]],
366 ["eyeWipe",
367 ["vertical",
368 "horizontal"]],
370 ["roundRectWipe",
371 ["horizontal",
372 "vertical"]],
374 ["starWipe",
375 ["fourPoint",
376 "fivePoint",
377 "sixPoint"]],
379 ["miscShapeWipe",
380 ["heart",
381 "keyhole"]],
383 ["clockWipe",
384 ["clockwiseTwelve",
385 "clockwiseThree",
386 "clockwiseSix",
387 "clockwiseNine"]],
389 ["pinWheelWipe",
390 ["oneBlade",
391 "twoBladeVertical",
392 "twoBladeHorizontal",
393 "threeBlade",
394 "fourBlade",
395 "eightBlade"]],
397 ["singleSweepWipe",
398 ["clockwiseTop",
399 "clockwiseRight",
400 "clockwiseBottom",
401 "clockwiseLeft",
402 "clockwiseTopLeft",
403 "counterClockwiseBottomLeft",
404 "clockwiseBottomRight",
405 "counterClockwiseTopRight"]],
407 ["fanWipe",
408 ["centerTop",
409 "centerRight",
410 "top",
411 "right",
412 "bottom",
413 "left"]],
415 ["doubleFanWipe",
416 ["fanOutVertical",
417 "fanOutHorizontal",
418 "fanInVertical",
419 "fanInHorizontal"]],
421 ["doubleSweepWipe",
422 ["parallelVertical",
423 "parallelDiagonal",
424 "oppositeVertical",
425 "oppositeHorizontal",
426 "parallelDiagonalTopLeft",
427 "parallelDiagonalBottomLeft"]],
429 ["saloonDoorWipe",
430 ["top",
431 "left",
432 "bottom",
433 "right"]],
435 ["windshieldWipe",
436 ["right",
437 "up",
438 "vertical",
439 "horizontal"]],
441 ["snakeWipe",
442 ["topLeftHorizontal",
443 "topLeftVertical",
444 "topLeftDiagonal",
445 "topRightDiagonal",
446 "bottomRightDiagonal",
447 "bottomLeftDiagonal"]],
449 ["spiralWipe",
450 ["topLeftClockwise",
451 "topRightClockwise",
452 "bottomRightClockwise",
453 "bottomLeftClockwise",
454 "topLeftCounterClockwise",
455 "topRightCounterClockwise",
456 "bottomRightCounterClockwise",
457 "bottomLeftCounterClockwise"]],
459 ["parallelSnakesWipe",
460 ["verticalTopSame",
461 "verticalBottomSame",
462 "verticalTopLeftOpposite",
463 "verticalBottomLeftOpposite",
464 "horizontalLeftSame",
465 "horizontalRightSame",
466 "horizontalTopLeftOpposite",
467 "horizontalTopRightOpposite",
468 "diagonalBottomLeftOpposite",
469 "diagonalTopLeftOpposite"]],
471 ["boxSnakesWipe",
472 ["twoBoxTop",
473 "twoBoxLeft",
474 "twoBoxRight",
475 "fourBoxVertical",
476 "fourBoxHorizontal"]],
478 ["waterfallWipe",
479 ["verticalLeft",
480 "verticalRight",
481 "horizontalLeft",
482 "horizontalRight"]],
484 ["pushWipe",
485 ["fromLeft",
486 "fromTop",
487 "fromRight",
488 "fromBottom",
489 "fromBottomRight",
490 "fromBottomLeft",
491 "fromTopRight",
492 "fromTopLeft",
493 "combHorizontal",
494 "combVertical"]],
496 ["slideWipe",
497 ["fromLeft",
498 "fromTop",
499 "fromRight",
500 "fromBottom",
501 "fromBottomRight",
502 "fromBottomLeft",
503 "fromTopRight",
504 "fromTopLeft"]],
506 ["fade",
507 ["crossfade",
508 "fadeToColor",
509 "fadeFromColor",
510 "fadeOverColor"]],
512 ["randomBarWipe",
513 ["vertical",
514 "horizontal"]],
516 ["checkerBoardWipe",
517 ["down",
518 "across"]],
520 ["dissolve",
521 ["default"]]
525 ###############################################################################
526 # Print usage information.
528 sub usage ()
530 print <<END_OF_USAGE;
531 usage: $0 <option>* [<output-file-name>]
533 output-file-name defaults to alltransitions.odp.
535 options: -a Generate _all_ combinations of type, subtype,
536 direction, and mode
537 -h Print this usage information.
538 END_OF_USAGE
541 ###############################################################################
542 # Process the command line.
544 sub process_command_line
546 foreach (@ARGV)
548 if (/^-h/)
550 usage;
551 exit 0;
555 $global_gen_all=0;
556 $global_output_name = "alltransitions.odp";
558 my $j = 0;
559 for (my $i=0; $i<=$#ARGV; $i++)
561 if ($ARGV[$i] eq "-a")
563 $global_gen_all=1;
565 elsif ($ARGV[$i] =~ /^-/)
567 print "Unknown option $ARGV[$i]\n";
568 usage;
569 exit 1;
571 elsif ($#ARGV == $i )
573 $global_output_name = $ARGV[$i];
577 print "output to $global_output_name\n";
581 ###############################################################################
582 # Main
583 ###############################################################################
585 $ZipCmd = $ENV{LOG_FILE_ZIP_CMD};
586 $ZipFlags = $ENV{LOG_FILE_ZIP_FLAGS};
587 # Provide default values for the zip command and it's flags.
588 if ( ! defined $ZipCmd)
590 $ZipCmd = "zip" unless defined $ZipCmd;
591 $ZipFlags = "-r -q" unless defined $ZipFlags;
594 process_command_line();
596 writeManifest();
598 $OUT = open_file( "content.xml" );
600 writeHeader();
602 $slideNum=1;
603 foreach $transitionRef (@$transitionsRef)
605 $transitionType = @$transitionRef[0];
607 foreach $subtype (@{$transitionRef->[1]})
609 if( $global_gen_all != 0 )
611 writeSlideStyles($slideNum++,
612 $transitionType,
613 $subtype,
614 0, 0);
615 writeSlideStyles($slideNum++,
616 $transitionType,
617 $subtype,
618 1, 0);
619 writeSlideStyles($slideNum++,
620 $transitionType,
621 $subtype,
622 0, 1);
623 writeSlideStyles($slideNum++,
624 $transitionType,
625 $subtype,
626 1, 1);
628 else
630 writeSlideStyles($slideNum++,
631 $transitionType,
632 $subtype,
633 0, 0);
638 writeIntermediate();
640 $slideNum=1;
641 foreach $transitionRef (@$transitionsRef)
643 $transitionType = @$transitionRef[0];
645 foreach $subtype (@{$transitionRef->[1]})
647 if( $global_gen_all != 0 )
649 writeSlide($slideNum++,
650 $transitionType,
651 $subtype,
652 0, 0);
653 writeSlide($slideNum++,
654 $transitionType,
655 $subtype,
656 1, 0);
657 writeSlide($slideNum++,
658 $transitionType,
659 $subtype,
660 0, 1);
661 writeSlide($slideNum++,
662 $transitionType,
663 $subtype,
664 1, 1);
666 else
668 writeSlide($slideNum++,
669 $transitionType,
670 $subtype,
671 0, 0);
676 writeFooter();
678 $OUT->close;
680 zip_dirtree ($global_output_name);