diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-11-22 13:11:47 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-11-22 13:34:17 +0100 |
commit | 0d653000a6c07327d6db1f95be3d21d50d505423 (patch) | |
tree | 31c38f67117af9f72664dbba170eb822fc4e1193 /sw/source/core/unocore/unostyle.cxx | |
parent | 7f91d6cceeeafb588f545be4c383e312d9e42bf7 (diff) |
improve function-local statics in sw
Change-Id: I36b0e9b2819a442f01182f551dbc2bf7d5c878f4
Reviewed-on: https://gerrit.libreoffice.org/63788
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/core/unocore/unostyle.cxx')
-rw-r--r-- | sw/source/core/unocore/unostyle.cxx | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 1fc47bd59ce7..8ce993467596 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -4331,30 +4331,26 @@ void SwXTextTableStyle::UpdateCellStylesMapping() const CellStyleNameMap& SwXTextTableStyle::GetCellStyleNameMap() { - static CellStyleNameMap aMap; - if(aMap.empty()) - { - CellStyleNameMap aNewMap; - aNewMap[ "first-row" ] = FIRST_ROW_STYLE; - aNewMap[ "last-row" ] = LAST_ROW_STYLE; - aNewMap[ "first-column" ] = FIRST_COLUMN_STYLE; - aNewMap[ "last-column" ] = LAST_COLUMN_STYLE; - aNewMap[ "body" ] = BODY_STYLE; - aNewMap[ "even-rows" ] = EVEN_ROWS_STYLE; - aNewMap[ "odd-rows" ] = ODD_ROWS_STYLE; - aNewMap[ "even-columns" ] = EVEN_COLUMNS_STYLE; - aNewMap[ "odd-columns" ] = ODD_COLUMNS_STYLE; - aNewMap[ "background" ] = BACKGROUND_STYLE; + static CellStyleNameMap const aMap + { + { "first-row" , FIRST_ROW_STYLE }, + { "last-row" , LAST_ROW_STYLE }, + { "first-column" , FIRST_COLUMN_STYLE }, + { "last-column" , LAST_COLUMN_STYLE }, + { "body" , BODY_STYLE }, + { "even-rows" , EVEN_ROWS_STYLE }, + { "odd-rows" , ODD_ROWS_STYLE }, + { "even-columns" , EVEN_COLUMNS_STYLE }, + { "odd-columns" , ODD_COLUMNS_STYLE }, + { "background" , BACKGROUND_STYLE }, // loext namespace - aNewMap[ "first-row-start-column" ] = FIRST_ROW_START_COLUMN_STYLE; - aNewMap[ "first-row-end-column" ] = FIRST_ROW_END_COLUMN_STYLE; - aNewMap[ "last-row-start-column" ] = LAST_ROW_START_COLUMN_STYLE; - aNewMap[ "last-row-end-column" ] = LAST_ROW_END_COLUMN_STYLE; - aNewMap[ "first-row-even-column" ] = FIRST_ROW_EVEN_COLUMN_STYLE; - aNewMap[ "last-row-even-column" ] = LAST_ROW_EVEN_COLUMN_STYLE; - - aMap.swap(aNewMap); - } + { "first-row-start-column" , FIRST_ROW_START_COLUMN_STYLE }, + { "first-row-end-column" , FIRST_ROW_END_COLUMN_STYLE }, + { "last-row-start-column" , LAST_ROW_START_COLUMN_STYLE }, + { "last-row-end-column" , LAST_ROW_END_COLUMN_STYLE }, + { "first-row-even-column" , FIRST_ROW_EVEN_COLUMN_STYLE }, + { "last-row-even-column" , LAST_ROW_EVEN_COLUMN_STYLE }, + }; return aMap; } @@ -4731,10 +4727,8 @@ css::uno::Reference<css::style::XStyle> SwXTextCellStyle::CreateXTextCellStyle(S if (!pBoxFormat) { // return a default-dummy style to prevent crash - static SwBoxAutoFormat* pDefaultBoxFormat; - if (!pDefaultBoxFormat) - pDefaultBoxFormat = new SwBoxAutoFormat(); - pBoxFormat = pDefaultBoxFormat; + static SwBoxAutoFormat aDefaultBoxFormat; + pBoxFormat = &aDefaultBoxFormat; } xTextCellStyle.set(pBoxFormat->GetXObject(), uno::UNO_QUERY); |