fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / oox / source / drawingml / customshapes / generatePresetsPPTXs.pl
blob5795ea9a5072b273a06a9c45348be35a88e58e69
1 #!/usr/bin/perl
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 use IO::Handle;
12 $shapes = loadShapes ();
14 generatePPTXs($shapes);
15 exit;
18 sub generatePPTXs
20 $shapes = shift;
22 foreach $shape (keys %$shapes)
24 generatePPTX ($shapes, $shape);
27 generatePPTX ($shapes);
30 sub generatePPTX
32 $shapes = shift;
33 $type = shift;
35 mkdir ("cshape");
36 mkdir ("pptx");
37 system ("unzip -qq -o -d cshape cshape.pptx");
39 # custom shape(s) slide with preset definition
40 generateSlide ($shapes, $type, ">cshape/ppt/slides/slide1.xml", 0);
42 $pptx = "../pptx/cshape-" . (defined $type ? $type : "all") . ".pptx";
43 system ("cd cshape\nrm -rf ". $pptx . "\nzip -q -r " . $pptx . " .\ncd ..");
45 # preset(s) slide, for testing
46 generateSlide ($shapes, $type, ">cshape/ppt/slides/slide1.xml", 1);
48 $pptx = "../pptx/preset-cshape-" . (defined $type ? $type : "all") . ".pptx";
49 system ("cd cshape\nrm -rf ". $pptx . "\nzip -q -r " . $pptx . " .\ncd ..");
52 sub loadShapes()
54 open (IN, "<presetShapeDefinitions.xml");
56 $inside = false;
57 my %shapes;
59 while (<IN>)
61 if (/^ <[^\/]/)
63 $inside = true;
64 @definition = ();
66 else
68 if (/^ <\//)
70 chomp;
71 s/^ <\/([^>]+)>.*/$1/;
72 undef $inside;
73 $shapes{$_} = [ @definition ];
74 #print "added ", $_, "\n";
76 else
78 if ($inside)
80 push @definition, $_;
86 close (IN);
88 return \%shapes;
91 sub generateSlide
93 $shapes = shift;
94 $type = shift;
95 $file = shift;
96 $preset = shift;
98 open (OUT, $file);
100 print OUT "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
101 <p:sld xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:p=\"http://schemas.openxmlformats.org/presentationml/2006/main\">
102 <p:cSld>
103 <p:spTree>
104 <p:nvGrpSpPr>
105 <p:cNvPr id=\"1\" name=\"\"/>
106 <p:cNvGrpSpPr/>
107 <p:nvPr/>
108 </p:nvGrpSpPr>
109 <p:grpSpPr>
110 <a:xfrm>
111 <a:off x=\"0\" y=\"0\"/>
112 <a:ext cx=\"0\" cy=\"0\"/>
113 <a:chOff x=\"0\" y=\"0\"/>
114 <a:chExt cx=\"0\" cy=\"0\"/>
115 </a:xfrm>
116 </p:grpSpPr>
119 $id = 16;
120 $col = 0;
121 $row = 0;
122 $size = 500000;
123 foreach $shape (keys %$shapes)
125 if (defined $type) {
126 if ($shape ne $type) { next; }
127 # <a:ext cx=\"1050925\" cy=\"457200\"/>
128 # <a:ext cx=\"1000000\" cy=\"1000000\"/>
129 $size *= 10;
130 $col = 0.5;
131 $row = 0.25;
134 if ($col > 15) {
135 $col = 0;
136 $row ++;
139 print OUT " <p:sp>
140 <p:nvSpPr>
141 <p:cNvPr id=\"", $id++, "\" name=\"", $shape, "\"/>
142 <p:cNvSpPr/>
143 <p:nvPr/>
144 </p:nvSpPr>
145 <p:spPr bwMode=\"auto\">
146 <a:xfrm>
147 <a:off x=\"" . (350000 + $col++*$size) . "\" y=\"" . (450000 + $row*$size) . "\"/>
148 <a:ext cx=\"" . (4*$size/5) . "\" cy=\"" . (4*$size/5) . "\"/>
149 </a:xfrm>
151 if ($preset) {
152 print OUT " <a:prstGeom prst=\"" . $shape . "\"><a:avLst/></a:prstGeom>
154 } else {
155 print OUT " <a:custGeom>
157 print OUT @{$shapes->{$shape}};
158 print OUT " </a:custGeom>
161 print OUT " <a:solidFill>
162 <a:srgbClr val=\"FFFF7F\"/>
163 </a:solidFill>
164 <a:ln w=\"19080\">
165 <a:solidFill>
166 <a:srgbClr val=\"A0A060\"/>
167 </a:solidFill>
168 <a:miter lim=\"800000\"/>
169 <a:headEnd/>
170 <a:tailEnd/>
171 </a:ln>
172 </p:spPr>
173 </p:sp>
177 print OUT " </p:spTree>
178 </p:cSld>
179 <p:clrMapOvr>
180 <a:masterClrMapping/>
181 </p:clrMapOvr>
182 <p:timing>
183 <p:tnLst>
184 <p:par>
185 <p:cTn id=\"1\" dur=\"indefinite\" restart=\"never\" nodeType=\"tmRoot\"/>
186 </p:par>
187 </p:tnLst>
188 </p:timing>
189 </p:sld>
192 close (OUT);