GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / oox / source / drawingml / customshapes / generatePresetsCXX.pl
blobe5a509d394160248ea6ad9b28e82d113769025e6
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"
66 // This file was generated by: $0
68 // Please, DO NOT EDIT.
70 // We mean it.
72 #include <oox/drawingml/customshapeproperties.hxx>
73 #include <oox/token/tokenmap.hxx>
74 #include <com/sun/star/awt/Rectangle.hpp>
75 #include <com/sun/star/awt/Size.hpp>
76 #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
77 #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
78 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
79 #include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp>
81 using namespace ::com::sun::star;
82 using namespace ::com::sun::star::beans;
83 using namespace ::com::sun::star::drawing;
84 using namespace ::com::sun::star::uno;
86 namespace oox { namespace drawingml {
88 namespace
90 EOS
95 sub endSource
97 my $count = shift;
98 my $classes = shift;
99 $endBrace > 0 && print OUT "}\n\n";
101 print OUT "} // anonymous namespace\n";
102 print OUT "void CustomShapeProperties::initializePresetsMap" . $count . "()\n";
103 print OUT "{\n";
104 for my $class (@{$classes})
106 print OUT " maPresetsMap [ StaticTokenMap::get().getTokenFromUnicode( \"", $class, "\" ) ] = new ShapeC".$class."();\n";
108 print OUT "}
110 } } // oox // drawingml
115 sub generateSource
117 my $sources = shift;
118 my $count = 0;
119 my $shCount = 0;
121 startSource (++$count);
123 my @classes = ();
124 foreach $shape (keys %$sources)
126 push @classes, $shape;
127 print OUT "class ShapeC".$shape." : public CustomShapeProvider\n";
128 print OUT "{\n";
129 print OUT " virtual PropertyMap getProperties()\n";
130 print OUT " {\n";
131 print OUT " PropertyMap aPropertyMap;\n\n";
132 print OUT @{$sources->{$shape}};
133 print OUT " aPropertyMap [ PROP_Type ] <<= OUString(\"ooxml-", $shape, "\");\n\n";
134 print OUT " return aPropertyMap;\n";
135 print OUT " }\n";
136 print OUT "};\n";
137 print OUT "\n";
138 print OUT "// This is a generated source file. DO NOT EDIT.\n";
139 print OUT "\n";
141 $shCount++;
143 if ($shCount >= 35) {
144 $shCount = 0;
146 endSource ($count, \@classes);
147 close OUT;
148 startSource (++$count);
149 @classes = ();
153 endSource ($count, \@classes);
155 print OUT << "EOS"
157 void ::oox::drawingml::CustomShapeProperties::initializePresetsMap()
162 for ($i=1; $i <= $count; $i++) {
163 print OUT "initializePresetsMap" . $i . "();\n";
166 print OUT "}\n";
168 close OUT;
171 generateSource (loadSourceCode ());