diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-11-22 08:56:49 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-11-22 11:06:58 +0100 |
commit | 94ef4c13138c5d3b410c7ef5f285cc63c585e784 (patch) | |
tree | 1f06774dd547bbbf7ebd9521203b32840a1e5247 /svx/source/unodraw/unoshape.cxx | |
parent | 7b34fb18a4d60bfc4e32b7c382ac596cbc2e776f (diff) |
improve function-local statics in svx
Change-Id: I636fcc8ba1012d774d98f6a880bf29eb4b233128
Reviewed-on: https://gerrit.libreoffice.org/63783
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx/source/unodraw/unoshape.cxx')
-rw-r--r-- | svx/source/unodraw/unoshape.cxx | 267 |
1 files changed, 122 insertions, 145 deletions
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index 8d7f3e6f6271..21938249c7f5 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -3103,30 +3103,26 @@ uno::Sequence< OUString > SvxShape::_getSupportedServiceNames() { case OBJ_GRUP: { - static uno::Sequence< OUString > *pSeq = nullptr; - if( nullptr == pSeq ) + static uno::Sequence< OUString > aSvxShape_GroupServices = [&]() { - static uno::Sequence< OUString > SvxShape_GroupServices; - - comphelper::ServiceInfoHelper::addToSequence( SvxShape_GroupServices, + uno::Sequence< OUString > tmp; + comphelper::ServiceInfoHelper::addToSequence( tmp, {sUNO_service_drawing_GroupShape, sUNO_service_drawing_Shape} ); + return tmp; + }(); - pSeq = &SvxShape_GroupServices; - } - - return *pSeq; + return aSvxShape_GroupServices; } case OBJ_CUSTOMSHAPE: { - static uno::Sequence< OUString > *pSeq = nullptr; - if( nullptr == pSeq ) + static uno::Sequence< OUString > aSvxShape_CustomShapeServices = [&]() { - static uno::Sequence< OUString > SvxShape_CustomShapeServices; + uno::Sequence< OUString > tmp; - comphelper::ServiceInfoHelper::addToSequence( SvxShape_CustomShapeServices, - {sUNO_service_drawing_CustomShape, - sUNO_service_drawing_Shape, + comphelper::ServiceInfoHelper::addToSequence( tmp, + {sUNO_service_drawing_CustomShape, + sUNO_service_drawing_Shape, sUNO_service_drawing_CustomShapeProperties, sUNO_service_drawing_FillProperties, sUNO_service_drawing_LineProperties, @@ -3140,18 +3136,17 @@ uno::Sequence< OUString > SvxShape::_getSupportedServiceNames() sUNO_service_style_CharacterPropertiesAsian, sUNO_service_drawing_ShadowProperties, sUNO_service_drawing_RotationDescriptor}); - pSeq = &SvxShape_CustomShapeServices; - } - return *pSeq; + return tmp; + }(); + return aSvxShape_CustomShapeServices; } case OBJ_LINE: { - static uno::Sequence< OUString > *pSeq = nullptr; - if( nullptr == pSeq ) + static uno::Sequence< OUString > aSvxShape_LineServices = [&]() { - static uno::Sequence< OUString > SvxShape_LineServices; + uno::Sequence< OUString > tmp; - comphelper::ServiceInfoHelper::addToSequence( SvxShape_LineServices, + comphelper::ServiceInfoHelper::addToSequence( tmp, {sUNO_service_drawing_LineShape, sUNO_service_drawing_Shape, @@ -3169,20 +3164,18 @@ uno::Sequence< OUString > SvxShape::_getSupportedServiceNames() sUNO_service_drawing_PolyPolygonDescriptor, sUNO_service_drawing_ShadowProperties, sUNO_service_drawing_RotationDescriptor}); - - pSeq = &SvxShape_LineServices; - } - return *pSeq; + return tmp; + }(); + return aSvxShape_LineServices; } case OBJ_RECT: { - static uno::Sequence< OUString > *pSeq = nullptr; - if( nullptr == pSeq ) + static uno::Sequence< OUString > aSvxShape_RectServices = [&]() { - static uno::Sequence< OUString > SvxShape_RectServices; + uno::Sequence< OUString > tmp; - comphelper::ServiceInfoHelper::addToSequence( SvxShape_RectServices, + comphelper::ServiceInfoHelper::addToSequence( tmp, {sUNO_service_drawing_RectangleShape, sUNO_service_drawing_Shape, @@ -3199,9 +3192,9 @@ uno::Sequence< OUString > SvxShape::_getSupportedServiceNames() sUNO_service_drawing_ShadowProperties, sUNO_service_drawing_RotationDescriptor}); - pSeq = &SvxShape_RectServices; - } - return *pSeq; + return tmp; + }(); + return aSvxShape_RectServices; } case OBJ_CIRC: @@ -3209,12 +3202,11 @@ uno::Sequence< OUString > SvxShape::_getSupportedServiceNames() case OBJ_CARC: case OBJ_CCUT: { - static uno::Sequence< OUString > *pSeq = nullptr; - if( nullptr == pSeq ) + static uno::Sequence< OUString > aSvxShape_CircServices = [&]() { - static uno::Sequence< OUString > SvxShape_CircServices; + uno::Sequence< OUString > tmp; - comphelper::ServiceInfoHelper::addToSequence( SvxShape_CircServices, + comphelper::ServiceInfoHelper::addToSequence( tmp, {sUNO_service_drawing_EllipseShape, sUNO_service_drawing_Shape, @@ -3233,20 +3225,19 @@ uno::Sequence< OUString > SvxShape::_getSupportedServiceNames() sUNO_service_drawing_ShadowProperties, sUNO_service_drawing_RotationDescriptor}); - pSeq = &SvxShape_CircServices; - } + return tmp; + }(); - return *pSeq; + return aSvxShape_CircServices; } case OBJ_PATHPLIN: case OBJ_PLIN: { - static uno::Sequence< OUString > *pSeq = nullptr; - if( nullptr == pSeq ) + static uno::Sequence< OUString > aSvxShape_PathServices = [&]() { - static uno::Sequence< OUString > SvxShape_PathServices; - comphelper::ServiceInfoHelper::addToSequence( SvxShape_PathServices, + uno::Sequence< OUString > tmp; + comphelper::ServiceInfoHelper::addToSequence( tmp, {sUNO_service_drawing_PolyLineShape, sUNO_service_drawing_Shape, @@ -3265,19 +3256,18 @@ uno::Sequence< OUString > SvxShape::_getSupportedServiceNames() sUNO_service_drawing_ShadowProperties, sUNO_service_drawing_RotationDescriptor}); - pSeq = &SvxShape_PathServices; - } - return *pSeq; + return tmp; + }(); + return aSvxShape_PathServices; } case OBJ_PATHPOLY: case OBJ_POLY: { - static uno::Sequence< OUString > *pSeq = nullptr; - if( nullptr == pSeq ) + static uno::Sequence< OUString > aSvxShape_PolyServices = [&]() { - static uno::Sequence< OUString > SvxShape_PolyServices; - comphelper::ServiceInfoHelper::addToSequence( SvxShape_PolyServices, + uno::Sequence< OUString > tmp; + comphelper::ServiceInfoHelper::addToSequence( tmp, {sUNO_service_drawing_PolyPolygonShape, sUNO_service_drawing_Shape, @@ -3298,20 +3288,19 @@ uno::Sequence< OUString > SvxShape::_getSupportedServiceNames() sUNO_service_drawing_ShadowProperties, sUNO_service_drawing_RotationDescriptor}); - pSeq = &SvxShape_PolyServices; - } - return *pSeq; + return tmp; + }(); + return aSvxShape_PolyServices; } case OBJ_FREELINE: case OBJ_PATHLINE: { - static uno::Sequence< OUString > *pSeq = nullptr; - if( nullptr == pSeq ) + static uno::Sequence< OUString > aSvxShape_FreeLineServices = [&]() { - static uno::Sequence< OUString > SvxShape_FreeLineServices; + uno::Sequence< OUString > tmp; - comphelper::ServiceInfoHelper::addToSequence( SvxShape_FreeLineServices, + comphelper::ServiceInfoHelper::addToSequence( tmp, {sUNO_service_drawing_OpenBezierShape, sUNO_service_drawing_Shape, @@ -3332,20 +3321,19 @@ uno::Sequence< OUString > SvxShape::_getSupportedServiceNames() sUNO_service_drawing_ShadowProperties, sUNO_service_drawing_RotationDescriptor}); - pSeq = &SvxShape_FreeLineServices; - } + return tmp; + }(); - return *pSeq; + return aSvxShape_FreeLineServices; } case OBJ_FREEFILL: case OBJ_PATHFILL: { - static uno::Sequence< OUString > *pSeq = nullptr; - if( nullptr == pSeq ) + static uno::Sequence< OUString > aSvxShape_FreeFillServices = [&]() { - static uno::Sequence< OUString > SvxShape_FreeFillServices; - comphelper::ServiceInfoHelper::addToSequence( SvxShape_FreeFillServices, + uno::Sequence< OUString > tmp; + comphelper::ServiceInfoHelper::addToSequence( tmp, {sUNO_service_drawing_ClosedBezierShape, sUNO_service_drawing_Shape, @@ -3366,20 +3354,19 @@ uno::Sequence< OUString > SvxShape::_getSupportedServiceNames() sUNO_service_drawing_ShadowProperties, sUNO_service_drawing_RotationDescriptor}); - pSeq = &SvxShape_FreeFillServices; - } - return *pSeq; + return tmp; + }(); + return aSvxShape_FreeFillServices; } case OBJ_OUTLINETEXT: case OBJ_TITLETEXT: case OBJ_TEXT: { - static uno::Sequence< OUString > *pSeq = nullptr; - if( nullptr == pSeq ) + static uno::Sequence< OUString > aSvxShape_TextServices = [&]() { - static uno::Sequence< OUString > SvxShape_TextServices; - comphelper::ServiceInfoHelper::addToSequence( SvxShape_TextServices, + uno::Sequence< OUString > tmp; + comphelper::ServiceInfoHelper::addToSequence( tmp, {sUNO_service_drawing_TextShape, sUNO_service_drawing_Shape, @@ -3398,18 +3385,17 @@ uno::Sequence< OUString > SvxShape::_getSupportedServiceNames() sUNO_service_drawing_ShadowProperties, sUNO_service_drawing_RotationDescriptor}); - pSeq = &SvxShape_TextServices; - } - return *pSeq; + return tmp; + }(); + return aSvxShape_TextServices; } case OBJ_GRAF: { - static uno::Sequence< OUString > *pSeq = nullptr; - if( nullptr == pSeq ) + static uno::Sequence< OUString > aSvxShape_GrafServices = [&]() { - static uno::Sequence< OUString > SvxShape_GrafServices; - comphelper::ServiceInfoHelper::addToSequence( SvxShape_GrafServices, + uno::Sequence< OUString > tmp; + comphelper::ServiceInfoHelper::addToSequence( tmp, {sUNO_service_drawing_GraphicObjectShape, sUNO_service_drawing_Shape, @@ -3426,19 +3412,18 @@ uno::Sequence< OUString > SvxShape::_getSupportedServiceNames() sUNO_service_drawing_ShadowProperties, sUNO_service_drawing_RotationDescriptor}); - pSeq = &SvxShape_GrafServices; - } - return *pSeq; + return tmp; + }(); + return aSvxShape_GrafServices; } case OBJ_OLE2: { - static uno::Sequence< OUString > *pSeq = nullptr; - if( nullptr == pSeq ) + static uno::Sequence< OUString > aSvxShape_Ole2Services = [&]() { - static uno::Sequence< OUString > SvxShape_Ole2Services; + uno::Sequence< OUString > tmp; - comphelper::ServiceInfoHelper::addToSequence( SvxShape_Ole2Services, + comphelper::ServiceInfoHelper::addToSequence( tmp, {sUNO_service_drawing_OLE2Shape, sUNO_service_drawing_Shape, @@ -3455,19 +3440,18 @@ uno::Sequence< OUString > SvxShape::_getSupportedServiceNames() sUNO_service_drawing_ShadowProperties, sUNO_service_drawing_RotationDescriptor}); - pSeq = &SvxShape_Ole2Services; - } - return *pSeq; + return tmp; + }(); + return aSvxShape_Ole2Services; } case OBJ_CAPTION: { - static uno::Sequence< OUString > *pSeq = nullptr; - if( nullptr == pSeq ) + static uno::Sequence< OUString > aSvxShape_CaptionServices = [&]() { - static uno::Sequence< OUString > SvxShape_CaptionServices; + uno::Sequence< OUString > tmp; - comphelper::ServiceInfoHelper::addToSequence( SvxShape_CaptionServices, + comphelper::ServiceInfoHelper::addToSequence( tmp, {sUNO_service_drawing_CaptionShape, sUNO_service_drawing_Shape, @@ -3486,36 +3470,34 @@ uno::Sequence< OUString > SvxShape::_getSupportedServiceNames() sUNO_service_drawing_ShadowProperties, sUNO_service_drawing_RotationDescriptor}); - pSeq = &SvxShape_CaptionServices; - } + return tmp; + }(); - return *pSeq; + return aSvxShape_CaptionServices; } case OBJ_PAGE: { - static uno::Sequence< OUString > *pSeq = nullptr; - if( nullptr == pSeq ) + static uno::Sequence< OUString > aSvxShape_PageServices = [&]() { - static uno::Sequence< OUString > SvxShape_PageServices; + uno::Sequence< OUString > tmp; - comphelper::ServiceInfoHelper::addToSequence( SvxShape_PageServices, + comphelper::ServiceInfoHelper::addToSequence( tmp, {sUNO_service_drawing_PageShape, sUNO_service_drawing_Shape} ); - pSeq = &SvxShape_PageServices; - } + return tmp; + }(); - return *pSeq; + return aSvxShape_PageServices; } case OBJ_MEASURE: { - static uno::Sequence< OUString > *pSeq = nullptr; - if( nullptr == pSeq ) + static uno::Sequence< OUString > aSvxShape_MeasureServices = [&]() { - static uno::Sequence< OUString > SvxShape_MeasureServices; - comphelper::ServiceInfoHelper::addToSequence( SvxShape_MeasureServices, + uno::Sequence< OUString > tmp; + comphelper::ServiceInfoHelper::addToSequence( tmp, {sUNO_service_drawing_MeasureShape, sUNO_service_drawing_MeasureProperties, @@ -3536,52 +3518,49 @@ uno::Sequence< OUString > SvxShape::_getSupportedServiceNames() sUNO_service_drawing_ShadowProperties, sUNO_service_drawing_RotationDescriptor}); - pSeq = &SvxShape_MeasureServices; - } + return tmp; + }(); - return *pSeq; + return aSvxShape_MeasureServices; } case OBJ_FRAME: { - static uno::Sequence< OUString > *pSeq = nullptr; - if( nullptr == pSeq ) + static uno::Sequence< OUString > aSvxShape_FrameServices = [&]() { - static uno::Sequence< OUString > SvxShape_FrameServices; + uno::Sequence< OUString > tmp; - comphelper::ServiceInfoHelper::addToSequence( SvxShape_FrameServices, + comphelper::ServiceInfoHelper::addToSequence( tmp, {sUNO_service_drawing_FrameShape, sUNO_service_drawing_Shape} ); - pSeq = &SvxShape_FrameServices; - } + return tmp; + }(); - return *pSeq; + return aSvxShape_FrameServices; } case OBJ_UNO: { - static uno::Sequence< OUString > *pSeq = nullptr; - if( nullptr == pSeq ) + static uno::Sequence< OUString > aSvxShape_UnoServices = [&]() { - static uno::Sequence< OUString > SvxShape_UnoServices; - comphelper::ServiceInfoHelper::addToSequence( SvxShape_UnoServices, + uno::Sequence< OUString > tmp; + comphelper::ServiceInfoHelper::addToSequence( tmp, {sUNO_service_drawing_ControlShape, sUNO_service_drawing_Shape} ); - pSeq = &SvxShape_UnoServices; - } - return *pSeq; + return tmp; + }(); + return aSvxShape_UnoServices; } case OBJ_EDGE: { - static uno::Sequence< OUString > *pSeq = nullptr; - if( nullptr == pSeq ) + static uno::Sequence< OUString > aSvxShape_EdgeServices = [&]() { - static uno::Sequence< OUString > SvxShape_EdgeServices; + uno::Sequence< OUString > tmp; - comphelper::ServiceInfoHelper::addToSequence( SvxShape_EdgeServices, + comphelper::ServiceInfoHelper::addToSequence( tmp, {sUNO_service_drawing_ConnectorShape, sUNO_service_drawing_ConnectorProperties, @@ -3601,24 +3580,23 @@ uno::Sequence< OUString > SvxShape::_getSupportedServiceNames() sUNO_service_drawing_ShadowProperties, sUNO_service_drawing_RotationDescriptor}); - pSeq = &SvxShape_EdgeServices; - } - return *pSeq; + return tmp; + }(); + return aSvxShape_EdgeServices; } case OBJ_MEDIA: { - static uno::Sequence< OUString > *pSeq = nullptr; - if( nullptr == pSeq ) + static uno::Sequence< OUString > aSvxShape_MediaServices = [&]() { - static uno::Sequence< OUString > SvxShape_MediaServices; + uno::Sequence< OUString > tmp; - comphelper::ServiceInfoHelper::addToSequence( SvxShape_MediaServices, + comphelper::ServiceInfoHelper::addToSequence( tmp, {sUNO_service_drawing_MediaShape, sUNO_service_drawing_Shape}); - pSeq = &SvxShape_MediaServices; - } - return *pSeq; + return tmp; + }(); + return aSvxShape_MediaServices; } } } @@ -3628,17 +3606,16 @@ uno::Sequence< OUString > SvxShape::_getSupportedServiceNames() const sal_uInt16 nIdent = GetSdrObject()->GetObjIdentifier(); OSL_ENSURE( nIdent == OBJ_UNO, "SvxShape::_getSupportedServiceNames: SdrInventor::FmForm, but no UNO object?" ); #endif - static uno::Sequence< OUString > *pSeq = nullptr; - if( nullptr == pSeq ) + static uno::Sequence< OUString > aSvxShape_UnoServices = [&]() { - static uno::Sequence< OUString > SvxShape_UnoServices; - comphelper::ServiceInfoHelper::addToSequence( SvxShape_UnoServices, + uno::Sequence< OUString > tmp; + comphelper::ServiceInfoHelper::addToSequence( tmp, {sUNO_service_drawing_ControlShape, sUNO_service_drawing_Shape} ); - pSeq = &SvxShape_UnoServices; - } - return *pSeq; + return tmp; + }(); + return aSvxShape_UnoServices; } OSL_FAIL( "SvxShape::_getSupportedServiceNames: could not determine object type!" ); uno::Sequence< OUString > aSeq; |