summaryrefslogtreecommitdiffstats
path: root/oox
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@suse.com>2012-03-02 17:05:57 +0000
committerMichael Meeks <michael.meeks@suse.com>2012-03-02 17:10:24 +0000
commitf291fb57d087de41385a22dfacd8b694d8b9abc7 (patch)
treeaa68c465d1671086949938845284363a5f72a8a2 /oox
parentdocument customshapes (re-)generation flow. (diff)
downloadcore-f291fb57d087de41385a22dfacd8b694d8b9abc7.tar.gz
core-f291fb57d087de41385a22dfacd8b694d8b9abc7.zip
customshapes: re-work generation to create many small methods
each custom shape now has a virtual constructor we can call to construct it, this shrinks the function size, and helps the optimiser much accelerating compile time. It may even help improve import time too.
Diffstat (limited to 'oox')
-rw-r--r--oox/inc/oox/drawingml/customshapeproperties.hxx8
-rw-r--r--oox/source/drawingml/customshapeproperties.cxx4
-rwxr-xr-xoox/source/drawingml/customshapes/generatePresetsCXX.pl104
3 files changed, 68 insertions, 48 deletions
diff --git a/oox/inc/oox/drawingml/customshapeproperties.hxx b/oox/inc/oox/drawingml/customshapeproperties.hxx
index 004d7713d354..a36a022ed5a2 100644
--- a/oox/inc/oox/drawingml/customshapeproperties.hxx
+++ b/oox/inc/oox/drawingml/customshapeproperties.hxx
@@ -112,6 +112,12 @@ struct Path2D
Path2D() : w( 0 ), h( 0 ), fill( XML_norm ), stroke( sal_True ), extrusionOk( sal_True ) {};
};
+
+class CustomShapeProvider {
+public:
+ virtual PropertyMap getProperties() = 0;
+};
+
class CustomShapeProperties
{
public:
@@ -160,7 +166,7 @@ private:
sal_Bool mbMirroredY;
sal_Int32 mnTextRotateAngle;
- typedef boost::unordered_map< sal_Int32, PropertyMap > PresetsMap;
+ typedef boost::unordered_map< sal_Int32, CustomShapeProvider * > PresetsMap;
static PresetsMap maPresetsMap;
static void initializePresetsMap();
diff --git a/oox/source/drawingml/customshapeproperties.cxx b/oox/source/drawingml/customshapeproperties.cxx
index e5bb6d88e446..1b0cac256939 100644
--- a/oox/source/drawingml/customshapeproperties.cxx
+++ b/oox/source/drawingml/customshapeproperties.cxx
@@ -147,7 +147,9 @@ void CustomShapeProperties::pushToPropSet( const ::oox::core::FilterBase& /* rFi
{
OSL_TRACE("found property map for preset: %s (%d)", USS(getShapePresetTypeName()), mnShapePresetType);
- aPropertyMap = maPresetsMap[ mnShapePresetType ];
+ CustomShapeProvider *pProvider = maPresetsMap[ mnShapePresetType ];
+ if (pProvider)
+ aPropertyMap = pProvider->getProperties();
#ifdef DEBUG
aPropertyMap.dumpCode();
#endif
diff --git a/oox/source/drawingml/customshapes/generatePresetsCXX.pl b/oox/source/drawingml/customshapes/generatePresetsCXX.pl
index 827537c3a1d5..f2150ce99fd6 100755
--- a/oox/source/drawingml/customshapes/generatePresetsCXX.pl
+++ b/oox/source/drawingml/customshapes/generatePresetsCXX.pl
@@ -1,9 +1,5 @@
#!/usr/bin/perl
-generateSource (loadSourceCode ());
-
-exit;
-
sub loadSourceCode()
{
open (IN, "<custom-shapes.log");
@@ -56,7 +52,10 @@ sub loadSourceCode()
sub startSource
{
my $count = shift;
- my $head = "// this file was generated by: " . $0 . "
+
+ open (OUT, ">customshapepresets" . $count . ".cxx");
+ print OUT << "EOS"
+// this file was generated by: $0
// please do not edit
#include \"oox/drawingml/customshapeproperties.hxx\"
@@ -76,71 +75,84 @@ using namespace ::com::sun::star::uno;
namespace oox { namespace drawingml {
-void CustomShapeProperties::initializePresetsMap" . $count . "()
+namespace
{
-";
+EOS
+;
- open (OUT, ">customshapepresets" . $count . ".cxx");
- print OUT $head;
}
sub endSource
{
- my $endBrace = shift;
- my $tail = "
-}
-}
-
-";
+ my $count = shift;
+ my $classes = shift;
+ $endBrace > 0 && print OUT "}\n\n";
+
+ print OUT "} // anonymous namespace\n";
+ print OUT "void CustomShapeProperties::initializePresetsMap" . $count . "()\n";
+ print OUT "{\n";
+ for my $class (@{$classes})
+ {
+ print OUT " maPresetsMap [ StaticTokenMap::get().getTokenFromUnicode( OUString( RTL_CONSTASCII_USTRINGPARAM( \"", $class, "\" ) ) ) ] = new ShapeC".$class."();\n";
+ }
+ print OUT "}
- if ($endBrace > 0) {
- print OUT "}\n\n";
- }
+} } // oox // drawingml
- print OUT $tail;
- close (OUT);
+";
}
sub generateSource
{
- $sources = shift;
- $count = 1;
- $shCount = 0;
-
- startSource($count++);
-
- foreach $shape (keys %$sources)
- {
- print OUT " {\n";
- print OUT " PropertyMap aPropertyMap;\n\n";
- print OUT @{$sources->{$shape}};
- print OUT " aPropertyMap [ PROP_Type ] <<= CREATE_OUSTRING(\"ooxml-", $shape, "\");\n\n";
- print OUT " maPresetsMap [ StaticTokenMap::get().getTokenFromUnicode( OUString( RTL_CONSTASCII_USTRINGPARAM( \"", $shape, "\" ) ) ) ] = aPropertyMap;\n";
- print OUT " }\n";
+ my $sources = shift;
+ my $count = 0;
+ my $shCount = 0;
+
+ startSource (++$count);
+
+ my @classes = ();
+ foreach $shape (keys %$sources)
+ {
+ push @classes, $shape;
+ print OUT "class ShapeC".$shape." : public CustomShapeProvider\n";
+ print OUT "{\n";
+ print OUT " virtual PropertyMap getProperties()\n";
+ print OUT " {\n";
+ print OUT " PropertyMap aPropertyMap;\n\n";
+ print OUT @{$sources->{$shape}};
+ print OUT " aPropertyMap [ PROP_Type ] <<= CREATE_OUSTRING(\"ooxml-", $shape, "\");\n\n";
+ print OUT " return aPropertyMap;\n";
+ print OUT " }\n";
+ print OUT "};\n";
$shCount++;
if ($shCount >= 35) {
$shCount = 0;
- endSource(1);
- startSource($count++);
+ endSource ($count, \@classes);
+ close OUT;
+ startSource (++$count);
+ @classes = ();
}
- }
+ }
- print OUT "
-}
+ endSource ($count, \@classes);
-void CustomShapeProperties::initializePresetsMap()
-{\n";
+ print OUT << "EOS"
- for ($i=1; $i < $count; $i++) {
+void ::oox::drawingml::CustomShapeProperties::initializePresetsMap()
+{
+EOS
+ ;
+
+ for ($i=1; $i <= $count; $i++) {
print OUT "initializePresetsMap" . $i . "();\n";
- }
+ }
print OUT "}\n";
- if ($shCount > 0) {
- endSource(0);
- }
+ close OUT;
}
+
+generateSource (loadSourceCode ());