summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@suse.com>2012-03-02 20:31:20 +0000
committerMichael Meeks <michael.meeks@suse.com>2012-03-02 22:14:24 +0000
commit36f8ef7f3f344086f55028f725fb70e488bc3411 (patch)
tree29c7868067954ae1fc14d9c6a98e9385e94a422a /oox
parent8d7321c8eb658c409122feaef4960cc88aa63459 (diff)
customshapes: 800k size saving, and 25% compile speedup
Use static const char * arrays and a helper function instead of inlining umpteen OUString intern calls.
Diffstat (limited to 'oox')
-rw-r--r--oox/inc/oox/drawingml/customshapeproperties.hxx2
-rw-r--r--oox/source/drawingml/customshapeproperties.cxx14
-rw-r--r--oox/source/helper/propertymap.cxx11
3 files changed, 24 insertions, 3 deletions
diff --git a/oox/inc/oox/drawingml/customshapeproperties.hxx b/oox/inc/oox/drawingml/customshapeproperties.hxx
index a36a022ed5a2..26a5a231efb6 100644
--- a/oox/inc/oox/drawingml/customshapeproperties.hxx
+++ b/oox/inc/oox/drawingml/customshapeproperties.hxx
@@ -114,6 +114,8 @@ struct Path2D
class CustomShapeProvider {
+protected:
+ static com::sun::star::uno::Any createStringSequence( size_t nStrings, const char **pStrings );
public:
virtual PropertyMap getProperties() = 0;
};
diff --git a/oox/source/drawingml/customshapeproperties.cxx b/oox/source/drawingml/customshapeproperties.cxx
index 1b0cac256939..5beaef4012f9 100644
--- a/oox/source/drawingml/customshapeproperties.cxx
+++ b/oox/source/drawingml/customshapeproperties.cxx
@@ -370,6 +370,20 @@ double CustomShapeProperties::getValue( const std::vector< CustomShapeGuide >& r
return fRet;
}
+Any CustomShapeProvider::createStringSequence( size_t nStrings, const char **pStrings )
+{
+ Sequence< OUString > aStringSequence( nStrings );
+ for (size_t i = 0; i < nStrings; i++)
+ {
+ aStringSequence[i] = ::rtl::OUString::intern(
+ pStrings[i], strlen( pStrings[i] ),
+ RTL_TEXTENCODING_ASCII_US );
+ }
+ Any aAny;
+ aAny <<= aStringSequence;
+ return aAny;
+}
+
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/helper/propertymap.cxx b/oox/source/helper/propertymap.cxx
index dcc3a8310414..1b2e2ea86bc1 100644
--- a/oox/source/helper/propertymap.cxx
+++ b/oox/source/helper/propertymap.cxx
@@ -501,13 +501,18 @@ static const char* lclDumpAnyValueCode( Any value, int level = 0)
fprintf (stderr,"OUString str = CREATE_OUSTRING (\"%s\");\n", USS( strValue ) );
return "Any (str)";
} else if( value >>= strArray ) {
+ if (strArray.getLength() == 0)
+ return "Sequence< OUString >(0)";
+
printLevel (level);
- fprintf (stderr,"Sequence< OUString > aStringSequence (%" SAL_PRIdINT32 ");\n", strArray.getLength());
+ fprintf (stderr,"static const char *aStrings[] = {\n");
for( int i=0; i<strArray.getLength(); i++ ) {
printLevel (level);
- fprintf (stderr,"aStringSequence[%d] = CREATE_OUSTRING (\"%s\");\n", i, USS( strArray[i] ) );
+ fprintf (stderr,"\t\"%s\"%s\n", USS( strArray[i] ), i < strArray.getLength() - 1 ? "," : "" );
}
- return "aStringSequence";
+ printLevel (level);
+ fprintf (stderr,"};\n");
+ return "createStringSequence( SAL_N_ELEMENTS( aStrings ), aStrings )";
} else if( value >>= propArray ) {
printLevel (level);
fprintf (stderr,"Sequence< PropertyValue > aPropSequence (%" SAL_PRIdINT32 ");\n", propArray.getLength());