From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- .../drawingml/customshapes/generatePresetsPPTXs.pl | 193 +++++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100755 oox/source/drawingml/customshapes/generatePresetsPPTXs.pl (limited to 'oox/source/drawingml/customshapes/generatePresetsPPTXs.pl') diff --git a/oox/source/drawingml/customshapes/generatePresetsPPTXs.pl b/oox/source/drawingml/customshapes/generatePresetsPPTXs.pl new file mode 100755 index 000000000..246bfddcd --- /dev/null +++ b/oox/source/drawingml/customshapes/generatePresetsPPTXs.pl @@ -0,0 +1,193 @@ +#!/usr/bin/env perl +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +use IO::Handle; + +$shapes = loadShapes (); + +generatePPTXs($shapes); +exit; + + +sub generatePPTXs +{ + $shapes = shift; + + foreach $shape (keys %$shapes) + { + generatePPTX ($shapes, $shape); + } + + generatePPTX ($shapes); +} + +sub generatePPTX +{ + $shapes = shift; + $type = shift; + + mkdir ("cshape"); + mkdir ("pptx"); + system ("unzip -qq -o -d cshape cshape.pptx"); + + # custom shape(s) slide with preset definition + generateSlide ($shapes, $type, ">cshape/ppt/slides/slide1.xml", 0); + + $pptx = "../pptx/cshape-" . (defined $type ? $type : "all") . ".pptx"; + system ("cd cshape\nrm -rf ". $pptx . "\nzip -q -r " . $pptx . " .\ncd .."); + + # preset(s) slide, for testing + generateSlide ($shapes, $type, ">cshape/ppt/slides/slide1.xml", 1); + + $pptx = "../pptx/preset-cshape-" . (defined $type ? $type : "all") . ".pptx"; + system ("cd cshape\nrm -rf ". $pptx . "\nzip -q -r " . $pptx . " .\ncd .."); +} + +sub loadShapes() +{ + open (IN, ") + { + if (/^ <[^\/]/) + { + $inside = true; + @definition = (); + } + else + { + if (/^ <\//) + { + chomp; + s/^ <\/([^>]+)>.*/$1/; + undef $inside; + $shapes{$_} = [ @definition ]; + #print "added ", $_, "\n"; + } + else + { + if ($inside) + { + push @definition, $_; + } + } + } + } + + close (IN); + + return \%shapes; +} + +sub generateSlide +{ + $shapes = shift; + $type = shift; + $file = shift; + $preset = shift; + + open (OUT, $file); + + print OUT " + + + + + + + + + + + + + + + + +"; + + $id = 16; + $col = 0; + $row = 0; + $size = 500000; + foreach $shape (keys %$shapes) + { + if (defined $type) { + if ($shape ne $type) { next; } +# +# + $size *= 10; + $col = 0.5; + $row = 0.25; + } + + if ($col > 15) { + $col = 0; + $row ++; + } + + print OUT " + + + + + + + + + + +"; + if ($preset) { + print OUT " +"; + } else { + print OUT " +"; + print OUT @{$shapes->{$shape}}; + print OUT " +"; + } + print OUT " + + + + + + + + + + + + +"; + } + + print OUT " + + + + + + + + + + + + +"; + + close (OUT); +} -- cgit v1.2.3