bump product version to 4.1.6.2
[LibreOffice.git] / oox / source / drawingml / customshapes / generatePresetsCXX.pl
blobe129d0320a8b7a329822e91e272e8188d943b044
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 sub loadSourceCode()
12 open (IN, "<custom-shapes.log");
14 my %sources;
16 while (<IN>)
18 if (/==cscode== /)
20 if (/shape name: '/)
22 chop;
23 s/.*shape name: '([^']+)'.*/$1/;
24 $name = $_;
26 else
28 if (/==cscode== begin/)
30 $inside = true;
31 @code = ();
33 else
35 if (/==cscode== end/)
37 s/^ <\/([^>]+)>/$1/;
38 undef $inside;
39 $sources{$name} = [ @code ];
40 #print "added ", $name, "\n";
45 else
47 if ($inside)
49 push @code, $_;
54 close (IN);
56 return \%sources;
59 sub startSource
61 my $count = shift;
63 open (OUT, ">customshapepresets" . $count . ".cxx");
64 print OUT << "EOS"
65 // this file was generated by: $0
66 // please do not edit
68 #include \"oox/drawingml/customshapeproperties.hxx\"
69 #include \"oox/token/tokenmap.hxx\"
70 #include <com/sun/star/awt/Rectangle.hpp>
71 #include <com/sun/star/awt/Size.hpp>
72 #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
73 #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
74 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
75 #include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp>
77 using rtl::OUString;
78 using namespace ::com::sun::star;
79 using namespace ::com::sun::star::beans;
80 using namespace ::com::sun::star::drawing;
81 using namespace ::com::sun::star::uno;
83 namespace oox { namespace drawingml {
85 namespace
87 EOS
92 sub endSource
94 my $count = shift;
95 my $classes = shift;
96 $endBrace > 0 && print OUT "}\n\n";
98 print OUT "} // anonymous namespace\n";
99 print OUT "void CustomShapeProperties::initializePresetsMap" . $count . "()\n";
100 print OUT "{\n";
101 for my $class (@{$classes})
103 print OUT " maPresetsMap [ StaticTokenMap::get().getTokenFromUnicode( OUString( RTL_CONSTASCII_USTRINGPARAM( \"", $class, "\" ) ) ) ] = new ShapeC".$class."();\n";
105 print OUT "}
107 } } // oox // drawingml
112 sub generateSource
114 my $sources = shift;
115 my $count = 0;
116 my $shCount = 0;
118 startSource (++$count);
120 my @classes = ();
121 foreach $shape (keys %$sources)
123 push @classes, $shape;
124 print OUT "class ShapeC".$shape." : public CustomShapeProvider\n";
125 print OUT "{\n";
126 print OUT " virtual PropertyMap getProperties()\n";
127 print OUT " {\n";
128 print OUT " PropertyMap aPropertyMap;\n\n";
129 print OUT @{$sources->{$shape}};
130 print OUT " aPropertyMap [ PROP_Type ] <<= OUString(\"ooxml-", $shape, "\");\n\n";
131 print OUT " return aPropertyMap;\n";
132 print OUT " }\n";
133 print OUT "};\n";
135 $shCount++;
137 if ($shCount >= 35) {
138 $shCount = 0;
140 endSource ($count, \@classes);
141 close OUT;
142 startSource (++$count);
143 @classes = ();
147 endSource ($count, \@classes);
149 print OUT << "EOS"
151 void ::oox::drawingml::CustomShapeProperties::initializePresetsMap()
156 for ($i=1; $i <= $count; $i++) {
157 print OUT "initializePresetsMap" . $i . "();\n";
160 print OUT "}\n";
162 close OUT;
165 generateSource (loadSourceCode ());