diff options
author | Michael Meeks <michael.meeks@suse.com> | 2012-03-02 20:56:55 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2012-03-02 22:14:24 +0000 |
commit | f59733657fdffbc66b2cc3531791aa0bb7a96b51 (patch) | |
tree | e86ec9b27cc11a363e407738ad07ec85f4a10381 /oox | |
parent | 36f8ef7f3f344086f55028f725fb70e488bc3411 (diff) |
customshapes: use static integer array for EnhancedCustomShapeSequences
Saves 4% compile time and 200K of space
Diffstat (limited to 'oox')
-rw-r--r-- | oox/inc/oox/drawingml/customshapeproperties.hxx | 1 | ||||
-rw-r--r-- | oox/source/drawingml/customshapeproperties.cxx | 15 | ||||
-rw-r--r-- | oox/source/helper/propertymap.cxx | 21 |
3 files changed, 24 insertions, 13 deletions
diff --git a/oox/inc/oox/drawingml/customshapeproperties.hxx b/oox/inc/oox/drawingml/customshapeproperties.hxx index 26a5a231efb6..a2d72e8c69e1 100644 --- a/oox/inc/oox/drawingml/customshapeproperties.hxx +++ b/oox/inc/oox/drawingml/customshapeproperties.hxx @@ -116,6 +116,7 @@ struct Path2D class CustomShapeProvider { protected: static com::sun::star::uno::Any createStringSequence( size_t nStrings, const char **pStrings ); + static com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeSegment > createCustomShapeSegmentSequence( size_t nElems, const sal_uInt16 *pValues ); public: virtual PropertyMap getProperties() = 0; }; diff --git a/oox/source/drawingml/customshapeproperties.cxx b/oox/source/drawingml/customshapeproperties.cxx index 5beaef4012f9..a5e31dd2772e 100644 --- a/oox/source/drawingml/customshapeproperties.cxx +++ b/oox/source/drawingml/customshapeproperties.cxx @@ -374,14 +374,21 @@ Any CustomShapeProvider::createStringSequence( size_t nStrings, const char **pSt { 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 ); + return makeAny( aStringSequence ); +} + +com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeSegment > CustomShapeProvider::createCustomShapeSegmentSequence( size_t nElems, const sal_uInt16 *pValues ) +{ + Sequence< EnhancedCustomShapeSegment > aSequence( (nElems + 1) / 2 ); + for (size_t i = 0, j = 0; i < nElems / 2; i++) + { + aSequence[i].Command = pValues[j++]; + aSequence[i].Count = pValues[j++]; } - Any aAny; - aAny <<= aStringSequence; - return aAny; + return aSequence; } } } diff --git a/oox/source/helper/propertymap.cxx b/oox/source/helper/propertymap.cxx index 1b2e2ea86bc1..334a9214f933 100644 --- a/oox/source/helper/propertymap.cxx +++ b/oox/source/helper/propertymap.cxx @@ -574,18 +574,21 @@ static const char* lclDumpAnyValueCode( Any value, int level = 0) } return "aAdjSequence"; } else if( value >>= segArray ) { + if (segArray.getLength() == 0) + return "Sequence< EnhancedCustomShapeSegment >(0)"; + printLevel (level); - fprintf (stderr, "Sequence< EnhancedCustomShapeSegment > aSegmentSeq (%" SAL_PRIdINT32 ");\n", segArray.getLength()); - for( int i=0; i<segArray.getLength(); i++ ) { - printLevel (level); - fprintf (stderr, "{\n"); - const char *var = lclDumpAnyValueCode (makeAny (segArray[i]), level + 1); - printLevel (level + 1); - fprintf (stderr, "aSegmentSeq [%d] = %s;\n", i, var); + fprintf (stderr,"static const sal_uInt16 nValues[] = {\n"); + printLevel (level); + fprintf (stderr,"// Command, Count\n"); + for( int i = 0; i < segArray.getLength(); i++ ) { printLevel (level); - fprintf (stderr, "}\n"); + fprintf (stderr,"\t%d,%d%s\n", segArray[i].Command, + segArray[i].Count, i < segArray.getLength() - 1 ? "," : ""); } - return "aSegmentSeq"; + printLevel (level); + fprintf (stderr,"};\n"); + return "createCustomShapeSegmentSequence( SAL_N_ELEMENTS( nValues ), nValues )"; } else if( value >>= segTextFrame ) { printLevel (level); fprintf (stderr, "Sequence< EnhancedCustomShapeTextFrame > aTextFrameSeq (%" SAL_PRIdINT32 ");\n", segTextFrame.getLength()); |